@accelint/design-system 0.8.1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/aria/index.d.ts +32 -3
- package/dist/components/aria/index.js +36 -1
- package/dist/components/aria/index.js.map +1 -1
- package/dist/components/button/index.d.ts +45 -6
- package/dist/components/button/index.js +105 -3
- package/dist/components/button/index.js.map +1 -1
- package/dist/components/checkbox/index.d.ts +28 -7
- package/dist/components/checkbox/index.js +124 -3
- package/dist/components/checkbox/index.js.map +1 -1
- package/dist/components/chip/index.d.ts +36 -6
- package/dist/components/chip/index.js +171 -3
- package/dist/components/chip/index.js.map +1 -1
- package/dist/components/collection/index.d.ts +16 -5
- package/dist/components/collection/index.js +19 -1
- package/dist/components/collection/index.js.map +1 -1
- package/dist/components/combo-box/index.d.ts +13 -5
- package/dist/components/combo-box/index.js +116 -3
- package/dist/components/combo-box/index.js.map +1 -1
- package/dist/components/date-field/index.d.ts +13 -5
- package/dist/components/date-field/index.js +106 -2
- package/dist/components/date-field/index.js.map +1 -1
- package/dist/components/date-input/index.d.ts +19 -7
- package/dist/components/date-input/index.js +134 -2
- package/dist/components/date-input/index.js.map +1 -1
- package/dist/components/dialog/index.d.ts +24 -6
- package/dist/components/dialog/index.js +187 -3
- package/dist/components/dialog/index.js.map +1 -1
- package/dist/components/drawer/index.d.ts +19 -7
- package/dist/components/drawer/index.js +306 -3
- package/dist/components/drawer/index.js.map +1 -1
- package/dist/components/element/index.d.ts +15 -4
- package/dist/components/element/index.js +21 -2
- package/dist/components/element/index.js.map +1 -1
- package/dist/components/group/index.d.ts +15 -5
- package/dist/components/group/index.js +60 -3
- package/dist/components/group/index.js.map +1 -1
- package/dist/components/icon/index.d.ts +17 -5
- package/dist/components/icon/index.js +39 -3
- package/dist/components/icon/index.js.map +1 -1
- package/dist/components/index.d.ts +35 -35
- package/dist/components/index.js +58 -28
- package/dist/components/input/index.d.ts +12 -5
- package/dist/components/input/index.js +141 -3
- package/dist/components/input/index.js.map +1 -1
- package/dist/components/menu/index.d.ts +29 -5
- package/dist/components/menu/index.js +253 -3
- package/dist/components/menu/index.js.map +1 -1
- package/dist/components/merge-provider/index.d.ts +18 -3
- package/dist/components/merge-provider/index.js +43 -2
- package/dist/components/merge-provider/index.js.map +1 -1
- package/dist/components/number-field/index.d.ts +14 -6
- package/dist/components/number-field/index.js +127 -2
- package/dist/components/number-field/index.js.map +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.d.ts +25 -5
- package/dist/components/options/index.js +254 -3
- package/dist/components/options/index.js.map +1 -1
- package/dist/components/picker/index.d.ts +23 -5
- package/dist/components/picker/index.js +113 -3
- package/dist/components/picker/index.js.map +1 -1
- package/dist/components/popover/index.d.ts +14 -6
- package/dist/components/popover/index.js +140 -3
- package/dist/components/popover/index.js.map +1 -1
- package/dist/components/query-builder/group.js +1 -1
- package/dist/components/query-builder/group.js.map +1 -1
- package/dist/components/query-builder/index.d.ts +7 -7
- package/dist/components/query-builder/index.js +198 -5
- package/dist/components/query-builder/index.js.map +1 -1
- package/dist/components/query-builder/rule.js +1 -1
- package/dist/components/query-builder/rule.js.map +1 -1
- package/dist/components/query-builder/value-editor.js.map +1 -1
- package/dist/components/query-builder/value-selector.js +1 -1
- package/dist/components/query-builder/value-selector.js.map +1 -1
- package/dist/components/radio/index.d.ts +22 -6
- package/dist/components/radio/index.js +114 -3
- package/dist/components/radio/index.js.map +1 -1
- package/dist/components/search-field/index.d.ts +15 -6
- package/dist/components/search-field/index.js +92 -3
- package/dist/components/search-field/index.js.map +1 -1
- package/dist/components/select/index.d.ts +13 -5
- package/dist/components/select/index.js +109 -3
- package/dist/components/select/index.js.map +1 -1
- package/dist/components/slider/index.d.ts +41 -7
- package/dist/components/slider/index.js +232 -3
- package/dist/components/slider/index.js.map +1 -1
- package/dist/components/slider/slider.css.d.ts +1 -1
- package/dist/components/slider/types.d.ts +1 -1
- package/dist/components/switch/index.d.ts +9 -5
- package/dist/components/switch/index.js +60 -3
- package/dist/components/switch/index.js.map +1 -1
- package/dist/components/tabs/index.d.ts +74 -7
- package/dist/components/tabs/index.js +259 -3
- package/dist/components/tabs/index.js.map +1 -1
- package/dist/components/text-field/index.d.ts +61 -6
- package/dist/components/text-field/index.js +93 -2
- package/dist/components/text-field/index.js.map +1 -1
- package/dist/components/textarea/index.d.ts +18 -5
- package/dist/components/textarea/index.js +134 -3
- package/dist/components/textarea/index.js.map +1 -1
- package/dist/components/time-field/index.d.ts +14 -6
- package/dist/components/time-field/index.js +103 -2
- package/dist/components/time-field/index.js.map +1 -1
- package/dist/components/tooltip/index.d.ts +29 -6
- package/dist/components/tooltip/index.js +112 -3
- package/dist/components/tooltip/index.js.map +1 -1
- package/dist/components/tree/index.d.ts +17 -5
- package/dist/components/tree/index.js +491 -3
- package/dist/components/tree/index.js.map +1 -1
- package/dist/components/tree/utils.js.map +1 -1
- package/dist/hooks/index.d.ts +12 -12
- package/dist/hooks/use-collection-render/index.d.ts +11 -3
- package/dist/hooks/use-collection-render/index.js +25 -1
- package/dist/hooks/use-collection-render/index.js.map +1 -1
- package/dist/hooks/use-context-props/index.d.ts +10 -3
- package/dist/hooks/use-context-props/index.js +15 -1
- package/dist/hooks/use-context-props/index.js.map +1 -1
- package/dist/hooks/use-defaults/index.d.ts +99 -31
- package/dist/hooks/use-defaults/index.js +33 -2
- package/dist/hooks/use-defaults/index.js.map +1 -1
- package/dist/hooks/use-defaults/types.d.ts +6 -6
- package/dist/hooks/use-propagating-press/index.d.ts +13 -2
- package/dist/hooks/use-propagating-press/index.js +19 -1
- package/dist/hooks/use-propagating-press/index.js.map +1 -1
- package/dist/hooks/use-slot/index.d.ts +16 -2
- package/dist/hooks/use-slot/index.js +18 -1
- package/dist/hooks/use-slot/index.js.map +1 -1
- package/dist/hooks/use-theme/index.d.ts +37 -8
- package/dist/hooks/use-theme/index.js +105 -2
- package/dist/hooks/use-theme/index.js.map +1 -1
- package/dist/hooks/use-theme/types.d.ts +2 -2
- package/dist/hooks/use-tree/index.d.ts +5 -2
- package/dist/hooks/use-tree/index.js +259 -1
- package/dist/hooks/use-tree/index.js.map +1 -1
- package/dist/hooks/use-tree/utils.js.map +1 -1
- package/dist/hooks/use-update-effect/index.d.ts +3 -1
- package/dist/hooks/use-update-effect/index.js +20 -1
- package/dist/hooks/use-update-effect/index.js.map +1 -1
- package/dist/index.css +119 -119
- package/dist/index.d.ts +47 -47
- package/dist/ladle/actions.js.map +1 -1
- package/dist/styles/layers.css.d.ts +3 -3
- package/dist/styles/surfaces.css.d.ts +1 -1
- package/dist/test/setup.js +78 -8
- package/dist/test/setup.js.map +1 -1
- package/dist/utils/{css.d.ts → css/index.d.ts} +2 -2
- package/dist/utils/{css.js → css/index.js} +5 -5
- package/dist/utils/css/index.js.map +1 -0
- package/dist/utils/events/index.js +10 -0
- package/dist/utils/events/index.js.map +1 -0
- package/dist/utils/index.d.ts +4 -4
- package/dist/utils/index.js +4 -4
- package/dist/utils/{props.d.ts → props/index.d.ts} +2 -2
- package/dist/utils/{props.js → props/index.js} +3 -3
- package/dist/utils/props/index.js.map +1 -0
- package/dist/utils/{validators.d.ts → validators/index.d.ts} +1 -1
- package/dist/utils/{validators.js → validators/index.js} +3 -3
- package/dist/utils/validators/index.js.map +1 -0
- package/dist/vanilla.d.ts +1 -1
- package/dist/vanilla.js +1 -1
- package/package.json +7 -8
- package/dist/components/aria/aria.d.ts +0 -32
- package/dist/components/aria/aria.js +0 -39
- package/dist/components/aria/aria.js.map +0 -1
- package/dist/components/button/button.d.ts +0 -47
- package/dist/components/button/button.js +0 -104
- package/dist/components/button/button.js.map +0 -1
- package/dist/components/checkbox/checkbox.d.ts +0 -30
- package/dist/components/checkbox/checkbox.js +0 -123
- package/dist/components/checkbox/checkbox.js.map +0 -1
- package/dist/components/chip/chip.d.ts +0 -41
- package/dist/components/chip/chip.js +0 -171
- package/dist/components/chip/chip.js.map +0 -1
- package/dist/components/collection/collection.d.ts +0 -17
- package/dist/components/collection/collection.js +0 -22
- package/dist/components/collection/collection.js.map +0 -1
- package/dist/components/combo-box/combo-box.d.ts +0 -21
- package/dist/components/combo-box/combo-box.js +0 -116
- package/dist/components/combo-box/combo-box.js.map +0 -1
- package/dist/components/date-field/date-field.d.ts +0 -20
- package/dist/components/date-field/date-field.js +0 -106
- package/dist/components/date-field/date-field.js.map +0 -1
- package/dist/components/date-input/date-input.d.ts +0 -42
- package/dist/components/date-input/date-input.js +0 -128
- package/dist/components/date-input/date-input.js.map +0 -1
- package/dist/components/dialog/dialog.d.ts +0 -29
- package/dist/components/dialog/dialog.js +0 -186
- package/dist/components/dialog/dialog.js.map +0 -1
- package/dist/components/drawer/drawer.d.ts +0 -28
- package/dist/components/drawer/drawer.js +0 -305
- package/dist/components/drawer/drawer.js.map +0 -1
- package/dist/components/element/element.d.ts +0 -16
- package/dist/components/element/element.js +0 -24
- package/dist/components/element/element.js.map +0 -1
- package/dist/components/group/group.d.ts +0 -16
- package/dist/components/group/group.js +0 -61
- package/dist/components/group/group.js.map +0 -1
- package/dist/components/icon/icon.d.ts +0 -17
- package/dist/components/icon/icon.js +0 -39
- package/dist/components/icon/icon.js.map +0 -1
- package/dist/components/input/input.d.ts +0 -13
- package/dist/components/input/input.js +0 -141
- package/dist/components/input/input.js.map +0 -1
- package/dist/components/menu/menu.d.ts +0 -32
- package/dist/components/menu/menu.js +0 -252
- package/dist/components/menu/menu.js.map +0 -1
- package/dist/components/merge-provider/merge-provider.d.ts +0 -20
- package/dist/components/merge-provider/merge-provider.js +0 -46
- package/dist/components/merge-provider/merge-provider.js.map +0 -1
- package/dist/components/number-field/number-field.d.ts +0 -20
- package/dist/components/number-field/number-field.js +0 -125
- package/dist/components/number-field/number-field.js.map +0 -1
- package/dist/components/options/options.d.ts +0 -28
- package/dist/components/options/options.js +0 -253
- package/dist/components/options/options.js.map +0 -1
- package/dist/components/picker/picker.d.ts +0 -24
- package/dist/components/picker/picker.js +0 -113
- package/dist/components/picker/picker.js.map +0 -1
- package/dist/components/popover/popover.d.ts +0 -22
- package/dist/components/popover/popover.js +0 -139
- package/dist/components/popover/popover.js.map +0 -1
- package/dist/components/query-builder/query-builder.d.ts +0 -23
- package/dist/components/query-builder/query-builder.js +0 -200
- package/dist/components/query-builder/query-builder.js.map +0 -1
- package/dist/components/radio/radio.d.ts +0 -23
- package/dist/components/radio/radio.js +0 -114
- package/dist/components/radio/radio.js.map +0 -1
- package/dist/components/search-field/search-field.d.ts +0 -21
- package/dist/components/search-field/search-field.js +0 -92
- package/dist/components/search-field/search-field.js.map +0 -1
- package/dist/components/select/select.d.ts +0 -20
- package/dist/components/select/select.js +0 -109
- package/dist/components/select/select.js.map +0 -1
- package/dist/components/slider/slider.d.ts +0 -49
- package/dist/components/slider/slider.js +0 -230
- package/dist/components/slider/slider.js.map +0 -1
- package/dist/components/switch/switch.d.ts +0 -10
- package/dist/components/switch/switch.js +0 -60
- package/dist/components/switch/switch.js.map +0 -1
- package/dist/components/tabs/tabs.d.ts +0 -75
- package/dist/components/tabs/tabs.js +0 -258
- package/dist/components/tabs/tabs.js.map +0 -1
- package/dist/components/text-field/text-field.d.ts +0 -64
- package/dist/components/text-field/text-field.js +0 -92
- package/dist/components/text-field/text-field.js.map +0 -1
- package/dist/components/textarea/textarea.d.ts +0 -19
- package/dist/components/textarea/textarea.js +0 -134
- package/dist/components/textarea/textarea.js.map +0 -1
- package/dist/components/time-field/time-field.d.ts +0 -21
- package/dist/components/time-field/time-field.js +0 -106
- package/dist/components/time-field/time-field.js.map +0 -1
- package/dist/components/tooltip/tooltip.d.ts +0 -30
- package/dist/components/tooltip/tooltip.js +0 -112
- package/dist/components/tooltip/tooltip.js.map +0 -1
- package/dist/components/tree/tree.d.ts +0 -29
- package/dist/components/tree/tree.js +0 -491
- package/dist/components/tree/tree.js.map +0 -1
- package/dist/hooks/use-collection-render/use-collection-render.d.ts +0 -11
- package/dist/hooks/use-collection-render/use-collection-render.js +0 -28
- package/dist/hooks/use-collection-render/use-collection-render.js.map +0 -1
- package/dist/hooks/use-context-props/use-context-props.d.ts +0 -10
- package/dist/hooks/use-context-props/use-context-props.js +0 -18
- package/dist/hooks/use-context-props/use-context-props.js.map +0 -1
- package/dist/hooks/use-defaults/use-defaults.d.ts +0 -110
- package/dist/hooks/use-defaults/use-defaults.js +0 -36
- package/dist/hooks/use-defaults/use-defaults.js.map +0 -1
- package/dist/hooks/use-propagating-press/use-propagating-press.d.ts +0 -13
- package/dist/hooks/use-propagating-press/use-propagating-press.js +0 -21
- package/dist/hooks/use-propagating-press/use-propagating-press.js.map +0 -1
- package/dist/hooks/use-slot/use-slot.d.ts +0 -16
- package/dist/hooks/use-slot/use-slot.js +0 -21
- package/dist/hooks/use-slot/use-slot.js.map +0 -1
- package/dist/hooks/use-theme/use-theme.d.ts +0 -77
- package/dist/hooks/use-theme/use-theme.js +0 -108
- package/dist/hooks/use-theme/use-theme.js.map +0 -1
- package/dist/hooks/use-tree/use-tree.d.ts +0 -7
- package/dist/hooks/use-tree/use-tree.js +0 -262
- package/dist/hooks/use-tree/use-tree.js.map +0 -1
- package/dist/hooks/use-update-effect/use-update-effect.d.ts +0 -3
- package/dist/hooks/use-update-effect/use-update-effect.js +0 -23
- package/dist/hooks/use-update-effect/use-update-effect.js.map +0 -1
- package/dist/utils/css.js.map +0 -1
- package/dist/utils/events.js +0 -10
- package/dist/utils/events.js.map +0 -1
- package/dist/utils/props.js.map +0 -1
- package/dist/utils/validators.js.map +0 -1
- /package/dist/utils/{events.d.ts → events/index.d.ts} +0 -0
|
@@ -1,3 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
import 'react';
|
|
3
|
-
import 'react-aria-components';
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { RefAttributes } from 'react';
|
|
3
|
+
import * as react_aria_components from 'react-aria-components';
|
|
4
|
+
import { ContextValue, SectionProps, SelectValueProps } from 'react-aria-components';
|
|
5
|
+
|
|
6
|
+
declare const AriaFieldError: (props: react_aria_components.FieldErrorProps & RefAttributes<HTMLElement>) => react.ReactElement | null;
|
|
7
|
+
declare const AriaFieldErrorContext: react.Context<ContextValue<react_aria_components.FieldErrorProps & RefAttributes<HTMLElement>, HTMLElement>>;
|
|
8
|
+
declare const AriaGroup: (props: react_aria_components.GroupProps & RefAttributes<HTMLDivElement>) => react.ReactElement | null;
|
|
9
|
+
declare const AriaGroupContext: react.Context<ContextValue<react_aria_components.GroupProps & RefAttributes<HTMLDivElement>, HTMLDivElement>>;
|
|
10
|
+
declare const AriaHeader: (props: react.HTMLAttributes<HTMLElement> & RefAttributes<object> & RefAttributes<HTMLElement>) => react.ReactElement | null;
|
|
11
|
+
declare const AriaHeaderContext: react.Context<ContextValue<react.HTMLAttributes<HTMLElement> & RefAttributes<object>, HTMLElement>>;
|
|
12
|
+
declare const AriaHeading: (props: react_aria_components.HeadingProps & RefAttributes<HTMLHeadingElement>) => react.ReactElement | null;
|
|
13
|
+
declare const AriaHeadingContext: react.Context<ContextValue<react_aria_components.HeadingProps & RefAttributes<HTMLHeadingElement>, HTMLHeadingElement>>;
|
|
14
|
+
declare const AriaKeyboard: (props: react.HTMLAttributes<HTMLElement> & RefAttributes<HTMLElement>) => react.ReactElement | null;
|
|
15
|
+
declare const AriaKeyboardContext: react.Context<ContextValue<react.HTMLAttributes<HTMLElement> & RefAttributes<HTMLElement>, HTMLElement>>;
|
|
16
|
+
declare const AriaLabel: (props: react_aria_components.LabelProps & RefAttributes<HTMLLabelElement>) => react.ReactElement | null;
|
|
17
|
+
declare const AriaLabelContext: react.Context<ContextValue<react_aria_components.LabelProps & RefAttributes<HTMLLabelElement>, HTMLLabelElement>>;
|
|
18
|
+
declare const AriaSeparator: (props: react_aria_components.SeparatorProps & RefAttributes<object> & RefAttributes<HTMLElement>) => react.ReactElement | null;
|
|
19
|
+
declare const AriaSeparatorContext: react.Context<ContextValue<react_aria_components.SeparatorProps & RefAttributes<object>, HTMLElement>>;
|
|
20
|
+
declare const AriaText: (props: react_aria_components.TextProps & RefAttributes<HTMLElement>) => react.ReactElement | null;
|
|
21
|
+
declare const AriaTextContext: react.Context<ContextValue<react_aria_components.TextProps & RefAttributes<HTMLElement>, HTMLElement>>;
|
|
22
|
+
/**
|
|
23
|
+
* Due to the complexity of types and technical constraints of TS, it's not
|
|
24
|
+
* possible for the above wrapping utility to support components that accept
|
|
25
|
+
* generic parameters. This means that these components must be manually wrapped
|
|
26
|
+
*/
|
|
27
|
+
declare const AriaSectionContext: react.Context<ContextValue<SectionProps<object>, HTMLElement>>;
|
|
28
|
+
declare const AriaSection: <T extends object>(props: SectionProps<T> & RefAttributes<HTMLElement>) => react.ReactElement | null;
|
|
29
|
+
declare const AriaSelectValueContext: react.Context<ContextValue<SelectValueProps<object>, HTMLSpanElement>>;
|
|
30
|
+
declare const AriaSelectValue: <T extends object>(props: SelectValueProps<T> & RefAttributes<HTMLSpanElement>) => react.ReactElement | null;
|
|
31
|
+
|
|
32
|
+
export { AriaFieldError, AriaFieldErrorContext, AriaGroup, AriaGroupContext, AriaHeader, AriaHeaderContext, AriaHeading, AriaHeadingContext, AriaKeyboard, AriaKeyboardContext, AriaLabel, AriaLabelContext, AriaSection, AriaSectionContext, AriaSelectValue, AriaSelectValueContext, AriaSeparator, AriaSeparatorContext, AriaText, AriaTextContext };
|
|
@@ -1,4 +1,39 @@
|
|
|
1
1
|
import '../../chunk-PZ5AY32C.js';
|
|
2
|
-
|
|
2
|
+
import { createContext, forwardRef } from 'react';
|
|
3
|
+
import { Section, SelectValue, FieldError, Group, Header, Heading, Keyboard, Label, Separator, Text } from 'react-aria-components';
|
|
4
|
+
import { useContextProps } from '../../hooks/use-context-props/index.js';
|
|
5
|
+
import { jsx } from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
function wrap(Component) {
|
|
8
|
+
const Context = createContext(null);
|
|
9
|
+
return {
|
|
10
|
+
// biome-ignore lint/style/useNamingConvention: intentional
|
|
11
|
+
Component: forwardRef(function WrappedComponent(props, ref) {
|
|
12
|
+
[props, ref] = useContextProps(props, ref, Context);
|
|
13
|
+
return /* @__PURE__ */ jsx(Component, { ...props, ref });
|
|
14
|
+
}),
|
|
15
|
+
Context
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
var { Component: AriaFieldError, Context: AriaFieldErrorContext } = wrap(FieldError);
|
|
19
|
+
var { Component: AriaGroup, Context: AriaGroupContext } = wrap(Group);
|
|
20
|
+
var { Component: AriaHeader, Context: AriaHeaderContext } = wrap(Header);
|
|
21
|
+
var { Component: AriaHeading, Context: AriaHeadingContext } = wrap(Heading);
|
|
22
|
+
var { Component: AriaKeyboard, Context: AriaKeyboardContext } = wrap(Keyboard);
|
|
23
|
+
var { Component: AriaLabel, Context: AriaLabelContext } = wrap(Label);
|
|
24
|
+
var { Component: AriaSeparator, Context: AriaSeparatorContext } = wrap(Separator);
|
|
25
|
+
var { Component: AriaText, Context: AriaTextContext } = wrap(Text);
|
|
26
|
+
var AriaSectionContext = createContext(null);
|
|
27
|
+
var AriaSection = forwardRef(function AriaSection2(props, ref) {
|
|
28
|
+
[props, ref] = useContextProps(props, ref, AriaSectionContext);
|
|
29
|
+
return /* @__PURE__ */ jsx(Section, { ...props, ref });
|
|
30
|
+
});
|
|
31
|
+
var AriaSelectValueContext = createContext(null);
|
|
32
|
+
var AriaSelectValue = forwardRef(function AriaSelectValue2(props, ref) {
|
|
33
|
+
[props, ref] = useContextProps(props, ref, AriaSelectValueContext);
|
|
34
|
+
return /* @__PURE__ */ jsx(SelectValue, { ...props, ref });
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
export { AriaFieldError, AriaFieldErrorContext, AriaGroup, AriaGroupContext, AriaHeader, AriaHeaderContext, AriaHeading, AriaHeadingContext, AriaKeyboard, AriaKeyboardContext, AriaLabel, AriaLabelContext, AriaSection, AriaSectionContext, AriaSelectValue, AriaSelectValueContext, AriaSeparator, AriaSeparatorContext, AriaText, AriaTextContext };
|
|
3
38
|
//# sourceMappingURL=index.js.map
|
|
4
39
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js","sourcesContent":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/aria/index.tsx"],"names":["AriaSection","AriaSelectValue"],"mappings":";;;;;;AA0CA,SAAS,KACP,SACA,EAAA;AACA,EAAM,MAAA,OAAA,GAAU,cAAkC,IAAI,CAAA;AAEtD,EAAO,OAAA;AAAA;AAAA,IAEL,SAAW,EAAA,UAAA,CAAiB,SAAS,gBAAA,CAAiB,OAAO,GAAK,EAAA;AAChE,MAAA,CAAC,OAAO,GAAG,CAAA,GAAI,eAAgB,CAAA,KAAA,EAAO,KAAK,OAAO,CAAA;AAElD,MAAA,uBAAQ,GAAA,CAAA,SAAA,EAAA,EAAW,GAAG,KAAA,EAAO,GAAU,EAAA,CAAA;AAAA,KACxC,CAAA;AAAA,IACD;AAAA,GACF;AACF;AAEO,IAAM,EAAE,SAAW,EAAA,cAAA,EAAgB,SAAS,qBAAsB,EAAA,GACvE,KAAK,UAAU;AAEV,IAAM,EAAE,SAAW,EAAA,SAAA,EAAW,SAAS,gBAAiB,EAAA,GAAI,KAAK,KAAK;AAEtE,IAAM,EAAE,SAAW,EAAA,UAAA,EAAY,SAAS,iBAAkB,EAAA,GAC/D,KAAK,MAAM;AAEN,IAAM,EAAE,SAAW,EAAA,WAAA,EAAa,SAAS,kBAAmB,EAAA,GACjE,KAAK,OAAO;AAEP,IAAM,EAAE,SAAW,EAAA,YAAA,EAAc,SAAS,mBAAoB,EAAA,GACnE,KAAK,QAAQ;AAER,IAAM,EAAE,SAAW,EAAA,SAAA,EAAW,SAAS,gBAAiB,EAAA,GAAI,KAAK,KAAK;AAEtE,IAAM,EAAE,SAAW,EAAA,aAAA,EAAe,SAAS,oBAAqB,EAAA,GACrE,KAAK,SAAS;AAET,IAAM,EAAE,SAAW,EAAA,QAAA,EAAU,SAAS,eAAgB,EAAA,GAAI,KAAK,IAAI;AAQ7D,IAAA,kBAAA,GACX,cAA+D,IAAI;AAE9D,IAAM,WAAc,GAAA,UAAA,CAAW,SAASA,YAAAA,CAC7C,OACA,GACA,EAAA;AACA,EAAA,CAAC,OAAO,GAAG,CAAA,GAAI,eAAgB,CAAA,KAAA,EAAO,KAAK,kBAAkB,CAAA;AAE7D,EAAA,uBAAQ,GAAA,CAAA,OAAA,EAAA,EAAS,GAAG,KAAA,EAAO,GAAU,EAAA,CAAA;AACvC,CAAC;AAEY,IAAA,sBAAA,GACX,cAAuE,IAAI;AAEtE,IAAM,eAAkB,GAAA,UAAA,CAAW,SAASC,gBAAAA,CAEjD,OAA4B,GAAoC,EAAA;AAChE,EAAA,CAAC,OAAO,GAAG,CAAA,GAAI,eAAgB,CAAA,KAAA,EAAO,KAAK,sBAAsB,CAAA;AAEjE,EAAA,uBAAQ,GAAA,CAAA,WAAA,EAAA,EAAa,GAAG,KAAA,EAAO,GAAU,EAAA,CAAA;AAC3C,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 type ForwardedRef,\n type ReactNode,\n type RefAttributes,\n createContext,\n forwardRef,\n} from 'react';\nimport {\n type ContextValue,\n FieldError,\n Group,\n Header,\n Heading,\n Keyboard,\n Label,\n Section,\n type SectionProps,\n SelectValue,\n type SelectValueProps,\n Separator,\n Text,\n} from 'react-aria-components';\nimport { useContextProps } from '../../hooks/use-context-props';\n\n/**\n * To better align with the guidance from RAC about establishing a unique\n * context for components to avoid conflict of props being provided by RAC\n * and design system components, this wrapping utility accepts an RAC and returns\n * a wrapped version along with the new context for the design system to use\n */\nfunction wrap<P extends object, E extends HTMLElement>(\n Component: (props: P & RefAttributes<E>) => ReactNode,\n) {\n const Context = createContext<ContextValue<P, E>>(null);\n\n return {\n // biome-ignore lint/style/useNamingConvention: intentional\n Component: forwardRef<E, P>(function WrappedComponent(props, ref) {\n [props, ref] = useContextProps(props, ref, Context);\n\n return <Component {...props} ref={ref} />;\n }),\n Context,\n };\n}\n\nexport const { Component: AriaFieldError, Context: AriaFieldErrorContext } =\n wrap(FieldError);\n\nexport const { Component: AriaGroup, Context: AriaGroupContext } = wrap(Group);\n\nexport const { Component: AriaHeader, Context: AriaHeaderContext } =\n wrap(Header);\n\nexport const { Component: AriaHeading, Context: AriaHeadingContext } =\n wrap(Heading);\n\nexport const { Component: AriaKeyboard, Context: AriaKeyboardContext } =\n wrap(Keyboard);\n\nexport const { Component: AriaLabel, Context: AriaLabelContext } = wrap(Label);\n\nexport const { Component: AriaSeparator, Context: AriaSeparatorContext } =\n wrap(Separator);\n\nexport const { Component: AriaText, Context: AriaTextContext } = wrap(Text);\n\n/**\n * Due to the complexity of types and technical constraints of TS, it's not\n * possible for the above wrapping utility to support components that accept\n * generic parameters. This means that these components must be manually wrapped\n */\n\nexport const AriaSectionContext =\n createContext<ContextValue<SectionProps<object>, HTMLElement>>(null);\n\nexport const AriaSection = forwardRef(function AriaSection<T extends object>(\n props: SectionProps<T>,\n ref: ForwardedRef<HTMLElement>,\n) {\n [props, ref] = useContextProps(props, ref, AriaSectionContext);\n\n return <Section {...props} ref={ref} />;\n});\n\nexport const AriaSelectValueContext =\n createContext<ContextValue<SelectValueProps<object>, HTMLSpanElement>>(null);\n\nexport const AriaSelectValue = forwardRef(function AriaSelectValue<\n T extends object,\n>(props: SelectValueProps<T>, ref: ForwardedRef<HTMLSpanElement>) {\n [props, ref] = useContextProps(props, ref, AriaSelectValueContext);\n\n return <SelectValue {...props} ref={ref} />;\n});\n"]}
|
|
@@ -1,8 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import 'react';
|
|
5
|
-
import '
|
|
6
|
-
import '../../types/react-aria.js';
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { Context } from 'react';
|
|
3
|
+
import * as react_aria_components from 'react-aria-components';
|
|
4
|
+
import { ContextValue } from 'react-aria-components';
|
|
5
|
+
import { ButtonRenderProps, ButtonColors, ButtonMapping, ButtonSizes, ButtonVariants, ButtonProps, LinkButtonProps, ToggleButtonProps } from './types.js';
|
|
6
|
+
import { RenderPropsChildren } from '../../types/react-aria.js';
|
|
7
7
|
import '../../types/props.js';
|
|
8
8
|
import '../icon/types.js';
|
|
9
|
+
|
|
10
|
+
declare const ButtonContext: Context<ContextValue<ButtonProps, HTMLButtonElement>>;
|
|
11
|
+
declare const Button: (props: Omit<react_aria_components.ButtonProps, "children" | "className" | "style"> & {
|
|
12
|
+
children?: RenderPropsChildren<ButtonRenderProps>;
|
|
13
|
+
classNames?: Partial<{
|
|
14
|
+
container: string;
|
|
15
|
+
button: string;
|
|
16
|
+
}> | undefined;
|
|
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
|
+
}> | undefined;
|
|
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
|
+
}> | undefined;
|
|
41
|
+
color?: ButtonColors;
|
|
42
|
+
mapping?: Partial<ButtonMapping>;
|
|
43
|
+
size?: ButtonSizes;
|
|
44
|
+
variant?: ButtonVariants;
|
|
45
|
+
} & react.RefAttributes<HTMLButtonElement>) => react.ReactElement | null;
|
|
46
|
+
|
|
47
|
+
export { Button, ButtonContext, LinkButton, LinkButtonContext, ToggleButton, ToggleButtonContext };
|
|
@@ -1,6 +1,108 @@
|
|
|
1
1
|
import '../../chunk-PZ5AY32C.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import '
|
|
2
|
+
import { noop } from '@accelint/core';
|
|
3
|
+
import { clsx } from 'clsx';
|
|
4
|
+
import { createContext, forwardRef, useMemo, useCallback } from 'react';
|
|
5
|
+
import { Button as Button$1, Link, ToggleButton as ToggleButton$1, Provider } from 'react-aria-components';
|
|
6
|
+
import { useContextProps } from '../../hooks/use-context-props/index.js';
|
|
7
|
+
import { useDefaultProps } from '../../hooks/use-defaults/index.js';
|
|
8
|
+
import { useTheme } from '../../hooks/use-theme/index.js';
|
|
9
|
+
import { surfaces } from '../../styles/surfaces.css.js';
|
|
10
|
+
import { bodies } from '../../styles/typography.css.js';
|
|
11
|
+
import { inlineVars } from '../../utils/css/index.js';
|
|
12
|
+
import { mergeClassNames, callRenderProps } from '../../utils/props/index.js';
|
|
13
|
+
import { IconContext } from '../icon/index.js';
|
|
14
|
+
import { buttonClassNames, buttonStateVars } from './button.css.js';
|
|
15
|
+
import { jsx } from 'react/jsx-runtime';
|
|
16
|
+
|
|
17
|
+
var noopToggleState = { isSelected: false, setSelected: noop, toggle: noop };
|
|
18
|
+
var buttonSizes = ["xs", "sm", "md", "lg", "xl"];
|
|
19
|
+
var defaultMapping = {
|
|
20
|
+
font: bodies,
|
|
21
|
+
icon: buttonSizes.reduce(
|
|
22
|
+
(acc, size) => {
|
|
23
|
+
acc[size] = { size };
|
|
24
|
+
return acc;
|
|
25
|
+
},
|
|
26
|
+
{}
|
|
27
|
+
)
|
|
28
|
+
};
|
|
29
|
+
function useButton(props, ref, context, key) {
|
|
30
|
+
[props, ref] = useContextProps(props, ref, context);
|
|
31
|
+
props = useDefaultProps(props, key);
|
|
32
|
+
const {
|
|
33
|
+
children: childrenProp,
|
|
34
|
+
classNames: classNamesProp,
|
|
35
|
+
color = "primary",
|
|
36
|
+
mapping: mappingProp,
|
|
37
|
+
size = "md",
|
|
38
|
+
variant = "solid",
|
|
39
|
+
...rest
|
|
40
|
+
} = props;
|
|
41
|
+
const theme = useTheme();
|
|
42
|
+
const mapping = useMemo(
|
|
43
|
+
() => ({
|
|
44
|
+
...defaultMapping,
|
|
45
|
+
...mappingProp
|
|
46
|
+
}),
|
|
47
|
+
[mappingProp]
|
|
48
|
+
);
|
|
49
|
+
const classNames = useMemo(
|
|
50
|
+
() => mergeClassNames(buttonClassNames, theme.Button, classNamesProp, {
|
|
51
|
+
button: clsx(
|
|
52
|
+
mapping.font[size],
|
|
53
|
+
variant === "floating" && surfaces.default.proud
|
|
54
|
+
)
|
|
55
|
+
}),
|
|
56
|
+
[theme.Button, classNamesProp, mapping.font, size, variant]
|
|
57
|
+
);
|
|
58
|
+
const style = useCallback(
|
|
59
|
+
(renderProps) => inlineVars(buttonStateVars, {
|
|
60
|
+
isCurrent: false,
|
|
61
|
+
isSelected: false,
|
|
62
|
+
...renderProps,
|
|
63
|
+
color,
|
|
64
|
+
size,
|
|
65
|
+
variant
|
|
66
|
+
}),
|
|
67
|
+
[color, size, variant]
|
|
68
|
+
);
|
|
69
|
+
const values = useMemo(() => [[IconContext, mapping.icon[size]]], [mapping.icon, size]);
|
|
70
|
+
const children = useCallback(
|
|
71
|
+
(renderProps) => /* @__PURE__ */ jsx(Provider, { values, children: /* @__PURE__ */ jsx("span", { className: classNames?.button, children: callRenderProps(childrenProp, {
|
|
72
|
+
state: noopToggleState,
|
|
73
|
+
isCurrent: false,
|
|
74
|
+
isPending: false,
|
|
75
|
+
isSelected: false,
|
|
76
|
+
...renderProps
|
|
77
|
+
}) }) }),
|
|
78
|
+
[values, classNames?.button, childrenProp]
|
|
79
|
+
);
|
|
80
|
+
return useMemo(
|
|
81
|
+
() => ({ ...rest, ref, children, className: classNames?.container, style }),
|
|
82
|
+
[rest, ref, children, classNames?.container, style]
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
var ButtonContext = createContext(null);
|
|
86
|
+
var Button = forwardRef(function Button2(props, ref) {
|
|
87
|
+
const buttonProps = useButton(props, ref, ButtonContext, "Button");
|
|
88
|
+
return /* @__PURE__ */ jsx(Button$1, { ...buttonProps });
|
|
89
|
+
});
|
|
90
|
+
var LinkButtonContext = createContext(null);
|
|
91
|
+
var LinkButton = forwardRef(function LinkButton2(props, ref) {
|
|
92
|
+
const buttonProps = useButton(props, ref, LinkButtonContext, "LinkButton");
|
|
93
|
+
return /* @__PURE__ */ jsx(Link, { ...buttonProps });
|
|
94
|
+
});
|
|
95
|
+
var ToggleButtonContext = createContext(null);
|
|
96
|
+
var ToggleButton = forwardRef(function ToggleButton2(props, ref) {
|
|
97
|
+
const buttonProps = useButton(
|
|
98
|
+
props,
|
|
99
|
+
ref,
|
|
100
|
+
ToggleButtonContext,
|
|
101
|
+
"ToggleButton"
|
|
102
|
+
);
|
|
103
|
+
return /* @__PURE__ */ jsx(ToggleButton$1, { ...buttonProps });
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
export { Button, ButtonContext, LinkButton, LinkButtonContext, ToggleButton, ToggleButtonContext };
|
|
5
107
|
//# sourceMappingURL=index.js.map
|
|
6
108
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js","sourcesContent":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/button/index.tsx"],"names":["Button","RACButton","LinkButton","ToggleButton","RACToggleButton"],"mappings":";;;;;;;;;;;;;;;;AAmDA,IAAM,kBAAkB,EAAE,UAAA,EAAY,OAAO,WAAa,EAAA,IAAA,EAAM,QAAQ,IAAK,EAAA;AAC7E,IAAM,cAA6B,CAAC,IAAA,EAAM,IAAM,EAAA,IAAA,EAAM,MAAM,IAAI,CAAA;AAEhE,IAAM,cAAgC,GAAA;AAAA,EACpC,IAAM,EAAA,MAAA;AAAA,EACN,MAAM,WAAY,CAAA,MAAA;AAAA,IAChB,CAAC,KAAK,IAAS,KAAA;AACb,MAAI,GAAA,CAAA,IAAI,CAAI,GAAA,EAAE,IAAK,EAAA;AAEnB,MAAO,OAAA,GAAA;AAAA,KACT;AAAA,IACA;AAAC;AAEL,CAAA;AAEA,SAAS,SAIP,CAAA,KAAA,EACA,GACA,EAAA,OAAA,EACA,GACA,EAAA;AACA,EAAA,CAAC,OAAO,GAAG,CAAA,GAAI,eAAgB,CAAA,KAAA,EAAO,KAAK,OAAO,CAAA;AAElD,EAAQ,KAAA,GAAA,eAAA,CAAgB,OAAO,GAAG,CAAA;AAElC,EAAM,MAAA;AAAA,IACJ,QAAU,EAAA,YAAA;AAAA,IACV,UAAY,EAAA,cAAA;AAAA,IACZ,KAAQ,GAAA,SAAA;AAAA,IACR,OAAS,EAAA,WAAA;AAAA,IACT,IAAO,GAAA,IAAA;AAAA,IACP,OAAU,GAAA,OAAA;AAAA,IACV,GAAG;AAAA,GACD,GAAA,KAAA;AAEJ,EAAA,MAAM,QAAQ,QAAS,EAAA;AAEvB,EAAA,MAAM,OAAU,GAAA,OAAA;AAAA,IACd,OAAO;AAAA,MACL,GAAG,cAAA;AAAA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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 { noop } from '@accelint/core';\nimport { clsx } from 'clsx';\nimport {\n type Context,\n type ForwardedRef,\n createContext,\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 type { OmitProtectedProps } from '../../types/props';\nimport { inlineVars } from '../../utils/css';\nimport { callRenderProps, mergeClassNames } from '../../utils/props';\nimport { IconContext } from '../icon';\nimport type { IconProps } from '../icon/types';\nimport { buttonClassNames, buttonStateVars } from './button.css';\nimport type {\n ButtonMapping,\n ButtonProps,\n ButtonSizes,\n LinkButtonProps,\n ToggleButtonProps,\n} from './types';\n\nconst noopToggleState = { isSelected: false, setSelected: noop, toggle: noop };\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 [props, ref] = useContextProps(props, ref, context);\n\n props = useDefaultProps(props, 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 } = props;\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 () => ({ ...rest, ref, children, className: classNames?.container, style }),\n [rest, ref, 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,9 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import '
|
|
5
|
-
import 'react';
|
|
6
|
-
import 'react-aria
|
|
7
|
-
import '../../types/react-aria.js';
|
|
1
|
+
import * as _react_types_shared from '@react-types/shared';
|
|
2
|
+
import { CheckboxRenderProps, CheckboxClassNames, CheckboxAlignment, CheckboxProps, CheckboxGroupRenderProps, CheckboxGroupProps } from './types.js';
|
|
3
|
+
import * as react from 'react';
|
|
4
|
+
import * as react_aria_components from 'react-aria-components';
|
|
5
|
+
import { ContextValue } from 'react-aria-components';
|
|
6
|
+
import { RenderPropsChildren } from '../../types/react-aria.js';
|
|
8
7
|
import 'type-fest';
|
|
9
8
|
import '../icon/types.js';
|
|
9
|
+
|
|
10
|
+
declare const CheckboxContext: react.Context<ContextValue<CheckboxProps, HTMLLabelElement>>;
|
|
11
|
+
declare const Checkbox: (props: Omit<react_aria_components.CheckboxProps, "children" | "className" | "style"> & {
|
|
12
|
+
children?: RenderPropsChildren<CheckboxRenderProps>;
|
|
13
|
+
label?: string;
|
|
14
|
+
classNames?: CheckboxClassNames;
|
|
15
|
+
alignInput?: CheckboxAlignment;
|
|
16
|
+
} & react.RefAttributes<HTMLLabelElement>) => react.ReactElement | null;
|
|
17
|
+
declare const CheckboxGroupContext: react.Context<ContextValue<CheckboxGroupProps, HTMLDivElement>>;
|
|
18
|
+
declare const CheckboxGroup: (props: Omit<react_aria_components.CheckboxGroupProps, "children" | "className" | "style"> & {
|
|
19
|
+
children?: RenderPropsChildren<CheckboxGroupRenderProps>;
|
|
20
|
+
classNames?: CheckboxClassNames;
|
|
21
|
+
label?: string;
|
|
22
|
+
orientation?: _react_types_shared.Orientation;
|
|
23
|
+
} & Pick<{
|
|
24
|
+
children?: RenderPropsChildren<CheckboxRenderProps>;
|
|
25
|
+
label?: string;
|
|
26
|
+
classNames?: CheckboxClassNames;
|
|
27
|
+
alignInput?: CheckboxAlignment;
|
|
28
|
+
}, "alignInput"> & react.RefAttributes<HTMLDivElement>) => react.ReactElement | null;
|
|
29
|
+
|
|
30
|
+
export { Checkbox, CheckboxContext, CheckboxGroup, CheckboxGroupContext };
|
|
@@ -1,6 +1,127 @@
|
|
|
1
1
|
import '../../chunk-PZ5AY32C.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import '
|
|
2
|
+
import { createContext, forwardRef, useMemo, useCallback } from 'react';
|
|
3
|
+
import { TextContext, Provider, Checkbox as Checkbox$1, CheckboxGroup as CheckboxGroup$1 } from 'react-aria-components';
|
|
4
|
+
import { useContextProps } from '../../hooks/use-context-props/index.js';
|
|
5
|
+
import { useDefaultProps } from '../../hooks/use-defaults/index.js';
|
|
6
|
+
import { useSlot } from '../../hooks/use-slot/index.js';
|
|
7
|
+
import { useTheme } from '../../hooks/use-theme/index.js';
|
|
8
|
+
import { inlineVars } from '../../utils/css/index.js';
|
|
9
|
+
import { mergeClassNames, callRenderProps } from '../../utils/props/index.js';
|
|
10
|
+
import { AriaTextContext, AriaLabelContext } from '../aria/index.js';
|
|
11
|
+
import { IconContext } from '../icon/index.js';
|
|
12
|
+
import { checkboxClassNames, checkboxStateVars, checkboxGroupStateVars } from './checkbox.css.js';
|
|
13
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
14
|
+
|
|
15
|
+
var CheckboxContext = createContext(null);
|
|
16
|
+
var Checkbox = forwardRef(function Checkbox2(props, ref) {
|
|
17
|
+
[props, ref] = useContextProps(props, ref, CheckboxContext);
|
|
18
|
+
props = useDefaultProps(props, "Checkbox");
|
|
19
|
+
const {
|
|
20
|
+
children: childrenProp,
|
|
21
|
+
classNames: classNamesProp,
|
|
22
|
+
alignInput = "end",
|
|
23
|
+
...rest
|
|
24
|
+
} = props;
|
|
25
|
+
const [iconRef, hasIcon] = useSlot();
|
|
26
|
+
const theme = useTheme();
|
|
27
|
+
const classNames = useMemo(
|
|
28
|
+
() => mergeClassNames(checkboxClassNames, theme.Checkbox, classNamesProp),
|
|
29
|
+
[theme.Checkbox, classNamesProp]
|
|
30
|
+
);
|
|
31
|
+
const style = useCallback(
|
|
32
|
+
(renderProps) => inlineVars(checkboxStateVars, {
|
|
33
|
+
...renderProps,
|
|
34
|
+
alignInput
|
|
35
|
+
}),
|
|
36
|
+
[alignInput]
|
|
37
|
+
);
|
|
38
|
+
const values = useMemo(
|
|
39
|
+
() => [
|
|
40
|
+
[AriaTextContext, { className: classNames?.checkbox?.label }],
|
|
41
|
+
[
|
|
42
|
+
IconContext,
|
|
43
|
+
{
|
|
44
|
+
ref: iconRef,
|
|
45
|
+
classNames: classNames?.checkbox?.icon
|
|
46
|
+
}
|
|
47
|
+
],
|
|
48
|
+
[TextContext, null]
|
|
49
|
+
],
|
|
50
|
+
[classNames?.checkbox?.label, classNames?.checkbox?.icon, iconRef]
|
|
51
|
+
);
|
|
52
|
+
const children = useCallback(
|
|
53
|
+
(renderProps) => /* @__PURE__ */ jsx(Provider, { values, children: /* @__PURE__ */ jsxs("div", { className: classNames?.checkbox?.checkbox, children: [
|
|
54
|
+
!hasIcon && /* @__PURE__ */ jsx("span", { className: classNames?.checkbox?.icon?.container }),
|
|
55
|
+
callRenderProps(childrenProp, renderProps)
|
|
56
|
+
] }) }),
|
|
57
|
+
[childrenProp, classNames?.checkbox, hasIcon, values]
|
|
58
|
+
);
|
|
59
|
+
return /* @__PURE__ */ jsx(
|
|
60
|
+
Checkbox$1,
|
|
61
|
+
{
|
|
62
|
+
...rest,
|
|
63
|
+
ref,
|
|
64
|
+
className: classNames?.checkbox?.container,
|
|
65
|
+
style,
|
|
66
|
+
children
|
|
67
|
+
}
|
|
68
|
+
);
|
|
69
|
+
});
|
|
70
|
+
var CheckboxGroupContext = createContext(null);
|
|
71
|
+
var CheckboxGroup = forwardRef(function CheckboxGroup2(props, ref) {
|
|
72
|
+
[props, ref] = useContextProps(props, ref, CheckboxGroupContext);
|
|
73
|
+
props = useDefaultProps(props, "CheckboxGroup");
|
|
74
|
+
const {
|
|
75
|
+
children: childrenProp,
|
|
76
|
+
classNames: classNamesProp,
|
|
77
|
+
alignInput = "end",
|
|
78
|
+
orientation = "vertical",
|
|
79
|
+
...rest
|
|
80
|
+
} = props;
|
|
81
|
+
const theme = useTheme();
|
|
82
|
+
const classNames = useMemo(
|
|
83
|
+
() => mergeClassNames(checkboxClassNames, theme.Checkbox, classNamesProp),
|
|
84
|
+
[classNamesProp, theme.Checkbox]
|
|
85
|
+
);
|
|
86
|
+
const style = useCallback(
|
|
87
|
+
(renderProps) => inlineVars(checkboxGroupStateVars, {
|
|
88
|
+
...renderProps,
|
|
89
|
+
orientation
|
|
90
|
+
}),
|
|
91
|
+
[orientation]
|
|
92
|
+
);
|
|
93
|
+
const values = useMemo(
|
|
94
|
+
() => [
|
|
95
|
+
[AriaLabelContext, { className: classNames?.group?.label }],
|
|
96
|
+
[
|
|
97
|
+
CheckboxContext,
|
|
98
|
+
{
|
|
99
|
+
classNames,
|
|
100
|
+
alignInput
|
|
101
|
+
}
|
|
102
|
+
]
|
|
103
|
+
],
|
|
104
|
+
[alignInput, classNames]
|
|
105
|
+
);
|
|
106
|
+
const children = useCallback(
|
|
107
|
+
(renderProps) => /* @__PURE__ */ jsx(Provider, { values, children: /* @__PURE__ */ jsx("div", { className: classNames?.group?.group, children: callRenderProps(childrenProp, {
|
|
108
|
+
...renderProps,
|
|
109
|
+
defaultChildren: null
|
|
110
|
+
}) }) }),
|
|
111
|
+
[childrenProp, classNames?.group, values]
|
|
112
|
+
);
|
|
113
|
+
return /* @__PURE__ */ jsx(
|
|
114
|
+
CheckboxGroup$1,
|
|
115
|
+
{
|
|
116
|
+
...rest,
|
|
117
|
+
ref,
|
|
118
|
+
className: classNames?.group?.container,
|
|
119
|
+
style,
|
|
120
|
+
children
|
|
121
|
+
}
|
|
122
|
+
);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
export { Checkbox, CheckboxContext, CheckboxGroup, CheckboxGroupContext };
|
|
5
126
|
//# sourceMappingURL=index.js.map
|
|
6
127
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js","sourcesContent":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/checkbox/index.tsx"],"names":["Checkbox","RACCheckbox","CheckboxGroup","RACCheckboxGroup"],"mappings":";;;;;;;;;;;;;;AAiDa,IAAA,eAAA,GACX,cAA6D,IAAI;AAE5D,IAAM,QAAW,GAAA,UAAA,CAAW,SAASA,SAAAA,CAC1C,OACA,GACA,EAAA;AACA,EAAA,CAAC,OAAO,GAAG,CAAA,GAAI,eAAgB,CAAA,KAAA,EAAO,KAAK,eAAe,CAAA;AAE1D,EAAQ,KAAA,GAAA,eAAA,CAAgB,OAAO,UAAU,CAAA;AAEzC,EAAM,MAAA;AAAA,IACJ,QAAU,EAAA,YAAA;AAAA,IACV,UAAY,EAAA,cAAA;AAAA,IACZ,UAAa,GAAA,KAAA;AAAA,IACb,GAAG;AAAA,GACD,GAAA,KAAA;AAEJ,EAAA,MAAM,CAAC,OAAA,EAAS,OAAO,CAAA,GAAI,OAAQ,EAAA;AACnC,EAAA,MAAM,QAAQ,QAAS,EAA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A,CAAC,YAAY,UAAU;AAAA,GACzB;AAEA,EAAA,MAAM,QAAW,GAAA,WAAA;AAAA,IACf,CAAC,WAAA,qBACE,GAAA,CAAA,QAAA,EAAA,EAAS,MACR,EAAA,QAAA,kBAAA,GAAA,CAAC,KAAI,EAAA,EAAA,SAAA,EAAW,UAAY,EAAA,KAAA,EAAO,KAChC,EAAA,QAAA,EAAA,eAAA,CAAgB,YAAc,EAAA;AAAA,MAC7B,GAAG,WAAA;AAAA,MACH,eAAiB,EAAA;AAAA,KAClB,GACH,CACF,EAAA,CAAA;AAAA,IAEF,CAAC,YAAA,EAAc,UAAY,EAAA,KAAA,EAAO,MAAM;AAAA,GAC1C;AAEA,EACE,uBAAA,GAAA;AAAA,IAACC,eAAA;AAAA,IAAA;AAAA,MACE,GAAG,IAAA;AAAA,MACJ,GAAA;AAAA,MACA,SAAA,EAAW,YAAY,KAAO,EAAA,SAAA;AAAA,MAC9B,KAAA;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 type ForwardedRef,\n createContext,\n forwardRef,\n useCallback,\n useMemo,\n} from 'react';\nimport {\n type ContextValue,\n type LabelProps,\n Provider,\n Checkbox as RACCheckbox,\n CheckboxGroup as RACCheckboxGroup,\n TextContext,\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 { inlineVars } from '../../utils/css';\nimport { callRenderProps, mergeClassNames } from '../../utils/props';\nimport { AriaLabelContext, AriaTextContext } from '../aria';\nimport { IconContext } from '../icon';\nimport type { IconProps } from '../icon/types';\nimport {\n checkboxClassNames,\n checkboxGroupStateVars,\n checkboxStateVars,\n} from './checkbox.css';\nimport type {\n CheckboxGroupProps,\n CheckboxGroupRenderProps,\n CheckboxProps,\n CheckboxRenderProps,\n} from './types';\n\nexport const CheckboxContext =\n createContext<ContextValue<CheckboxProps, HTMLLabelElement>>(null);\n\nexport const Checkbox = forwardRef(function Checkbox(\n props: CheckboxProps,\n ref: ForwardedRef<HTMLLabelElement>,\n) {\n [props, ref] = useContextProps(props, ref, CheckboxContext);\n\n props = useDefaultProps(props, 'Checkbox');\n\n const {\n children: childrenProp,\n classNames: classNamesProp,\n alignInput = 'end',\n ...rest\n } = props;\n\n const [iconRef, hasIcon] = useSlot();\n const theme = useTheme();\n\n const classNames = useMemo(\n () => mergeClassNames(checkboxClassNames, theme.Checkbox, classNamesProp),\n [theme.Checkbox, classNamesProp],\n );\n\n const style = useCallback(\n (renderProps: CheckboxRenderProps) =>\n inlineVars(checkboxStateVars, {\n ...renderProps,\n alignInput,\n }),\n [alignInput],\n );\n\n const values = useMemo<\n [\n [typeof AriaTextContext, ContextValue<TextProps, HTMLElement>],\n [typeof IconContext, ContextValue<IconProps, HTMLDivElement>],\n [typeof TextContext, ContextValue<TextProps, HTMLElement>],\n ]\n >(\n () => [\n [AriaTextContext, { className: classNames?.checkbox?.label }],\n [\n IconContext,\n {\n ref: iconRef,\n classNames: classNames?.checkbox?.icon,\n },\n ],\n [TextContext, null],\n ],\n [classNames?.checkbox?.label, classNames?.checkbox?.icon, iconRef],\n );\n\n const children = useCallback(\n (renderProps: CheckboxRenderProps) => (\n <Provider values={values}>\n <div className={classNames?.checkbox?.checkbox}>\n {!hasIcon && (\n <span className={classNames?.checkbox?.icon?.container} />\n )}\n {callRenderProps(childrenProp, renderProps)}\n </div>\n </Provider>\n ),\n [childrenProp, classNames?.checkbox, hasIcon, values],\n );\n\n return (\n <RACCheckbox\n {...rest}\n ref={ref}\n className={classNames?.checkbox?.container}\n style={style}\n >\n {children}\n </RACCheckbox>\n );\n});\n\nexport const CheckboxGroupContext =\n createContext<ContextValue<CheckboxGroupProps, HTMLDivElement>>(null);\n\nexport const CheckboxGroup = forwardRef(function CheckboxGroup(\n props: CheckboxGroupProps,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n [props, ref] = useContextProps(props, ref, CheckboxGroupContext);\n\n props = useDefaultProps(props, 'CheckboxGroup');\n\n const {\n children: childrenProp,\n classNames: classNamesProp,\n alignInput = 'end',\n orientation = 'vertical',\n ...rest\n } = props;\n\n const theme = useTheme();\n\n const classNames = useMemo(\n () => mergeClassNames(checkboxClassNames, theme.Checkbox, classNamesProp),\n [classNamesProp, theme.Checkbox],\n );\n\n const style = useCallback(\n (renderProps: CheckboxGroupRenderProps) =>\n inlineVars(checkboxGroupStateVars, {\n ...renderProps,\n orientation,\n }),\n [orientation],\n );\n\n const values = useMemo<\n [\n [typeof AriaLabelContext, ContextValue<LabelProps, HTMLLabelElement>],\n [typeof CheckboxContext, ContextValue<CheckboxProps, HTMLLabelElement>],\n ]\n >(\n () => [\n [AriaLabelContext, { className: classNames?.group?.label }],\n [\n CheckboxContext,\n {\n classNames,\n alignInput,\n },\n ],\n ],\n [alignInput, classNames],\n );\n\n const children = useCallback(\n (renderProps: CheckboxGroupRenderProps) => (\n <Provider values={values}>\n <div className={classNames?.group?.group}>\n {callRenderProps(childrenProp, {\n ...renderProps,\n defaultChildren: null,\n })}\n </div>\n </Provider>\n ),\n [childrenProp, classNames?.group, values],\n );\n\n return (\n <RACCheckboxGroup\n {...rest}\n ref={ref}\n className={classNames?.group?.container}\n style={style}\n >\n {children}\n </RACCheckboxGroup>\n );\n});\n"]}
|
|
@@ -1,11 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import 'react
|
|
5
|
-
import 'react';
|
|
6
|
-
import 'react/jsx-runtime';
|
|
1
|
+
import { ChipProps, ChipItemProps, BaseChipProps, ChipGroupProps, ChipListProps } from './types.js';
|
|
2
|
+
import * as react_aria_components from 'react-aria-components';
|
|
3
|
+
import { ContextValue } from 'react-aria-components';
|
|
4
|
+
import * as react from 'react';
|
|
5
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
7
6
|
import '../../types/generic.js';
|
|
8
7
|
import '../../types/props.js';
|
|
9
8
|
import '../../types/react-aria.js';
|
|
10
9
|
import '../button/types.js';
|
|
11
10
|
import '../icon/types.js';
|
|
11
|
+
|
|
12
|
+
declare function Chip(props: ChipProps): react_jsx_runtime.JSX.Element;
|
|
13
|
+
declare const ChipContext: react.Context<ContextValue<ChipItemProps, HTMLDivElement>>;
|
|
14
|
+
/**
|
|
15
|
+
* Must be used in conjunction with ChipList & ChipGroup and
|
|
16
|
+
* cannot be used outside of ChipList, else will throw error
|
|
17
|
+
*
|
|
18
|
+
* Color & Size props can be passed in from ChipGroup and overriden
|
|
19
|
+
* on each instance of this components
|
|
20
|
+
*
|
|
21
|
+
* Order of precedence (from lowest to highest):
|
|
22
|
+
* Design System Defaults of Chip
|
|
23
|
+
* Global Defaults of ChipGroup
|
|
24
|
+
* Instance of ChipGroup
|
|
25
|
+
* Global Defaults of ChipItem
|
|
26
|
+
* Instance of ChipItem
|
|
27
|
+
*/
|
|
28
|
+
declare const ChipItem: (props: Omit<react_aria_components.TagProps, "children" | "className" | "style"> & BaseChipProps & react.RefAttributes<HTMLDivElement>) => react.ReactElement | null;
|
|
29
|
+
/**
|
|
30
|
+
* Must be used in conjunction with ChipItem & ChipGroup and
|
|
31
|
+
* cannot be used outside of ChipGroup, else will throw error
|
|
32
|
+
*/
|
|
33
|
+
declare function ChipList<T extends object>({ classNames: classNamesProp, ...rest }: ChipListProps<T>): react_jsx_runtime.JSX.Element;
|
|
34
|
+
declare const ChipGroupContext: react.Context<ContextValue<ChipGroupProps, HTMLDivElement>>;
|
|
35
|
+
/**
|
|
36
|
+
* Color & Size props are passed down to ChipItem but can be overridden
|
|
37
|
+
* on each component if desired
|
|
38
|
+
*/
|
|
39
|
+
declare const ChipGroup: (props: Omit<react_aria_components.TagGroupProps, "className" | "style"> & Omit<BaseChipProps, "children"> & react.RefAttributes<HTMLDivElement>) => react.ReactElement | null;
|
|
40
|
+
|
|
41
|
+
export { Chip, ChipContext, ChipGroup, ChipGroupContext, ChipItem, ChipList };
|