@okam/next-component 1.2.4 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/components/AdminBar/components/AdminBarError.d.ts +4 -0
- package/components/AdminBar/index.d.ts +5 -0
- package/components/AdminBar/index.js +14 -0
- package/components/AdminBar/index.mjs +15 -0
- package/components/AdminBar/interface.d.ts +14 -0
- package/components/Filter/index.d.ts +26 -0
- package/components/Filter/index.js +54 -0
- package/components/Filter/index.mjs +55 -0
- package/components/Filter/interface.d.ts +9 -0
- package/components/Link/index.js +2 -2
- package/hooks/useFilterState/index.d.ts +15 -0
- package/hooks/useFilterState/index.js +50 -0
- package/hooks/useFilterState/index.mjs +50 -0
- package/hooks/useFilterState/interface.d.ts +17 -0
- package/hooks/useHash/index.js +2 -2
- package/hooks/useLink/index.js +5 -5
- package/index.d.ts +7 -0
- package/index.js +16 -4
- package/index.mjs +12 -0
- package/lib/createServerContext/index.js +2 -2
- package/package.json +10 -3
- package/providers/AdminBar/index.d.ts +4 -0
- package/providers/AdminBar/index.js +16 -0
- package/providers/AdminBar/index.mjs +16 -0
- package/providers/AdminBar/interface.d.ts +10 -0
- package/providers/DraftMode/index.d.ts +4 -0
- package/providers/DraftMode/index.js +15 -0
- package/providers/DraftMode/index.mjs +15 -0
- package/providers/DraftMode/interface.d.ts +12 -0
- package/providers/DraftMode/server.d.ts +4 -0
- package/providers/DraftMode/server.js +10 -0
- package/providers/DraftMode/server.mjs +11 -0
- package/server.d.ts +2 -0
- package/server.js +6 -2
- package/server.mjs +4 -0
- package/theme/AdminBar/index.d.ts +900 -0
- package/theme/AdminBar/index.js +120 -0
- package/theme/AdminBar/index.mjs +120 -0
- package/theme/Button/index.d.ts +149 -0
- package/theme/Button/index.js +75 -0
- package/theme/Button/index.mjs +76 -0
- package/theme/Filter/index.d.ts +2030 -0
- package/theme/Filter/index.js +72 -0
- package/theme/Filter/index.mjs +73 -0
- package/theme/Typography/index.d.ts +233 -0
- package/theme/Typography/index.js +43 -0
- package/theme/Typography/index.mjs +44 -0
- package/theme/index.d.ts +3 -1
- package/theme/index.js +16 -0
- package/theme/index.mjs +17 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
## 1.3.0 (2026-01-15)
|
|
2
|
+
|
|
3
|
+
### 🚀 Features
|
|
4
|
+
|
|
5
|
+
- **admin-bar:** add AdminBar with draft mode support ([289427e](https://github.com/OKAMca/stack/commit/289427e))
|
|
6
|
+
- **next-component:** nuqs wrapper for react-aria ([d63f2f7](https://github.com/OKAMca/stack/commit/d63f2f7))
|
|
7
|
+
- ⚠️ React 19 + Next.js 15 upgrade for all @okam/* packages ([#369](https://github.com/OKAMca/stack/pull/369))
|
|
8
|
+
|
|
9
|
+
### 🩹 Fixes
|
|
10
|
+
|
|
11
|
+
- adminbar safe draft mode handling ([#385](https://github.com/OKAMca/stack/pull/385))
|
|
12
|
+
|
|
13
|
+
### ⚠️ Breaking Changes
|
|
14
|
+
|
|
15
|
+
- Consumers must now have react and react-dom in their own
|
|
16
|
+
|
|
17
|
+
### ❤️ Thank You
|
|
18
|
+
|
|
19
|
+
- Marie-Maxime Tanguay @marie-maxime
|
|
20
|
+
- Pierre-Olivier Clerson @poclerson
|
|
21
|
+
|
|
1
22
|
## 1.2.4 (2026-01-14)
|
|
2
23
|
|
|
3
24
|
### 🚀 Features
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { TToken } from '../../../../stack-ui/src/index.ts';
|
|
2
|
+
import { TAdminBarProps } from './interface';
|
|
3
|
+
|
|
4
|
+
declare const AdminBar: <T extends TToken>({ children, themeName, tokens, customTheme, }: TAdminBarProps<T>) => Promise<false | import("react/jsx-runtime").JSX.Element>;
|
|
5
|
+
export default AdminBar;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
3
|
+
const stackUi = require("@okam/stack-ui");
|
|
4
|
+
const headers_js = require("next/headers.js");
|
|
5
|
+
const AdminBar = async ({
|
|
6
|
+
children,
|
|
7
|
+
themeName = "adminBar",
|
|
8
|
+
tokens,
|
|
9
|
+
customTheme
|
|
10
|
+
}) => {
|
|
11
|
+
const { isEnabled } = await headers_js.draftMode();
|
|
12
|
+
return isEnabled && /* @__PURE__ */ jsxRuntime.jsx(stackUi.Box, { themeName: `${themeName}.container`, tokens, customTheme, children: /* @__PURE__ */ jsxRuntime.jsx(stackUi.Box, { themeName: `${themeName}.content`, tokens, children }) });
|
|
13
|
+
};
|
|
14
|
+
module.exports = AdminBar;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Box } from "@okam/stack-ui";
|
|
3
|
+
import { draftMode } from "next/headers.js";
|
|
4
|
+
const AdminBar = async ({
|
|
5
|
+
children,
|
|
6
|
+
themeName = "adminBar",
|
|
7
|
+
tokens,
|
|
8
|
+
customTheme
|
|
9
|
+
}) => {
|
|
10
|
+
const { isEnabled } = await draftMode();
|
|
11
|
+
return isEnabled && /* @__PURE__ */ jsx(Box, { themeName: `${themeName}.container`, tokens, customTheme, children: /* @__PURE__ */ jsx(Box, { themeName: `${themeName}.content`, tokens, children }) });
|
|
12
|
+
};
|
|
13
|
+
export {
|
|
14
|
+
AdminBar as default
|
|
15
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TDefaultComponent, TToken } from '../../../../stack-ui/src/index.ts';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* AdminBar Component Props
|
|
6
|
+
*
|
|
7
|
+
* The AdminBar is inspired by WordPress admin bar and provides a container for administrative controls.
|
|
8
|
+
* Its visibility is driven by Next.js's draftMode cookie.
|
|
9
|
+
*
|
|
10
|
+
* @property {ReactNode} children - Content to render inside the AdminBar. Put the DraftMode component inside the children.
|
|
11
|
+
*/
|
|
12
|
+
export interface TAdminBarProps<T = TToken> extends TDefaultComponent<T> {
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { TToken } from '../../../../stack-ui/src/index.ts';
|
|
2
|
+
import { TFilterProps } from './interface';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* ### Filter component for URL search params filtering.
|
|
6
|
+
*
|
|
7
|
+
* Format: `?{{props.id}}={{props.selectedKeys}}` where `selectedKeys` is a comma-separated list of all currently selected keys
|
|
8
|
+
* @param props.selectedKeys - The currently selected keys. Leave empty for the Filter component to be uncontrolled, or pass a `Key[]` for controlled behavior.
|
|
9
|
+
* @param props.onSelectionChange - The callback function that is called when the selection changes. Pass a function that updates the `selectedKeys` state if you are using controlled behavior.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* #### Controlled state
|
|
13
|
+
* ```tsx
|
|
14
|
+
* const [selectedKeys, setSelectedKeys] = useState<Key[]>([])
|
|
15
|
+
*
|
|
16
|
+
* <Filter id="shape" selectedKeys={selectedKeys} onSelectionChange={setSelectedKeys}>
|
|
17
|
+
* <Item key="circle">Circle</Item>
|
|
18
|
+
* <Item key="square">Square</Item>
|
|
19
|
+
* <Item key="triangle">Triangle</Item>
|
|
20
|
+
* </Filter>
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @returns
|
|
24
|
+
*/
|
|
25
|
+
declare const Filter: <T extends TToken = TToken>(props: TFilterProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
export default Filter;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const stackUi = require("@okam/stack-ui");
|
|
5
|
+
const index = require("../../hooks/useFilterState/index.js");
|
|
6
|
+
const Filter = (props) => {
|
|
7
|
+
const {
|
|
8
|
+
// TagGroup-specific props
|
|
9
|
+
children,
|
|
10
|
+
items,
|
|
11
|
+
defaultSelectedKeys,
|
|
12
|
+
selectedKeys,
|
|
13
|
+
selectionBehavior,
|
|
14
|
+
selectionMode = "multiple",
|
|
15
|
+
options,
|
|
16
|
+
description,
|
|
17
|
+
disabledKeys,
|
|
18
|
+
disallowEmptySelection,
|
|
19
|
+
errorMessage,
|
|
20
|
+
onRemove,
|
|
21
|
+
onSelectionChange,
|
|
22
|
+
// Common props
|
|
23
|
+
themeName = "filter",
|
|
24
|
+
tokens,
|
|
25
|
+
customTheme,
|
|
26
|
+
// PopoverButton props with defaults
|
|
27
|
+
type = "dialog",
|
|
28
|
+
placement = "bottom",
|
|
29
|
+
// Remaining PopoverButton props
|
|
30
|
+
...popoverButtonProps
|
|
31
|
+
} = props;
|
|
32
|
+
const tagGroupProps = {
|
|
33
|
+
items,
|
|
34
|
+
selectionBehavior,
|
|
35
|
+
selectionMode,
|
|
36
|
+
description,
|
|
37
|
+
disallowEmptySelection,
|
|
38
|
+
errorMessage,
|
|
39
|
+
onRemove
|
|
40
|
+
};
|
|
41
|
+
const state = index.useFilterState({ ...props, selectionMode });
|
|
42
|
+
return /* @__PURE__ */ jsxRuntime.jsx(stackUi.Box, { themeName: `${themeName}.wrapper`, tokens, customTheme, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
43
|
+
stackUi.PopoverButton,
|
|
44
|
+
{
|
|
45
|
+
themeName: `${themeName}.popover`,
|
|
46
|
+
tokens,
|
|
47
|
+
type,
|
|
48
|
+
placement,
|
|
49
|
+
...popoverButtonProps,
|
|
50
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(stackUi.TagGroup, { themeName: `${themeName}.tagGroup`, tokens, ...tagGroupProps, ...state, children })
|
|
51
|
+
}
|
|
52
|
+
) });
|
|
53
|
+
};
|
|
54
|
+
module.exports = Filter;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Box, PopoverButton, TagGroup } from "@okam/stack-ui";
|
|
4
|
+
import { useFilterState } from "../../hooks/useFilterState/index.mjs";
|
|
5
|
+
const Filter = (props) => {
|
|
6
|
+
const {
|
|
7
|
+
// TagGroup-specific props
|
|
8
|
+
children,
|
|
9
|
+
items,
|
|
10
|
+
defaultSelectedKeys,
|
|
11
|
+
selectedKeys,
|
|
12
|
+
selectionBehavior,
|
|
13
|
+
selectionMode = "multiple",
|
|
14
|
+
options,
|
|
15
|
+
description,
|
|
16
|
+
disabledKeys,
|
|
17
|
+
disallowEmptySelection,
|
|
18
|
+
errorMessage,
|
|
19
|
+
onRemove,
|
|
20
|
+
onSelectionChange,
|
|
21
|
+
// Common props
|
|
22
|
+
themeName = "filter",
|
|
23
|
+
tokens,
|
|
24
|
+
customTheme,
|
|
25
|
+
// PopoverButton props with defaults
|
|
26
|
+
type = "dialog",
|
|
27
|
+
placement = "bottom",
|
|
28
|
+
// Remaining PopoverButton props
|
|
29
|
+
...popoverButtonProps
|
|
30
|
+
} = props;
|
|
31
|
+
const tagGroupProps = {
|
|
32
|
+
items,
|
|
33
|
+
selectionBehavior,
|
|
34
|
+
selectionMode,
|
|
35
|
+
description,
|
|
36
|
+
disallowEmptySelection,
|
|
37
|
+
errorMessage,
|
|
38
|
+
onRemove
|
|
39
|
+
};
|
|
40
|
+
const state = useFilterState({ ...props, selectionMode });
|
|
41
|
+
return /* @__PURE__ */ jsx(Box, { themeName: `${themeName}.wrapper`, tokens, customTheme, children: /* @__PURE__ */ jsx(
|
|
42
|
+
PopoverButton,
|
|
43
|
+
{
|
|
44
|
+
themeName: `${themeName}.popover`,
|
|
45
|
+
tokens,
|
|
46
|
+
type,
|
|
47
|
+
placement,
|
|
48
|
+
...popoverButtonProps,
|
|
49
|
+
children: /* @__PURE__ */ jsx(TagGroup, { themeName: `${themeName}.tagGroup`, tokens, ...tagGroupProps, ...state, children })
|
|
50
|
+
}
|
|
51
|
+
) });
|
|
52
|
+
};
|
|
53
|
+
export {
|
|
54
|
+
Filter as default
|
|
55
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TToken, TDefaultComponent, TPopoverButtonProps } from '../../../../stack-ui/src/index.ts';
|
|
2
|
+
import { TFilter } from '../../hooks/useFilterState/interface';
|
|
3
|
+
|
|
4
|
+
export interface TFilterTagGroupProps<T = TToken> extends Omit<TDefaultComponent<T>, 'children'>, TFilter {
|
|
5
|
+
}
|
|
6
|
+
export interface TFilterPopoverButtonProps<T = TToken> extends Omit<TPopoverButtonProps<T>, 'type' | 'placement'>, Pick<Partial<TPopoverButtonProps<T>>, 'type' | 'placement'> {
|
|
7
|
+
}
|
|
8
|
+
export interface TFilterProps<T = TToken> extends Omit<TFilterTagGroupProps<T>, 'label'>, Omit<TFilterPopoverButtonProps<T>, 'children' | 'id'> {
|
|
9
|
+
}
|
package/components/Link/index.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
|
4
4
|
const stackUi = require("@okam/stack-ui");
|
|
5
5
|
const NextLink = require("next/link.js");
|
|
6
|
-
const
|
|
6
|
+
const React = require("react");
|
|
7
7
|
const index = require("../../hooks/useLink/index.js");
|
|
8
|
-
const Link =
|
|
8
|
+
const Link = React.forwardRef((props, ref) => {
|
|
9
9
|
const {
|
|
10
10
|
themeName = "link",
|
|
11
11
|
tokens,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Selection } from 'react-stately';
|
|
2
|
+
import { TFilter } from './interface';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Manages the selection state of a single filter.
|
|
6
|
+
* The state is managed by `useListState` from `react-stately`, which controls `useQueryState` from `nuqs` to display the selected keys in the URL search params.
|
|
7
|
+
*/
|
|
8
|
+
export declare function useFilterState(props: TFilter): {
|
|
9
|
+
onSelectionChange: (keys: Selection) => void;
|
|
10
|
+
selectedKeys: import('./interface').TFilterValue;
|
|
11
|
+
defaultSelectedKeys: Set<import('react-stately').Key>;
|
|
12
|
+
collection: import('react-stately').Collection<import('react-stately').Node<import('./interface').TFilterItem<import('../../../../stack-ui/src/index.ts').TToken>>>;
|
|
13
|
+
disabledKeys: Set<import('react-stately').Key>;
|
|
14
|
+
selectionManager: import('@react-stately/selection').SelectionManager;
|
|
15
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
+
const nuqs = require("nuqs");
|
|
5
|
+
const radashi = require("radashi");
|
|
6
|
+
const React = require("react");
|
|
7
|
+
const reactStately = require("react-stately");
|
|
8
|
+
const reactUse = require("react-use");
|
|
9
|
+
function useFilterState(props) {
|
|
10
|
+
const {
|
|
11
|
+
id,
|
|
12
|
+
defaultSelectedKeys: defaultSelectedKeysProp = [],
|
|
13
|
+
onSelectionChange,
|
|
14
|
+
selectionMode = "multiple",
|
|
15
|
+
parser = nuqs.parseAsArrayOf(nuqs.parseAsString),
|
|
16
|
+
children,
|
|
17
|
+
items,
|
|
18
|
+
options,
|
|
19
|
+
...rest
|
|
20
|
+
} = props;
|
|
21
|
+
const defaultValue = Array.from(defaultSelectedKeysProp).map((key) => key.toString());
|
|
22
|
+
const queryStateOptions = React.useMemo(
|
|
23
|
+
() => parser.withOptions(options ?? {}).withDefault(defaultValue),
|
|
24
|
+
[parser, options, defaultValue]
|
|
25
|
+
);
|
|
26
|
+
const [selectedKeys, setSelectedKeys] = nuqs.useQueryState(id, queryStateOptions);
|
|
27
|
+
const onSelectedKeysChange = (keys) => {
|
|
28
|
+
onSelectionChange == null ? void 0 : onSelectionChange(keys);
|
|
29
|
+
const stringKeys = Array.from(keys).map((key) => key.toString());
|
|
30
|
+
setSelectedKeys(stringKeys);
|
|
31
|
+
};
|
|
32
|
+
const defaultSelectedKeys = /* @__PURE__ */ new Set([...defaultSelectedKeysProp, ...selectedKeys ?? []]);
|
|
33
|
+
const state = reactStately.useListState({
|
|
34
|
+
...rest,
|
|
35
|
+
children,
|
|
36
|
+
items,
|
|
37
|
+
selectionMode,
|
|
38
|
+
defaultSelectedKeys,
|
|
39
|
+
onSelectionChange: onSelectedKeysChange
|
|
40
|
+
});
|
|
41
|
+
reactUse.useUpdateEffect(() => {
|
|
42
|
+
const next = [...state.selectionManager.selectedKeys].map(String);
|
|
43
|
+
if (radashi.isEqual(next, selectedKeys)) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
setSelectedKeys(next);
|
|
47
|
+
}, [state.selectionManager.selectedKeys]);
|
|
48
|
+
return { ...state, onSelectionChange: onSelectedKeysChange, selectedKeys, defaultSelectedKeys };
|
|
49
|
+
}
|
|
50
|
+
exports.useFilterState = useFilterState;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { parseAsArrayOf, parseAsString, useQueryState } from "nuqs";
|
|
3
|
+
import { isEqual } from "radashi";
|
|
4
|
+
import { useMemo } from "react";
|
|
5
|
+
import { useListState } from "react-stately";
|
|
6
|
+
import { useUpdateEffect } from "react-use";
|
|
7
|
+
function useFilterState(props) {
|
|
8
|
+
const {
|
|
9
|
+
id,
|
|
10
|
+
defaultSelectedKeys: defaultSelectedKeysProp = [],
|
|
11
|
+
onSelectionChange,
|
|
12
|
+
selectionMode = "multiple",
|
|
13
|
+
parser = parseAsArrayOf(parseAsString),
|
|
14
|
+
children,
|
|
15
|
+
items,
|
|
16
|
+
options,
|
|
17
|
+
...rest
|
|
18
|
+
} = props;
|
|
19
|
+
const defaultValue = Array.from(defaultSelectedKeysProp).map((key) => key.toString());
|
|
20
|
+
const queryStateOptions = useMemo(
|
|
21
|
+
() => parser.withOptions(options ?? {}).withDefault(defaultValue),
|
|
22
|
+
[parser, options, defaultValue]
|
|
23
|
+
);
|
|
24
|
+
const [selectedKeys, setSelectedKeys] = useQueryState(id, queryStateOptions);
|
|
25
|
+
const onSelectedKeysChange = (keys) => {
|
|
26
|
+
onSelectionChange == null ? void 0 : onSelectionChange(keys);
|
|
27
|
+
const stringKeys = Array.from(keys).map((key) => key.toString());
|
|
28
|
+
setSelectedKeys(stringKeys);
|
|
29
|
+
};
|
|
30
|
+
const defaultSelectedKeys = /* @__PURE__ */ new Set([...defaultSelectedKeysProp, ...selectedKeys ?? []]);
|
|
31
|
+
const state = useListState({
|
|
32
|
+
...rest,
|
|
33
|
+
children,
|
|
34
|
+
items,
|
|
35
|
+
selectionMode,
|
|
36
|
+
defaultSelectedKeys,
|
|
37
|
+
onSelectionChange: onSelectedKeysChange
|
|
38
|
+
});
|
|
39
|
+
useUpdateEffect(() => {
|
|
40
|
+
const next = [...state.selectionManager.selectedKeys].map(String);
|
|
41
|
+
if (isEqual(next, selectedKeys)) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
setSelectedKeys(next);
|
|
45
|
+
}, [state.selectionManager.selectedKeys]);
|
|
46
|
+
return { ...state, onSelectionChange: onSelectedKeysChange, selectedKeys, defaultSelectedKeys };
|
|
47
|
+
}
|
|
48
|
+
export {
|
|
49
|
+
useFilterState
|
|
50
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { TDefaultItemComponent, TToken } from '../../../../stack-ui/src/index.ts';
|
|
2
|
+
import { Options, ParserBuilder } from 'nuqs';
|
|
3
|
+
import { AriaTagGroupProps } from 'react-aria';
|
|
4
|
+
import { SelectionMode } from 'react-stately';
|
|
5
|
+
|
|
6
|
+
export type TFilterValue = string[];
|
|
7
|
+
export type TFilterItem<T extends TToken = TToken> = TDefaultItemComponent<never, T>;
|
|
8
|
+
export interface TFilter extends Omit<AriaTagGroupProps<TFilterItem>, 'selectionMode'> {
|
|
9
|
+
id: string;
|
|
10
|
+
/**
|
|
11
|
+
* @default parseAsArrayOf(parseAsString)
|
|
12
|
+
*/
|
|
13
|
+
parser?: ParserBuilder<TFilterValue>;
|
|
14
|
+
defaultSelectedKeys?: Exclude<AriaTagGroupProps<object>['defaultSelectedKeys'], 'all'>;
|
|
15
|
+
options?: Options;
|
|
16
|
+
selectionMode?: Exclude<SelectionMode, 'none'>;
|
|
17
|
+
}
|
package/hooks/useHash/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
-
const
|
|
4
|
+
const React = require("react");
|
|
5
5
|
const reactUse = require("react-use");
|
|
6
6
|
function getHash() {
|
|
7
7
|
if (typeof window === "undefined") return "";
|
|
@@ -9,7 +9,7 @@ function getHash() {
|
|
|
9
9
|
}
|
|
10
10
|
function useHash() {
|
|
11
11
|
const defaultHash = getHash();
|
|
12
|
-
const [hash, setHash] =
|
|
12
|
+
const [hash, setHash] = React.useState(defaultHash);
|
|
13
13
|
const handleHashChangeEvent = ({ newURL }) => {
|
|
14
14
|
if (!URL.canParse(newURL)) return;
|
|
15
15
|
const { hash: newHash } = new URL(newURL);
|
package/hooks/useLink/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
4
|
const navigation_js = require("next/navigation.js");
|
|
5
|
-
const
|
|
5
|
+
const React = require("react");
|
|
6
6
|
const reactAria = require("react-aria");
|
|
7
7
|
const index = require("../useHash/index.js");
|
|
8
8
|
function scrollToTop(behavior) {
|
|
@@ -55,7 +55,7 @@ function useLink(props) {
|
|
|
55
55
|
const hash = index.useHash();
|
|
56
56
|
const isNextScroll = typeof scroll === "boolean";
|
|
57
57
|
const nextScroll = isNextScroll ? scroll : false;
|
|
58
|
-
const handleScroll =
|
|
58
|
+
const handleScroll = React.useCallback(() => {
|
|
59
59
|
if (isNextScroll) return;
|
|
60
60
|
scrollToTop(behavior);
|
|
61
61
|
}, [behavior, isNextScroll]);
|
|
@@ -67,13 +67,13 @@ function useLink(props) {
|
|
|
67
67
|
onTouchStart == null ? void 0 : onTouchStart(event);
|
|
68
68
|
handleScroll();
|
|
69
69
|
};
|
|
70
|
-
|
|
70
|
+
React.useEffect(() => {
|
|
71
71
|
onPathnameChange == null ? void 0 : onPathnameChange(pathname);
|
|
72
72
|
}, [onPathnameChange, pathname]);
|
|
73
|
-
|
|
73
|
+
React.useEffect(() => {
|
|
74
74
|
onSearchParamsChange == null ? void 0 : onSearchParamsChange(searchParams);
|
|
75
75
|
}, [onSearchParamsChange, searchParams]);
|
|
76
|
-
|
|
76
|
+
React.useEffect(() => {
|
|
77
77
|
onHashChange == null ? void 0 : onHashChange(hash);
|
|
78
78
|
}, [onHashChange, hash]);
|
|
79
79
|
return {
|
package/index.d.ts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
export { default as Img } from './components/Img';
|
|
2
2
|
export { default as Link } from './components/Link';
|
|
3
|
+
export { default as Filter } from './components/Filter';
|
|
3
4
|
export { useLink } from './hooks/useLink';
|
|
4
5
|
export { useHash } from './hooks/useHash';
|
|
6
|
+
export { useFilterState } from './hooks/useFilterState';
|
|
5
7
|
export type { default as TImgProps } from './components/Img/interface';
|
|
6
8
|
export type { TLinkProps } from './components/Link/interface';
|
|
7
9
|
export type { TLink } from './hooks/useLink/interface';
|
|
10
|
+
export type { TFilter } from './hooks/useFilterState/interface';
|
|
11
|
+
export type { TFilterProps } from './components/Filter/interface';
|
|
12
|
+
export { DraftModeContextProvider, useDraftMode } from './providers/DraftMode';
|
|
13
|
+
export { AdminBarContextProvider, useAdminBar } from './providers/AdminBar';
|
|
14
|
+
export { default as ThemeProvider } from './theme';
|
package/index.js
CHANGED
|
@@ -2,9 +2,21 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const index = require("./components/Img/index.js");
|
|
4
4
|
const index$1 = require("./components/Link/index.js");
|
|
5
|
-
const index$2 = require("./
|
|
6
|
-
const index$3 = require("./hooks/
|
|
5
|
+
const index$2 = require("./components/Filter/index.js");
|
|
6
|
+
const index$3 = require("./hooks/useLink/index.js");
|
|
7
|
+
const index$4 = require("./hooks/useHash/index.js");
|
|
8
|
+
const index$5 = require("./hooks/useFilterState/index.js");
|
|
9
|
+
const index$6 = require("./providers/DraftMode/index.js");
|
|
10
|
+
const index$7 = require("./providers/AdminBar/index.js");
|
|
11
|
+
const index$8 = require("./theme/index.js");
|
|
7
12
|
exports.Img = index;
|
|
8
13
|
exports.Link = index$1;
|
|
9
|
-
exports.
|
|
10
|
-
exports.
|
|
14
|
+
exports.Filter = index$2;
|
|
15
|
+
exports.useLink = index$3.useLink;
|
|
16
|
+
exports.useHash = index$4.useHash;
|
|
17
|
+
exports.useFilterState = index$5.useFilterState;
|
|
18
|
+
exports.DraftModeContextProvider = index$6.DraftModeContextProvider;
|
|
19
|
+
exports.useDraftMode = index$6.useDraftMode;
|
|
20
|
+
exports.AdminBarContextProvider = index$7.AdminBarContextProvider;
|
|
21
|
+
exports.useAdminBar = index$7.useAdminBar;
|
|
22
|
+
exports.ThemeProvider = index$8;
|
package/index.mjs
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
import { default as default2 } from "./components/Img/index.mjs";
|
|
2
2
|
import { default as default3 } from "./components/Link/index.mjs";
|
|
3
|
+
import { default as default4 } from "./components/Filter/index.mjs";
|
|
3
4
|
import { useLink } from "./hooks/useLink/index.mjs";
|
|
4
5
|
import { useHash } from "./hooks/useHash/index.mjs";
|
|
6
|
+
import { useFilterState } from "./hooks/useFilterState/index.mjs";
|
|
7
|
+
import { DraftModeContextProvider, useDraftMode } from "./providers/DraftMode/index.mjs";
|
|
8
|
+
import { AdminBarContextProvider, useAdminBar } from "./providers/AdminBar/index.mjs";
|
|
9
|
+
import { default as default5 } from "./theme/index.mjs";
|
|
5
10
|
export {
|
|
11
|
+
AdminBarContextProvider,
|
|
12
|
+
DraftModeContextProvider,
|
|
13
|
+
default4 as Filter,
|
|
6
14
|
default2 as Img,
|
|
7
15
|
default3 as Link,
|
|
16
|
+
default5 as ThemeProvider,
|
|
17
|
+
useAdminBar,
|
|
18
|
+
useDraftMode,
|
|
19
|
+
useFilterState,
|
|
8
20
|
useHash,
|
|
9
21
|
useLink
|
|
10
22
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
3
|
+
const React = require("react");
|
|
4
4
|
function createServerContext(defaultValue) {
|
|
5
|
-
const getRef =
|
|
5
|
+
const getRef = React.cache(() => ({ current: defaultValue }));
|
|
6
6
|
const getValue = () => getRef().current;
|
|
7
7
|
const setValue = (value) => {
|
|
8
8
|
getRef().current = value;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@okam/next-component",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -31,13 +31,20 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@okam/stack-ui": "1.44.0",
|
|
34
|
+
"@okam/core-lib": "1.17.0",
|
|
34
35
|
"next": "^15.0.0",
|
|
35
36
|
"react-use": "17.5.1",
|
|
36
37
|
"tailwind-variants": "^0.3.0",
|
|
37
|
-
"react-aria": "^3.39.0"
|
|
38
|
+
"react-aria": "^3.39.0",
|
|
39
|
+
"react-stately": "^3.43.0",
|
|
40
|
+
"nuqs": "^2.4.3",
|
|
41
|
+
"radashi": "^12.3.0"
|
|
38
42
|
},
|
|
39
43
|
"peerDependencies": {
|
|
40
|
-
"react": "^18.0.0 || ^19.0.0"
|
|
44
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
45
|
+
"next": "^15.0.0",
|
|
46
|
+
"nuqs": "^2.4.0",
|
|
47
|
+
"react-stately": "^3.43.0"
|
|
41
48
|
},
|
|
42
49
|
"devDependencies": {
|
|
43
50
|
"react": "^19.0.0"
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { TAdminBarContext, TAdminBarProviderProps } from './interface';
|
|
2
|
+
|
|
3
|
+
export declare const useAdminBar: () => TAdminBarContext, AdminBarProvider: import('react').Provider<TAdminBarContext | undefined>;
|
|
4
|
+
export declare function AdminBarContextProvider(props: TAdminBarProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
5
|
+
const coreLib = require("@okam/core-lib");
|
|
6
|
+
const React = require("react");
|
|
7
|
+
const [useAdminBar, AdminBarProvider] = coreLib.createCtx();
|
|
8
|
+
function AdminBarContextProvider(props) {
|
|
9
|
+
const { children } = props;
|
|
10
|
+
const [error, setError] = React.useState();
|
|
11
|
+
const value = React.useMemo(() => ({ error, setError }), [error]);
|
|
12
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AdminBarProvider, { value, children });
|
|
13
|
+
}
|
|
14
|
+
exports.AdminBarContextProvider = AdminBarContextProvider;
|
|
15
|
+
exports.AdminBarProvider = AdminBarProvider;
|
|
16
|
+
exports.useAdminBar = useAdminBar;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { createCtx } from "@okam/core-lib";
|
|
4
|
+
import { useState, useMemo } from "react";
|
|
5
|
+
const [useAdminBar, AdminBarProvider] = createCtx();
|
|
6
|
+
function AdminBarContextProvider(props) {
|
|
7
|
+
const { children } = props;
|
|
8
|
+
const [error, setError] = useState();
|
|
9
|
+
const value = useMemo(() => ({ error, setError }), [error]);
|
|
10
|
+
return /* @__PURE__ */ jsx(AdminBarProvider, { value, children });
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
AdminBarContextProvider,
|
|
14
|
+
AdminBarProvider,
|
|
15
|
+
useAdminBar
|
|
16
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Nullable } from '../../../../stack-ui/src/index.ts';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
export interface TAdminBarProviderProps {
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export type TAdminBarContext = {
|
|
8
|
+
error: Nullable<Error>;
|
|
9
|
+
setError: (error: Nullable<Error>) => void;
|
|
10
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { TDraftModeContext, TDraftModeProviderProps } from './interface';
|
|
2
|
+
|
|
3
|
+
export declare const useDraftMode: () => TDraftModeContext, DraftModeProvider: import('react').Provider<TDraftModeContext | undefined>;
|
|
4
|
+
export declare function DraftModeContextProvider(props: TDraftModeProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
5
|
+
const coreLib = require("@okam/core-lib");
|
|
6
|
+
const React = require("react");
|
|
7
|
+
const [useDraftMode, DraftModeProvider] = coreLib.createCtx();
|
|
8
|
+
function DraftModeContextProvider(props) {
|
|
9
|
+
const { children, isEnabled } = props;
|
|
10
|
+
const value = React.useMemo(() => ({ isEnabled }), [isEnabled]);
|
|
11
|
+
return /* @__PURE__ */ jsxRuntime.jsx(DraftModeProvider, { value, children });
|
|
12
|
+
}
|
|
13
|
+
exports.DraftModeContextProvider = DraftModeContextProvider;
|
|
14
|
+
exports.DraftModeProvider = DraftModeProvider;
|
|
15
|
+
exports.useDraftMode = useDraftMode;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { createCtx } from "@okam/core-lib";
|
|
4
|
+
import { useMemo } from "react";
|
|
5
|
+
const [useDraftMode, DraftModeProvider] = createCtx();
|
|
6
|
+
function DraftModeContextProvider(props) {
|
|
7
|
+
const { children, isEnabled } = props;
|
|
8
|
+
const value = useMemo(() => ({ isEnabled }), [isEnabled]);
|
|
9
|
+
return /* @__PURE__ */ jsx(DraftModeProvider, { value, children });
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
DraftModeContextProvider,
|
|
13
|
+
DraftModeProvider,
|
|
14
|
+
useDraftMode
|
|
15
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
export interface TDraftModeProviderProps {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
isEnabled: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface TDraftModeServerProviderProps {
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
}
|
|
10
|
+
export type TDraftModeContext = {
|
|
11
|
+
isEnabled: boolean;
|
|
12
|
+
};
|