Skip to content

Commit

Permalink
enhance: Update dokan src package root name.
Browse files Browse the repository at this point in the history
  • Loading branch information
MdAsifHossainNadim committed Jan 24, 2025
1 parent cc2515e commit a6ccacf
Show file tree
Hide file tree
Showing 16 changed files with 32 additions and 63 deletions.
12 changes: 3 additions & 9 deletions docs/frontend/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,7 @@ if (file_exists($script_assets)) {

## Component Access

For `Dokan Free`, we can import the components via `@/components`:

```js
import { DataViews } from '@/components';
```

In `Dokan Pro`, components can be imported directly from `@dokan/components`:
For `dokan free & premium version`, we can import the components via `@dokan/components`:

```js
import { DataViews } from '@dokan/components';
Expand All @@ -73,8 +67,8 @@ externals: {
|____ src/
| |___ components/
| | |___ index.tsx # Main export file
| | |___ DataViews/ # Existing component
| | |___ YourComponent/ # Your new component directory
| | |___ dataviews/ # Existing component
| | |___ your-component/ # Your new component directory
| | | |___ index.tsx
| | | |___ style.scss
| | |
Expand Down
7 changes: 3 additions & 4 deletions docs/frontend/dataviews.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ domReady(() => {
### Step 3: Create a DataViewTable component.
In `Dokan Pro`, we can use the `DataViews` component from the `@dokan/components` package. For the free version, we can import `DataViews` from the `src/components` (`lite`) directory.
We can use the `DataViews` component from the `@dokan/components` package. `(for both free & premium version)`
All the (free version) global components are available in `@dokan/components` package.
Expand All @@ -108,9 +108,8 @@ import {
__experimentalVStack as VStack, Button
} from "@wordpress/components";

// For dokan-pro, we will import the `DataViews` component from the @dokan/components package. Otherwise, in free version we will import from the `@/components` directory.
import { DataViews } from '@dokan/components'; // For pro version
// import { DataViews } from '@/components'; // For free version
// We will import the `DataViews` component from the @dokan/components package.
import { DataViews } from '@dokan/components';

const WPostsDataView = ({ navigate }) => {
const [ data, setData ] = useState([]);
Expand Down
14 changes: 1 addition & 13 deletions docs/frontend/filter.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,7 @@ The Filter component provides a standardized way to implement filtering function

## Installation

#### Dokan lite

```jsx
import Filter from '../components';
```

#### Dokan pro or external plugins
For `dokan free & premium version`, we can import the `Filter` components from `@dokan/components` package:

```jsx
import { Filter } from '@dokan/components';
Expand Down Expand Up @@ -153,12 +147,6 @@ The filter hook name should follow this pattern:

You can use the `snakeCase` utility to ensure proper formatting:

For Dokan Lite:
```jsx
import { snakeCase } from "@/utilities";
```

For Dokan Pro or other plugins:
```jsx
import { snakeCase } from "@dokan/utilities";
```
Expand Down
14 changes: 4 additions & 10 deletions docs/frontend/hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Overview

`Dokan` provides a set of reusable `hooks` that can be used across both `Free` and `Pro` versions. This documentation explains how to properly set up and use `hooks` in your project.
`Dokan` provides a set of reusable `hooks` that can be used across both `Free` and `Premium` versions. This documentation explains how to properly set up and use `hooks` in your project.

## Important Dependencies

Expand All @@ -11,7 +11,7 @@ For both `Dokan Free and Pro` versions, we must register the `dokan-react-compon
### Implementation Example

```php
// Register scripts with dokan-react-components dependency
// Register scripts with `dokan-react-components` dependency
$script_assets = 'add_your_script_assets_path_here';

if (file_exists($script_assets)) {
Expand Down Expand Up @@ -44,13 +44,7 @@ if (file_exists($script_assets)) {

## Component Access

For `Dokan Free`, we can import the components via `@/hooks`:

```js
import { useWindowDimensions } from '@/hooks';
```

In `Dokan Pro`, components can be imported directly from `@dokan/components`:
For `Dokan free & premium version`, we can import the components via `@dokan/hooks`:

```js
import { useWindowDimensions } from '@dokan/hooks';
Expand Down Expand Up @@ -83,7 +77,7 @@ externals: {
|____ Other Files
```

**Finally,** we need to export the new `hook` from the `src/hooks/index.tsx` file. Then, we can import the new component from `@dokan/hooks` in `dokan pro` version.
**Finally,** we need to export the new `hook` from the `src/hooks/index.tsx` file. Then, we can import the new component via `@dokan/hooks`.

```tsx
export { default as useWindowDimensions } from '@/hooks/ViewportDimensions';
Expand Down
4 changes: 2 additions & 2 deletions docs/frontend/sortable-list.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
- [Component Properties](#component-properties)

## Introduction
The Dokan `SortableList` component provide a `flexible` and `reusable` `drag-and-drop` interface for managing `sortable lists`, `grids`, and `horizontal` layouts. Built on top of `@dnd-kit`, these components offer seamless integration with Dokan's existing component ecosystem.
The Dokan `SortableList` component provide a `flexible` and `reusable` `drag-and-drop` interface for managing `sortable lists`, `grids`, and `horizontal` layouts. Built on top of `@dnd-kit`, these components offer seamless integration with `Dokan's` existing component ecosystem.

## Data Structures
The `SortableList` component accommodates an `array` data type for its `items` property, which can follow `three primary array data structure patterns`:
Expand Down Expand Up @@ -109,7 +109,7 @@ For both `Dokan Free and Pro` versions, we must register the `dokan-react-compon

```tsx
import { useState } from '@wordpress/element';
import SortableList from '@/components/sortable-list';
import SortableList from '@dokan/components/sortable-list';
```

#### Step 2: Set Up Your State Management
Expand Down
10 changes: 2 additions & 8 deletions docs/frontend/utilities.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export * from './YourUtility';

## Change Case Utilities

In `Dokan` and `Dokan Pro`, we recommend using the `change-case` utility methods from the `Dokan utilities package`. These utilities are accessible through the `@dokan/utilities` import in `Dokan Pro`.
In `Dokan` and `Dokan Pro`, we recommend using the `change-case` utility methods from the `Dokan utilities package`. These utilities are accessible through the `@dokan/utilities` package.

## Why Use Change Case from Dokan Utilities?

Expand Down Expand Up @@ -62,13 +62,7 @@ The following case transformation utilities are available:

## Utilities Access

For `Dokan Free`, we can import the `utilities` via `@/utilities`:

```js
import { snakeCase, camelCase, kebabCase } from '@/utilities';
```

In `Dokan Pro`, `utilities` can be imported directly from `@dokan/components`:
For `Dokan free & premium version`, we can import the `utilities` via `@dokan/utilities`:

```js
import { snakeCase, camelCase, kebabCase } from '@dokan/utilities';
Expand Down
2 changes: 1 addition & 1 deletion src/components/PriceHtml.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { RawHTML } from '@wordpress/element';
import { formatPrice } from '@/utilities';
import { formatPrice } from '@dokan/utilities';

type PriceHtmlProps = {
price: string | number;
Expand Down
6 changes: 3 additions & 3 deletions src/components/dataviews/DataViewTable.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { DataViews } from '@wordpress/dataviews/wp';
import { Slot } from "@wordpress/components";
import { ViewportDimensions } from '@/Hooks/ViewportDimensions';
import { ViewportDimensions } from '@dokan/hooks';
import type { Action, Field, SupportedLayouts, View } from "@wordpress/dataviews/src/types";
import { kebabCase, snakeCase } from "@/utilities";
import { kebabCase, snakeCase } from "@dokan/utilities";
import { useEffect } from "@wordpress/element";
import { useWindowDimensions } from "@/hooks";
import { useWindowDimensions } from "@dokan/hooks";
import './style.scss';

type ItemWithId = { id: string };
Expand Down
2 changes: 1 addition & 1 deletion src/components/sortable-list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
} from '@dnd-kit/sortable';

import { Slot } from "@wordpress/components";
import { snakeCase, kebabCase } from "@/utilities";
import { snakeCase, kebabCase } from "@dokan/utilities";
import SortableItem from './SortableItem';
import type { Announcements, ScreenReaderInstructions } from "@dnd-kit/core";
import type { AutoScrollOptions } from "@dnd-kit/core";
Expand Down
2 changes: 1 addition & 1 deletion src/dashboard/Withdraw/RequestList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import DateTimeHtml from '../../Components/DateTimeHtml';
import { useWithdraw } from './Hooks/useWithdraw';
import { UseWithdrawRequestsReturn } from './Hooks/useWithdrawRequests';
import { isEqual } from 'lodash';
import { DataViews } from '@/Components';
import { DataViews } from '@dokan/components';

function RequestList( {
withdrawRequests,
Expand Down
2 changes: 1 addition & 1 deletion src/dashboard/Withdraw/RequestWithdrawBtn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { useDebounceCallback } from 'usehooks-ts';
import { useCharge } from './Hooks/useCharge';
import { UseWithdrawSettingsReturn } from './Hooks/useWithdrawSettings';
import { UseWithdrawRequestsReturn } from './Hooks/useWithdrawRequests';
import { formatPrice } from '@/utilities';
import { formatPrice } from '@dokan/utilities';

function RequestWithdrawBtn( {
settings,
Expand Down
2 changes: 1 addition & 1 deletion src/dashboard/Withdraw/WithdrawRequests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { __ } from '@wordpress/i18n';
import { twMerge } from 'tailwind-merge';
import RequestWithdrawBtn from './RequestWithdrawBtn';
import { useWithdrawSettings } from './Hooks/useWithdrawSettings';
import { useCurrentUser } from "@/hooks";
import { useCurrentUser } from "@dokan/hooks";

function WithdrawRequests() {
const useWithdrawRequestHook = useWithdrawRequests( true );
Expand Down
2 changes: 1 addition & 1 deletion src/dashboard/Withdraw/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import PaymentDetails from './PaymentDetails';
import PaymentMethods from './PaymentMethods';
import { DokanToaster } from '@getdokan/dokan-ui';
import { useEffect } from '@wordpress/element';
import { useCurrentUser } from "@/hooks";
import { useCurrentUser } from "@dokan/hooks";

const Index = () => {
const useWithdrawRequestHook = useWithdrawRequests( true );
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/index.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { default as useWindowDimensions } from '@/hooks/ViewportDimensions';
export { useCurrentUser } from '@/hooks/useCurrentUser';
export { default as useWindowDimensions } from '@dokan/hooks/ViewportDimensions';
export { useCurrentUser } from '@dokan/hooks/useCurrentUser';
4 changes: 2 additions & 2 deletions src/utils/Bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import Moment from 'moment'
import Notifications from 'vue-notification'
import ListTable from 'vue-wp-list-table';
import Multiselect from 'vue-multiselect'
import API_Helper from '@/utils/Api'
import API_Helper from '@dokan/utils/Api'
import ChartJS from 'vue-chartjs'
import Mixin from './Mixin'
import Debounce from 'debounce'
import VersionCompare from '@/utils/VersionCompare'
import VersionCompare from '@dokan/utils/VersionCompare'
import { parse } from 'papaparse'

window.__ = function( text, domain ) {
Expand Down
8 changes: 4 additions & 4 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ const updatedConfig = {
entry: {
...entryPoints,
'components': {
import: '@/components/index.tsx',
import: '@dokan/components/index.tsx',
},
'utilities': {
import: '@/utilities/index.ts',
import: '@dokan/utilities/index.ts',
},
'hooks': {
import: '@/hooks/index.tsx',
import: '@dokan/hooks/index.tsx',
},
'dokan-status': '/src/Status/index.tsx',
},
Expand All @@ -35,7 +35,7 @@ const updatedConfig = {
...defaultConfig.resolve,
alias: {
'vue$': 'vue/dist/vue.esm.js',
'@': path.resolve('./src/'),
'@dokan': path.resolve('./src/'),
'frontend': path.resolve('./src/frontend/'),
'admin': path.resolve('./src/admin/'),
},
Expand Down

0 comments on commit a6ccacf

Please sign in to comment.