@yamada-ui/react 2.3.0-dev-20261024165228 → 2.3.0-dev-20261025045056
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/dist/cjs/components/accordion/use-accordion.cjs +4 -5
- package/dist/cjs/components/accordion/use-accordion.cjs.map +1 -1
- package/dist/cjs/components/checkbox/use-checkbox-group.cjs +6 -6
- package/dist/cjs/components/checkbox/use-checkbox-group.cjs.map +1 -1
- package/dist/cjs/components/checkbox/use-checkbox.cjs +17 -18
- package/dist/cjs/components/checkbox/use-checkbox.cjs.map +1 -1
- package/dist/cjs/components/code/code.style.cjs +2 -1
- package/dist/cjs/components/code/code.style.cjs.map +1 -1
- package/dist/cjs/components/color-picker/use-color-picker.cjs +14 -16
- package/dist/cjs/components/color-picker/use-color-picker.cjs.map +1 -1
- package/dist/cjs/components/color-selector/use-color-selector.cjs +4 -5
- package/dist/cjs/components/color-selector/use-color-selector.cjs.map +1 -1
- package/dist/cjs/components/dropzone/use-dropzone.cjs +3 -4
- package/dist/cjs/components/dropzone/use-dropzone.cjs.map +1 -1
- package/dist/cjs/components/file-input/use-file-input.cjs +5 -5
- package/dist/cjs/components/file-input/use-file-input.cjs.map +1 -1
- package/dist/cjs/components/kbd/kbd.style.cjs +2 -1
- package/dist/cjs/components/kbd/kbd.style.cjs.map +1 -1
- package/dist/cjs/components/menu/use-menu.cjs +36 -49
- package/dist/cjs/components/menu/use-menu.cjs.map +1 -1
- package/dist/cjs/components/modal/use-modal.cjs +5 -7
- package/dist/cjs/components/modal/use-modal.cjs.map +1 -1
- package/dist/cjs/components/native-popover/use-native-popover.cjs +8 -8
- package/dist/cjs/components/native-popover/use-native-popover.cjs.map +1 -1
- package/dist/cjs/components/pin-input/use-pin-input.cjs +10 -9
- package/dist/cjs/components/pin-input/use-pin-input.cjs.map +1 -1
- package/dist/cjs/components/radio/use-radio-group.cjs +12 -13
- package/dist/cjs/components/radio/use-radio-group.cjs.map +1 -1
- package/dist/cjs/components/radio/use-radio.cjs +15 -18
- package/dist/cjs/components/radio/use-radio.cjs.map +1 -1
- package/dist/cjs/components/saturation-slider/use-saturation-slider.cjs +4 -6
- package/dist/cjs/components/saturation-slider/use-saturation-slider.cjs.map +1 -1
- package/dist/cjs/components/select/use-select.cjs +5 -6
- package/dist/cjs/components/select/use-select.cjs.map +1 -1
- package/dist/cjs/components/sidebar/use-sidebar.cjs +13 -19
- package/dist/cjs/components/sidebar/use-sidebar.cjs.map +1 -1
- package/dist/cjs/components/slider/use-slider.cjs +13 -18
- package/dist/cjs/components/slider/use-slider.cjs.map +1 -1
- package/dist/cjs/components/steps/use-steps.cjs +4 -6
- package/dist/cjs/components/steps/use-steps.cjs.map +1 -1
- package/dist/cjs/components/tabs/use-tabs.cjs +5 -5
- package/dist/cjs/components/tabs/use-tabs.cjs.map +1 -1
- package/dist/cjs/components/tooltip/use-tooltip.cjs +13 -14
- package/dist/cjs/components/tooltip/use-tooltip.cjs.map +1 -1
- package/dist/cjs/core/components/props.cjs +12 -1
- package/dist/cjs/core/components/props.cjs.map +1 -1
- package/dist/cjs/core/index.cjs +2 -0
- package/dist/cjs/core/system/index.cjs +2 -0
- package/dist/cjs/core/system/styled.cjs +23 -12
- package/dist/cjs/core/system/styled.cjs.map +1 -1
- package/dist/cjs/hooks/use-combobox/index.cjs +23 -28
- package/dist/cjs/hooks/use-combobox/index.cjs.map +1 -1
- package/dist/cjs/index.cjs +4 -0
- package/dist/esm/components/accordion/use-accordion.js +4 -5
- package/dist/esm/components/accordion/use-accordion.js.map +1 -1
- package/dist/esm/components/checkbox/use-checkbox-group.js +6 -6
- package/dist/esm/components/checkbox/use-checkbox-group.js.map +1 -1
- package/dist/esm/components/checkbox/use-checkbox.js +17 -18
- package/dist/esm/components/checkbox/use-checkbox.js.map +1 -1
- package/dist/esm/components/code/code.style.js +2 -1
- package/dist/esm/components/code/code.style.js.map +1 -1
- package/dist/esm/components/color-picker/use-color-picker.js +14 -16
- package/dist/esm/components/color-picker/use-color-picker.js.map +1 -1
- package/dist/esm/components/color-selector/use-color-selector.js +4 -5
- package/dist/esm/components/color-selector/use-color-selector.js.map +1 -1
- package/dist/esm/components/dropzone/use-dropzone.js +3 -4
- package/dist/esm/components/dropzone/use-dropzone.js.map +1 -1
- package/dist/esm/components/file-input/use-file-input.js +5 -5
- package/dist/esm/components/file-input/use-file-input.js.map +1 -1
- package/dist/esm/components/kbd/kbd.style.js +2 -1
- package/dist/esm/components/kbd/kbd.style.js.map +1 -1
- package/dist/esm/components/menu/use-menu.js +36 -49
- package/dist/esm/components/menu/use-menu.js.map +1 -1
- package/dist/esm/components/modal/use-modal.js +5 -7
- package/dist/esm/components/modal/use-modal.js.map +1 -1
- package/dist/esm/components/native-popover/use-native-popover.js +8 -8
- package/dist/esm/components/native-popover/use-native-popover.js.map +1 -1
- package/dist/esm/components/pin-input/use-pin-input.js +10 -9
- package/dist/esm/components/pin-input/use-pin-input.js.map +1 -1
- package/dist/esm/components/radio/use-radio-group.js +12 -13
- package/dist/esm/components/radio/use-radio-group.js.map +1 -1
- package/dist/esm/components/radio/use-radio.js +15 -18
- package/dist/esm/components/radio/use-radio.js.map +1 -1
- package/dist/esm/components/saturation-slider/use-saturation-slider.js +4 -6
- package/dist/esm/components/saturation-slider/use-saturation-slider.js.map +1 -1
- package/dist/esm/components/select/use-select.js +5 -6
- package/dist/esm/components/select/use-select.js.map +1 -1
- package/dist/esm/components/sidebar/use-sidebar.js +13 -19
- package/dist/esm/components/sidebar/use-sidebar.js.map +1 -1
- package/dist/esm/components/slider/use-slider.js +13 -18
- package/dist/esm/components/slider/use-slider.js.map +1 -1
- package/dist/esm/components/steps/use-steps.js +4 -6
- package/dist/esm/components/steps/use-steps.js.map +1 -1
- package/dist/esm/components/tabs/use-tabs.js +5 -5
- package/dist/esm/components/tabs/use-tabs.js.map +1 -1
- package/dist/esm/components/tooltip/use-tooltip.js +14 -15
- package/dist/esm/components/tooltip/use-tooltip.js.map +1 -1
- package/dist/esm/core/components/props.js +12 -1
- package/dist/esm/core/components/props.js.map +1 -1
- package/dist/esm/core/index.js +2 -2
- package/dist/esm/core/system/index.js +2 -2
- package/dist/esm/core/system/styled.js +22 -13
- package/dist/esm/core/system/styled.js.map +1 -1
- package/dist/esm/hooks/use-combobox/index.js +23 -28
- package/dist/esm/hooks/use-combobox/index.js.map +1 -1
- package/dist/esm/index.js +4 -2
- package/dist/types/components/carousel/carousel.style.d.ts +2 -2
- package/dist/types/components/menu/menu.style.d.ts +2 -2
- package/dist/types/components/menu/use-menu.d.ts +1 -1
- package/dist/types/components/segmented-control/segmented-control.style.d.ts +2 -2
- package/dist/types/components/steps/steps.style.d.ts +1 -1
- package/dist/types/components/steps/use-steps.d.ts +1 -1
- package/dist/types/components/tabs/use-tabs.d.ts +1 -1
- package/dist/types/components/timeline/timeline.d.ts +1 -1
- package/dist/types/components/timeline/timeline.style.d.ts +1 -1
- package/dist/types/components/tree/tree.style.d.ts +1 -1
- package/dist/types/core/components/index.d.ts +2 -2
- package/dist/types/core/components/props.d.ts +2 -1
- package/dist/types/core/index.d.ts +3 -3
- package/dist/types/core/system/index.d.ts +2 -2
- package/dist/types/core/system/styled.d.ts +1 -0
- package/dist/types/hooks/use-combobox/index.d.ts +1 -1
- package/dist/types/index.d.ts +4 -4
- package/package.json +2 -2
package/dist/cjs/core/index.cjs
CHANGED
|
@@ -43,6 +43,7 @@ exports.DEFAULT_LOCALE = require_constant.DEFAULT_LOCALE;
|
|
|
43
43
|
exports.DEFAULT_VAR_PREFIX = require_constant.DEFAULT_VAR_PREFIX;
|
|
44
44
|
exports.EnvironmentProvider = require_environment_provider.EnvironmentProvider;
|
|
45
45
|
exports.GlobalStyles = require_theme_provider.GlobalStyles;
|
|
46
|
+
exports.HydrationContext = require_styled.HydrationContext;
|
|
46
47
|
exports.SystemProvider = require_system_provider.SystemProvider;
|
|
47
48
|
exports.THEME_SCHEME_STORAGE_KEY = require_constant.THEME_SCHEME_STORAGE_KEY;
|
|
48
49
|
exports.ThemeProvider = require_theme_provider.ThemeProvider;
|
|
@@ -155,6 +156,7 @@ exports.useComponentSlotStyle = require_use_component_style.useComponentSlotStyl
|
|
|
155
156
|
exports.useComponentStyle = require_use_component_style.useComponentStyle;
|
|
156
157
|
exports.useEnvironment = require_environment_provider.useEnvironment;
|
|
157
158
|
exports.useExtractProps = require_props.useExtractProps;
|
|
159
|
+
exports.useHydrationContext = require_styled.useHydrationContext;
|
|
158
160
|
exports.useInjectVarsIntoCss = require_use_inject_vars.useInjectVarsIntoCss;
|
|
159
161
|
exports.useInjectVarsIntoProps = require_use_inject_vars.useInjectVarsIntoProps;
|
|
160
162
|
exports.useSplitProps = require_props.useSplitProps;
|
|
@@ -20,6 +20,7 @@ exports.ColorModeScript = require_storage_script.ColorModeScript;
|
|
|
20
20
|
exports.ColorSchemeContext = require_styled.ColorSchemeContext;
|
|
21
21
|
exports.EnvironmentProvider = require_environment_provider.EnvironmentProvider;
|
|
22
22
|
exports.GlobalStyles = require_theme_provider.GlobalStyles;
|
|
23
|
+
exports.HydrationContext = require_styled.HydrationContext;
|
|
23
24
|
exports.SystemProvider = require_system_provider.SystemProvider;
|
|
24
25
|
exports.ThemeProvider = require_theme_provider.ThemeProvider;
|
|
25
26
|
exports.ThemeSchemeScript = require_storage_script.ThemeSchemeScript;
|
|
@@ -56,6 +57,7 @@ exports.useColorMode = require_color_mode_provider.useColorMode;
|
|
|
56
57
|
exports.useColorModeValue = require_use_color_mode_value.useColorModeValue;
|
|
57
58
|
exports.useColorSchemeContext = require_styled.useColorSchemeContext;
|
|
58
59
|
exports.useEnvironment = require_environment_provider.useEnvironment;
|
|
60
|
+
exports.useHydrationContext = require_styled.useHydrationContext;
|
|
59
61
|
exports.useSystem = require_system_provider.useSystem;
|
|
60
62
|
exports.useSystemColorMode = require_use_system_color_mode.useSystemColorMode;
|
|
61
63
|
exports.useTheme = require_theme_provider.useTheme;
|
|
@@ -65,6 +65,10 @@ const [ColorSchemeContext, useColorSchemeContext] = require_context.createContex
|
|
|
65
65
|
name: "ColorSchemeContext",
|
|
66
66
|
strict: false
|
|
67
67
|
});
|
|
68
|
+
const [HydrationContext, useHydrationContext] = require_context.createContext({
|
|
69
|
+
name: "HydrationContext",
|
|
70
|
+
strict: false
|
|
71
|
+
});
|
|
68
72
|
function createStyled(el, { name, base, compounds, props, sizes, variants, defaultProps, transferProps, ...options } = {}) {
|
|
69
73
|
const displayName = options.displayName ?? require_utils.getDisplayName(name, "");
|
|
70
74
|
const shouldForwardProp = !options.shouldForwardProp ? require_props.createShouldForwardProp(options.forwardProps) : void 0;
|
|
@@ -91,6 +95,7 @@ function createStyled(el, { name, base, compounds, props, sizes, variants, defau
|
|
|
91
95
|
const forwardAsChild = options.forwardAsChild || options.forwardProps?.includes("asChild");
|
|
92
96
|
const [omittedProps, styleProps] = useSplitProps(props, shouldForwardProp);
|
|
93
97
|
const [, rest] = require_use_component_style.useComponentStyle(omittedProps, componentStyleOptions);
|
|
98
|
+
const suppressHydrationWarning = useHydrationContext();
|
|
94
99
|
const [cssArray, colorScheme, forwardProps] = (0, react.useMemo)(() => {
|
|
95
100
|
const { css, colorScheme, ...forwardProps } = rest;
|
|
96
101
|
return [
|
|
@@ -100,6 +105,7 @@ function createStyled(el, { name, base, compounds, props, sizes, variants, defau
|
|
|
100
105
|
];
|
|
101
106
|
}, [rest]);
|
|
102
107
|
styleProps.colorScheme ??= colorScheme;
|
|
108
|
+
forwardProps.suppressHydrationWarning ??= suppressHydrationWarning;
|
|
103
109
|
if (forwardProps.className) className = (0, _emotion_utils.getRegisteredStyles)(cache.registered, registered.current, forwardProps.className).trim();
|
|
104
110
|
const interpolations = (0, react.useMemo)(() => [...registered.current, ...(0, require_utils_index.utils_exports.filterEmpty)([...cssArray, styleProps].map(require_css.css(system, theme)))], [
|
|
105
111
|
cssArray,
|
|
@@ -116,19 +122,22 @@ function createStyled(el, { name, base, compounds, props, sizes, variants, defau
|
|
|
116
122
|
className,
|
|
117
123
|
children
|
|
118
124
|
};
|
|
119
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.
|
|
125
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ColorSchemeContext, {
|
|
120
126
|
value: styleProps.colorScheme,
|
|
121
|
-
children:
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
127
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(HydrationContext, {
|
|
128
|
+
value: mergedProps.suppressHydrationWarning,
|
|
129
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Insertion, {
|
|
130
|
+
cache,
|
|
131
|
+
htmlTag,
|
|
132
|
+
serialized
|
|
133
|
+
}), asChild && !forwardAsChild ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_slot.Slot, {
|
|
134
|
+
ref,
|
|
135
|
+
...mergedProps
|
|
136
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Component, {
|
|
137
|
+
ref,
|
|
138
|
+
...mergedProps
|
|
139
|
+
})]
|
|
140
|
+
})
|
|
132
141
|
});
|
|
133
142
|
});
|
|
134
143
|
StyledComponent.displayName = displayName || "StyledComponent";
|
|
@@ -136,7 +145,9 @@ function createStyled(el, { name, base, compounds, props, sizes, variants, defau
|
|
|
136
145
|
}
|
|
137
146
|
//#endregion
|
|
138
147
|
exports.ColorSchemeContext = ColorSchemeContext;
|
|
148
|
+
exports.HydrationContext = HydrationContext;
|
|
139
149
|
exports.createStyled = createStyled;
|
|
140
150
|
exports.useColorSchemeContext = useColorSchemeContext;
|
|
151
|
+
exports.useHydrationContext = useHydrationContext;
|
|
141
152
|
|
|
142
153
|
//# sourceMappingURL=styled.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styled.cjs","names":["useInsertionEffectAlwaysWithSyncFallback","useRef","isEqual","useMemo","createContext","getDisplayName","createShouldForwardProp","withEmotionCache","useSystem","useTheme","useComponentStyle","getRegisteredStyles","css","serializeStyles","Slot"],"sources":["../../../../src/core/system/styled.tsx"],"sourcesContent":["\"use client\"\n\nimport type { EmotionCache, SerializedStyles } from \"@emotion/utils\"\nimport type { FC } from \"react\"\nimport type { Dict } from \"../../utils\"\nimport type { As, ShouldForwardProp, StyledComponent } from \"../components\"\nimport type { CSSModifierObject, CSSPropObject } from \"../css\"\nimport type {\n ColorScheme,\n ComponentStyle,\n System,\n UsageTheme,\n} from \"./index.type\"\nimport { withEmotionCache } from \"@emotion/react\"\nimport { serializeStyles } from \"@emotion/serialize\"\nimport { useInsertionEffectAlwaysWithSyncFallback } from \"@emotion/use-insertion-effect-with-fallbacks\"\nimport { getRegisteredStyles, registerStyles } from \"@emotion/utils\"\nimport { useMemo, useRef } from \"react\"\nimport isEqual from \"react-fast-compare\"\nimport { Slot } from \"../../components/slot\"\nimport {\n createContext,\n createdDom,\n cx,\n filterEmpty,\n filterUndefined,\n isString,\n isUndefined,\n runIfFn,\n splitObject,\n toArray,\n toKebabCase,\n} from \"../../utils\"\nimport {\n createShouldForwardProp,\n getDisplayName,\n useComponentStyle,\n} from \"../components\"\nimport { css } from \"../css\"\nimport { useSystem } from \"./system-provider\"\nimport { useTheme } from \"./theme-provider\"\n\ninterface InsertionProps {\n cache: EmotionCache\n htmlTag: boolean\n serialized: SerializedStyles\n}\n\nfunction normalizeHostSelector(rule: string, className: string) {\n const selector = `.${className}`\n\n return rule\n .replaceAll(\n `${selector}:host([data-mode=dark]) ${selector}`,\n `:host([data-mode=dark]) ${selector}`,\n )\n .replaceAll(\n `${selector}:host([data-mode=light]) ${selector}`,\n `:host([data-mode=light]) ${selector}`,\n )\n}\n\nfunction insertStyles(cache: EmotionCache, serialized: SerializedStyles) {\n const className = `${cache.key}-${serialized.name}`\n\n if (!isUndefined(cache.inserted[serialized.name])) return\n\n const sheet = Object.create(cache.sheet) as typeof cache.sheet\n\n sheet.insert = (rule) => {\n cache.sheet.insert(normalizeHostSelector(rule, className))\n }\n\n let styleForSsr = \"\"\n let current: SerializedStyles | undefined = serialized\n\n do {\n const style =\n cache.insert(\n serialized === current ? `.${className}` : \"\",\n current,\n sheet,\n true,\n ) || undefined\n\n if (!createdDom() && !isUndefined(style))\n styleForSsr += normalizeHostSelector(style, className)\n\n current = current.next\n } while (current !== undefined)\n\n return styleForSsr || undefined\n}\n\nconst Insertion: FC<InsertionProps> = ({ cache, htmlTag, serialized }) => {\n registerStyles(cache, serialized, htmlTag)\n\n const style = useInsertionEffectAlwaysWithSyncFallback(() =>\n insertStyles(cache, serialized),\n )\n\n if (!createdDom() && !isUndefined(style)) {\n let className = serialized.name\n let next = serialized.next\n\n while (next !== undefined) {\n className = cx(className, next.name) ?? \"\"\n next = next.next\n }\n\n return (\n <style\n data-emotion={cx(cache.key, className)}\n dangerouslySetInnerHTML={{ __html: style }}\n nonce={cache.sheet.nonce}\n />\n )\n } else {\n return null\n }\n}\n\nconst useSplitProps = <Y extends Dict, M extends Dict>(\n props: Dict,\n shouldForwardProp?: ShouldForwardProp,\n) => {\n const propsRef = useRef(props)\n\n if (!isEqual(propsRef.current, props)) propsRef.current = props\n\n const computedProps = propsRef.current\n\n return useMemo(\n () => splitObject<Y, M>(computedProps, shouldForwardProp),\n [computedProps, shouldForwardProp],\n )\n}\n\nexport const [ColorSchemeContext, useColorSchemeContext] =\n createContext<ColorScheme>({\n name: \"ColorSchemeContext\",\n strict: false,\n })\n\nexport interface StyledOptions<\n Y extends CSSPropObject = CSSPropObject,\n M extends CSSModifierObject = CSSModifierObject,\n D extends CSSModifierObject = CSSModifierObject,\n H extends number | string | symbol = string,\n> extends Omit<ComponentStyle<Y, M, D>, \"className\"> {\n className?: ((system: System) => string) | string\n displayName?: string\n forwardAsChild?: boolean\n name?: string\n shouldForwardProp?: boolean | ShouldForwardProp\n target?: string\n forwardProps?: string[]\n transferProps?: H[]\n}\n\nexport function createStyled<\n Y extends As,\n M extends object = {},\n D extends CSSPropObject = CSSPropObject,\n H extends CSSModifierObject = CSSModifierObject,\n R extends CSSModifierObject = CSSModifierObject,\n>(\n el: Y,\n {\n name,\n base,\n compounds,\n props,\n sizes,\n variants,\n defaultProps,\n transferProps,\n ...options\n }: StyledOptions<D, H, R, keyof M> = {},\n) {\n const displayName = options.displayName ?? getDisplayName(name, \"\")\n const shouldForwardProp = !options.shouldForwardProp\n ? createShouldForwardProp(options.forwardProps)\n : undefined\n const style = filterUndefined({\n base,\n compounds,\n props,\n sizes,\n variants,\n defaultProps,\n })\n\n const StyledComponent = withEmotionCache<Dict>(function (\n { as: Component = el, asChild, children, ...props },\n cache,\n ref,\n ) {\n let className: string | undefined = \"\"\n\n const system = useSystem()\n const { theme } = useTheme<UsageTheme>()\n const componentStyleOptions = {\n name,\n className: system.utils.getClassName(\n runIfFn(options.className, system) ?? toKebabCase(name ?? \"\"),\n ),\n style,\n transferProps,\n }\n const registered = useRef<string[]>([])\n const htmlTag = isString(Component)\n const forwardAsChild =\n options.forwardAsChild || options.forwardProps?.includes(\"asChild\")\n const [omittedProps, styleProps] = useSplitProps(props, shouldForwardProp)\n const [, rest] = useComponentStyle<any, {}>(\n omittedProps,\n componentStyleOptions,\n )\n const [cssArray, colorScheme, forwardProps] = useMemo(() => {\n const { css, colorScheme, ...forwardProps } = rest\n\n return [toArray(css), colorScheme, forwardProps]\n }, [rest])\n\n styleProps.colorScheme ??= colorScheme\n\n if (forwardProps.className)\n className = getRegisteredStyles(\n cache.registered,\n registered.current,\n forwardProps.className,\n ).trim()\n\n const interpolations = useMemo(\n () => [\n ...registered.current,\n ...filterEmpty([...cssArray, styleProps].map(css(system, theme))),\n ],\n [cssArray, system, styleProps, theme],\n )\n\n const serialized = useMemo(\n () => serializeStyles(interpolations, cache.registered),\n [interpolations, cache.registered],\n )\n\n className = cx(\n className,\n serialized.styles ? `${cache.key}-${serialized.name}` : undefined,\n )\n className = cx(className, options.target)\n\n if (!className) className = undefined\n\n const mergedProps = { ...forwardProps, className, children }\n\n return (\n <ColorSchemeContext value={styleProps.colorScheme}>\n <Insertion cache={cache} htmlTag={htmlTag} serialized={serialized} />\n\n {asChild && !forwardAsChild ? (\n <Slot ref={ref} {...mergedProps} />\n ) : (\n <Component ref={ref} {...mergedProps} />\n )}\n </ColorSchemeContext>\n )\n }) as StyledComponent<Y, M>\n\n StyledComponent.displayName = displayName || \"StyledComponent\"\n\n return StyledComponent\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAgDA,SAAS,sBAAsB,MAAc,WAAmB;CAC9D,MAAM,WAAW,IAAI;CAErB,OAAO,KACJ,WACC,GAAG,SAAS,0BAA0B,YACtC,2BAA2B,UAC7B,CAAC,CACA,WACC,GAAG,SAAS,2BAA2B,YACvC,4BAA4B,UAC9B;AACJ;AAEA,SAAS,aAAa,OAAqB,YAA8B;CACvE,MAAM,YAAY,GAAG,MAAM,IAAI,GAAG,WAAW;CAE7C,IAAI,EAAA,GAAA,oBAAA,cAAC,YAAA,CAAY,MAAM,SAAS,WAAW,KAAK,GAAG;CAEnD,MAAM,QAAQ,OAAO,OAAO,MAAM,KAAK;CAEvC,MAAM,UAAU,SAAS;EACvB,MAAM,MAAM,OAAO,sBAAsB,MAAM,SAAS,CAAC;CAC3D;CAEA,IAAI,cAAc;CAClB,IAAI,UAAwC;CAE5C,GAAG;EACD,MAAM,QACJ,MAAM,OACJ,eAAe,UAAU,IAAI,cAAc,IAC3C,SACA,OACA,IACF,KAAK,KAAA;EAEP,IAAI,EAAA,GAAA,oBAAA,cAAC,WAAA,CAAW,KAAK,EAAA,GAAA,oBAAA,cAAC,YAAA,CAAY,KAAK,GACrC,eAAe,sBAAsB,OAAO,SAAS;EAEvD,UAAU,QAAQ;CACpB,SAAS,YAAY,KAAA;CAErB,OAAO,eAAe,KAAA;AACxB;AAEA,MAAM,aAAiC,EAAE,OAAO,SAAS,iBAAiB;CACxE,CAAA,GAAA,eAAA,eAAA,CAAe,OAAO,YAAY,OAAO;CAEzC,MAAM,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CAAC,CAClE,GACA;GAAC;GAAU;GAAQ;GAAY;EAAK,CACtC;EAEA,MAAM,cAAA,GAAaT,MAAAA,QAAAA,QAAAA,GACXU,mBAAAA,gBAAAA,CAAgB,gBAAgB,MAAM,UAAU,GACtD,CAAC,gBAAgB,MAAM,UAAU,CACnC;EAEA,aAAA,GAAA,oBAAA,cAAY,GAAA,CACV,WACA,WAAW,SAAS,GAAG,MAAM,IAAI,GAAG,WAAW,SAAS,KAAA,CAC1D;EACA,aAAA,GAAA,oBAAA,cAAY,GAAA,CAAG,WAAW,QAAQ,MAAM;EAExC,IAAI,CAAC,WAAW,YAAY,KAAA;EAE5B,MAAM,cAAc;GAAE,GAAG;GAAc;GAAW;EAAS;EAE3D,OACE,iBAAA,GAAA,kBAAA,KAAA,CAAC,oBAAD;GAAoB,OAAO,WAAW;GAAtC,UAAA,CACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,WAAD;IAAkB;IAAgB;IAAqB;GAAa,CAAA,GAEnE,WAAW,CAAC,iBACX,iBAAA,GAAA,kBAAA,IAAA,CAACC,aAAAA,MAAD;IAAW;IAAK,GAAI;GAAc,CAAA,IAElC,iBAAA,GAAA,kBAAA,IAAA,CAAC,WAAD;IAAgB;IAAK,GAAI;GAAc,CAAA,CAEvB;;CAExB,CAAC;CAED,gBAAgB,cAAc,eAAe;CAE7C,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"styled.cjs","names":["useInsertionEffectAlwaysWithSyncFallback","useRef","isEqual","useMemo","createContext","getDisplayName","createShouldForwardProp","withEmotionCache","useSystem","useTheme","useComponentStyle","getRegisteredStyles","css","serializeStyles","Slot"],"sources":["../../../../src/core/system/styled.tsx"],"sourcesContent":["\"use client\"\n\nimport type { EmotionCache, SerializedStyles } from \"@emotion/utils\"\nimport type { FC } from \"react\"\nimport type { Dict } from \"../../utils\"\nimport type {\n As,\n HTMLProps,\n ShouldForwardProp,\n StyledComponent,\n} from \"../components\"\nimport type { CSSModifierObject, CSSPropObject } from \"../css\"\nimport type {\n ColorScheme,\n ComponentStyle,\n System,\n UsageTheme,\n} from \"./index.type\"\nimport { withEmotionCache } from \"@emotion/react\"\nimport { serializeStyles } from \"@emotion/serialize\"\nimport { useInsertionEffectAlwaysWithSyncFallback } from \"@emotion/use-insertion-effect-with-fallbacks\"\nimport { getRegisteredStyles, registerStyles } from \"@emotion/utils\"\nimport { useMemo, useRef } from \"react\"\nimport isEqual from \"react-fast-compare\"\nimport { Slot } from \"../../components/slot\"\nimport {\n createContext,\n createdDom,\n cx,\n filterEmpty,\n filterUndefined,\n isString,\n isUndefined,\n runIfFn,\n splitObject,\n toArray,\n toKebabCase,\n} from \"../../utils\"\nimport {\n createShouldForwardProp,\n getDisplayName,\n useComponentStyle,\n} from \"../components\"\nimport { css } from \"../css\"\nimport { useSystem } from \"./system-provider\"\nimport { useTheme } from \"./theme-provider\"\n\ninterface InsertionProps {\n cache: EmotionCache\n htmlTag: boolean\n serialized: SerializedStyles\n}\n\nfunction normalizeHostSelector(rule: string, className: string) {\n const selector = `.${className}`\n\n return rule\n .replaceAll(\n `${selector}:host([data-mode=dark]) ${selector}`,\n `:host([data-mode=dark]) ${selector}`,\n )\n .replaceAll(\n `${selector}:host([data-mode=light]) ${selector}`,\n `:host([data-mode=light]) ${selector}`,\n )\n}\n\nfunction insertStyles(cache: EmotionCache, serialized: SerializedStyles) {\n const className = `${cache.key}-${serialized.name}`\n\n if (!isUndefined(cache.inserted[serialized.name])) return\n\n const sheet = Object.create(cache.sheet) as typeof cache.sheet\n\n sheet.insert = (rule) => {\n cache.sheet.insert(normalizeHostSelector(rule, className))\n }\n\n let styleForSsr = \"\"\n let current: SerializedStyles | undefined = serialized\n\n do {\n const style =\n cache.insert(\n serialized === current ? `.${className}` : \"\",\n current,\n sheet,\n true,\n ) || undefined\n\n if (!createdDom() && !isUndefined(style))\n styleForSsr += normalizeHostSelector(style, className)\n\n current = current.next\n } while (current !== undefined)\n\n return styleForSsr || undefined\n}\n\nconst Insertion: FC<InsertionProps> = ({ cache, htmlTag, serialized }) => {\n registerStyles(cache, serialized, htmlTag)\n\n const style = useInsertionEffectAlwaysWithSyncFallback(() =>\n insertStyles(cache, serialized),\n )\n\n if (!createdDom() && !isUndefined(style)) {\n let className = serialized.name\n let next = serialized.next\n\n while (next !== undefined) {\n className = cx(className, next.name) ?? \"\"\n next = next.next\n }\n\n return (\n <style\n data-emotion={cx(cache.key, className)}\n dangerouslySetInnerHTML={{ __html: style }}\n nonce={cache.sheet.nonce}\n />\n )\n } else {\n return null\n }\n}\n\nconst useSplitProps = <Y extends Dict, M extends Dict>(\n props: Dict,\n shouldForwardProp?: ShouldForwardProp,\n) => {\n const propsRef = useRef(props)\n\n if (!isEqual(propsRef.current, props)) propsRef.current = props\n\n const computedProps = propsRef.current\n\n return useMemo(\n () => splitObject<Y, M>(computedProps, shouldForwardProp),\n [computedProps, shouldForwardProp],\n )\n}\n\nexport const [ColorSchemeContext, useColorSchemeContext] =\n createContext<ColorScheme>({\n name: \"ColorSchemeContext\",\n strict: false,\n })\n\nexport const [HydrationContext, useHydrationContext] = createContext<boolean>({\n name: \"HydrationContext\",\n strict: false,\n})\n\nexport interface StyledOptions<\n Y extends CSSPropObject = CSSPropObject,\n M extends CSSModifierObject = CSSModifierObject,\n D extends CSSModifierObject = CSSModifierObject,\n H extends number | string | symbol = string,\n> extends Omit<ComponentStyle<Y, M, D>, \"className\"> {\n className?: ((system: System) => string) | string\n displayName?: string\n forwardAsChild?: boolean\n name?: string\n shouldForwardProp?: boolean | ShouldForwardProp\n target?: string\n forwardProps?: string[]\n transferProps?: H[]\n}\n\nexport function createStyled<\n Y extends As,\n M extends object = {},\n D extends CSSPropObject = CSSPropObject,\n H extends CSSModifierObject = CSSModifierObject,\n R extends CSSModifierObject = CSSModifierObject,\n>(\n el: Y,\n {\n name,\n base,\n compounds,\n props,\n sizes,\n variants,\n defaultProps,\n transferProps,\n ...options\n }: StyledOptions<D, H, R, keyof M> = {},\n) {\n const displayName = options.displayName ?? getDisplayName(name, \"\")\n const shouldForwardProp = !options.shouldForwardProp\n ? createShouldForwardProp(options.forwardProps)\n : undefined\n const style = filterUndefined({\n base,\n compounds,\n props,\n sizes,\n variants,\n defaultProps,\n })\n\n const StyledComponent = withEmotionCache<Dict>(function (\n { as: Component = el, asChild, children, ...props },\n cache,\n ref,\n ) {\n let className: string | undefined = \"\"\n\n const system = useSystem()\n const { theme } = useTheme<UsageTheme>()\n const componentStyleOptions = {\n name,\n className: system.utils.getClassName(\n runIfFn(options.className, system) ?? toKebabCase(name ?? \"\"),\n ),\n style,\n transferProps,\n }\n const registered = useRef<string[]>([])\n const htmlTag = isString(Component)\n const forwardAsChild =\n options.forwardAsChild || options.forwardProps?.includes(\"asChild\")\n const [omittedProps, styleProps] = useSplitProps(props, shouldForwardProp)\n const [, rest] = useComponentStyle<any, {}>(\n omittedProps,\n componentStyleOptions,\n )\n const suppressHydrationWarning = useHydrationContext()\n const [cssArray, colorScheme, forwardProps] = useMemo(() => {\n const { css, colorScheme, ...forwardProps } = rest\n\n return [toArray(css), colorScheme, forwardProps]\n }, [rest])\n\n styleProps.colorScheme ??= colorScheme\n forwardProps.suppressHydrationWarning ??= suppressHydrationWarning\n\n if (forwardProps.className)\n className = getRegisteredStyles(\n cache.registered,\n registered.current,\n forwardProps.className,\n ).trim()\n\n const interpolations = useMemo(\n () => [\n ...registered.current,\n ...filterEmpty([...cssArray, styleProps].map(css(system, theme))),\n ],\n [cssArray, system, styleProps, theme],\n )\n\n const serialized = useMemo(\n () => serializeStyles(interpolations, cache.registered),\n [interpolations, cache.registered],\n )\n\n className = cx(\n className,\n serialized.styles ? `${cache.key}-${serialized.name}` : undefined,\n )\n className = cx(className, options.target)\n\n if (!className) className = undefined\n\n const mergedProps: HTMLProps = { ...forwardProps, className, children }\n\n return (\n <ColorSchemeContext value={styleProps.colorScheme}>\n <HydrationContext value={mergedProps.suppressHydrationWarning}>\n <Insertion cache={cache} htmlTag={htmlTag} serialized={serialized} />\n\n {asChild && !forwardAsChild ? (\n <Slot ref={ref} {...mergedProps} />\n ) : (\n <Component ref={ref} {...mergedProps} />\n )}\n </HydrationContext>\n </ColorSchemeContext>\n )\n }) as StyledComponent<Y, M>\n\n StyledComponent.displayName = displayName || \"StyledComponent\"\n\n return StyledComponent\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAqDA,SAAS,sBAAsB,MAAc,WAAmB;CAC9D,MAAM,WAAW,IAAI;CAErB,OAAO,KACJ,WACC,GAAG,SAAS,0BAA0B,YACtC,2BAA2B,UAC7B,CAAC,CACA,WACC,GAAG,SAAS,2BAA2B,YACvC,4BAA4B,UAC9B;AACJ;AAEA,SAAS,aAAa,OAAqB,YAA8B;CACvE,MAAM,YAAY,GAAG,MAAM,IAAI,GAAG,WAAW;CAE7C,IAAI,EAAA,GAAA,oBAAA,cAAC,YAAA,CAAY,MAAM,SAAS,WAAW,KAAK,GAAG;CAEnD,MAAM,QAAQ,OAAO,OAAO,MAAM,KAAK;CAEvC,MAAM,UAAU,SAAS;EACvB,MAAM,MAAM,OAAO,sBAAsB,MAAM,SAAS,CAAC;CAC3D;CAEA,IAAI,cAAc;CAClB,IAAI,UAAwC;CAE5C,GAAG;EACD,MAAM,QACJ,MAAM,OACJ,eAAe,UAAU,IAAI,cAAc,IAC3C,SACA,OACA,IACF,KAAK,KAAA;EAEP,IAAI,EAAA,GAAA,oBAAA,cAAC,WAAA,CAAW,KAAK,EAAA,GAAA,oBAAA,cAAC,YAAA,CAAY,KAAK,GACrC,eAAe,sBAAsB,OAAO,SAAS;EAEvD,UAAU,QAAQ;CACpB,SAAS,YAAY,KAAA;CAErB,OAAO,eAAe,KAAA;AACxB;AAEA,MAAM,aAAiC,EAAE,OAAO,SAAS,iBAAiB;CACxE,CAAA,GAAA,eAAA,eAAA,CAAe,OAAO,YAAY,OAAO;CAEzC,MAAM,SAAA,GAAQA,6CAAAA,yCAAAA,OACZ,aAAa,OAAO,UAAU,CAChC;CAEA,IAAI,EAAA,GAAA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AU,CAAC,CAAC,IAAIS,YAAAA,IAAI,QAAQ,KAAK,CAAC,CAAC,CAClE,GACA;GAAC;GAAU;GAAQ;GAAY;EAAK,CACtC;EAEA,MAAM,cAAA,GAAaT,MAAAA,QAAAA,QAAAA,GACXU,mBAAAA,gBAAAA,CAAgB,gBAAgB,MAAM,UAAU,GACtD,CAAC,gBAAgB,MAAM,UAAU,CACnC;EAEA,aAAA,GAAA,oBAAA,cAAY,GAAA,CACV,WACA,WAAW,SAAS,GAAG,MAAM,IAAI,GAAG,WAAW,SAAS,KAAA,CAC1D;EACA,aAAA,GAAA,oBAAA,cAAY,GAAA,CAAG,WAAW,QAAQ,MAAM;EAExC,IAAI,CAAC,WAAW,YAAY,KAAA;EAE5B,MAAM,cAAyB;GAAE,GAAG;GAAc;GAAW;EAAS;EAEtE,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,oBAAD;GAAoB,OAAO,WAAW;GACpC,UAAA,iBAAA,GAAA,kBAAA,KAAA,CAAC,kBAAD;IAAkB,OAAO,YAAY;IAArC,UAAA,CACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,WAAD;KAAkB;KAAgB;KAAqB;IAAa,CAAA,GAEnE,WAAW,CAAC,iBACX,iBAAA,GAAA,kBAAA,IAAA,CAACC,aAAAA,MAAD;KAAW;KAAK,GAAI;IAAc,CAAA,IAElC,iBAAA,GAAA,kBAAA,IAAA,CAAC,WAAD;KAAgB;KAAK,GAAI;IAAc,CAAA,CAEzB;;EACA,CAAA;CAExB,CAAC;CAED,gBAAgB,cAAc,eAAe;CAE7C,OAAO;AACT"}
|
|
@@ -68,7 +68,7 @@ const { DescendantsContext: ComboboxDescendantsContext, useDescendant: useCombob
|
|
|
68
68
|
const [ComboboxContext, useComboboxContext] = require_context.createContext({ name: "ComboboxContext" });
|
|
69
69
|
const [ComboboxGroupContext, useComboboxGroupContext] = require_context.createContext({ name: "ComboboxGroupContext" });
|
|
70
70
|
const useCombobox = (props = {}) => {
|
|
71
|
-
const [{ matchWidth = true, ...popoverProps }, { "aria-label":
|
|
71
|
+
const [{ matchWidth = true, ...popoverProps }, { "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, closeOnSelect: closeOnSelectProp = true, defaultOpen, disabled, initialFocusValue, open: openProp, openOnClick = true, openOnEnter = true, openOnSpace = true, readOnly, selectFocusRef, selectOnSpace = true, onChange: onChangeProp, onClose: onCloseProp, onOpen: onOpenProp, ...rest }] = require_use_popover.usePopoverProps(props, [
|
|
72
72
|
"disabled",
|
|
73
73
|
"open",
|
|
74
74
|
"defaultOpen",
|
|
@@ -258,30 +258,29 @@ const useCombobox = (props = {}) => {
|
|
|
258
258
|
if (open) return;
|
|
259
259
|
activeDescendant.current = null;
|
|
260
260
|
}, [open]);
|
|
261
|
-
const getTriggerProps = (0, react.useCallback)((
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
}), [
|
|
261
|
+
const getTriggerProps = (0, react.useCallback)((props = {}) => ({ ...require_props.mergeProps({
|
|
262
|
+
ref: triggerRef,
|
|
263
|
+
"aria-controls": open ? contentId : void 0,
|
|
264
|
+
"aria-disabled": (0, require_utils_index.utils_exports.ariaAttr)(!interactive),
|
|
265
|
+
"aria-expanded": open,
|
|
266
|
+
"aria-haspopup": "listbox",
|
|
267
|
+
"aria-label": ariaLabel,
|
|
268
|
+
"aria-labelledby": ariaLabelledby,
|
|
269
|
+
"data-disabled": (0, require_utils_index.utils_exports.dataAttr)(disabled),
|
|
270
|
+
"data-readonly": (0, require_utils_index.utils_exports.dataAttr)(readOnly),
|
|
271
|
+
role: "combobox",
|
|
272
|
+
tabIndex: interactive ? 0 : -1
|
|
273
|
+
}, rest, props, {
|
|
274
|
+
onClick,
|
|
275
|
+
onKeyDown
|
|
276
|
+
})() }), [
|
|
278
277
|
open,
|
|
279
278
|
contentId,
|
|
280
279
|
interactive,
|
|
281
|
-
ariaLabelledbyProp,
|
|
282
280
|
disabled,
|
|
283
281
|
readOnly,
|
|
284
|
-
|
|
282
|
+
ariaLabelledby,
|
|
283
|
+
ariaLabel,
|
|
285
284
|
rest,
|
|
286
285
|
onClick,
|
|
287
286
|
onKeyDown
|
|
@@ -312,17 +311,13 @@ const useCombobox = (props = {}) => {
|
|
|
312
311
|
onSelect
|
|
313
312
|
};
|
|
314
313
|
};
|
|
315
|
-
const useComboboxGroup = ({
|
|
314
|
+
const useComboboxGroup = ({ ...rest } = {}) => {
|
|
316
315
|
const labelId = (0, react.useId)();
|
|
317
316
|
return {
|
|
318
|
-
getGroupProps: (0, react.useCallback)((
|
|
319
|
-
"aria-labelledby":
|
|
317
|
+
getGroupProps: (0, react.useCallback)((props = {}) => require_props.mergeProps({
|
|
318
|
+
"aria-labelledby": labelId,
|
|
320
319
|
role: "group"
|
|
321
|
-
}, rest, props)(), [
|
|
322
|
-
ariaLabelledbyProp,
|
|
323
|
-
labelId,
|
|
324
|
-
rest
|
|
325
|
-
]),
|
|
320
|
+
}, rest, props)(), [labelId, rest]),
|
|
326
321
|
getLabelProps: (0, react.useCallback)((props) => ({
|
|
327
322
|
id: labelId,
|
|
328
323
|
role: "presentation",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["getValidChildren","isSomeElement","findChild","createDescendants","createContext","usePopoverProps","useEnvironment","useRef","useId","useDisclosure","useMemo","useCallback","isComposing","mergeProps","mergeRefs"],"sources":["../../../../src/hooks/use-combobox/index.tsx"],"sourcesContent":["\"use client\"\n\nimport type {\n JSXElementConstructor,\n KeyboardEvent,\n MouseEvent,\n ReactNode,\n RefObject,\n} from \"react\"\nimport type { UsePopoverProps } from \"../../components/popover\"\nimport type { HTMLProps, PropGetter, SimpleDirection } from \"../../core\"\nimport type { Descendant } from \"../use-descendants\"\nimport type { UseDisclosureProps } from \"../use-disclosure\"\nimport { useCallback, useId, useMemo, useRef } from \"react\"\nimport scrollIntoView from \"scroll-into-view-if-needed\"\nimport { usePopoverProps } from \"../../components/popover\"\nimport { mergeProps, useEnvironment } from \"../../core\"\nimport {\n ariaAttr,\n createContext,\n cx,\n dataAttr,\n findChild,\n getValidChildren,\n handlerAll,\n isComposing,\n isSomeElement,\n isUndefined,\n mergeRefs,\n runKeyAction,\n useUpdateEffect,\n} from \"../../utils\"\nimport { createDescendants } from \"../use-descendants\"\nimport { useDisclosure } from \"../use-disclosure\"\n\ninterface ComboboxSharedItem extends Omit<HTMLProps, \"children\" | \"value\"> {\n label: ReactNode\n}\n\nexport interface ComboboxItemWithValue extends ComboboxSharedItem {\n query?: string\n value?: string\n}\n\nexport interface ComboboxItemWithItems extends ComboboxSharedItem {\n items: ComboboxItemWithValue[]\n}\n\nexport type ComboboxItem = ComboboxItemWithItems | ComboboxItemWithValue\n\nexport interface CreateComboboxItemOptions {\n Group: JSXElementConstructor<any>\n Label: JSXElementConstructor<any>\n Option: JSXElementConstructor<any>\n}\n\nexport const createComboboxItem = (\n children: ReactNode,\n { Group, Label, Option }: CreateComboboxItemOptions,\n) => {\n const validChildren = getValidChildren(children)\n\n return validChildren\n .filter(\n ({ type }) => isSomeElement(type, Option) || isSomeElement(type, Group),\n )\n .map(({ type, props }) => {\n if (isSomeElement(type, Option)) {\n return { ...props, label: props.children }\n } else {\n const validChildren = getValidChildren(props.children)\n const label = findChild(validChildren, Label)\n\n return {\n ...props,\n items: validChildren\n .filter(({ type }) => isSomeElement(type, Option))\n .map(({ props }) => ({ ...props, label: props.children })),\n label: label?.props.children ?? props.label,\n }\n }\n })\n}\n\nexport interface CreateComboboxChildrenOptions {\n Group: JSXElementConstructor<any>\n Option: JSXElementConstructor<any>\n Empty?: JSXElementConstructor<any>\n}\n\nexport const createComboboxChildren = (\n items: ComboboxItem[],\n { Empty, Group, Option }: CreateComboboxChildrenOptions,\n) => {\n return items.map((item, index) => {\n if (\"data-empty\" in item && Empty) {\n const { label, ...rest } = item\n\n return (\n <Empty key={index} {...rest}>\n {label}\n </Empty>\n )\n } else if (\"items\" in item) {\n const { items, label, ...rest } = item\n\n return (\n <Group key={index} label={label} {...rest}>\n {items.map(({ label, ...rest }, index) => (\n <Option key={index} {...rest}>\n {label}\n </Option>\n ))}\n </Group>\n )\n } else {\n const { label, ...rest } = item\n\n return (\n <Option key={index} {...rest}>\n {label}\n </Option>\n )\n }\n })\n}\n\nexport interface ComboboxDescendantProps {\n id: string\n closeOnSelect?: boolean\n value?: string\n}\nexport type ComboboxDescendant = Descendant<\n HTMLDivElement,\n ComboboxDescendantProps\n>\n\nconst {\n DescendantsContext: ComboboxDescendantsContext,\n useDescendant: useComboboxDescendant,\n useDescendantRegister: useComboboxDescendantRegister,\n useDescendants: useComboboxDescendants,\n} = createDescendants<HTMLDivElement, ComboboxDescendantProps>()\n\nexport {\n ComboboxDescendantsContext,\n useComboboxDescendant,\n useComboboxDescendantRegister,\n useComboboxDescendants,\n}\n\ninterface ComboboxContext extends Pick<\n UseComboboxReturn,\n \"onActiveDescendant\" | \"onClose\" | \"onSelect\"\n> {}\n\nconst [ComboboxContext, useComboboxContext] = createContext<ComboboxContext>({\n name: \"ComboboxContext\",\n})\n\ninterface ComboboxGroupContext extends Pick<\n UseComboboxGroupReturn,\n \"getLabelProps\"\n> {}\n\nconst [ComboboxGroupContext, useComboboxGroupContext] =\n createContext<ComboboxGroupContext>({\n name: \"ComboboxGroupContext\",\n })\n\nexport {\n ComboboxContext,\n ComboboxGroupContext,\n useComboboxContext,\n useComboboxGroupContext,\n}\n\nexport interface UseComboboxProps\n extends\n Omit<HTMLProps, \"onChange\">,\n Omit<UseDisclosureProps, \"timing\">,\n Omit<\n UsePopoverProps,\n \"autoFocus\" | \"initialFocusRef\" | \"modal\" | \"transform\" | \"updateRef\"\n > {\n /**\n * If `true`, the list element will be closed when value is selected.\n *\n * @default true\n */\n closeOnSelect?: boolean\n /**\n * If `true`, the combobox will be disabled.\n *\n * @default false\n */\n disabled?: boolean\n /**\n * The value to focus on when the combobox is opened.\n */\n initialFocusValue?: string\n /**\n * If `true`, the combobox will be opened when click on the field.\n *\n * @default true\n */\n openOnClick?: boolean\n /**\n * If `true`, the combobox will be opened when enter is pressed.\n *\n * @default true\n */\n openOnEnter?: boolean\n /**\n * If `true`, the combobox will be opened when space is pressed.\n *\n * @default true\n */\n openOnSpace?: boolean\n /**\n * If `true`, the combobox will be readonly.\n *\n * @default false\n */\n readOnly?: boolean\n /**\n * The `ref` of the element that should receive focus when selected.\n */\n selectFocusRef?: RefObject<HTMLElement | null>\n /**\n * If `true`, the item will be selected when space is pressed.\n *\n * @default true\n */\n selectOnSpace?: boolean\n /**\n * The callback invoked when value is selected.\n */\n onChange?: (value: string) => void\n}\n\nexport const useCombobox = (props: UseComboboxProps = {}) => {\n const [\n { matchWidth = true, ...popoverProps },\n {\n \"aria-label\": ariaLabelProp,\n \"aria-labelledby\": ariaLabelledbyProp,\n closeOnSelect: closeOnSelectProp = true,\n defaultOpen,\n disabled,\n initialFocusValue,\n open: openProp,\n openOnClick = true,\n openOnEnter = true,\n openOnSpace = true,\n readOnly,\n selectFocusRef,\n selectOnSpace = true,\n onChange: onChangeProp,\n onClose: onCloseProp,\n onOpen: onOpenProp,\n ...rest\n },\n ] = usePopoverProps(props, [\n \"disabled\",\n \"open\",\n \"defaultOpen\",\n \"onOpen\",\n \"onClose\",\n \"openOnClick\",\n ])\n const { getWindow } = useEnvironment()\n const interactive = !(readOnly || disabled)\n const triggerRef = useRef<HTMLDivElement>(null)\n const contentRef = useRef<HTMLDivElement>(null)\n const contentId = useId()\n const descendants = useComboboxDescendants()\n const { open, onClose, onOpen } = useDisclosure({\n defaultOpen,\n open: openProp,\n onClose: onCloseProp,\n onOpen: onOpenProp,\n })\n const activeDescendant = useRef<ComboboxDescendant | null>(null)\n const mergedPopoverProps = useMemo<UsePopoverProps>(\n () => ({\n autoFocus: false,\n matchWidth,\n openOnClick: false,\n ...popoverProps,\n disabled: !interactive,\n open,\n onClose,\n onOpen,\n }),\n [interactive, matchWidth, onClose, onOpen, open, popoverProps],\n )\n\n const onSelect = useCallback(\n (value?: string, closeOnSelect = closeOnSelectProp) => {\n const ref = selectFocusRef ?? triggerRef\n\n ref.current?.focus()\n\n if (!interactive || isUndefined(value)) return\n\n onChangeProp?.(value)\n\n if (!closeOnSelect) return\n\n onClose()\n },\n [closeOnSelectProp, interactive, onChangeProp, onClose, selectFocusRef],\n )\n\n const onScrollIntoView = useCallback(\n (descendant?: ComboboxDescendant, block: SimpleDirection = \"start\") => {\n if (!contentRef.current || !descendant) return\n\n const style = getWindow()?.getComputedStyle(contentRef.current)\n const padding =\n block === \"start\" ? style?.paddingBlockStart : style?.paddingBlockEnd\n const value = parseInt(padding ?? \"0px\")\n\n scrollIntoView(descendant.node, {\n behavior: (actions) =>\n actions.forEach(({ el, top }) => {\n el.scrollTop = block === \"start\" ? top - value : top + value\n }),\n block,\n boundary: contentRef.current,\n inline: \"nearest\",\n scrollMode: \"if-needed\",\n })\n },\n [getWindow],\n )\n\n const onActiveDescendant = useCallback(\n (descendant?: ComboboxDescendant) => {\n if (!triggerRef.current || !descendant || disabled) return\n\n triggerRef.current.setAttribute(\"aria-activedescendant\", descendant.id)\n\n activeDescendant.current = descendant\n\n descendants.active(descendant)\n },\n [descendants, disabled],\n )\n\n const onOpenWithActiveDescendant = useCallback(\n (\n getFallbackDescendant: () => ComboboxDescendant | undefined,\n block: SimpleDirection = \"start\",\n ) => {\n onOpen()\n\n setTimeout(() => {\n if (!initialFocusValue) {\n const descendant = getFallbackDescendant()\n\n onActiveDescendant(descendant)\n onScrollIntoView(descendant, block)\n } else {\n const values = descendants.values()\n const descendant =\n values.find(({ value }) => initialFocusValue === value) ??\n getFallbackDescendant()\n\n onActiveDescendant(descendant)\n onScrollIntoView(descendant, block)\n }\n })\n },\n [\n descendants,\n initialFocusValue,\n onActiveDescendant,\n onOpen,\n onScrollIntoView,\n ],\n )\n\n const onClick = useCallback(\n (ev: MouseEvent<HTMLDivElement>) => {\n if (disabled) return\n\n ev.preventDefault()\n\n if (!open) {\n if (openOnClick)\n onOpenWithActiveDescendant(descendants.enabledFirstValue)\n } else {\n onClose()\n }\n },\n [\n descendants,\n disabled,\n onClose,\n onOpenWithActiveDescendant,\n open,\n openOnClick,\n ],\n )\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLDivElement>) => {\n if (disabled || isComposing(ev)) return\n\n runKeyAction(\n ev,\n {\n ArrowDown: (ev) => {\n ev.preventDefault()\n\n if (!open) {\n onOpenWithActiveDescendant(descendants.enabledFirstValue)\n } else if (activeDescendant.current) {\n const descendant = descendants.enabledNextValue(\n activeDescendant.current,\n )\n\n onActiveDescendant(descendant)\n\n onScrollIntoView(\n descendant,\n descendant?.recurred ? \"start\" : \"end\",\n )\n } else {\n const descendant = descendants.enabledFirstValue()\n\n onActiveDescendant(descendant)\n\n onScrollIntoView(descendant)\n }\n },\n ArrowUp: (ev) => {\n ev.preventDefault()\n\n if (!open) {\n onOpenWithActiveDescendant(descendants.enabledLastValue, \"end\")\n } else if (activeDescendant.current) {\n const descendant = descendants.enabledPrevValue(\n activeDescendant.current,\n )\n\n onActiveDescendant(descendant)\n\n onScrollIntoView(\n descendant,\n descendant?.recurred ? \"end\" : \"start\",\n )\n } else {\n const descendant = descendants.enabledLastValue()\n\n onActiveDescendant(descendant)\n\n onScrollIntoView(descendant, \"end\")\n }\n },\n End: (ev) => {\n ev.preventDefault()\n\n if (!open) return\n\n const descendant = descendants.enabledLastValue()\n\n onActiveDescendant(descendant)\n\n onScrollIntoView(descendant, \"end\")\n },\n Enter: (ev) => {\n if (!open) {\n if (!openOnEnter) return\n\n ev.preventDefault()\n\n onOpenWithActiveDescendant(descendants.enabledFirstValue)\n } else {\n if (!activeDescendant.current) return\n\n ev.preventDefault()\n\n const { closeOnSelect, value } = activeDescendant.current\n\n onSelect(value, closeOnSelect)\n }\n },\n Home: (ev) => {\n if (!open) return\n\n ev.preventDefault()\n\n const descendant = descendants.enabledFirstValue()\n\n onActiveDescendant(descendant)\n\n onScrollIntoView(descendant)\n },\n Space: (ev) => {\n if (!open) {\n if (!openOnSpace) return\n\n ev.preventDefault()\n\n onOpenWithActiveDescendant(descendants.enabledFirstValue)\n } else {\n if (!activeDescendant.current || !selectOnSpace) return\n\n ev.preventDefault()\n\n const { closeOnSelect, value } = activeDescendant.current\n\n onSelect(value, closeOnSelect)\n }\n },\n },\n { preventDefault: false },\n )\n },\n [\n disabled,\n open,\n onOpenWithActiveDescendant,\n descendants,\n onActiveDescendant,\n onScrollIntoView,\n openOnEnter,\n onSelect,\n openOnSpace,\n selectOnSpace,\n ],\n )\n\n useUpdateEffect(() => {\n if (open) return\n\n activeDescendant.current = null\n }, [open])\n\n const getTriggerProps: PropGetter = useCallback(\n ({\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledby,\n ...props\n } = {}) => ({\n ...mergeProps(\n {\n ref: triggerRef,\n \"aria-controls\": open ? contentId : undefined,\n \"aria-disabled\": ariaAttr(!interactive),\n \"aria-expanded\": open,\n \"aria-haspopup\": \"listbox\",\n \"aria-label\": ariaLabel || ariaLabelProp,\n \"aria-labelledby\": cx(ariaLabelledby, ariaLabelledbyProp),\n \"data-disabled\": dataAttr(disabled),\n \"data-readonly\": dataAttr(readOnly),\n role: \"combobox\",\n tabIndex: interactive ? 0 : -1,\n },\n rest,\n props,\n )({ mergeEvent: false }),\n onClick: handlerAll(props.onClick, rest.onClick, onClick),\n onKeyDown: handlerAll(props.onKeyDown, rest.onKeyDown, onKeyDown),\n }),\n [\n open,\n contentId,\n interactive,\n ariaLabelledbyProp,\n disabled,\n readOnly,\n ariaLabelProp,\n rest,\n onClick,\n onKeyDown,\n ],\n )\n\n const getContentProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) => ({\n id: contentId,\n role: \"listbox\",\n ...props,\n ref: mergeRefs(ref, contentRef),\n onKeyDown: handlerAll(props.onKeyDown),\n }),\n [contentId],\n )\n\n const getSeparatorProps: PropGetter = useCallback(\n (props) => ({ role: \"separator\", ...props }),\n [],\n )\n\n return {\n activeDescendant,\n descendants,\n interactive,\n open,\n getContentProps,\n getSeparatorProps,\n getTriggerProps,\n popoverProps: mergedPopoverProps,\n onActiveDescendant,\n onClose,\n onOpen,\n onOpenWithActiveDescendant,\n onScrollIntoView,\n onSelect,\n }\n}\n\nexport type UseComboboxReturn = ReturnType<typeof useCombobox>\n\nexport interface UseComboboxGroupProps extends HTMLProps {}\n\nexport const useComboboxGroup = ({\n \"aria-labelledby\": ariaLabelledbyProp,\n ...rest\n}: UseComboboxGroupProps = {}) => {\n const labelId = useId()\n\n const getGroupProps: PropGetter = useCallback(\n ({ \"aria-labelledby\": ariaLabelledby, ...props } = {}) =>\n mergeProps(\n {\n \"aria-labelledby\": cx(ariaLabelledbyProp, ariaLabelledby, labelId),\n role: \"group\",\n },\n rest,\n props,\n )(),\n [ariaLabelledbyProp, labelId, rest],\n )\n\n const getLabelProps: PropGetter<\"span\"> = useCallback(\n (props) => ({ id: labelId, role: \"presentation\", ...props }),\n [labelId],\n )\n\n return { getGroupProps, getLabelProps }\n}\n\nexport type UseComboboxGroupReturn = ReturnType<typeof useComboboxGroup>\n\nexport interface UseComboboxItemProps extends HTMLProps {\n /**\n * If `true`, the item will be closed when selected.\n */\n closeOnSelect?: boolean\n /**\n * If `true`, the item will be disabled.\n *\n * @default false\n */\n disabled?: boolean\n /**\n * If `true`, the item will be selected.\n */\n selected?: boolean\n /**\n * The value of the item.\n */\n value?: string\n}\n\nexport const useComboboxItem = ({\n id,\n \"aria-disabled\": ariaDisabled,\n \"data-disabled\": dataDisabled,\n closeOnSelect,\n disabled = false,\n selected = false,\n value,\n ...rest\n}: UseComboboxItemProps = {}) => {\n const uuid = useId()\n const itemRef = useRef<HTMLDivElement>(null)\n const { onActiveDescendant, onClose, onSelect } = useComboboxContext()\n\n id ??= uuid\n\n const { descendants, register } = useComboboxDescendant({\n id,\n closeOnSelect,\n disabled,\n value,\n })\n\n const onActive = useCallback(() => {\n if (disabled) return\n\n const current = descendants.value(itemRef.current)\n\n onActiveDescendant(current)\n }, [descendants, disabled, onActiveDescendant])\n\n const onClick = useCallback(\n (ev: MouseEvent<HTMLDivElement>) => {\n ev.preventDefault()\n\n if (disabled) return\n\n onSelect(value, closeOnSelect)\n },\n [closeOnSelect, disabled, onSelect, value],\n )\n\n const getItemProps: PropGetter = useCallback(\n (props = {}) => ({\n ...mergeProps(\n {\n id,\n ref: itemRef,\n \"aria-disabled\": ariaDisabled ?? ariaAttr(disabled),\n \"aria-selected\": selected,\n \"data-disabled\": dataDisabled ?? dataAttr(disabled),\n \"data-selected\": dataAttr(selected),\n \"data-value\": value,\n role: \"option\",\n tabIndex: -1,\n },\n rest,\n props,\n { ref: register },\n )({ mergeEvent: false }),\n onClick: handlerAll(props.onClick, rest.onClick, onClick),\n onMouseMove: handlerAll(props.onMouseMove, rest.onMouseMove, onActive),\n }),\n [\n id,\n ariaDisabled,\n disabled,\n selected,\n dataDisabled,\n value,\n rest,\n register,\n onClick,\n onActive,\n ],\n )\n\n const getIndicatorProps: PropGetter = useCallback(\n (props = {}) =>\n mergeProps({ style: { opacity: selected ? 1 : 0 } }, props)(),\n [selected],\n )\n\n return {\n descendants,\n disabled,\n selected,\n getIndicatorProps,\n getItemProps,\n onActiveDescendant,\n onClose,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAwDA,MAAa,sBACX,UACA,EAAE,OAAO,OAAO,aACb;CAGH,OAFsBA,iBAAAA,iBAAiB,QAEpB,CAAC,CACjB,QACE,EAAE,WAAWC,iBAAAA,cAAc,MAAM,MAAM,KAAKA,iBAAAA,cAAc,MAAM,KAAK,CACxE,CAAC,CACA,KAAK,EAAE,MAAM,YAAY;EACxB,IAAIA,iBAAAA,cAAc,MAAM,MAAM,GAC5B,OAAO;GAAE,GAAG;GAAO,OAAO,MAAM;EAAS;OACpC;GACL,MAAM,gBA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MAAAA,YAAAA,EACnC,QAAQ,CAAC,MACRE,cAAAA,WAAW,EAAE,OAAO,EAAE,SAAS,WAAW,IAAI,EAAE,EAAE,GAAG,KAAK,CAAC,CAAC,GAC9D,CAAC,QAAQ,CAOO;EAChB;EACA;EACA;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["getValidChildren","isSomeElement","findChild","createDescendants","createContext","usePopoverProps","useEnvironment","useRef","useId","useDisclosure","useMemo","useCallback","isComposing","mergeProps","mergeRefs"],"sources":["../../../../src/hooks/use-combobox/index.tsx"],"sourcesContent":["\"use client\"\n\nimport type {\n JSXElementConstructor,\n KeyboardEvent,\n MouseEvent,\n ReactNode,\n RefObject,\n} from \"react\"\nimport type { UsePopoverProps } from \"../../components/popover\"\nimport type { HTMLProps, PropGetter, SimpleDirection } from \"../../core\"\nimport type { Descendant } from \"../use-descendants\"\nimport type { UseDisclosureProps } from \"../use-disclosure\"\nimport { useCallback, useId, useMemo, useRef } from \"react\"\nimport scrollIntoView from \"scroll-into-view-if-needed\"\nimport { usePopoverProps } from \"../../components/popover\"\nimport { mergeProps, useEnvironment } from \"../../core\"\nimport {\n ariaAttr,\n createContext,\n dataAttr,\n findChild,\n getValidChildren,\n handlerAll,\n isComposing,\n isSomeElement,\n isUndefined,\n mergeRefs,\n runKeyAction,\n useUpdateEffect,\n} from \"../../utils\"\nimport { createDescendants } from \"../use-descendants\"\nimport { useDisclosure } from \"../use-disclosure\"\n\ninterface ComboboxSharedItem extends Omit<HTMLProps, \"children\" | \"value\"> {\n label: ReactNode\n}\n\nexport interface ComboboxItemWithValue extends ComboboxSharedItem {\n query?: string\n value?: string\n}\n\nexport interface ComboboxItemWithItems extends ComboboxSharedItem {\n items: ComboboxItemWithValue[]\n}\n\nexport type ComboboxItem = ComboboxItemWithItems | ComboboxItemWithValue\n\nexport interface CreateComboboxItemOptions {\n Group: JSXElementConstructor<any>\n Label: JSXElementConstructor<any>\n Option: JSXElementConstructor<any>\n}\n\nexport const createComboboxItem = (\n children: ReactNode,\n { Group, Label, Option }: CreateComboboxItemOptions,\n) => {\n const validChildren = getValidChildren(children)\n\n return validChildren\n .filter(\n ({ type }) => isSomeElement(type, Option) || isSomeElement(type, Group),\n )\n .map(({ type, props }) => {\n if (isSomeElement(type, Option)) {\n return { ...props, label: props.children }\n } else {\n const validChildren = getValidChildren(props.children)\n const label = findChild(validChildren, Label)\n\n return {\n ...props,\n items: validChildren\n .filter(({ type }) => isSomeElement(type, Option))\n .map(({ props }) => ({ ...props, label: props.children })),\n label: label?.props.children ?? props.label,\n }\n }\n })\n}\n\nexport interface CreateComboboxChildrenOptions {\n Group: JSXElementConstructor<any>\n Option: JSXElementConstructor<any>\n Empty?: JSXElementConstructor<any>\n}\n\nexport const createComboboxChildren = (\n items: ComboboxItem[],\n { Empty, Group, Option }: CreateComboboxChildrenOptions,\n) => {\n return items.map((item, index) => {\n if (\"data-empty\" in item && Empty) {\n const { label, ...rest } = item\n\n return (\n <Empty key={index} {...rest}>\n {label}\n </Empty>\n )\n } else if (\"items\" in item) {\n const { items, label, ...rest } = item\n\n return (\n <Group key={index} label={label} {...rest}>\n {items.map(({ label, ...rest }, index) => (\n <Option key={index} {...rest}>\n {label}\n </Option>\n ))}\n </Group>\n )\n } else {\n const { label, ...rest } = item\n\n return (\n <Option key={index} {...rest}>\n {label}\n </Option>\n )\n }\n })\n}\n\nexport interface ComboboxDescendantProps {\n id: string\n closeOnSelect?: boolean\n value?: string\n}\nexport type ComboboxDescendant = Descendant<\n HTMLDivElement,\n ComboboxDescendantProps\n>\n\nconst {\n DescendantsContext: ComboboxDescendantsContext,\n useDescendant: useComboboxDescendant,\n useDescendantRegister: useComboboxDescendantRegister,\n useDescendants: useComboboxDescendants,\n} = createDescendants<HTMLDivElement, ComboboxDescendantProps>()\n\nexport {\n ComboboxDescendantsContext,\n useComboboxDescendant,\n useComboboxDescendantRegister,\n useComboboxDescendants,\n}\n\ninterface ComboboxContext extends Pick<\n UseComboboxReturn,\n \"onActiveDescendant\" | \"onClose\" | \"onSelect\"\n> {}\n\nconst [ComboboxContext, useComboboxContext] = createContext<ComboboxContext>({\n name: \"ComboboxContext\",\n})\n\ninterface ComboboxGroupContext extends Pick<\n UseComboboxGroupReturn,\n \"getLabelProps\"\n> {}\n\nconst [ComboboxGroupContext, useComboboxGroupContext] =\n createContext<ComboboxGroupContext>({\n name: \"ComboboxGroupContext\",\n })\n\nexport {\n ComboboxContext,\n ComboboxGroupContext,\n useComboboxContext,\n useComboboxGroupContext,\n}\n\nexport interface UseComboboxProps\n extends\n Omit<HTMLProps, \"onChange\">,\n Omit<UseDisclosureProps, \"timing\">,\n Omit<\n UsePopoverProps,\n \"autoFocus\" | \"initialFocusRef\" | \"modal\" | \"transform\" | \"updateRef\"\n > {\n /**\n * If `true`, the list element will be closed when value is selected.\n *\n * @default true\n */\n closeOnSelect?: boolean\n /**\n * If `true`, the combobox will be disabled.\n *\n * @default false\n */\n disabled?: boolean\n /**\n * The value to focus on when the combobox is opened.\n */\n initialFocusValue?: string\n /**\n * If `true`, the combobox will be opened when click on the field.\n *\n * @default true\n */\n openOnClick?: boolean\n /**\n * If `true`, the combobox will be opened when enter is pressed.\n *\n * @default true\n */\n openOnEnter?: boolean\n /**\n * If `true`, the combobox will be opened when space is pressed.\n *\n * @default true\n */\n openOnSpace?: boolean\n /**\n * If `true`, the combobox will be readonly.\n *\n * @default false\n */\n readOnly?: boolean\n /**\n * The `ref` of the element that should receive focus when selected.\n */\n selectFocusRef?: RefObject<HTMLElement | null>\n /**\n * If `true`, the item will be selected when space is pressed.\n *\n * @default true\n */\n selectOnSpace?: boolean\n /**\n * The callback invoked when value is selected.\n */\n onChange?: (value: string) => void\n}\n\nexport const useCombobox = (props: UseComboboxProps = {}) => {\n const [\n { matchWidth = true, ...popoverProps },\n {\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledby,\n closeOnSelect: closeOnSelectProp = true,\n defaultOpen,\n disabled,\n initialFocusValue,\n open: openProp,\n openOnClick = true,\n openOnEnter = true,\n openOnSpace = true,\n readOnly,\n selectFocusRef,\n selectOnSpace = true,\n onChange: onChangeProp,\n onClose: onCloseProp,\n onOpen: onOpenProp,\n ...rest\n },\n ] = usePopoverProps(props, [\n \"disabled\",\n \"open\",\n \"defaultOpen\",\n \"onOpen\",\n \"onClose\",\n \"openOnClick\",\n ])\n const { getWindow } = useEnvironment()\n const interactive = !(readOnly || disabled)\n const triggerRef = useRef<HTMLDivElement>(null)\n const contentRef = useRef<HTMLDivElement>(null)\n const contentId = useId()\n const descendants = useComboboxDescendants()\n const { open, onClose, onOpen } = useDisclosure({\n defaultOpen,\n open: openProp,\n onClose: onCloseProp,\n onOpen: onOpenProp,\n })\n const activeDescendant = useRef<ComboboxDescendant | null>(null)\n const mergedPopoverProps = useMemo<UsePopoverProps>(\n () => ({\n autoFocus: false,\n matchWidth,\n openOnClick: false,\n ...popoverProps,\n disabled: !interactive,\n open,\n onClose,\n onOpen,\n }),\n [interactive, matchWidth, onClose, onOpen, open, popoverProps],\n )\n\n const onSelect = useCallback(\n (value?: string, closeOnSelect = closeOnSelectProp) => {\n const ref = selectFocusRef ?? triggerRef\n\n ref.current?.focus()\n\n if (!interactive || isUndefined(value)) return\n\n onChangeProp?.(value)\n\n if (!closeOnSelect) return\n\n onClose()\n },\n [closeOnSelectProp, interactive, onChangeProp, onClose, selectFocusRef],\n )\n\n const onScrollIntoView = useCallback(\n (descendant?: ComboboxDescendant, block: SimpleDirection = \"start\") => {\n if (!contentRef.current || !descendant) return\n\n const style = getWindow()?.getComputedStyle(contentRef.current)\n const padding =\n block === \"start\" ? style?.paddingBlockStart : style?.paddingBlockEnd\n const value = parseInt(padding ?? \"0px\")\n\n scrollIntoView(descendant.node, {\n behavior: (actions) =>\n actions.forEach(({ el, top }) => {\n el.scrollTop = block === \"start\" ? top - value : top + value\n }),\n block,\n boundary: contentRef.current,\n inline: \"nearest\",\n scrollMode: \"if-needed\",\n })\n },\n [getWindow],\n )\n\n const onActiveDescendant = useCallback(\n (descendant?: ComboboxDescendant) => {\n if (!triggerRef.current || !descendant || disabled) return\n\n triggerRef.current.setAttribute(\"aria-activedescendant\", descendant.id)\n\n activeDescendant.current = descendant\n\n descendants.active(descendant)\n },\n [descendants, disabled],\n )\n\n const onOpenWithActiveDescendant = useCallback(\n (\n getFallbackDescendant: () => ComboboxDescendant | undefined,\n block: SimpleDirection = \"start\",\n ) => {\n onOpen()\n\n setTimeout(() => {\n if (!initialFocusValue) {\n const descendant = getFallbackDescendant()\n\n onActiveDescendant(descendant)\n onScrollIntoView(descendant, block)\n } else {\n const values = descendants.values()\n const descendant =\n values.find(({ value }) => initialFocusValue === value) ??\n getFallbackDescendant()\n\n onActiveDescendant(descendant)\n onScrollIntoView(descendant, block)\n }\n })\n },\n [\n descendants,\n initialFocusValue,\n onActiveDescendant,\n onOpen,\n onScrollIntoView,\n ],\n )\n\n const onClick = useCallback(\n (ev: MouseEvent<HTMLDivElement>) => {\n if (disabled) return\n\n ev.preventDefault()\n\n if (!open) {\n if (openOnClick)\n onOpenWithActiveDescendant(descendants.enabledFirstValue)\n } else {\n onClose()\n }\n },\n [\n descendants,\n disabled,\n onClose,\n onOpenWithActiveDescendant,\n open,\n openOnClick,\n ],\n )\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLDivElement>) => {\n if (disabled || isComposing(ev)) return\n\n runKeyAction(\n ev,\n {\n ArrowDown: (ev) => {\n ev.preventDefault()\n\n if (!open) {\n onOpenWithActiveDescendant(descendants.enabledFirstValue)\n } else if (activeDescendant.current) {\n const descendant = descendants.enabledNextValue(\n activeDescendant.current,\n )\n\n onActiveDescendant(descendant)\n\n onScrollIntoView(\n descendant,\n descendant?.recurred ? \"start\" : \"end\",\n )\n } else {\n const descendant = descendants.enabledFirstValue()\n\n onActiveDescendant(descendant)\n\n onScrollIntoView(descendant)\n }\n },\n ArrowUp: (ev) => {\n ev.preventDefault()\n\n if (!open) {\n onOpenWithActiveDescendant(descendants.enabledLastValue, \"end\")\n } else if (activeDescendant.current) {\n const descendant = descendants.enabledPrevValue(\n activeDescendant.current,\n )\n\n onActiveDescendant(descendant)\n\n onScrollIntoView(\n descendant,\n descendant?.recurred ? \"end\" : \"start\",\n )\n } else {\n const descendant = descendants.enabledLastValue()\n\n onActiveDescendant(descendant)\n\n onScrollIntoView(descendant, \"end\")\n }\n },\n End: (ev) => {\n ev.preventDefault()\n\n if (!open) return\n\n const descendant = descendants.enabledLastValue()\n\n onActiveDescendant(descendant)\n\n onScrollIntoView(descendant, \"end\")\n },\n Enter: (ev) => {\n if (!open) {\n if (!openOnEnter) return\n\n ev.preventDefault()\n\n onOpenWithActiveDescendant(descendants.enabledFirstValue)\n } else {\n if (!activeDescendant.current) return\n\n ev.preventDefault()\n\n const { closeOnSelect, value } = activeDescendant.current\n\n onSelect(value, closeOnSelect)\n }\n },\n Home: (ev) => {\n if (!open) return\n\n ev.preventDefault()\n\n const descendant = descendants.enabledFirstValue()\n\n onActiveDescendant(descendant)\n\n onScrollIntoView(descendant)\n },\n Space: (ev) => {\n if (!open) {\n if (!openOnSpace) return\n\n ev.preventDefault()\n\n onOpenWithActiveDescendant(descendants.enabledFirstValue)\n } else {\n if (!activeDescendant.current || !selectOnSpace) return\n\n ev.preventDefault()\n\n const { closeOnSelect, value } = activeDescendant.current\n\n onSelect(value, closeOnSelect)\n }\n },\n },\n { preventDefault: false },\n )\n },\n [\n disabled,\n open,\n onOpenWithActiveDescendant,\n descendants,\n onActiveDescendant,\n onScrollIntoView,\n openOnEnter,\n onSelect,\n openOnSpace,\n selectOnSpace,\n ],\n )\n\n useUpdateEffect(() => {\n if (open) return\n\n activeDescendant.current = null\n }, [open])\n\n const getTriggerProps: PropGetter = useCallback(\n (props = {}) => ({\n ...mergeProps(\n {\n ref: triggerRef,\n \"aria-controls\": open ? contentId : undefined,\n \"aria-disabled\": ariaAttr(!interactive),\n \"aria-expanded\": open,\n \"aria-haspopup\": \"listbox\",\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledby,\n \"data-disabled\": dataAttr(disabled),\n \"data-readonly\": dataAttr(readOnly),\n role: \"combobox\",\n tabIndex: interactive ? 0 : -1,\n },\n rest,\n props,\n { onClick, onKeyDown },\n )(),\n }),\n [\n open,\n contentId,\n interactive,\n disabled,\n readOnly,\n ariaLabelledby,\n ariaLabel,\n rest,\n onClick,\n onKeyDown,\n ],\n )\n\n const getContentProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) => ({\n id: contentId,\n role: \"listbox\",\n ...props,\n ref: mergeRefs(ref, contentRef),\n onKeyDown: handlerAll(props.onKeyDown),\n }),\n [contentId],\n )\n\n const getSeparatorProps: PropGetter = useCallback(\n (props) => ({ role: \"separator\", ...props }),\n [],\n )\n\n return {\n activeDescendant,\n descendants,\n interactive,\n open,\n getContentProps,\n getSeparatorProps,\n getTriggerProps,\n popoverProps: mergedPopoverProps,\n onActiveDescendant,\n onClose,\n onOpen,\n onOpenWithActiveDescendant,\n onScrollIntoView,\n onSelect,\n }\n}\n\nexport type UseComboboxReturn = ReturnType<typeof useCombobox>\n\nexport interface UseComboboxGroupProps extends HTMLProps {}\n\nexport const useComboboxGroup = ({ ...rest }: UseComboboxGroupProps = {}) => {\n const labelId = useId()\n\n const getGroupProps: PropGetter = useCallback(\n (props = {}) =>\n mergeProps({ \"aria-labelledby\": labelId, role: \"group\" }, rest, props)(),\n [labelId, rest],\n )\n\n const getLabelProps: PropGetter<\"span\"> = useCallback(\n (props) => ({ id: labelId, role: \"presentation\", ...props }),\n [labelId],\n )\n\n return { getGroupProps, getLabelProps }\n}\n\nexport type UseComboboxGroupReturn = ReturnType<typeof useComboboxGroup>\n\nexport interface UseComboboxItemProps extends HTMLProps {\n /**\n * If `true`, the item will be closed when selected.\n */\n closeOnSelect?: boolean\n /**\n * If `true`, the item will be disabled.\n *\n * @default false\n */\n disabled?: boolean\n /**\n * If `true`, the item will be selected.\n */\n selected?: boolean\n /**\n * The value of the item.\n */\n value?: string\n}\n\nexport const useComboboxItem = ({\n id,\n \"aria-disabled\": ariaDisabled,\n \"data-disabled\": dataDisabled,\n closeOnSelect,\n disabled = false,\n selected = false,\n value,\n ...rest\n}: UseComboboxItemProps = {}) => {\n const uuid = useId()\n const itemRef = useRef<HTMLDivElement>(null)\n const { onActiveDescendant, onClose, onSelect } = useComboboxContext()\n\n id ??= uuid\n\n const { descendants, register } = useComboboxDescendant({\n id,\n closeOnSelect,\n disabled,\n value,\n })\n\n const onActive = useCallback(() => {\n if (disabled) return\n\n const current = descendants.value(itemRef.current)\n\n onActiveDescendant(current)\n }, [descendants, disabled, onActiveDescendant])\n\n const onClick = useCallback(\n (ev: MouseEvent<HTMLDivElement>) => {\n ev.preventDefault()\n\n if (disabled) return\n\n onSelect(value, closeOnSelect)\n },\n [closeOnSelect, disabled, onSelect, value],\n )\n\n const getItemProps: PropGetter = useCallback(\n (props = {}) => ({\n ...mergeProps(\n {\n id,\n ref: itemRef,\n \"aria-disabled\": ariaDisabled ?? ariaAttr(disabled),\n \"aria-selected\": selected,\n \"data-disabled\": dataDisabled ?? dataAttr(disabled),\n \"data-selected\": dataAttr(selected),\n \"data-value\": value,\n role: \"option\",\n tabIndex: -1,\n },\n rest,\n props,\n { ref: register },\n )({ mergeEvent: false }),\n onClick: handlerAll(props.onClick, rest.onClick, onClick),\n onMouseMove: handlerAll(props.onMouseMove, rest.onMouseMove, onActive),\n }),\n [\n id,\n ariaDisabled,\n disabled,\n selected,\n dataDisabled,\n value,\n rest,\n register,\n onClick,\n onActive,\n ],\n )\n\n const getIndicatorProps: PropGetter = useCallback(\n (props = {}) =>\n mergeProps({ style: { opacity: selected ? 1 : 0 } }, props)(),\n [selected],\n )\n\n return {\n descendants,\n disabled,\n selected,\n getIndicatorProps,\n getItemProps,\n onActiveDescendant,\n onClose,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAuDA,MAAa,sBACX,UACA,EAAE,OAAO,OAAO,aACb;CAGH,OAFsBA,iBAAAA,iBAAi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I,EAAE,EAAE,GAAG,KAAK,CAAC,CAAC,GAC9D,CAAC,QAAQ,CAOO;EAChB;EACA;EACA;CACF;AACF"}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -3557,6 +3557,7 @@ var src_exports = /* @__PURE__ */ require_runtime.__exportAll({
|
|
|
3557
3557
|
HueSliderRoot: () => require_hue_slider.HueSliderRoot,
|
|
3558
3558
|
HueSliderThumb: () => require_hue_slider.HueSliderThumb,
|
|
3559
3559
|
HueSliderTrack: () => require_hue_slider.HueSliderTrack,
|
|
3560
|
+
HydrationContext: () => require_styled.HydrationContext,
|
|
3560
3561
|
I18nContext: () => require_i18n_provider.I18nContext,
|
|
3561
3562
|
I18nProvider: () => require_i18n_provider.I18nProvider,
|
|
3562
3563
|
IceCreamBowlIcon: () => require_ice_cream_bowl_icon.IceCreamBowlIcon,
|
|
@@ -5367,6 +5368,7 @@ var src_exports = /* @__PURE__ */ require_runtime.__exportAll({
|
|
|
5367
5368
|
useHighlight: () => require_use_highlight.useHighlight,
|
|
5368
5369
|
useHover: () => require_hooks_use_hover_index.useHover,
|
|
5369
5370
|
useHueSliderPropsContext: () => require_hue_slider.useHueSliderPropsContext,
|
|
5371
|
+
useHydrationContext: () => require_styled.useHydrationContext,
|
|
5370
5372
|
useI18n: () => require_i18n_provider.useI18n,
|
|
5371
5373
|
useIconButtonPropsContext: () => require_icon_button.useIconButtonPropsContext,
|
|
5372
5374
|
useIconPropsContext: () => require_icon.useIconPropsContext,
|
|
@@ -6930,6 +6932,7 @@ exports.HueSliderPropsContext = require_hue_slider.HueSliderPropsContext;
|
|
|
6930
6932
|
exports.HueSliderRoot = require_hue_slider.HueSliderRoot;
|
|
6931
6933
|
exports.HueSliderThumb = require_hue_slider.HueSliderThumb;
|
|
6932
6934
|
exports.HueSliderTrack = require_hue_slider.HueSliderTrack;
|
|
6935
|
+
exports.HydrationContext = require_styled.HydrationContext;
|
|
6933
6936
|
exports.I18nContext = require_i18n_provider.I18nContext;
|
|
6934
6937
|
exports.I18nProvider = require_i18n_provider.I18nProvider;
|
|
6935
6938
|
exports.IceCreamBowlIcon = require_ice_cream_bowl_icon.IceCreamBowlIcon;
|
|
@@ -8920,6 +8923,7 @@ exports.useHeadingPropsContext = require_heading.useHeadingPropsContext;
|
|
|
8920
8923
|
exports.useHighlight = require_use_highlight.useHighlight;
|
|
8921
8924
|
exports.useHover = require_hooks_use_hover_index.useHover;
|
|
8922
8925
|
exports.useHueSliderPropsContext = require_hue_slider.useHueSliderPropsContext;
|
|
8926
|
+
exports.useHydrationContext = require_styled.useHydrationContext;
|
|
8923
8927
|
exports.useI18n = require_i18n_provider.useI18n;
|
|
8924
8928
|
exports.useIconButtonPropsContext = require_icon_button.useIconButtonPropsContext;
|
|
8925
8929
|
exports.useIconPropsContext = require_icon.useIconPropsContext;
|
|
@@ -111,12 +111,11 @@ const useAccordionItem = ({ disabled, index, ...rest }) => {
|
|
|
111
111
|
onFocus,
|
|
112
112
|
onKeyDown
|
|
113
113
|
]);
|
|
114
|
-
const getPanelProps = useCallback((
|
|
114
|
+
const getPanelProps = useCallback((props = {}) => mergeProps({
|
|
115
115
|
id: panelId,
|
|
116
|
-
"aria-labelledby":
|
|
117
|
-
role: "region"
|
|
118
|
-
|
|
119
|
-
}), [itemId, panelId]);
|
|
116
|
+
"aria-labelledby": itemId,
|
|
117
|
+
role: "region"
|
|
118
|
+
}, props)(), [itemId, panelId]);
|
|
120
119
|
return {
|
|
121
120
|
disabled,
|
|
122
121
|
open,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-accordion.js","names":["createContext","isArray","dataAttr","ariaAttr","handlerAll","cx"],"sources":["../../../../src/components/accordion/use-accordion.ts"],"sourcesContent":["\"use client\"\n\nimport type { KeyboardEvent } from \"react\"\nimport type { HTMLProps, PropGetter } from \"../../core\"\nimport { useCallback, useEffect, useId, useState } from \"react\"\nimport { mergeProps } from \"../../core\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { createDescendants } from \"../../hooks/use-descendants\"\nimport {\n ariaAttr,\n createContext,\n cx,\n dataAttr,\n handlerAll,\n isArray,\n mergeRefs,\n runKeyAction,\n} from \"../../utils\"\n\nconst {\n DescendantsContext: AccordionDescendantsContext,\n useDescendant: useAccordionDescendant,\n useDescendants: useAccordionDescendants,\n} = createDescendants<HTMLButtonElement>()\n\nexport {\n AccordionDescendantsContext,\n useAccordionDescendant,\n useAccordionDescendants,\n}\n\ninterface AccordionContext extends Omit<\n UseAccordionReturn,\n \"descendants\" | \"getRootProps\"\n> {}\n\nconst [AccordionContext, useAccordionContext] = createContext<AccordionContext>(\n { name: \"AccordionContext\" },\n)\n\nexport { AccordionContext, useAccordionContext }\n\ninterface AccordionItemContext extends Omit<\n UseAccordionItemReturn,\n \"getItemProps\"\n> {}\n\nconst [AccordionItemContext, useAccordionItemContext] =\n createContext<AccordionItemContext>({\n name: \"AccordionItemContext\",\n })\n\nexport { AccordionItemContext, useAccordionItemContext }\n\nexport interface UseAccordionProps extends Omit<HTMLProps, \"onChange\"> {\n /**\n * The initial index(es) of the accordion item to expand.\n */\n defaultIndex?: number | number[]\n /**\n * The index(es) of the accordion item to expand.\n */\n index?: number | number[]\n /**\n * If `true`, multiple accordion items can be expanded at once.\n *\n * @default false\n */\n multiple?: boolean\n /**\n * If `true`, any expanded accordion item can be collapsed again.\n *\n * @default false\n */\n toggle?: boolean\n /**\n * The callback invoked when accordion items are expanded or collapsed.\n */\n onChange?: (index: number | number[]) => void\n}\n\nexport const useAccordion = ({\n defaultIndex: defaultIndexProp,\n index: indexProp,\n multiple,\n toggle,\n onChange,\n ...rest\n}: UseAccordionProps = {}) => {\n if (\n (indexProp || defaultIndexProp) != null &&\n !isArray(indexProp || defaultIndexProp) &&\n multiple\n )\n console.warn(\n `Accordion: If 'multiple' is passed, then 'index' or 'defaultIndex' must be an array.`,\n )\n\n if (multiple && toggle)\n console.warn(\n `Accordion: If 'multiple' is passed, 'toggle' will be ignored. Either remove 'toggle' or 'multiple' depending on whether you want multiple accordions visible or not`,\n )\n\n const descendants = useAccordionDescendants()\n\n const [focusedIndex, setFocusedIndex] = useState<number>(-1)\n\n const [index, setIndex] = useControllableState({\n defaultValue: () =>\n multiple ? (defaultIndexProp ?? []) : (defaultIndexProp ?? -1),\n value: indexProp,\n onChange,\n })\n\n const getRootProps: PropGetter = useCallback(\n (props = {}) => mergeProps(rest, props)(),\n [rest],\n )\n\n useEffect(() => {\n return () => setFocusedIndex(-1)\n }, [])\n\n return {\n descendants,\n focusedIndex,\n index,\n multiple,\n setFocusedIndex,\n setIndex,\n toggle,\n getRootProps,\n }\n}\n\nexport type UseAccordionReturn = ReturnType<typeof useAccordion>\n\nexport interface UseAccordionItemProps extends HTMLProps {\n /**\n * The index of the accordion item.\n */\n index: number\n /**\n * If `true`, the accordion item will be disabled.\n *\n * @default false\n */\n disabled?: boolean\n}\n\nexport const useAccordionItem = ({\n disabled,\n index,\n ...rest\n}: UseAccordionItemProps) => {\n const itemId = useId()\n const panelId = useId()\n const {\n index: selectedIndex,\n multiple,\n setFocusedIndex,\n setIndex,\n toggle,\n } = useAccordionContext()\n const { descendants, register } = useAccordionDescendant({ disabled })\n const open =\n index !== -1\n ? isArray(selectedIndex)\n ? selectedIndex.includes(index)\n : selectedIndex === index\n : false\n\n if (open && disabled)\n console.warn(`Accordion: Cannot open a disabled accordion item`)\n\n const onChange = useCallback(\n (open: boolean) => {\n if (index === -1) return\n\n if (multiple && isArray(selectedIndex))\n setIndex(\n open\n ? selectedIndex.concat(index)\n : selectedIndex.filter((i) => i !== index),\n )\n else if (open) setIndex(index)\n else if (toggle) setIndex(-1)\n },\n [multiple, toggle, index, selectedIndex, setIndex],\n )\n\n const onFocus = useCallback(() => {\n setFocusedIndex(index)\n }, [setFocusedIndex, index])\n\n const onClick = useCallback(() => {\n onChange(!open)\n setFocusedIndex(index)\n descendants.value(index)?.node.focus()\n }, [index, setFocusedIndex, open, onChange, descendants])\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLButtonElement>) => {\n runKeyAction(ev, {\n ArrowDown: () => {\n const next = descendants.enabledNextValue(index)\n\n next?.node.focus()\n },\n ArrowUp: () => {\n const prev = descendants.enabledPrevValue(index)\n\n prev?.node.focus()\n },\n End: () => {\n const last = descendants.enabledLastValue()\n\n last?.node.focus()\n },\n Home: () => {\n const first = descendants.enabledFirstValue()\n\n first?.node.focus()\n },\n })\n },\n [descendants, index],\n )\n\n const getItemProps: PropGetter = useCallback(\n (props = {}) =>\n mergeProps({ \"data-expanded\": dataAttr(open) }, rest, props)(),\n [open, rest],\n )\n\n const getButtonProps: PropGetter<\"button\"> = useCallback(\n ({ ref, ...props } = {}) => ({\n id: itemId,\n type: \"button\",\n \"aria-controls\": panelId,\n \"aria-disabled\": ariaAttr((!multiple && !toggle && open) || disabled),\n \"aria-expanded\": open,\n tabIndex: 0,\n ...props,\n ref: mergeRefs(register, ref),\n disabled,\n onClick: handlerAll(props.onClick, onClick),\n onFocus: handlerAll(props.onFocus, onFocus),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown),\n }),\n [\n itemId,\n open,\n panelId,\n multiple,\n toggle,\n disabled,\n register,\n onClick,\n onFocus,\n onKeyDown,\n ],\n )\n\n const getPanelProps: PropGetter = useCallback(\n ({ \"aria-labelledby\": ariaLabelledby, ...props } = {}) => ({\n id: panelId,\n \"aria-labelledby\": cx(ariaLabelledby, itemId),\n role: \"region\",\n ...props,\n }),\n [itemId, panelId],\n )\n\n const getIconProps: PropGetter<\"svg\"> = useCallback(\n (props) => ({\n \"aria-disabled\": ariaAttr((!multiple && !toggle && open) || disabled),\n \"aria-expanded\": open,\n \"aria-hidden\": true,\n role: \"presentation\",\n ...props,\n }),\n [multiple, toggle, open, disabled],\n )\n\n return {\n disabled,\n open,\n getButtonProps,\n getIconProps,\n getItemProps,\n getPanelProps,\n }\n}\n\nexport type UseAccordionItemReturn = ReturnType<typeof useAccordionItem>\n"],"mappings":";;;;;;;;;;AAmBA,MAAM,EACJ,o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AAU,QAAS,QAAQ;EACpE,iBAAiB;EACjB,UAAU;EACV,GAAG;EACH,KAAK,UAAU,UAAU,GAAG;EAC5B;EACA,UAAA,GAASC,cAAAA,WAAAA,CAAW,MAAM,SAAS,OAAO;EAC1C,UAAA,GAASA,cAAAA,WAAAA,CAAW,MAAM,SAAS,OAAO;EAC1C,YAAA,GAAWA,cAAAA,WAAAA,CAAW,MAAM,WAAW,SAAS;CAClD,IACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CACF;CAEA,MAAM,gBAA4B,aAC/B,EAAE,mBAAmB,gBAAgB,GAAG,UAAU,CAAC,OAAO;EACzD,IAAI;EACJ,oBAAA,GAAmBC,cAAAA,GAAAA,CAAG,gBAAgB,MAAM;EAC5C,MAAM;EACN,GAAG;CACL,IACA,CAAC,QAAQ,OAAO,CAClB;CAaA,OAAO;EACL;EACA;EACA;EACA,cAfsC,aACrC,WAAW;GACV,kBAAA,GAAiBF,cAAAA,SAAAA,CAAU,CAAC,YAAY,CAAC,UAAU,QAAS,QAAQ;GACpE,iBAAiB;GACjB,eAAe;GACf,MAAM;GACN,GAAG;EACL,IACA;GAAC;GAAU;GAAQ;GAAM;EAAQ,CAOtB;EACX;EACA;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"use-accordion.js","names":["createContext","isArray","dataAttr","ariaAttr","handlerAll"],"sources":["../../../../src/components/accordion/use-accordion.ts"],"sourcesContent":["\"use client\"\n\nimport type { KeyboardEvent } from \"react\"\nimport type { HTMLProps, PropGetter } from \"../../core\"\nimport { useCallback, useEffect, useId, useState } from \"react\"\nimport { mergeProps } from \"../../core\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { createDescendants } from \"../../hooks/use-descendants\"\nimport {\n ariaAttr,\n createContext,\n dataAttr,\n handlerAll,\n isArray,\n mergeRefs,\n runKeyAction,\n} from \"../../utils\"\n\nconst {\n DescendantsContext: AccordionDescendantsContext,\n useDescendant: useAccordionDescendant,\n useDescendants: useAccordionDescendants,\n} = createDescendants<HTMLButtonElement>()\n\nexport {\n AccordionDescendantsContext,\n useAccordionDescendant,\n useAccordionDescendants,\n}\n\ninterface AccordionContext extends Omit<\n UseAccordionReturn,\n \"descendants\" | \"getRootProps\"\n> {}\n\nconst [AccordionContext, useAccordionContext] = createContext<AccordionContext>(\n { name: \"AccordionContext\" },\n)\n\nexport { AccordionContext, useAccordionContext }\n\ninterface AccordionItemContext extends Omit<\n UseAccordionItemReturn,\n \"getItemProps\"\n> {}\n\nconst [AccordionItemContext, useAccordionItemContext] =\n createContext<AccordionItemContext>({\n name: \"AccordionItemContext\",\n })\n\nexport { AccordionItemContext, useAccordionItemContext }\n\nexport interface UseAccordionProps extends Omit<HTMLProps, \"onChange\"> {\n /**\n * The initial index(es) of the accordion item to expand.\n */\n defaultIndex?: number | number[]\n /**\n * The index(es) of the accordion item to expand.\n */\n index?: number | number[]\n /**\n * If `true`, multiple accordion items can be expanded at once.\n *\n * @default false\n */\n multiple?: boolean\n /**\n * If `true`, any expanded accordion item can be collapsed again.\n *\n * @default false\n */\n toggle?: boolean\n /**\n * The callback invoked when accordion items are expanded or collapsed.\n */\n onChange?: (index: number | number[]) => void\n}\n\nexport const useAccordion = ({\n defaultIndex: defaultIndexProp,\n index: indexProp,\n multiple,\n toggle,\n onChange,\n ...rest\n}: UseAccordionProps = {}) => {\n if (\n (indexProp || defaultIndexProp) != null &&\n !isArray(indexProp || defaultIndexProp) &&\n multiple\n )\n console.warn(\n `Accordion: If 'multiple' is passed, then 'index' or 'defaultIndex' must be an array.`,\n )\n\n if (multiple && toggle)\n console.warn(\n `Accordion: If 'multiple' is passed, 'toggle' will be ignored. Either remove 'toggle' or 'multiple' depending on whether you want multiple accordions visible or not`,\n )\n\n const descendants = useAccordionDescendants()\n\n const [focusedIndex, setFocusedIndex] = useState<number>(-1)\n\n const [index, setIndex] = useControllableState({\n defaultValue: () =>\n multiple ? (defaultIndexProp ?? []) : (defaultIndexProp ?? -1),\n value: indexProp,\n onChange,\n })\n\n const getRootProps: PropGetter = useCallback(\n (props = {}) => mergeProps(rest, props)(),\n [rest],\n )\n\n useEffect(() => {\n return () => setFocusedIndex(-1)\n }, [])\n\n return {\n descendants,\n focusedIndex,\n index,\n multiple,\n setFocusedIndex,\n setIndex,\n toggle,\n getRootProps,\n }\n}\n\nexport type UseAccordionReturn = ReturnType<typeof useAccordion>\n\nexport interface UseAccordionItemProps extends HTMLProps {\n /**\n * The index of the accordion item.\n */\n index: number\n /**\n * If `true`, the accordion item will be disabled.\n *\n * @default false\n */\n disabled?: boolean\n}\n\nexport const useAccordionItem = ({\n disabled,\n index,\n ...rest\n}: UseAccordionItemProps) => {\n const itemId = useId()\n const panelId = useId()\n const {\n index: selectedIndex,\n multiple,\n setFocusedIndex,\n setIndex,\n toggle,\n } = useAccordionContext()\n const { descendants, register } = useAccordionDescendant({ disabled })\n const open =\n index !== -1\n ? isArray(selectedIndex)\n ? selectedIndex.includes(index)\n : selectedIndex === index\n : false\n\n if (open && disabled)\n console.warn(`Accordion: Cannot open a disabled accordion item`)\n\n const onChange = useCallback(\n (open: boolean) => {\n if (index === -1) return\n\n if (multiple && isArray(selectedIndex))\n setIndex(\n open\n ? selectedIndex.concat(index)\n : selectedIndex.filter((i) => i !== index),\n )\n else if (open) setIndex(index)\n else if (toggle) setIndex(-1)\n },\n [multiple, toggle, index, selectedIndex, setIndex],\n )\n\n const onFocus = useCallback(() => {\n setFocusedIndex(index)\n }, [setFocusedIndex, index])\n\n const onClick = useCallback(() => {\n onChange(!open)\n setFocusedIndex(index)\n descendants.value(index)?.node.focus()\n }, [index, setFocusedIndex, open, onChange, descendants])\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLButtonElement>) => {\n runKeyAction(ev, {\n ArrowDown: () => {\n const next = descendants.enabledNextValue(index)\n\n next?.node.focus()\n },\n ArrowUp: () => {\n const prev = descendants.enabledPrevValue(index)\n\n prev?.node.focus()\n },\n End: () => {\n const last = descendants.enabledLastValue()\n\n last?.node.focus()\n },\n Home: () => {\n const first = descendants.enabledFirstValue()\n\n first?.node.focus()\n },\n })\n },\n [descendants, index],\n )\n\n const getItemProps: PropGetter = useCallback(\n (props = {}) =>\n mergeProps({ \"data-expanded\": dataAttr(open) }, rest, props)(),\n [open, rest],\n )\n\n const getButtonProps: PropGetter<\"button\"> = useCallback(\n ({ ref, ...props } = {}) => ({\n id: itemId,\n type: \"button\",\n \"aria-controls\": panelId,\n \"aria-disabled\": ariaAttr((!multiple && !toggle && open) || disabled),\n \"aria-expanded\": open,\n tabIndex: 0,\n ...props,\n ref: mergeRefs(register, ref),\n disabled,\n onClick: handlerAll(props.onClick, onClick),\n onFocus: handlerAll(props.onFocus, onFocus),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown),\n }),\n [\n itemId,\n open,\n panelId,\n multiple,\n toggle,\n disabled,\n register,\n onClick,\n onFocus,\n onKeyDown,\n ],\n )\n\n const getPanelProps: PropGetter = useCallback(\n (props = {}) =>\n mergeProps(\n { id: panelId, \"aria-labelledby\": itemId, role: \"region\" },\n props,\n )(),\n [itemId, panelId],\n )\n\n const getIconProps: PropGetter<\"svg\"> = useCallback(\n (props) => ({\n \"aria-disabled\": ariaAttr((!multiple && !toggle && open) || disabled),\n \"aria-expanded\": open,\n \"aria-hidden\": true,\n role: \"presentation\",\n ...props,\n }),\n [multiple, toggle, open, disabled],\n )\n\n return {\n disabled,\n open,\n getButtonProps,\n getIconProps,\n getItemProps,\n getPanelProps,\n }\n}\n\nexport type UseAccordionItemReturn = ReturnType<typeof useAccordionItem>\n"],"mappings":";;;;;;;;;;AAkBA,MAAM,EACJ,oBAAoB,6BACpB,eAAe,wBACf,gBAAgB,4BACd,kBAAqC;AAazC,MAAM,CAAC,kBAAkB,uBAAuBA,gBAC9C,EAAE,MAAM,mBAAmB,CAC7B;AASA,MAAM,CAAC,sBAAsB,2BAC3BA,gBAAoC,EAClC,MAAM,uBACR,CAAC;AA+BH,MAAa,gBAAgB,EA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AAA,GAAWA,cAAAA,WAAAA,CAAW,MAAM,WAAW,SAAS;CAClD,IACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CACF;CAEA,MAAM,gBAA4B,aAC/B,QAAQ,CAAC,MACR,WACE;EAAE,IAAI;EAAS,mBAAmB;EAAQ,MAAM;CAAS,GACzD,KACF,CAAC,CAAC,GACJ,CAAC,QAAQ,OAAO,CAClB;CAaA,OAAO;EACL;EACA;EACA;EACA,cAfsC,aACrC,WAAW;GACV,kBAAA,GAAiBD,cAAAA,SAAAA,CAAU,CAAC,YAAY,CAAC,UAAU,QAAS,QAAQ;GACpE,iBAAiB;GACjB,eAAe;GACf,MAAM;GACN,GAAG;EACL,IACA;GAAC;GAAU;GAAQ;GAAM;EAAQ,CAOtB;EACX;EACA;CACF;AACF"}
|
|
@@ -12,7 +12,7 @@ const [CheckboxGroupContext, useCheckboxGroupContext] = createContext$1({
|
|
|
12
12
|
strict: false
|
|
13
13
|
});
|
|
14
14
|
const useCheckboxGroup = (props = {}) => {
|
|
15
|
-
const { context: { labelId } = {}, props: { defaultValue = [], disabled, max, readOnly, required, value: valueProp, onChange: onChangeProp, ...rest }, ariaProps: { "aria-describedby":
|
|
15
|
+
const { context: { labelId } = {}, props: { defaultValue = [], disabled, max, readOnly, required, value: valueProp, onChange: onChangeProp, ...rest }, ariaProps: { "aria-describedby": ariaDescribedby, ...ariaProps }, dataProps, eventProps } = useFieldProps(props);
|
|
16
16
|
const interactive = !(readOnly || disabled);
|
|
17
17
|
const [value, setValue] = useControllableState({
|
|
18
18
|
defaultValue,
|
|
@@ -32,12 +32,12 @@ const useCheckboxGroup = (props = {}) => {
|
|
|
32
32
|
max,
|
|
33
33
|
setValue
|
|
34
34
|
]);
|
|
35
|
-
const getRootProps = useCallback((
|
|
36
|
-
"aria-describedby":
|
|
37
|
-
"aria-labelledby":
|
|
35
|
+
const getRootProps = useCallback((props = {}) => mergeProps(dataProps, {
|
|
36
|
+
"aria-describedby": ariaDescribedby,
|
|
37
|
+
"aria-labelledby": labelId,
|
|
38
38
|
role: "group"
|
|
39
|
-
}, rest, props
|
|
40
|
-
|
|
39
|
+
}, rest, props)(), [
|
|
40
|
+
ariaDescribedby,
|
|
41
41
|
dataProps,
|
|
42
42
|
labelId,
|
|
43
43
|
rest
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-checkbox-group.js","names":["createContext","isObject","isNumber","
|
|
1
|
+
{"version":3,"file":"use-checkbox-group.js","names":["createContext","isObject","isNumber","isUndefined","isString","ariaAttr","dataAttr","handlerAll"],"sources":["../../../../src/components/checkbox/use-checkbox-group.ts"],"sourcesContent":["\"use client\"\n\nimport type { ChangeEvent } from \"react\"\nimport type { HTMLProps, PropGetter } from \"../../core\"\nimport type { FieldProps } from \"../field\"\nimport { useCallback } from \"react\"\nimport { mergeProps } from \"../../core\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport {\n ariaAttr,\n createContext,\n dataAttr,\n handlerAll,\n isNumber,\n isObject,\n isString,\n isUndefined,\n visuallyHiddenAttributes,\n} from \"../../utils\"\nimport { useFieldProps } from \"../field\"\n\ninterface CheckboxGroupContext extends Omit<\n UseCheckboxGroupReturn,\n \"getRootProps\"\n> {}\n\nconst [CheckboxGroupContext, useCheckboxGroupContext] =\n createContext<CheckboxGroupContext>({\n name: \"CheckboxGroupContext\",\n strict: false,\n })\n\nexport { CheckboxGroupContext, useCheckboxGroupContext }\n\nexport interface UseCheckboxGroupProps<Y extends string = string>\n extends Omit<HTMLProps, \"defaultValue\" | \"onChange\" | \"value\">, FieldProps {\n /**\n * The initial value of the checkbox group.\n *\n * @default []\n */\n defaultValue?: Y[]\n /**\n * The maximum number of checkboxes that can be checked.\n */\n max?: number\n /**\n * The value of the checkbox group.\n */\n value?: Y[]\n /**\n * The callback fired when any children checkbox is checked or unchecked.\n */\n onChange?: (value: Y[]) => void\n}\n\nexport const useCheckboxGroup = <Y extends string = string>(\n props: UseCheckboxGroupProps<Y> = {},\n) => {\n const {\n context: { labelId } = {},\n props: {\n defaultValue = [],\n disabled,\n max,\n readOnly,\n required,\n value: valueProp,\n onChange: onChangeProp,\n ...rest\n },\n ariaProps: { \"aria-describedby\": ariaDescribedby, ...ariaProps },\n dataProps,\n eventProps,\n } = useFieldProps(props)\n const interactive = !(readOnly || disabled)\n const [value, setValue] = useControllableState({\n defaultValue,\n value: valueProp,\n onChange: onChangeProp,\n })\n\n const onChange = useCallback(\n (valueOrEv: ChangeEvent<HTMLInputElement> | Y) => {\n if (!interactive) return\n\n if (isObject(valueOrEv)) valueOrEv = valueOrEv.target.value as Y\n\n setValue((prev) => {\n if (prev.includes(valueOrEv))\n return prev.filter((prevValue) => prevValue !== valueOrEv)\n else if (!isNumber(max) || prev.length < max)\n return [...prev, valueOrEv]\n else return prev\n })\n },\n [interactive, max, setValue],\n )\n\n const getRootProps: PropGetter = useCallback(\n (props = {}) =>\n mergeProps(\n dataProps,\n {\n \"aria-describedby\": ariaDescribedby,\n \"aria-labelledby\": labelId,\n role: \"group\",\n },\n rest,\n props,\n )(),\n [ariaDescribedby, dataProps, labelId, rest],\n )\n\n const getInputProps: PropGetter<\"input\"> = useCallback(\n (props = {}) => {\n const checked =\n !isUndefined(value) &&\n (isString(props.value) || isNumber(props.value)) &&\n value.includes(props.value as Y)\n const trulyDisabled = !checked && isNumber(max) && value.length >= max\n\n return {\n ...dataProps,\n ...ariaProps,\n type: \"checkbox\",\n style: visuallyHiddenAttributes.style,\n \"aria-checked\": checked,\n \"aria-disabled\": ariaAttr(trulyDisabled),\n \"data-checked\": dataAttr(checked),\n \"data-disabled\": dataAttr(trulyDisabled),\n checked,\n readOnly,\n required,\n ...props,\n disabled: Boolean(props.disabled || trulyDisabled),\n onBlur: handlerAll(props.onBlur, eventProps.onBlur),\n onChange: handlerAll(props.onChange, onChange),\n onFocus: handlerAll(props.onFocus, eventProps.onFocus),\n }\n },\n [\n ariaProps,\n dataProps,\n eventProps,\n max,\n onChange,\n readOnly,\n required,\n value,\n ],\n )\n\n const getLabelProps: PropGetter<\"label\"> = useCallback(\n (props) => ({\n ...dataProps,\n ...props,\n }),\n [dataProps],\n )\n\n return {\n max,\n value,\n getInputProps,\n getLabelProps,\n getRootProps,\n onChange,\n }\n}\n\nexport type UseCheckboxGroupReturn = ReturnType<typeof useCheckboxGroup>\n"],"mappings":";;;;;;;;;AA0BA,MAAM,CAAC,sBAAsB,2BAC3BA,gBAAoC;CAClC,MAAM;CACN,QAAQ;AACV,CAAC;AA0BH,MAAa,oBACX,QAAkC,CAAC,MAChC;CACH,MAAM,EACJ,SAAS,EAAE,YAAY,CAAC,GACxB,OAAO,EACL,eAAe,CAAC,GAChB,UACA,KACA,UACA,UACA,OAAO,WACP,UAAU,cACV,GAAG,QAEL,WAAW,EAAE,oBAAoB,iBAAiB,GAAG,aACrD,WACA,eACE,cAAc,KAAK;CACvB,MAAM,cAAc,EAAE,YAAY;CAClC,MAAM,CAAC,OAAO,YAAY,qBAAqB;EAC7C;EACA,OAAO;EACP,UAAU;CACZ,CAAC;CAED,MAAM,WAAW,aACd,cAAiD;EAChD,IAAI,CAAC,aAAa;EAElB,KAAA,GAAIC,cAAAA,SAAAA,CAAS,SAAS,GAAG,YAAY,UAAU,OAAO;EAEtD,UAAU,SAAS;GACjB,IAAI,KAAK,SAAS,SAAS,GACzB,OAAO,KAAK,QAAQ,cAAc,cAAc,SAAS;QACtD,IAAI,EAAA,GAACC,cAAAA,SAAAA,CAAS,GAAG,KAAK,KAAK,SAAS,KACvC,OAAO,CAAC,GAAG,MAAM,SAAS;QACvB,OAAO;EACd,CAAC;CACH,GACA;EAAC;EAAa;EAAK;CAAQ,CAC7B;CAEA,MAAM,eAA2B,aAC9B,QAAQ,CAAC,MACR,WACE,WACA;EACE,oBAAoB;EACpB,mBAAmB;EACnB,MAAM;CACR,GACA,MACA,KACF,CAAC,CAAC,GACJ;EAAC;EAAiB;EAAW;EAAS;CAAI,CAC5C;CAiDA,OAAO;EACL;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