@accelint/design-system 1.1.4 → 1.1.6
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/components/button/button.css.d.ts +1 -0
- package/dist/components/button/index.d.ts +9 -40
- package/dist/components/button/index.js +23 -17
- package/dist/components/button/index.js.map +1 -1
- package/dist/components/button/types.d.ts +3 -2
- package/dist/components/collection/index.d.ts +2 -2
- package/dist/components/collection/index.js.map +1 -1
- package/dist/components/date-input/index.js +4 -1
- package/dist/components/date-input/index.js.map +1 -1
- package/dist/components/dialog/dialog.css.d.ts +1 -0
- package/dist/components/dialog/index.d.ts +1 -0
- package/dist/components/dialog/types.d.ts +1 -0
- package/dist/components/drawer/drawer.css.d.ts +1 -1
- package/dist/components/drawer/index.d.ts +1 -1
- package/dist/components/drawer/types.d.ts +1 -1
- package/dist/components/index.d.ts +2 -2
- package/dist/components/menu/index.d.ts +2 -2
- package/dist/components/menu/index.js +1 -1
- package/dist/components/menu/index.js.map +1 -1
- package/dist/components/merge-provider/index.js +15 -7
- package/dist/components/merge-provider/index.js.map +1 -1
- package/dist/components/number-field/index.d.ts +1 -1
- package/dist/components/number-field/number-field.css.d.ts +1 -1
- package/dist/components/number-field/types.d.ts +1 -1
- package/dist/components/options/index.js +1 -1
- package/dist/components/options/index.js.map +1 -1
- package/dist/components/picker/index.js.map +1 -1
- package/dist/components/text-field/index.d.ts +3 -128
- package/dist/components/text-field/index.js +3 -3
- package/dist/components/text-field/index.js.map +1 -1
- package/dist/components/tree/index.js +5 -2
- package/dist/components/tree/index.js.map +1 -1
- package/dist/hooks/index.d.ts +11 -11
- package/dist/hooks/use-collection-render/index.d.ts +1 -1
- package/dist/hooks/use-collection-render/index.js +2 -3
- package/dist/hooks/use-collection-render/index.js.map +1 -1
- package/dist/hooks/use-context-props/index.js.map +1 -1
- package/dist/hooks/use-defaults/index.d.ts +32 -80
- package/dist/hooks/use-defaults/index.js +1 -4
- package/dist/hooks/use-defaults/index.js.map +1 -1
- package/dist/hooks/use-defaults/types.d.ts +1 -1
- package/dist/hooks/use-theme/index.d.ts +1 -1
- package/dist/hooks/use-theme/types.d.ts +1 -1
- package/dist/hooks/use-tree/index.js +3 -2
- package/dist/hooks/use-tree/index.js.map +1 -1
- package/dist/hooks/use-tree/utils.js +6 -9
- package/dist/hooks/use-tree/utils.js.map +1 -1
- package/dist/hooks/use-update-effect/index.js.map +1 -1
- package/dist/index.css +32 -32
- package/dist/index.d.ts +5 -5
- package/dist/ladle/actions.js.map +1 -1
- package/dist/test/setup.js +630 -1249
- package/dist/test/setup.js.map +1 -1
- package/dist/utils/props/index.d.ts +1 -2
- package/dist/utils/props/index.js.map +1 -1
- package/package.json +29 -29
|
@@ -1,47 +1,16 @@
|
|
|
1
|
-
import * as react from 'react';
|
|
2
1
|
import { Context } from 'react';
|
|
3
|
-
import * as react_aria_components from 'react-aria-components';
|
|
4
2
|
import { ContextValue } from 'react-aria-components';
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
3
|
+
import { ButtonProps, LinkButtonProps, ToggleButtonProps } from './types.js';
|
|
4
|
+
import '../../types/generic.js';
|
|
7
5
|
import '../../types/props.js';
|
|
6
|
+
import '../../types/react-aria.js';
|
|
8
7
|
import '../icon/types.js';
|
|
9
8
|
|
|
10
|
-
declare const ButtonContext: Context<ContextValue<ButtonProps, HTMLButtonElement
|
|
11
|
-
declare const Button:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}>;
|
|
17
|
-
color?: ButtonColors;
|
|
18
|
-
mapping?: Partial<ButtonMapping>;
|
|
19
|
-
size?: ButtonSizes;
|
|
20
|
-
variant?: ButtonVariants;
|
|
21
|
-
} & react.RefAttributes<HTMLButtonElement>) => react.ReactElement | null;
|
|
22
|
-
declare const LinkButtonContext: Context<ContextValue<LinkButtonProps, HTMLAnchorElement>>;
|
|
23
|
-
declare const LinkButton: (props: Omit<react_aria_components.LinkProps, "children" | "className" | "style"> & {
|
|
24
|
-
children?: RenderPropsChildren<ButtonRenderProps>;
|
|
25
|
-
classNames?: Partial<{
|
|
26
|
-
container: string;
|
|
27
|
-
button: string;
|
|
28
|
-
}>;
|
|
29
|
-
color?: ButtonColors;
|
|
30
|
-
mapping?: Partial<ButtonMapping>;
|
|
31
|
-
size?: ButtonSizes;
|
|
32
|
-
variant?: ButtonVariants;
|
|
33
|
-
} & react.RefAttributes<HTMLAnchorElement>) => react.ReactElement | null;
|
|
34
|
-
declare const ToggleButtonContext: Context<ContextValue<ToggleButtonProps, HTMLButtonElement>>;
|
|
35
|
-
declare const ToggleButton: (props: Omit<react_aria_components.ToggleButtonProps, "children" | "className" | "style"> & {
|
|
36
|
-
children?: RenderPropsChildren<ButtonRenderProps>;
|
|
37
|
-
classNames?: Partial<{
|
|
38
|
-
container: string;
|
|
39
|
-
button: string;
|
|
40
|
-
}>;
|
|
41
|
-
color?: ButtonColors;
|
|
42
|
-
mapping?: Partial<ButtonMapping>;
|
|
43
|
-
size?: ButtonSizes;
|
|
44
|
-
variant?: ButtonVariants;
|
|
45
|
-
} & react.RefAttributes<HTMLButtonElement>) => react.ReactElement | null;
|
|
9
|
+
declare const ButtonContext: Context<ContextValue<ButtonProps, HTMLButtonElement> | null>;
|
|
10
|
+
declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
11
|
+
declare const LinkButtonContext: Context<ContextValue<LinkButtonProps, HTMLAnchorElement> | null>;
|
|
12
|
+
declare const LinkButton: React.ForwardRefExoticComponent<LinkButtonProps & React.RefAttributes<HTMLAnchorElement>>;
|
|
13
|
+
declare const ToggleButtonContext: Context<ContextValue<ToggleButtonProps, HTMLButtonElement> | null>;
|
|
14
|
+
declare const ToggleButton: React.ForwardRefExoticComponent<ToggleButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
46
15
|
|
|
47
16
|
export { Button, ButtonContext, LinkButton, LinkButtonContext, ToggleButton, ToggleButtonContext };
|
|
@@ -96,25 +96,31 @@ function useButton(props, ref, context, key) {
|
|
|
96
96
|
);
|
|
97
97
|
}
|
|
98
98
|
var ButtonContext = createContext(null);
|
|
99
|
-
var Button = forwardRef(
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
});
|
|
99
|
+
var Button = forwardRef(
|
|
100
|
+
function Button2(props, ref) {
|
|
101
|
+
const buttonProps = useButton(props, ref, ButtonContext, "Button");
|
|
102
|
+
return /* @__PURE__ */ jsx(Button$1, { ...buttonProps });
|
|
103
|
+
}
|
|
104
|
+
);
|
|
103
105
|
var LinkButtonContext = createContext(null);
|
|
104
|
-
var LinkButton = forwardRef(
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
});
|
|
106
|
+
var LinkButton = forwardRef(
|
|
107
|
+
function LinkButton2(props, ref) {
|
|
108
|
+
const buttonProps = useButton(props, ref, LinkButtonContext, "LinkButton");
|
|
109
|
+
return /* @__PURE__ */ jsx(Link, { ...buttonProps });
|
|
110
|
+
}
|
|
111
|
+
);
|
|
108
112
|
var ToggleButtonContext = createContext(null);
|
|
109
|
-
var ToggleButton = forwardRef(
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
});
|
|
113
|
+
var ToggleButton = forwardRef(
|
|
114
|
+
function ToggleButton2(props, ref) {
|
|
115
|
+
const buttonProps = useButton(
|
|
116
|
+
props,
|
|
117
|
+
ref,
|
|
118
|
+
ToggleButtonContext,
|
|
119
|
+
"ToggleButton"
|
|
120
|
+
);
|
|
121
|
+
return /* @__PURE__ */ jsx(ToggleButton$1, { ...buttonProps });
|
|
122
|
+
}
|
|
123
|
+
);
|
|
118
124
|
|
|
119
125
|
export { Button, ButtonContext, LinkButton, LinkButtonContext, ToggleButton, ToggleButtonContext };
|
|
120
126
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/button/index.tsx"],"names":["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Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { noop } from '@accelint/core';\nimport { clsx } from 'clsx';\nimport {\n type Context,\n createContext,\n type ForwardedRef,\n forwardRef,\n useCallback,\n useMemo,\n} from 'react';\nimport {\n type ButtonRenderProps,\n type ContextValue,\n Link,\n type LinkRenderProps,\n Provider,\n Button as RACButton,\n ToggleButton as RACToggleButton,\n type ToggleButtonRenderProps,\n} from 'react-aria-components';\nimport { useContextProps } from '../../hooks/use-context-props';\nimport { useDefaultProps } from '../../hooks/use-defaults';\nimport { useTheme } from '../../hooks/use-theme';\nimport { surfaces } from '../../styles/surfaces.css';\nimport { bodies } from '../../styles/typography.css';\nimport { inlineVars } from '../../utils/css';\nimport { callRenderProps, mergeClassNames } from '../../utils/props';\nimport { IconContext } from '../icon';\nimport { buttonClassNames, buttonStateVars } from './button.css';\nimport type { OmitProtectedProps } from '../../types/props';\nimport type { IconProps } from '../icon/types';\nimport type {\n ButtonMapping,\n ButtonProps,\n ButtonSizes,\n LinkButtonProps,\n ToggleButtonProps,\n} from './types';\n\nconst noopToggleState = {\n defaultSelected: false,\n isSelected: false,\n setSelected: noop,\n toggle: noop,\n};\nconst buttonSizes: ButtonSizes[] = ['xs', 'sm', 'md', 'lg', 'xl'];\n\nconst defaultMapping: ButtonMapping = {\n font: bodies,\n icon: buttonSizes.reduce(\n (acc, size) => {\n acc[size] = { size };\n\n return acc;\n },\n {} as Record<ButtonSizes, OmitProtectedProps<IconProps>>,\n ),\n};\n\nfunction useButton<\n P extends ButtonProps | LinkButtonProps | ToggleButtonProps,\n E extends HTMLElement,\n>(\n props: P,\n ref: ForwardedRef<E>,\n context: Context<ContextValue<P, E>>,\n key: 'Button' | 'LinkButton' | 'ToggleButton',\n) {\n const [contextProps, contextRef] = useContextProps(props, ref, context);\n\n const defaultedProps = useDefaultProps(contextProps, key);\n\n const {\n children: childrenProp,\n classNames: classNamesProp,\n color = 'primary',\n mapping: mappingProp,\n size = 'md',\n variant = 'solid',\n ...rest\n } = defaultedProps;\n\n const theme = useTheme();\n\n const mapping = useMemo(\n () => ({\n ...defaultMapping,\n ...mappingProp,\n }),\n [mappingProp],\n );\n\n const classNames = useMemo(\n () =>\n mergeClassNames(buttonClassNames, theme.Button, classNamesProp, {\n button: clsx(\n mapping.font[size],\n variant === 'floating' && surfaces.default.proud,\n ),\n }),\n [theme.Button, classNamesProp, mapping.font, size, variant],\n );\n\n const style = useCallback(\n (\n renderProps:\n | ButtonRenderProps\n | LinkRenderProps\n | ToggleButtonRenderProps,\n ) =>\n inlineVars(buttonStateVars, {\n isCurrent: false,\n isSelected: false,\n ...renderProps,\n color,\n size,\n variant,\n }),\n [color, size, variant],\n );\n\n const values = useMemo<\n [[typeof IconContext, ContextValue<IconProps, HTMLDivElement>]]\n >(() => [[IconContext, mapping.icon[size]]], [mapping.icon, size]);\n\n const children = useCallback(\n (\n renderProps:\n | ButtonRenderProps\n | LinkRenderProps\n | ToggleButtonRenderProps,\n ) => (\n <Provider values={values}>\n <span className={classNames?.button}>\n {callRenderProps(childrenProp, {\n state: noopToggleState,\n isCurrent: false,\n isPending: false,\n isSelected: false,\n ...renderProps,\n })}\n </span>\n </Provider>\n ),\n [values, classNames?.button, childrenProp],\n );\n\n return useMemo(\n () => ({\n ...rest,\n ref: contextRef,\n children,\n className: classNames?.container,\n style,\n }),\n // TODO(ilk): This should be checked. \"rest changes on every re-render and should not be used as a hook dependency.\"\n // biome-ignore lint/correctness/useExhaustiveDependencies: This should be checked and verified.\n [rest, contextRef, children, classNames?.container, style],\n );\n}\n\nexport const ButtonContext =\n createContext<ContextValue<ButtonProps, HTMLButtonElement>>(null);\n\nexport const Button = forwardRef(function Button(\n props: ButtonProps,\n ref: ForwardedRef<HTMLButtonElement>,\n) {\n const buttonProps = useButton(props, ref, ButtonContext, 'Button');\n\n return <RACButton {...buttonProps} />;\n});\n\nexport const LinkButtonContext =\n createContext<ContextValue<LinkButtonProps, HTMLAnchorElement>>(null);\n\nexport const LinkButton = forwardRef(function LinkButton(\n props: LinkButtonProps,\n ref: ForwardedRef<HTMLAnchorElement>,\n) {\n const buttonProps = useButton(props, ref, LinkButtonContext, 'LinkButton');\n\n return <Link {...buttonProps} />;\n});\n\nexport const ToggleButtonContext =\n createContext<ContextValue<ToggleButtonProps, HTMLButtonElement>>(null);\n\nexport const ToggleButton = forwardRef(function ToggleButton(\n props: ToggleButtonProps,\n ref: ForwardedRef<HTMLButtonElement>,\n) {\n const buttonProps = useButton(\n props,\n ref,\n ToggleButtonContext,\n 'ToggleButton',\n );\n\n return <RACToggleButton {...buttonProps} />;\n});\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/button/index.tsx"],"names":["Button","RACButton","LinkButton","ToggleButton","RACToggleButton"],"mappings":";;;;;;;;;;;;;;;;AAoDA,IAAM,eAAA,GAAkB;AAAA,EACtB,eAAA,EAAiB,KAAA;AAAA,EACjB,UAAA,EAAY,KAAA;AAAA,EACZ,WAAA,EAAa,IAAA;AAAA,EACb,MAAA,EAAQ;AACV,CAAA;AACA,IAAM,cAA6B,CAAC,IAAA,EAAM,IAAA,EAAM,IAAA,EAAM,MAAM,IAAI,CAAA;AAEhE,IAAM,cAAA,GAAgC;AAAA,EACpC,IAAA,EAAM,MAAA;AAAA,EACN,MAAM,WAAA,CAAY,MAAA;AAAA,IAChB,CAAC,KAAK,IAAA,KAAS;AACb,MAAA,GAAA,CAAI,IAAI,CAAA,GAAI,EAAE,IAAA,EAAK;AAEnB,MAAA,OAAO,GAAA;AAAA,IACT,CAAA;AAAA,IACA;AAAC;AAEL,CAAA;AAEA,SAAS,SAAA,CAIP,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AAW,GAAG,WAAA,EAAa,CAAA;AAAA,EACrC;AACF;AAIO,IAAM,iBAAA,GAIX,cAAgE,IAAI;AAE/D,IAAM,UAAA,GAAa,UAAA;AAAA,EACxB,SAASC,WAAAA,CACP,KAAA,EACA,GAAA,EACA;AACA,IAAA,MAAM,WAAA,GAAc,SAAA,CAAU,KAAA,EAAO,GAAA,EAAK,mBAAmB,YAAY,CAAA;AAEzE,IAAA,uBAAO,GAAA,CAAC,IAAA,EAAA,EAAM,GAAG,WAAA,EAAa,CAAA;AAAA,EAChC;AACF;AAIO,IAAM,mBAAA,GAIX,cAAkE,IAAI;AAEjE,IAAM,YAAA,GAAe,UAAA;AAAA,EAC1B,SAASC,aAAAA,CACP,KAAA,EACA,GAAA,EACA;AACA,IAAA,MAAM,WAAA,GAAc,SAAA;AAAA,MAClB,KAAA;AAAA,MACA,GAAA;AAAA,MACA,mBAAA;AAAA,MACA;AAAA,KACF;AAEA,IAAA,uBAAO,GAAA,CAACC,cAAA,EAAA,EAAiB,GAAG,WAAA,EAAa,CAAA;AAAA,EAC3C;AACF","file":"index.js","sourcesContent":["/*\n * Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { noop } from '@accelint/core';\nimport { clsx } from 'clsx';\nimport {\n type Context,\n createContext,\n type ForwardedRef,\n forwardRef,\n useCallback,\n useMemo,\n} from 'react';\nimport {\n type ButtonRenderProps,\n type ContextValue,\n Link,\n type LinkRenderProps,\n Provider,\n Button as RACButton,\n ToggleButton as RACToggleButton,\n type ToggleButtonRenderProps,\n} from 'react-aria-components';\nimport { useContextProps } from '../../hooks/use-context-props';\nimport { useDefaultProps } from '../../hooks/use-defaults';\nimport { useTheme } from '../../hooks/use-theme';\nimport { surfaces } from '../../styles/surfaces.css';\nimport { bodies } from '../../styles/typography.css';\nimport { inlineVars } from '../../utils/css';\nimport { callRenderProps, mergeClassNames } from '../../utils/props';\nimport { IconContext } from '../icon';\nimport { buttonClassNames, buttonStateVars } from './button.css';\nimport type { AsType } from '../../types/generic';\nimport type { OmitProtectedProps } from '../../types/props';\nimport type { IconProps } from '../icon/types';\nimport type {\n ButtonMapping,\n ButtonProps,\n ButtonSizes,\n LinkButtonProps,\n ToggleButtonProps,\n} from './types';\n\nconst noopToggleState = {\n defaultSelected: false,\n isSelected: false,\n setSelected: noop,\n toggle: noop,\n};\nconst buttonSizes: ButtonSizes[] = ['xs', 'sm', 'md', 'lg', 'xl'];\n\nconst defaultMapping: ButtonMapping = {\n font: bodies,\n icon: buttonSizes.reduce(\n (acc, size) => {\n acc[size] = { size };\n\n return acc;\n },\n {} as Record<ButtonSizes, OmitProtectedProps<IconProps>>,\n ),\n};\n\nfunction useButton<\n P extends ButtonProps | LinkButtonProps | ToggleButtonProps,\n E extends HTMLElement,\n>(\n props: AsType<P>,\n ref: ForwardedRef<E>,\n context: Context<ContextValue<P, E>>,\n key: 'Button' | 'LinkButton' | 'ToggleButton',\n) {\n const [contextProps, contextRef] = useContextProps(props, ref, context);\n\n const defaultedProps = useDefaultProps(contextProps, key);\n\n const {\n children: childrenProp,\n classNames: classNamesProp,\n color = 'primary',\n mapping: mappingProp,\n size = 'md',\n variant = 'solid',\n ...rest\n } = defaultedProps;\n\n const theme = useTheme();\n\n const mapping = useMemo(\n () => ({\n ...defaultMapping,\n ...mappingProp,\n }),\n [mappingProp],\n );\n\n const classNames = useMemo(\n () =>\n mergeClassNames(buttonClassNames, theme.Button, classNamesProp, {\n button: clsx(\n mapping.font[size],\n variant === 'floating' && surfaces.default.proud,\n ),\n }),\n [theme.Button, classNamesProp, mapping.font, size, variant],\n );\n\n const style = useCallback(\n (\n renderProps:\n | ButtonRenderProps\n | LinkRenderProps\n | ToggleButtonRenderProps,\n ) =>\n inlineVars(buttonStateVars, {\n isCurrent: false,\n isSelected: false,\n ...renderProps,\n color,\n size,\n variant,\n }),\n [color, size, variant],\n );\n\n const values = useMemo<\n [[typeof IconContext, ContextValue<IconProps, HTMLDivElement>]]\n >(() => [[IconContext, mapping.icon[size]]], [mapping.icon, size]);\n\n const children = useCallback(\n (\n renderProps:\n | ButtonRenderProps\n | LinkRenderProps\n | ToggleButtonRenderProps,\n ) => (\n <Provider values={values}>\n <span className={classNames?.button}>\n {callRenderProps(childrenProp, {\n state: noopToggleState,\n isCurrent: false,\n isPending: false,\n isSelected: false,\n ...renderProps,\n })}\n </span>\n </Provider>\n ),\n [values, classNames?.button, childrenProp],\n );\n\n return useMemo(\n () => ({\n ...rest,\n ref: contextRef,\n children,\n className: classNames?.container,\n style,\n }),\n // TODO(ilk): This should be checked. \"rest changes on every re-render and should not be used as a hook dependency.\"\n // biome-ignore lint/correctness/useExhaustiveDependencies: This should be checked and verified.\n [rest, contextRef, children, classNames?.container, style],\n );\n}\n\nexport const ButtonContext: Context<ContextValue<\n ButtonProps,\n HTMLButtonElement\n> | null> = createContext<ContextValue<ButtonProps, HTMLButtonElement>>(null);\n\nexport const Button = forwardRef<HTMLButtonElement, ButtonProps>(\n function Button(props: ButtonProps, ref: ForwardedRef<HTMLButtonElement>) {\n const buttonProps = useButton(props, ref, ButtonContext, 'Button');\n\n return <RACButton {...buttonProps} />;\n },\n) as React.ForwardRefExoticComponent<\n ButtonProps & React.RefAttributes<HTMLButtonElement>\n>;\n\nexport const LinkButtonContext: Context<ContextValue<\n LinkButtonProps,\n HTMLAnchorElement\n> | null> =\n createContext<ContextValue<LinkButtonProps, HTMLAnchorElement>>(null);\n\nexport const LinkButton = forwardRef<HTMLAnchorElement, LinkButtonProps>(\n function LinkButton(\n props: LinkButtonProps,\n ref: ForwardedRef<HTMLAnchorElement>,\n ) {\n const buttonProps = useButton(props, ref, LinkButtonContext, 'LinkButton');\n\n return <Link {...buttonProps} />;\n },\n) as React.ForwardRefExoticComponent<\n LinkButtonProps & React.RefAttributes<HTMLAnchorElement>\n>;\n\nexport const ToggleButtonContext: Context<ContextValue<\n ToggleButtonProps,\n HTMLButtonElement\n> | null> =\n createContext<ContextValue<ToggleButtonProps, HTMLButtonElement>>(null);\n\nexport const ToggleButton = forwardRef<HTMLButtonElement, ToggleButtonProps>(\n function ToggleButton(\n props: ToggleButtonProps,\n ref: ForwardedRef<HTMLButtonElement>,\n ) {\n const buttonProps = useButton(\n props,\n ref,\n ToggleButtonContext,\n 'ToggleButton',\n );\n\n return <RACToggleButton {...buttonProps} />;\n },\n) as React.ForwardRefExoticComponent<\n ToggleButtonProps & React.RefAttributes<HTMLButtonElement>\n>;\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ButtonRenderProps as ButtonRenderProps$1, LinkRenderProps, ToggleButtonRenderProps,
|
|
1
|
+
import { ButtonProps as ButtonProps$1, ButtonRenderProps as ButtonRenderProps$1, LinkRenderProps, ToggleButtonRenderProps, LinkProps, ToggleButtonProps as ToggleButtonProps$1 } from 'react-aria-components';
|
|
2
|
+
import { AsType } from '../../types/generic.js';
|
|
2
3
|
import { OmitProtectedProps } from '../../types/props.js';
|
|
3
4
|
import { RenderPropsChildren } from '../../types/react-aria.js';
|
|
4
5
|
import { IconProps } from '../icon/types.js';
|
|
@@ -25,7 +26,7 @@ type BaseButtonProps = {
|
|
|
25
26
|
variant?: ButtonVariants;
|
|
26
27
|
};
|
|
27
28
|
type ButtonState = Omit<ButtonRenderProps, 'state'> & Required<Pick<BaseButtonProps, 'color' | 'size' | 'variant'>>;
|
|
28
|
-
type ButtonProps = Omit<ButtonProps$1, 'children' | 'className' | 'style'> & BaseButtonProps
|
|
29
|
+
type ButtonProps = AsType<Omit<ButtonProps$1, 'children' | 'className' | 'style'> & BaseButtonProps>;
|
|
29
30
|
type ToggleButtonProps = Omit<ToggleButtonProps$1, 'children' | 'className' | 'style'> & BaseButtonProps;
|
|
30
31
|
type LinkButtonProps = Omit<LinkProps, 'children' | 'className' | 'style'> & BaseButtonProps;
|
|
31
32
|
|
|
@@ -10,8 +10,8 @@ import '../../types/react-aria.js';
|
|
|
10
10
|
* Section as wrapper of list items at the top level as a styleable
|
|
11
11
|
* element within the RAC container
|
|
12
12
|
*/
|
|
13
|
-
declare function createCollectionRenderer<C extends {
|
|
14
|
-
readonly collection:
|
|
13
|
+
declare function createCollectionRenderer<T extends Collection<Node<object>>, C extends {
|
|
14
|
+
readonly collection: T;
|
|
15
15
|
}, V extends MergeProviderProps['values']>(context: Context<C>, values: V): CollectionRenderer;
|
|
16
16
|
|
|
17
17
|
export { createCollectionRenderer };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/collection/index.tsx"],"names":[],"mappings":";;;;;;AAyBO,SAAS,wBAAA,
|
|
1
|
+
{"version":3,"sources":["../../../src/components/collection/index.tsx"],"names":[],"mappings":";;;;;;AAyBO,SAAS,wBAAA,CAId,SAAqB,MAAA,EAA+B;AACpD,EAAA,OAAO;AAAA,IACL,gBAAgB,CAAC,EAAE,qBAAoB,qBACrC,GAAA,CAAC,iBAAc,MAAA,EACZ,QAAA,EAAA,mBAAA;AAAA,MACC,UAAA,CAAW,OAAO,CAAA,EAAG,UAAA;AAAA,MACrB,IAAA;AAAA,MACA;AAAA,KACF,EACF,CAAA;AAAA,IAEF,gBAAA,EAAkB,CAAC,EAAE,UAAA,EAAY,QAAQ,mBAAA,EAAoB,qBAC3D,GAAA,CAAC,aAAA,EAAA,EAAc,MAAA,EACZ,QAAA,EAAA,mBAAA,CAAoB,UAAA,EAAY,MAAA,EAAQ,mBAAmB,CAAA,EAC9D;AAAA,GAEJ;AACF","file":"index.js","sourcesContent":["/*\n * Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { type Context, useContext } from 'react';\nimport { useCollectionRender } from '../../hooks/use-collection-render';\nimport { MergeProvider } from '../merge-provider';\nimport type { Collection, Node } from '@react-types/shared';\nimport type { CollectionRenderer } from 'react-aria-components';\nimport type { MergeProviderProps } from '../merge-provider/types';\n\n/**\n * Replace the default collection renderer to allow for injection of\n * context props for multiple composed components. Also enables use of\n * Section as wrapper of list items at the top level as a styleable\n * element within the RAC container\n */\nexport function createCollectionRenderer<\n T extends Collection<Node<object>>,\n C extends { readonly collection: T },\n V extends MergeProviderProps['values'],\n>(context: Context<C>, values: V): CollectionRenderer {\n return {\n CollectionRoot: ({ renderDropIndicator }) => (\n <MergeProvider values={values}>\n {useCollectionRender(\n useContext(context)?.collection,\n null,\n renderDropIndicator,\n )}\n </MergeProvider>\n ),\n CollectionBranch: ({ collection, parent, renderDropIndicator }) => (\n <MergeProvider values={values}>\n {useCollectionRender(collection, parent, renderDropIndicator)}\n </MergeProvider>\n ),\n };\n}\n"]}
|
|
@@ -65,7 +65,10 @@ var DateInput = forwardRef(function DateInput2(props, ref) {
|
|
|
65
65
|
[size]
|
|
66
66
|
);
|
|
67
67
|
const children = useCallback(
|
|
68
|
-
(renderProps) => /* @__PURE__ */ jsx("div", { className: classNames?.input?.input, children: childrenProp && (provider ? callRenderProps(childrenProp, { ...renderProps, ...state }) :
|
|
68
|
+
(renderProps) => /* @__PURE__ */ jsx("div", { className: classNames?.input?.input, children: childrenProp && (provider ? callRenderProps(childrenProp, { ...renderProps, ...state }) : (
|
|
69
|
+
// biome-ignore lint/complexity/noUselessFragments: children group needs to be wrapped
|
|
70
|
+
/* @__PURE__ */ jsx(Fragment, { children: state.segments.map((segment, idx) => /* @__PURE__ */ jsx(Fragment$1, { children: childrenProp(segment) }, `${segment.type}_${idx}`)) })
|
|
71
|
+
)) }),
|
|
69
72
|
[childrenProp, state, provider, classNames?.input]
|
|
70
73
|
);
|
|
71
74
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/date-input/index.tsx"],"names":["DateInput","Fragment","DateSegment","RACDateSegment"],"mappings":";;;;;;;;;;;;;AAkDA,IAAM,cAAA,GAAiB;AAAA,EACrB,IAAA,EAAM;AAAA,IACJ,EAAA,EAAI,EAAE,IAAA,EAAM,IAAA,EAAK;AAAA,IACjB,EAAA,EAAI,EAAE,IAAA,EAAM,IAAA;AAAK,GACnB;AAAA,EACA,KAAA,EAAO;AAAA,IACL,IAAI,MAAA,CAAO,EAAA;AAAA,IACX,IAAI,MAAA,CAAO;AAAA;AAEf,CAAA;AAEA,IAAM,WAAA,GAAc,IAAA;AAEb,IAAM,gBAAA,GACX,cAA4D,IAAI;AAE3D,IAAM,SAAA,GAAY,UAAA,CAAW,SAASA,UAAAA,CAC3C,OACA,GAAA,EACA;AACA,EAAA,MAAM,CAAC,YAAA,EAAc,UAAU,CAAA,GAAI,eAAA;AAAA,IACjC,KAAA;AAAA,IACA,GAAA;AAAA,IACA;AAAA,GACF;AACA,EAAA,MAAM,UAAA,GAAa,eAAA,CAAgB,YAAA,EAAc,WAAW,CAAA;AAE5D,EAAA,MAAM;AAAA,IACJ,QAAA,EAAU,YAAA;AAAA,IACV,UAAA,EAAY,cAAA;AAAA,IACZ,OAAA,EAAS,WAAA;AAAA,IACT,IAAA,GAAO,WAAA;AAAA,IACP,QAAA;AAAA,IACA,GAAG;AAAA,GACL,GAAI,UAAA;AAEJ,EAAA,MAAM,cAAA,GAAiB,WAAW,qBAAqB,CAAA;AACvD,EAAA,MAAM,cAAA,GAAiB,WAAW,qBAAqB,CAAA;AACvD,EAAA,MAAM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AAA;AAAA,MAEjE,CAAA;AAAA,MACA,CAAC,cAAc,UAAU;AAAA,KAC3B;AAEA,IAAA,uBACE,GAAA;AAAA,MAACC,aAAA;AAAA,MAAA;AAAA,QACC,GAAA,EAAK,UAAA;AAAA,QACJ,GAAG,IAAA;AAAA,QACJ,KAAA;AAAA,QACA,SAAA,EAAW,YAAY,OAAA,EAAS,SAAA;AAAA,QAE/B;AAAA;AAAA,KACH;AAAA,EAEJ;AACF","file":"index.js","sourcesContent":["/*\n * Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n createContext,\n type FC,\n type ForwardedRef,\n Fragment,\n forwardRef,\n useCallback,\n useContext,\n useMemo,\n} from 'react';\nimport {\n type ContextValue,\n DateFieldStateContext,\n Group,\n DateSegment as RACDateSegment,\n type SlotProps,\n TimeFieldStateContext,\n} from 'react-aria-components';\nimport { useContextProps } from '../../hooks/use-context-props';\nimport { useDefaultProps } from '../../hooks/use-defaults';\nimport { useTheme } from '../../hooks/use-theme';\nimport { inputs } from '../../styles/typography.css';\nimport { inlineVars } from '../../utils/css';\nimport { callRenderProps, mergeClassNames } from '../../utils/props';\nimport { Input } from '../input';\nimport {\n dateInputClassNames,\n dateInputStateVars,\n dateSegmentStateVars,\n} from './date-input.css';\nimport type {\n DateInputProps,\n DateInputRenderProps,\n DateSegmentProps,\n DateSegmentRenderProps,\n DateSegmentsProps,\n} from './types';\n\nconst defaultMapping = {\n icon: {\n sm: { size: 'xs' },\n lg: { size: 'md' },\n },\n input: {\n sm: inputs.sm,\n lg: inputs.lg,\n },\n};\n\nconst defaultSize = 'lg';\n\nexport const DateInputContext =\n createContext<ContextValue<DateInputProps, HTMLDivElement>>(null);\n\nexport const DateInput = forwardRef(function DateInput(\n props: DateInputProps,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const [contextProps, contextRef] = useContextProps(\n props,\n ref,\n DateInputContext,\n );\n const finalProps = useDefaultProps(contextProps, 'DateInput');\n\n const {\n children: childrenProp,\n classNames: classNamesProp,\n mapping: mappingProp,\n size = defaultSize,\n provider,\n ...rest\n } = finalProps;\n\n const dateFieldState = useContext(DateFieldStateContext);\n const timeFieldState = useContext(TimeFieldStateContext);\n const state = dateFieldState ?? timeFieldState ?? null;\n\n if (!state) {\n throw new Error(\n 'Date Input component must be used as a child of either DateField or TimeField.',\n );\n }\n\n const theme = useTheme();\n\n const mapping = useMemo(\n () => ({\n ...defaultMapping,\n ...mappingProp,\n }),\n [mappingProp],\n );\n\n const classNames = useMemo(\n () =>\n mergeClassNames(dateInputClassNames, theme.DateInput, classNamesProp, {\n input: { input: mapping.input[size] },\n }),\n [theme.DateInput, classNamesProp, mapping, size],\n );\n\n const style = useCallback(\n (renderProps: DateInputRenderProps) =>\n inlineVars(dateInputStateVars, { ...renderProps, size }),\n [size],\n );\n\n const children = useCallback(\n (renderProps: DateInputRenderProps) => (\n <div className={classNames?.input?.input}>\n {childrenProp &&\n (provider ? (\n callRenderProps(childrenProp, { ...renderProps, ...state })\n ) : (\n <>\n {state.segments.map((segment, idx) => (\n <Fragment key={`${segment.type}_${idx}`}>\n {childrenProp(segment)}\n </Fragment>\n ))}\n </>\n ))}\n </div>\n ),\n [childrenProp, state, provider, classNames?.input],\n );\n\n return (\n <>\n <Group\n ref={contextRef}\n {...rest}\n className={classNames?.input?.container}\n style={style}\n >\n {children}\n </Group>\n <Input />\n </>\n );\n});\n\nexport const DateSegments = forwardRef(\n (props: DateSegmentsProps, ref: ForwardedRef<HTMLDivElement>) => {\n const { children, classNames: classNamesProp } = props;\n\n const dateFieldState = useContext(DateFieldStateContext);\n const timeFieldState = useContext(TimeFieldStateContext);\n const state = dateFieldState ?? timeFieldState ?? null;\n\n if (!state) {\n throw new Error(\n 'Date Segments component must be used as a child of either DateField or TimeField.',\n );\n }\n\n const theme = useTheme();\n\n const classNames = useMemo(\n () =>\n mergeClassNames(dateInputClassNames, theme.DateInput, classNamesProp),\n [theme.DateInput, classNamesProp],\n );\n\n return (\n <div className={classNames?.input?.segments} ref={ref}>\n {state.segments.map((segment, idx) => (\n <Fragment key={`${segment.type}_${idx}`}>\n {children(segment)}\n </Fragment>\n ))}\n </div>\n );\n },\n);\n\nexport const DateSegmentContext =\n createContext<ContextValue<SlotProps, HTMLDivElement>>(null);\n\nexport const DateSegment: FC<DateSegmentProps> = forwardRef(\n function DateSegment(\n props: DateSegmentProps,\n ref: ForwardedRef<HTMLDivElement>,\n ) {\n const [contextProps, contextRef] = useContextProps(\n props,\n ref,\n DateSegmentContext,\n );\n\n const {\n classNames: classNamesProp,\n children: childrenProp,\n ...rest\n } = contextProps;\n\n const classNames = useMemo(\n () => mergeClassNames(dateInputClassNames, classNamesProp),\n [classNamesProp],\n );\n\n const style = useCallback(\n (renderProps: DateSegmentRenderProps) =>\n inlineVars(dateSegmentStateVars, {\n ...renderProps,\n }),\n [],\n );\n\n const children = useCallback(\n (renderProps: DateSegmentRenderProps) => {\n const { isPlaceholder, placeholder, text, value } = renderProps;\n if (typeof childrenProp === 'function') {\n return childrenProp({ ...renderProps, defaultChildren: null });\n }\n\n if (isPlaceholder) {\n return placeholder;\n }\n\n return (\n <div className={classNames?.segment?.segment}>{value ?? text}</div>\n );\n },\n [childrenProp, classNames],\n );\n\n return (\n <RACDateSegment\n ref={contextRef}\n {...rest}\n style={style}\n className={classNames?.segment?.container}\n >\n {children}\n </RACDateSegment>\n );\n },\n);\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/date-input/index.tsx"],"names":["DateInput","Fragment","DateSegment","RACDateSegment"],"mappings":";;;;;;;;;;;;;AAkDA,IAAM,cA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yright 2025 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n createContext,\n type FC,\n type ForwardedRef,\n Fragment,\n forwardRef,\n useCallback,\n useContext,\n useMemo,\n} from 'react';\nimport {\n type ContextValue,\n DateFieldStateContext,\n Group,\n DateSegment as RACDateSegment,\n type SlotProps,\n TimeFieldStateContext,\n} from 'react-aria-components';\nimport { useContextProps } from '../../hooks/use-context-props';\nimport { useDefaultProps } from '../../hooks/use-defaults';\nimport { useTheme } from '../../hooks/use-theme';\nimport { inputs } from '../../styles/typography.css';\nimport { inlineVars } from '../../utils/css';\nimport { callRenderProps, mergeClassNames } from '../../utils/props';\nimport { Input } from '../input';\nimport {\n dateInputClassNames,\n dateInputStateVars,\n dateSegmentStateVars,\n} from './date-input.css';\nimport type {\n DateInputProps,\n DateInputRenderProps,\n DateSegmentProps,\n DateSegmentRenderProps,\n DateSegmentsProps,\n} from './types';\n\nconst defaultMapping = {\n icon: {\n sm: { size: 'xs' },\n lg: { size: 'md' },\n },\n input: {\n sm: inputs.sm,\n lg: inputs.lg,\n },\n};\n\nconst defaultSize = 'lg';\n\nexport const DateInputContext =\n createContext<ContextValue<DateInputProps, HTMLDivElement>>(null);\n\nexport const DateInput = forwardRef(function DateInput(\n props: DateInputProps,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const [contextProps, contextRef] = useContextProps(\n props,\n ref,\n DateInputContext,\n );\n const finalProps = useDefaultProps(contextProps, 'DateInput');\n\n const {\n children: childrenProp,\n classNames: classNamesProp,\n mapping: mappingProp,\n size = defaultSize,\n provider,\n ...rest\n } = finalProps;\n\n const dateFieldState = useContext(DateFieldStateContext);\n const timeFieldState = useContext(TimeFieldStateContext);\n const state = dateFieldState ?? timeFieldState ?? null;\n\n if (!state) {\n throw new Error(\n 'Date Input component must be used as a child of either DateField or TimeField.',\n );\n }\n\n const theme = useTheme();\n\n const mapping = useMemo(\n () => ({\n ...defaultMapping,\n ...mappingProp,\n }),\n [mappingProp],\n );\n\n const classNames = useMemo(\n () =>\n mergeClassNames(dateInputClassNames, theme.DateInput, classNamesProp, {\n input: { input: mapping.input[size] },\n }),\n [theme.DateInput, classNamesProp, mapping, size],\n );\n\n const style = useCallback(\n (renderProps: DateInputRenderProps) =>\n inlineVars(dateInputStateVars, { ...renderProps, size }),\n [size],\n );\n\n const children = useCallback(\n (renderProps: DateInputRenderProps) => (\n <div className={classNames?.input?.input}>\n {childrenProp &&\n (provider ? (\n callRenderProps(childrenProp, { ...renderProps, ...state })\n ) : (\n // biome-ignore lint/complexity/noUselessFragments: children group needs to be wrapped\n <>\n {state.segments.map((segment, idx) => (\n <Fragment key={`${segment.type}_${idx}`}>\n {childrenProp(segment)}\n </Fragment>\n ))}\n </>\n ))}\n </div>\n ),\n [childrenProp, state, provider, classNames?.input],\n );\n\n return (\n <>\n <Group\n ref={contextRef}\n {...rest}\n className={classNames?.input?.container}\n style={style}\n >\n {children}\n </Group>\n <Input />\n </>\n );\n});\n\nexport const DateSegments = forwardRef(\n (props: DateSegmentsProps, ref: ForwardedRef<HTMLDivElement>) => {\n const { children, classNames: classNamesProp } = props;\n\n const dateFieldState = useContext(DateFieldStateContext);\n const timeFieldState = useContext(TimeFieldStateContext);\n const state = dateFieldState ?? timeFieldState ?? null;\n\n if (!state) {\n throw new Error(\n 'Date Segments component must be used as a child of either DateField or TimeField.',\n );\n }\n\n const theme = useTheme();\n\n const classNames = useMemo(\n () =>\n mergeClassNames(dateInputClassNames, theme.DateInput, classNamesProp),\n [theme.DateInput, classNamesProp],\n );\n\n return (\n <div className={classNames?.input?.segments} ref={ref}>\n {state.segments.map((segment, idx) => (\n <Fragment key={`${segment.type}_${idx}`}>\n {children(segment)}\n </Fragment>\n ))}\n </div>\n );\n },\n);\n\nexport const DateSegmentContext =\n createContext<ContextValue<SlotProps, HTMLDivElement>>(null);\n\nexport const DateSegment: FC<DateSegmentProps> = forwardRef(\n function DateSegment(\n props: DateSegmentProps,\n ref: ForwardedRef<HTMLDivElement>,\n ) {\n const [contextProps, contextRef] = useContextProps(\n props,\n ref,\n DateSegmentContext,\n );\n\n const {\n classNames: classNamesProp,\n children: childrenProp,\n ...rest\n } = contextProps;\n\n const classNames = useMemo(\n () => mergeClassNames(dateInputClassNames, classNamesProp),\n [classNamesProp],\n );\n\n const style = useCallback(\n (renderProps: DateSegmentRenderProps) =>\n inlineVars(dateSegmentStateVars, {\n ...renderProps,\n }),\n [],\n );\n\n const children = useCallback(\n (renderProps: DateSegmentRenderProps) => {\n const { isPlaceholder, placeholder, text, value } = renderProps;\n if (typeof childrenProp === 'function') {\n return childrenProp({ ...renderProps, defaultChildren: null });\n }\n\n if (isPlaceholder) {\n return placeholder;\n }\n\n return (\n <div className={classNames?.segment?.segment}>{value ?? text}</div>\n );\n },\n [childrenProp, classNames],\n );\n\n return (\n <RACDateSegment\n ref={contextRef}\n {...rest}\n style={style}\n className={classNames?.segment?.container}\n >\n {children}\n </RACDateSegment>\n );\n },\n);\n"]}
|
|
@@ -5,6 +5,7 @@ import { RenderPropsChildren } from '../../types/react-aria.js';
|
|
|
5
5
|
import { DialogRenderProps, DialogMapping, DialogSizes, DialogProps } from './types.js';
|
|
6
6
|
import '../../types/props.js';
|
|
7
7
|
import '../button/types.js';
|
|
8
|
+
import '../../types/generic.js';
|
|
8
9
|
import '../icon/types.js';
|
|
9
10
|
import '../group/types.js';
|
|
10
11
|
import '@react-types/shared';
|
|
@@ -4,6 +4,7 @@ import { OmitProtectedProps } from '../../types/props.js';
|
|
|
4
4
|
import { RenderPropsChildren } from '../../types/react-aria.js';
|
|
5
5
|
import { ButtonProps } from '../button/types.js';
|
|
6
6
|
import { GroupProps } from '../group/types.js';
|
|
7
|
+
import '../../types/generic.js';
|
|
7
8
|
import '../icon/types.js';
|
|
8
9
|
import '@react-types/shared';
|
|
9
10
|
|
|
@@ -8,9 +8,9 @@ import '../../types/props.js';
|
|
|
8
8
|
import '../../types/react-aria.js';
|
|
9
9
|
import '../button/types.js';
|
|
10
10
|
import 'react-aria-components';
|
|
11
|
+
import '../../types/generic.js';
|
|
11
12
|
import '../icon/types.js';
|
|
12
13
|
import '../tabs/types.js';
|
|
13
|
-
import '../../types/generic.js';
|
|
14
14
|
|
|
15
15
|
declare const drawerContainer: string;
|
|
16
16
|
declare const drawerAnimationVars: {
|
|
@@ -9,9 +9,9 @@ import 'type-fest';
|
|
|
9
9
|
import '../../types/props.js';
|
|
10
10
|
import '../../types/react-aria.js';
|
|
11
11
|
import '../button/types.js';
|
|
12
|
+
import '../../types/generic.js';
|
|
12
13
|
import '../icon/types.js';
|
|
13
14
|
import '../tabs/types.js';
|
|
14
|
-
import '../../types/generic.js';
|
|
15
15
|
|
|
16
16
|
declare function Drawer(props: DrawerProps): react_jsx_runtime.JSX.Element;
|
|
17
17
|
declare function DrawerTabList<T extends object>(props: DrawerTabListProps<T>): react_jsx_runtime.JSX.Element;
|
|
@@ -8,8 +8,8 @@ import { RenderPropsChildren } from '../../types/react-aria.js';
|
|
|
8
8
|
import { ButtonClassNames, ButtonProps } from '../button/types.js';
|
|
9
9
|
import { TabsProps, TabsClassNames, TabProps, TabRenderProps, TabListProps } from '../tabs/types.js';
|
|
10
10
|
import 'react-aria-components';
|
|
11
|
-
import '../icon/types.js';
|
|
12
11
|
import '../../types/generic.js';
|
|
12
|
+
import '../icon/types.js';
|
|
13
13
|
|
|
14
14
|
type DrawerClassNames = PartialDeep<{
|
|
15
15
|
container: string;
|
|
@@ -92,15 +92,15 @@ export { TooltipClassNames, TooltipMapping, TooltipProps, TooltipRenderProps, To
|
|
|
92
92
|
export { TreeClassNames, TreeGroupProps, TreeGroupRenderProps, TreeGroupState, TreeIndicatorRenderProps, TreeIndicatorState, TreeItemProps, TreeItemRenderProps, TreeItemState, TreeMapping, TreeProps, TreeRenderProps, TreeSizes, TreeState, TreeStateContextValue } from './tree/types.js';
|
|
93
93
|
import 'react';
|
|
94
94
|
import 'react-aria-components';
|
|
95
|
-
import '../types/react-aria.js';
|
|
96
95
|
import '@react-types/shared';
|
|
96
|
+
import '../types/react-aria.js';
|
|
97
97
|
import 'react/jsx-runtime';
|
|
98
98
|
import '@react-stately/datepicker';
|
|
99
99
|
import 'react-querybuilder';
|
|
100
100
|
import 'type-fest';
|
|
101
101
|
import '@react-aria/datepicker';
|
|
102
|
-
import '../types/props.js';
|
|
103
102
|
import '../types/generic.js';
|
|
103
|
+
import '../types/props.js';
|
|
104
104
|
import '@react-aria/overlays';
|
|
105
105
|
import '@react-stately/overlays';
|
|
106
106
|
import '../types/use-tree.js';
|
|
@@ -16,13 +16,13 @@ declare const Menu: (props: Omit<react_aria_components.PopoverProps, "className"
|
|
|
16
16
|
mapping?: Partial<MenuMapping>;
|
|
17
17
|
size?: MenuSizes;
|
|
18
18
|
} & react.RefAttributes<HTMLElement>) => react.ReactElement | null;
|
|
19
|
-
declare const MenuListContext: react.Context<ContextValue<MenuListProps<
|
|
19
|
+
declare const MenuListContext: react.Context<ContextValue<MenuListProps<object>, HTMLDivElement>>;
|
|
20
20
|
declare const MenuList: <T extends object>(props: Omit<react_aria_components.MenuProps<T>, "className" | "style"> & {
|
|
21
21
|
classNames?: MenuClassNames;
|
|
22
22
|
mapping?: Partial<MenuMapping>;
|
|
23
23
|
size?: MenuSizes;
|
|
24
24
|
} & react.RefAttributes<HTMLDivElement>) => react.ReactElement | null;
|
|
25
|
-
declare const MenuItemContext: react.Context<ContextValue<MenuItemProps<
|
|
25
|
+
declare const MenuItemContext: react.Context<ContextValue<MenuItemProps<object>, HTMLDivElement>>;
|
|
26
26
|
declare const MenuItem: <T extends object>(props: Omit<react_aria_components.MenuItemProps<T>, "className" | "style"> & {
|
|
27
27
|
classNames?: MenuClassNames;
|
|
28
28
|
mapping?: Partial<MenuMapping>;
|
|
@@ -138,7 +138,7 @@ var MenuList = forwardRef(function MenuList2(props, ref) {
|
|
|
138
138
|
return /* @__PURE__ */ jsx(AriaMenuSection, { className: classNames?.list?.list, children: typeof childrenProp === "function" ? /* @__PURE__ */ jsx(Collection, { items, children: childrenProp }) : childrenProp });
|
|
139
139
|
}, [childrenProp, classNames?.list?.list, items]);
|
|
140
140
|
const renderer = useMemo(
|
|
141
|
-
// @ts-expect-error
|
|
141
|
+
// @ts-expect-error Type '{ readonly collection: Collection<Node<object>>; }' is missing the following properties from type 'TreeState<any>': disabledKeys, expandedKeys, toggleKey, setExpandedKeys, selectionManager ts
|
|
142
142
|
() => createCollectionRenderer(MenuStateContext, values),
|
|
143
143
|
[values]
|
|
144
144
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/menu/index.tsx"],"names":["Menu","MenuList","RACMenu","MenuItem","RACMenuItem"],"mappings":";;;;;;;;;;;;;;;;AAiEA,IAAM,cAAA,GAA8B;AAAA,EAClC,WAAA,EAAa;AAAA,IACX,IAAI,MAAA,CAAO,EAAA;AAAA,IACX,IAAI,MAAA,CAAO;AAAA,GACb;AAAA,EACA,MAAA,EAAQ;AAAA,IACN,IAAI,QAAA,CAAS,EAAA;AAAA,IACb,IAAI,QAAA,CAAS;AAAA,GACf;AAAA,EACA,KAAA,EAAO;AAAA,IACL,IAAI,MAAA,CAAO,EAAA;AAAA,IACX,IAAI,MAAA,CAAO;AAAA,GACb;AAAA,EACA,QAAA,EAAU;AAAA,IACR,IAAI,MAAA,CAAO,EAAA;AAAA,IACX,IAAI,MAAA,CAAO;AAAA;AAEf,CAAA;AAEA,IAAM,WAAA,GAAc,IAAA;AAEb,IAAM,WAAA,GACX,cAAoD,IAAI;AAMnD,IAAM,IAAA,GAAO,UAAA,CAAW,SAASA,KAAAA,CACtC,OACA,GAAA,EACA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AAA;AAAA,MAC7B,KAAA;AAAA,MACA,SAAA;AAAA,MAEC;AAAA;AAAA,GACH;AAEJ,CAAC","file":"index.js","sourcesContent":["/*\n * Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n createContext,\n type ForwardedRef,\n forwardRef,\n type HTMLAttributes,\n type Ref,\n useCallback,\n useMemo,\n} from 'react';\nimport {\n Collection,\n type CollectionRenderer,\n CollectionRendererContext,\n type ContextValue,\n DEFAULT_SLOT,\n type MenuSectionProps,\n MenuStateContext,\n Popover,\n type PopoverRenderProps,\n Provider,\n Menu as RACMenu,\n MenuItem as RACMenuItem,\n type MenuItemRenderProps as RACMenuItemRenderProps,\n type SeparatorProps,\n type TextProps,\n} from 'react-aria-components';\nimport { useContextProps } from '../../hooks/use-context-props';\nimport { useDefaultProps } from '../../hooks/use-defaults';\nimport { useSlot } from '../../hooks/use-slot';\nimport { useTheme } from '../../hooks/use-theme';\nimport { bodies, headings } from '../../styles/typography.css';\nimport { inlineVars } from '../../utils/css';\nimport { callRenderProps, mergeClassNames } from '../../utils/props';\nimport {\n AriaHeaderContext,\n AriaKeyboardContext,\n AriaMenuSection,\n AriaMenuSectionContext,\n AriaSeparatorContext,\n AriaText,\n AriaTextContext,\n} from '../aria';\nimport { createCollectionRenderer } from '../collection';\nimport { IconContext } from '../icon';\nimport { menuClassNames, menuItemStateVars, menuStateVars } from './menu.css';\nimport type { IconProps } from '../icon/types';\nimport type {\n MenuItemProps,\n MenuListProps,\n MenuMapping,\n MenuProps,\n} from './types';\n\nconst defaultMapping: MenuMapping = {\n description: {\n sm: bodies.xs,\n lg: bodies.xs,\n },\n header: {\n sm: headings.v4,\n lg: headings.v5,\n },\n label: {\n sm: bodies.sm,\n lg: bodies.sm,\n },\n shortcut: {\n sm: bodies.xs,\n lg: bodies.xs,\n },\n};\n\nconst defaultSize = 'lg';\n\nexport const MenuContext =\n createContext<ContextValue<MenuProps, HTMLElement>>(null);\n\n/**\n * Menu component that supports display and selection of menu items via a trigger (right-click or click)\n * Customization of React Aria's Menu and Menu Item components https://react-spectrum.adobe.com/react-aria/Menu.html\n */\nexport const Menu = forwardRef(function Menu(\n props: MenuProps,\n ref: ForwardedRef<HTMLElement>,\n) {\n const [mergedProps, mergedRef] = useContextProps(props, ref, MenuContext);\n const finalProps = useDefaultProps(mergedProps, 'Menu');\n\n const {\n children: childrenProp,\n classNames: classNamesProp,\n mapping: mappingProp,\n size = defaultSize,\n ...rest\n } = finalProps;\n\n const theme = useTheme();\n\n const classNames = useMemo(\n () =>\n mergeClassNames(menuClassNames, classNamesProp, theme.Menu, {\n menu: { container: theme.className }, // required to consume global theme within Popover\n }),\n [classNamesProp, theme.Menu, theme.className],\n );\n\n const mapping = useMemo(\n () => ({\n ...defaultMapping,\n ...mappingProp,\n }),\n [mappingProp],\n );\n\n const style = useCallback(\n (renderProps: PopoverRenderProps) => ({\n ...theme.style, // required to consume global styles within Popover\n ...inlineVars(menuStateVars, {\n ...renderProps,\n size,\n }),\n }),\n [theme.style, size],\n );\n\n const values = useMemo<\n [\n [\n typeof MenuListContext,\n ContextValue<MenuListProps<unknown>, HTMLDivElement>,\n ],\n ]\n >(\n () => [[MenuListContext, { classNames, mapping, size }]],\n [classNames, mapping, size],\n );\n\n const children = useCallback(\n (renderProps: PopoverRenderProps) => (\n <Provider values={values}>\n <div className={classNames?.menu?.menu}>\n {callRenderProps(childrenProp, {\n ...renderProps,\n size,\n defaultChildren: null,\n })}\n </div>\n </Provider>\n ),\n [childrenProp, classNames?.menu?.menu, size, values],\n );\n\n return (\n <Popover\n {...rest}\n ref={mergedRef}\n className={classNames?.menu?.container}\n style={style}\n >\n {children}\n </Popover>\n );\n});\n\nexport const MenuListContext =\n createContext<ContextValue<MenuListProps<unknown>, HTMLDivElement>>(null);\n\ntype MenuListContexts = [\n [\n typeof MenuItemContext,\n ContextValue<MenuItemProps<unknown>, HTMLDivElement>,\n ],\n [\n typeof AriaMenuSectionContext,\n ContextValue<MenuSectionProps<object>, HTMLElement>,\n ],\n [\n typeof AriaHeaderContext,\n ContextValue<HTMLAttributes<HTMLElement>, HTMLElement>,\n ],\n [typeof AriaSeparatorContext, ContextValue<SeparatorProps, HTMLElement>],\n];\n\nexport const MenuList = forwardRef(function MenuList<T extends object>(\n props: MenuListProps<T>,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const [mergedProps, mergedRef] = useContextProps(props, ref, MenuListContext);\n const finalProps = useDefaultProps(mergedProps, 'Menu');\n\n const {\n children: childrenProp,\n classNames: classNamesProp,\n items,\n mapping: mappingProp,\n selectionMode = 'single',\n size = defaultSize,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n ...rest\n } = finalProps;\n\n const theme = useTheme();\n\n const mapping = useMemo(\n () => ({\n ...defaultMapping,\n ...mappingProp,\n }),\n [mappingProp],\n );\n\n const classNames = useMemo(\n () =>\n mergeClassNames(menuClassNames, theme.Menu, classNamesProp, {\n list: { header: mapping.header[size] },\n }),\n [theme.Menu, classNamesProp, mapping.header, size],\n );\n\n const values = useMemo<MenuListContexts>(\n () => [\n [MenuItemContext, { classNames, mapping, size }],\n [AriaMenuSectionContext, { className: classNames?.list?.section }],\n [AriaHeaderContext, { className: classNames?.list?.header }],\n [AriaSeparatorContext, { className: classNames?.list?.separator }],\n ],\n [classNames, mapping, size],\n );\n\n const children = useMemo(() => {\n if (!(childrenProp || items)) {\n return null;\n }\n\n return (\n <AriaMenuSection className={classNames?.list?.list}>\n {typeof childrenProp === 'function' ? (\n <Collection items={items}>{childrenProp}</Collection>\n ) : (\n childrenProp\n )}\n </AriaMenuSection>\n );\n }, [childrenProp, classNames?.list?.list, items]);\n\n const renderer = useMemo<CollectionRenderer>(\n // @ts-expect-error ts unnecessarily guarding against null state\n () => createCollectionRenderer(MenuStateContext, values),\n [values],\n );\n\n return (\n <CollectionRendererContext.Provider value={renderer}>\n <Provider values={values}>\n <RACMenu<T>\n {...rest}\n ref={mergedRef}\n className={classNames?.list?.container}\n items={items}\n selectionMode={selectionMode}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n >\n {children}\n </RACMenu>\n </Provider>\n </CollectionRendererContext.Provider>\n );\n});\n\nexport const MenuItemContext =\n createContext<ContextValue<MenuItemProps<unknown>, HTMLDivElement>>(null);\n\nexport const MenuItem = forwardRef(function MenuItem<T extends object>(\n props: MenuItemProps<T>,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const [mergedProps, mergedRef] = useContextProps(props, ref, MenuItemContext);\n const finalProps = useDefaultProps(mergedProps, 'MenuItem');\n\n const {\n id,\n children: childrenProp,\n classNames: classNamesProp,\n mapping: mappingProp,\n size = defaultSize,\n textValue = typeof childrenProp === 'string' ? childrenProp : undefined,\n ...rest\n } = finalProps;\n\n const theme = useTheme();\n\n const mapping = useMemo(\n () => ({\n ...defaultMapping,\n ...mappingProp,\n }),\n [mappingProp],\n );\n\n const classNames = useMemo(\n () =>\n mergeClassNames(menuClassNames, classNamesProp, theme.Menu, {\n item: {\n description: mapping.description[size],\n label: mapping.label[size],\n shortcut: mapping.shortcut[size],\n },\n }),\n [theme.Menu, classNamesProp, mapping, size],\n );\n\n const [descriptionRef, hasDescription] = useSlot();\n\n const style = useCallback(\n (renderProps: RACMenuItemRenderProps) =>\n inlineVars(menuItemStateVars, { ...renderProps, size, hasDescription }),\n [hasDescription, size],\n );\n\n const values = useMemo<\n [\n [typeof AriaTextContext, ContextValue<TextProps, HTMLElement>],\n [typeof IconContext, ContextValue<IconProps, HTMLDivElement>],\n [\n typeof AriaKeyboardContext,\n ContextValue<HTMLAttributes<HTMLElement>, HTMLElement>,\n ],\n ]\n >(\n () => [\n [\n AriaTextContext,\n {\n slots: {\n [DEFAULT_SLOT]: {},\n label: { className: classNames?.item?.label },\n description: {\n ref: descriptionRef,\n className: classNames?.item?.description,\n },\n },\n },\n ],\n [\n IconContext,\n {\n slots: {\n [DEFAULT_SLOT]: { classNames: classNames?.item?.icon },\n more: { classNames: classNames?.item?.more },\n },\n },\n ],\n [AriaKeyboardContext, { className: classNames?.item?.shortcut }],\n ],\n [\n classNames?.item?.label,\n descriptionRef,\n classNames?.item?.description,\n classNames?.item?.icon,\n classNames?.item?.more,\n classNames?.item?.shortcut,\n ],\n );\n\n const children = useCallback(\n (renderProps: RACMenuItemRenderProps) => {\n const content = callRenderProps(childrenProp, {\n ...renderProps,\n size,\n defaultChildren: null,\n });\n\n return (\n <Provider values={values}>\n <div className={classNames?.item?.item}>\n {typeof content === 'string' ? (\n <AriaText slot='label'>{content}</AriaText>\n ) : (\n content\n )}\n </div>\n </Provider>\n );\n },\n [childrenProp, classNames?.item?.item, size, values],\n );\n\n return (\n <RACMenuItem<T>\n {...rest}\n id={id ?? textValue}\n ref={mergedRef as unknown as Ref<T>}\n className={classNames?.item?.container}\n style={style}\n textValue={textValue}\n >\n {children}\n </RACMenuItem>\n );\n});\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/menu/index.tsx"],"names":["Menu","MenuList","RACMenu","MenuItem","RACMenuItem"],"mappings":";;;;;;;;;;;;;;;;AAgEA,IAAM,cAAA,GAA8B;AAAA,EAClC,WAAA,EAAa;AAAA,IACX,IAAI,MAAA,CAAO,EAAA;AAAA,IACX,IAAI,MAAA,CAAO;AAAA,GACb;AAAA,EACA,MAAA,EAAQ;AAAA,IACN,IAAI,QAAA,CAAS,EAAA;AAAA,IACb,IAAI,QAAA,CAAS;AAAA,GACf;AAAA,EACA,KAAA,EAAO;AAAA,IACL,IAAI,MAAA,CAAO,EAAA;AAAA,IACX,IAAI,MAAA,CAAO;AAAA,GACb;AAA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Y,IAAA,EAAM,IAAA,EAAM,MAAM,MAAM;AAAA,GACrD;AAEA,EAAA,uBACE,GAAA;AAAA,IAACC,UAAA;AAAA,IAAA;AAAA,MACE,GAAG,IAAA;AAAA,MACJ,IAAI,EAAA,IAAM,SAAA;AAAA,MACV,GAAA,EAAK,SAAA;AAAA,MACL,SAAA,EAAW,YAAY,IAAA,EAAM,SAAA;AAAA,MAC7B,KAAA;AAAA,MACA,SAAA;AAAA,MAEC;AAAA;AAAA,GACH;AAEJ,CAAC","file":"index.js","sourcesContent":["/*\n * Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n createContext,\n type ForwardedRef,\n forwardRef,\n type HTMLAttributes,\n useCallback,\n useMemo,\n} from 'react';\nimport {\n Collection,\n type CollectionRenderer,\n CollectionRendererContext,\n type ContextValue,\n DEFAULT_SLOT,\n type MenuSectionProps,\n MenuStateContext,\n Popover,\n type PopoverRenderProps,\n Provider,\n Menu as RACMenu,\n MenuItem as RACMenuItem,\n type MenuItemRenderProps as RACMenuItemRenderProps,\n type SeparatorProps,\n type TextProps,\n} from 'react-aria-components';\nimport { useContextProps } from '../../hooks/use-context-props';\nimport { useDefaultProps } from '../../hooks/use-defaults';\nimport { useSlot } from '../../hooks/use-slot';\nimport { useTheme } from '../../hooks/use-theme';\nimport { bodies, headings } from '../../styles/typography.css';\nimport { inlineVars } from '../../utils/css';\nimport { callRenderProps, mergeClassNames } from '../../utils/props';\nimport {\n AriaHeaderContext,\n AriaKeyboardContext,\n AriaMenuSection,\n AriaMenuSectionContext,\n AriaSeparatorContext,\n AriaText,\n AriaTextContext,\n} from '../aria';\nimport { createCollectionRenderer } from '../collection';\nimport { IconContext } from '../icon';\nimport { menuClassNames, menuItemStateVars, menuStateVars } from './menu.css';\nimport type { IconProps } from '../icon/types';\nimport type {\n MenuItemProps,\n MenuListProps,\n MenuMapping,\n MenuProps,\n} from './types';\n\nconst defaultMapping: MenuMapping = {\n description: {\n sm: bodies.xs,\n lg: bodies.xs,\n },\n header: {\n sm: headings.v4,\n lg: headings.v5,\n },\n label: {\n sm: bodies.sm,\n lg: bodies.sm,\n },\n shortcut: {\n sm: bodies.xs,\n lg: bodies.xs,\n },\n};\n\nconst defaultSize = 'lg';\n\nexport const MenuContext =\n createContext<ContextValue<MenuProps, HTMLElement>>(null);\n\n/**\n * Menu component that supports display and selection of menu items via a trigger (right-click or click)\n * Customization of React Aria's Menu and Menu Item components https://react-spectrum.adobe.com/react-aria/Menu.html\n */\nexport const Menu = forwardRef(function Menu(\n props: MenuProps,\n ref: ForwardedRef<HTMLElement>,\n) {\n const [mergedProps, mergedRef] = useContextProps(props, ref, MenuContext);\n const finalProps = useDefaultProps(mergedProps, 'Menu');\n\n const {\n children: childrenProp,\n classNames: classNamesProp,\n mapping: mappingProp,\n size = defaultSize,\n ...rest\n } = finalProps;\n\n const theme = useTheme();\n\n const classNames = useMemo(\n () =>\n mergeClassNames(menuClassNames, classNamesProp, theme.Menu, {\n menu: { container: theme.className }, // required to consume global theme within Popover\n }),\n [classNamesProp, theme.Menu, theme.className],\n );\n\n const mapping = useMemo(\n () => ({\n ...defaultMapping,\n ...mappingProp,\n }),\n [mappingProp],\n );\n\n const style = useCallback(\n (renderProps: PopoverRenderProps) => ({\n ...theme.style, // required to consume global styles within Popover\n ...inlineVars(menuStateVars, {\n ...renderProps,\n size,\n }),\n }),\n [theme.style, size],\n );\n\n const values = useMemo<\n [\n [\n typeof MenuListContext,\n ContextValue<MenuListProps<object>, HTMLDivElement>,\n ],\n ]\n >(\n () => [[MenuListContext, { classNames, mapping, size }]],\n [classNames, mapping, size],\n );\n\n const children = useCallback(\n (renderProps: PopoverRenderProps) => (\n <Provider values={values}>\n <div className={classNames?.menu?.menu}>\n {callRenderProps(childrenProp, {\n ...renderProps,\n size,\n defaultChildren: null,\n })}\n </div>\n </Provider>\n ),\n [childrenProp, classNames?.menu?.menu, size, values],\n );\n\n return (\n <Popover\n {...rest}\n ref={mergedRef}\n className={classNames?.menu?.container}\n style={style}\n >\n {children}\n </Popover>\n );\n});\n\nexport const MenuListContext =\n createContext<ContextValue<MenuListProps<object>, HTMLDivElement>>(null);\n\ntype MenuListContexts = [\n [typeof MenuItemContext, ContextValue<MenuItemProps<object>, HTMLDivElement>],\n [\n typeof AriaMenuSectionContext,\n ContextValue<MenuSectionProps<object>, HTMLElement>,\n ],\n [\n typeof AriaHeaderContext,\n ContextValue<HTMLAttributes<HTMLElement>, HTMLElement>,\n ],\n [typeof AriaSeparatorContext, ContextValue<SeparatorProps, HTMLElement>],\n];\n\nexport const MenuList = forwardRef(function MenuList<T extends object>(\n props: MenuListProps<T>,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const [mergedProps, mergedRef] = useContextProps(props, ref, MenuListContext);\n const finalProps = useDefaultProps(mergedProps, 'Menu');\n\n const {\n children: childrenProp,\n classNames: classNamesProp,\n items,\n mapping: mappingProp,\n selectionMode = 'single',\n size = defaultSize,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n ...rest\n } = finalProps;\n\n const theme = useTheme();\n\n const mapping = useMemo(\n () => ({\n ...defaultMapping,\n ...mappingProp,\n }),\n [mappingProp],\n );\n\n const classNames = useMemo(\n () =>\n mergeClassNames(menuClassNames, theme.Menu, classNamesProp, {\n list: { header: mapping.header[size] },\n }),\n [theme.Menu, classNamesProp, mapping.header, size],\n );\n\n const values = useMemo<MenuListContexts>(\n () => [\n [MenuItemContext, { classNames, mapping, size }],\n [AriaMenuSectionContext, { className: classNames?.list?.section }],\n [AriaHeaderContext, { className: classNames?.list?.header }],\n [AriaSeparatorContext, { className: classNames?.list?.separator }],\n ],\n [classNames, mapping, size],\n );\n\n const children = useMemo(() => {\n if (!(childrenProp || items)) {\n return null;\n }\n\n return (\n <AriaMenuSection className={classNames?.list?.list}>\n {typeof childrenProp === 'function' ? (\n <Collection items={items}>{childrenProp}</Collection>\n ) : (\n childrenProp\n )}\n </AriaMenuSection>\n );\n }, [childrenProp, classNames?.list?.list, items]);\n\n const renderer = useMemo<CollectionRenderer>(\n // @ts-expect-error Type '{ readonly collection: Collection<Node<object>>; }' is missing the following properties from type 'TreeState<any>': disabledKeys, expandedKeys, toggleKey, setExpandedKeys, selectionManager ts\n () => createCollectionRenderer(MenuStateContext, values),\n [values],\n );\n\n return (\n <CollectionRendererContext.Provider value={renderer}>\n <Provider values={values}>\n <RACMenu<T>\n {...rest}\n ref={mergedRef}\n className={classNames?.list?.container}\n items={items}\n selectionMode={selectionMode}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n >\n {children}\n </RACMenu>\n </Provider>\n </CollectionRendererContext.Provider>\n );\n});\n\nexport const MenuItemContext =\n createContext<ContextValue<MenuItemProps<object>, HTMLDivElement>>(null);\n\nexport const MenuItem = forwardRef(function MenuItem<T extends object>(\n props: MenuItemProps<T>,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n const [mergedProps, mergedRef] = useContextProps(props, ref, MenuItemContext);\n const finalProps = useDefaultProps(mergedProps, 'MenuItem');\n\n const {\n id,\n children: childrenProp,\n classNames: classNamesProp,\n mapping: mappingProp,\n size = defaultSize,\n textValue = typeof childrenProp === 'string' ? childrenProp : undefined,\n ...rest\n } = finalProps;\n\n const theme = useTheme();\n\n const mapping = useMemo(\n () => ({\n ...defaultMapping,\n ...mappingProp,\n }),\n [mappingProp],\n );\n\n const classNames = useMemo(\n () =>\n mergeClassNames(menuClassNames, classNamesProp, theme.Menu, {\n item: {\n description: mapping.description[size],\n label: mapping.label[size],\n shortcut: mapping.shortcut[size],\n },\n }),\n [theme.Menu, classNamesProp, mapping, size],\n );\n\n const [descriptionRef, hasDescription] = useSlot();\n\n const style = useCallback(\n (renderProps: RACMenuItemRenderProps) =>\n inlineVars(menuItemStateVars, { ...renderProps, size, hasDescription }),\n [hasDescription, size],\n );\n\n const values = useMemo<\n [\n [typeof AriaTextContext, ContextValue<TextProps, HTMLElement>],\n [typeof IconContext, ContextValue<IconProps, HTMLDivElement>],\n [\n typeof AriaKeyboardContext,\n ContextValue<HTMLAttributes<HTMLElement>, HTMLElement>,\n ],\n ]\n >(\n () => [\n [\n AriaTextContext,\n {\n slots: {\n [DEFAULT_SLOT]: {},\n label: { className: classNames?.item?.label },\n description: {\n ref: descriptionRef,\n className: classNames?.item?.description,\n },\n },\n },\n ],\n [\n IconContext,\n {\n slots: {\n [DEFAULT_SLOT]: { classNames: classNames?.item?.icon },\n more: { classNames: classNames?.item?.more },\n },\n },\n ],\n [AriaKeyboardContext, { className: classNames?.item?.shortcut }],\n ],\n [\n classNames?.item?.label,\n descriptionRef,\n classNames?.item?.description,\n classNames?.item?.icon,\n classNames?.item?.more,\n classNames?.item?.shortcut,\n ],\n );\n\n const children = useCallback(\n (renderProps: RACMenuItemRenderProps) => {\n const content = callRenderProps(childrenProp, {\n ...renderProps,\n size,\n defaultChildren: null,\n });\n\n return (\n <Provider values={values}>\n <div className={classNames?.item?.item}>\n {typeof content === 'string' ? (\n <AriaText slot='label'>{content}</AriaText>\n ) : (\n content\n )}\n </div>\n </Provider>\n );\n },\n [childrenProp, classNames?.item?.item, size, values],\n );\n\n return (\n <RACMenuItem<T>\n {...rest}\n id={id ?? textValue}\n ref={mergedRef as unknown as React.Ref<T>}\n className={classNames?.item?.container}\n style={style}\n textValue={textValue}\n >\n {children}\n </RACMenuItem>\n );\n});\n"]}
|
|
@@ -2,6 +2,17 @@ import '../../chunk-PZ5AY32C.js';
|
|
|
2
2
|
import { mergeProps } from '../../utils/props/index.js';
|
|
3
3
|
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
4
4
|
|
|
5
|
+
var mergeSlotReducer = (acc, key, prevSlots, nextSlots) => {
|
|
6
|
+
const value = nextSlots[key];
|
|
7
|
+
const hasPrev = Object.hasOwn(prevSlots, key);
|
|
8
|
+
const prevValue = hasPrev ? prevSlots[key] : void 0;
|
|
9
|
+
if (hasPrev) {
|
|
10
|
+
acc[key] = mergeProps(prevValue ?? {}, value ?? {});
|
|
11
|
+
} else if (value != null) {
|
|
12
|
+
acc[key] = value;
|
|
13
|
+
}
|
|
14
|
+
return acc;
|
|
15
|
+
};
|
|
5
16
|
function merge(context, next, children) {
|
|
6
17
|
return function Consumer(prev) {
|
|
7
18
|
let merged = next;
|
|
@@ -15,13 +26,10 @@ function merge(context, next, children) {
|
|
|
15
26
|
slots: {
|
|
16
27
|
...prevSlots,
|
|
17
28
|
...nextSlots,
|
|
18
|
-
...Reflect.ownKeys(nextSlots).reduce(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
return acc;
|
|
24
|
-
}, {})
|
|
29
|
+
...Reflect.ownKeys(nextSlots).reduce(
|
|
30
|
+
(acc, key) => mergeSlotReducer(acc, key, prevSlots, nextSlots),
|
|
31
|
+
{}
|
|
32
|
+
)
|
|
25
33
|
}
|
|
26
34
|
};
|
|
27
35
|
} else if (!(prevSlots || nextSlots)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/merge-provider/index.tsx"],"names":[],"mappings":";;;;AAgBA,SAAS,KAAA,CAAS,OAAA,EAAqB,IAAA,EAAS,QAAA,EAAqB;AACnE,EAAA,OAAO,SAAS,SAAS,IAAA,EAAS;AAChC,IAAA,IAAI,MAAA,GAAS,IAAA;AAEb,IAAA,IACE,IAAA,IAAQ,QACR,IAAA,IAAQ,IAAA,IACR,OAAO,IAAA,KAAS,QAAA,IAChB,OAAO,IAAA,KAAS,QAAA,EAChB;AACA,MAAA,MAAM,SAAA,GACJ,OAAA,IAAW,IAAA,IAAS,IAAA,CAAK,KAA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,SAAA,GACJ,OAAA,IAAW,IAAA,IAAS,IAAA,CAAK,KAAA;AAE3B,MAAA,IAAI,aAAa,SAAA,EAAW;AAC1B,QAAA,MAAA,GAAS;AAAA,UACP,GAAG,IAAA;AAAA,UACH,GAAG,IAAA;AAAA,UACH,KAAA,EAAO;AAAA,YACL,GAAG,SAAA;AAAA,YACH,GAAG,SAAA;AAAA,YACH,GAAG,OAAA,CAAQ,OAAA,CAAQ,SAAS,CAAA,CAAE,MAAA;AAAA,cAG5B,CAAC,GAAA,EAAK,GAAA,KAAQ,iBAAiB,GAAA,EAAK,GAAA,EAAK,WAAW,SAAS,CAAA;AAAA,cAC7D;AAAC;AACH;AACF,SACF;AAAA,MACF,CAAA,MAAA,IAAW,EAAE,SAAA,IAAa,SAAA,CAAA,EAAY;AACpC,QAAA,MAAA,GAAS,UAAA,CAAW,MAAgB,IAAc,CAAA;AAAA,MACpD;AAAA,IACF;AAEA,IAAA,2BAAQ,OAAA,CAAQ,QAAA,EAAR,EAAiB,KAAA,EAAO,QAAS,QAAA,EAAS,CAAA;AAAA,EACpD,CAAA;AACF;AAcO,SAAS,aAAA,CAA+C;AAAA,EAC7D,MAAA;AAAA,EACA;AACF,CAAA,EAAwD;AACtD,EAAA,KAAA,MAAW,CAAC,OAAA,EAAS,IAAI,CAAA,IAAK,MAAA,EAAQ;AACpC,IAAA,QAAA,mBACE,GAAA,CAAC,QAAQ,QAAA,EAAR,EACE,gBAAM,OAAA,EAAiC,IAAA,EAAM,QAAQ,CAAA,EACxD,CAAA;AAAA,EAEJ;AAEA,EAAA,uCAAU,QAAA,EAAS,CAAA;AACrB","file":"index.js","sourcesContent":["/*\n * Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { mergeProps } from '../../utils/props';\nimport type { Context, ReactNode } from 'react';\nimport type { MergeProviderProps } from './types';\n\nconst mergeSlotReducer = (\n acc: Record<string | symbol, object>,\n key: PropertyKey,\n prevSlots: Record<string | symbol, object>,\n nextSlots: Record<string | symbol, object>,\n) => {\n const value = nextSlots[key];\n\n const hasPrev = Object.hasOwn(prevSlots, key);\n const prevValue = hasPrev ? prevSlots[key] : undefined;\n\n if (hasPrev) {\n acc[key] = mergeProps(prevValue ?? {}, value ?? {});\n } else if (value != null) {\n acc[key] = value;\n }\n\n return acc;\n};\n\nfunction merge<T>(context: Context<T>, next: T, children: ReactNode) {\n return function Consumer(prev: T) {\n let merged = next;\n\n if (\n prev != null &&\n next != null &&\n typeof prev === 'object' &&\n typeof next === 'object'\n ) {\n const prevSlots =\n 'slots' in prev && (prev.slots as Record<string | symbol, object>);\n\n const nextSlots =\n 'slots' in next && (next.slots as Record<string | symbol, object>);\n\n if (prevSlots && nextSlots) {\n merged = {\n ...prev,\n ...next,\n slots: {\n ...prevSlots,\n ...nextSlots,\n ...Reflect.ownKeys(nextSlots).reduce<\n Record<string | symbol, object>\n >(\n (acc, key) => mergeSlotReducer(acc, key, prevSlots, nextSlots),\n {},\n ),\n },\n } as T;\n } else if (!(prevSlots || nextSlots)) {\n merged = mergeProps(prev as object, next as object) as T;\n }\n }\n\n return <context.Provider value={merged}>{children}</context.Provider>;\n };\n}\n\n/**\n * Merges provided contexts with parent contexts, if available and of the same structure\n * If parent context doesn't exist or differs in structure (slotted vs non-slotted) from\n * the context being provided, the provided context will override the parent context\n *\n * This is typically used in conjunction with React Aria Component's contexts, where a\n * RAC may provide a slotted context (ex: ButtonContext, with a slot of \"remove\") where\n * that slot has a number of attributes and event listeners, but we want to merge in our\n * own to supplement things for stylistic or additional functionality purposes\n *\n * See tests for examples\n */\nexport function MergeProvider<A, B, C, D, E, F, G, H, I, J, K>({\n values,\n children,\n}: MergeProviderProps<A, B, C, D, E, F, G, H, I, J, K>) {\n for (const [context, next] of values) {\n children = (\n <context.Consumer>\n {merge(context as Context<typeof next>, next, children)}\n </context.Consumer>\n );\n }\n\n return <>{children}</>;\n}\n"]}
|
|
@@ -5,10 +5,10 @@ import * as react from 'react';
|
|
|
5
5
|
import 'type-fest';
|
|
6
6
|
import '../../types/props.js';
|
|
7
7
|
import '../button/types.js';
|
|
8
|
+
import '../../types/generic.js';
|
|
8
9
|
import '../../types/react-aria.js';
|
|
9
10
|
import '../icon/types.js';
|
|
10
11
|
import '../input/types.js';
|
|
11
|
-
import '../../types/generic.js';
|
|
12
12
|
|
|
13
13
|
declare const NumberFieldContext: react.Context<ContextValue<NumberFieldProps, HTMLDivElement>>;
|
|
14
14
|
declare const NumberField: (props: Omit<react_aria_components.NumberFieldProps, "className" | "style"> & {
|
|
@@ -3,11 +3,11 @@ import 'react-aria-components';
|
|
|
3
3
|
import 'type-fest';
|
|
4
4
|
import '../../types/props.js';
|
|
5
5
|
import '../button/types.js';
|
|
6
|
+
import '../../types/generic.js';
|
|
6
7
|
import '../../types/react-aria.js';
|
|
7
8
|
import 'react';
|
|
8
9
|
import '../icon/types.js';
|
|
9
10
|
import '../input/types.js';
|
|
10
|
-
import '../../types/generic.js';
|
|
11
11
|
|
|
12
12
|
declare const numberFieldContainer: string;
|
|
13
13
|
declare const numberFieldColorVars: {
|
|
@@ -3,10 +3,10 @@ import { PartialDeep } from 'type-fest';
|
|
|
3
3
|
import { OmitProtectedProps } from '../../types/props.js';
|
|
4
4
|
import { ButtonClassNames, ButtonProps } from '../button/types.js';
|
|
5
5
|
import { InputClassNames } from '../input/types.js';
|
|
6
|
+
import '../../types/generic.js';
|
|
6
7
|
import '../../types/react-aria.js';
|
|
7
8
|
import 'react';
|
|
8
9
|
import '../icon/types.js';
|
|
9
|
-
import '../../types/generic.js';
|
|
10
10
|
|
|
11
11
|
type NumberFieldClassNames = PartialDeep<{
|
|
12
12
|
container: string;
|
|
@@ -152,7 +152,7 @@ var OptionsList = forwardRef(function OptionList(props, ref) {
|
|
|
152
152
|
return /* @__PURE__ */ jsx(AriaListBoxSection, { className: classNames?.list?.list, children: typeof childrenProp === "function" ? /* @__PURE__ */ jsx(Collection, { items, children: childrenProp }) : childrenProp });
|
|
153
153
|
}, [classNames?.list?.list, childrenProp, items]);
|
|
154
154
|
const renderer = useMemo(
|
|
155
|
-
// @ts-expect-error
|
|
155
|
+
// @ts-expect-error Type '{ readonly collection: Collection<Node<object>>; }' is missing the following properties from type 'ListState<any>': disabledKeys, selectionManager
|
|
156
156
|
() => createCollectionRenderer(ListStateContext, values),
|
|
157
157
|
[values]
|
|
158
158
|
);
|