@salt-ds/core 1.46.1 → 1.47.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -0
- package/css/salt-core.css +240 -224
- package/dist-cjs/accordion/Accordion.css.js +1 -1
- package/dist-cjs/accordion/AccordionGroup.css.js +1 -1
- package/dist-cjs/accordion/AccordionHeader.css.js +1 -1
- package/dist-cjs/banner/Banner.css.js +1 -1
- package/dist-cjs/border-item/BorderItem.js +33 -32
- package/dist-cjs/border-item/BorderItem.js.map +1 -1
- package/dist-cjs/border-layout/BorderLayout.js +3 -1
- package/dist-cjs/border-layout/BorderLayout.js.map +1 -1
- package/dist-cjs/button/Button.css.js +1 -1
- package/dist-cjs/button/Button.js +2 -1
- package/dist-cjs/button/Button.js.map +1 -1
- package/dist-cjs/card/Card.css.js +1 -1
- package/dist-cjs/checkbox/Checkbox.css.js +1 -1
- package/dist-cjs/checkbox/CheckboxIcon.css.js +1 -1
- package/dist-cjs/dialog/Dialog.css.js +1 -1
- package/dist-cjs/dialog/DialogContent.css.js +1 -1
- package/dist-cjs/divider/Divider.css.js +1 -1
- package/dist-cjs/dropdown/Dropdown.css.js +1 -1
- package/dist-cjs/file-drop-zone/FileDropZone.css.js +1 -1
- package/dist-cjs/flex-item/FlexItem.js +46 -48
- package/dist-cjs/flex-item/FlexItem.js.map +1 -1
- package/dist-cjs/flex-layout/FlexLayout.css.js +1 -1
- package/dist-cjs/flex-layout/FlexLayout.js +60 -62
- package/dist-cjs/flex-layout/FlexLayout.js.map +1 -1
- package/dist-cjs/flow-layout/FlowLayout.js +3 -5
- package/dist-cjs/flow-layout/FlowLayout.js.map +1 -1
- package/dist-cjs/form-field/FormField.js +6 -2
- package/dist-cjs/form-field/FormField.js.map +1 -1
- package/dist-cjs/form-field/FormFieldHelperText.css.js +1 -1
- package/dist-cjs/form-field/FormFieldHelperText.js +7 -1
- package/dist-cjs/form-field/FormFieldHelperText.js.map +1 -1
- package/dist-cjs/form-field/FormFieldLabel.js +15 -3
- package/dist-cjs/form-field/FormFieldLabel.js.map +1 -1
- package/dist-cjs/form-field-context/FormFieldContext.js.map +1 -1
- package/dist-cjs/grid-item/GridItem.js +51 -53
- package/dist-cjs/grid-item/GridItem.js.map +1 -1
- package/dist-cjs/grid-layout/GridLayout.js +49 -51
- package/dist-cjs/grid-layout/GridLayout.js.map +1 -1
- package/dist-cjs/input/Input.css.js +1 -1
- package/dist-cjs/interactable-card/InteractableCard.css.js +1 -1
- package/dist-cjs/link-card/LinkCard.css.js +1 -1
- package/dist-cjs/list-box/ListBox.css.js +1 -1
- package/dist-cjs/list-box/ListBox.js +5 -0
- package/dist-cjs/list-box/ListBox.js.map +1 -1
- package/dist-cjs/menu/MenuBase.js +1 -1
- package/dist-cjs/menu/MenuBase.js.map +1 -1
- package/dist-cjs/menu/MenuGroup.css.js +1 -1
- package/dist-cjs/menu/MenuItem.css.js +1 -1
- package/dist-cjs/menu/MenuPanel.css.js +1 -1
- package/dist-cjs/menu/MenuTrigger.js +32 -29
- package/dist-cjs/menu/MenuTrigger.js.map +1 -1
- package/dist-cjs/multiline-input/MultilineInput.css.js +1 -1
- package/dist-cjs/navigation-item/NavigationItem.css.js +1 -1
- package/dist-cjs/option/Option.css.js +1 -1
- package/dist-cjs/option/Option.js +1 -0
- package/dist-cjs/option/Option.js.map +1 -1
- package/dist-cjs/option/OptionGroup.css.js +1 -1
- package/dist-cjs/option/OptionList.css.js +1 -1
- package/dist-cjs/overlay/OverlayPanel.css.js +1 -1
- package/dist-cjs/overlay/OverlayPanelContent.css.js +1 -1
- package/dist-cjs/overlay/OverlayPanelContent.js +1 -1
- package/dist-cjs/overlay/OverlayPanelContent.js.map +1 -1
- package/dist-cjs/overlay/OverlayTrigger.js +17 -11
- package/dist-cjs/overlay/OverlayTrigger.js.map +1 -1
- package/dist-cjs/pagination/PageButton.css.js +1 -1
- package/dist-cjs/pill/Pill.css.js +1 -1
- package/dist-cjs/pill-input/PillInput.css.js +1 -1
- package/dist-cjs/pill-input/PillInput.js +5 -3
- package/dist-cjs/pill-input/PillInput.js.map +1 -1
- package/dist-cjs/progress/CircularProgress/CircularProgress.css.js +1 -1
- package/dist-cjs/progress/LinearProgress/LinearProgress.css.js +1 -1
- package/dist-cjs/radio-button/RadioButton.css.js +1 -1
- package/dist-cjs/radio-button/RadioButtonIcon.css.js +1 -1
- package/dist-cjs/segmented-button-group/SegmentedButtonGroup.css.js +1 -1
- package/dist-cjs/slider/internal/SliderThumb.css.js +1 -1
- package/dist-cjs/slider/internal/SliderTooltip.css.js +1 -1
- package/dist-cjs/slider/internal/SliderTrack.css.js +1 -1
- package/dist-cjs/spinner/Spinner.css.js +1 -1
- package/dist-cjs/split-layout/SplitLayout.js +2 -1
- package/dist-cjs/split-layout/SplitLayout.js.map +1 -1
- package/dist-cjs/stack-layout/StackLayout.css.js +1 -1
- package/dist-cjs/stack-layout/StackLayout.js +4 -2
- package/dist-cjs/stack-layout/StackLayout.js.map +1 -1
- package/dist-cjs/stepper/internal/StepConnector.css.js +1 -1
- package/dist-cjs/switch/Switch.css.js +1 -1
- package/dist-cjs/tag/Tag.css.js +1 -1
- package/dist-cjs/text/Text.js.map +1 -1
- package/dist-cjs/theme/Theme.js.map +1 -1
- package/dist-cjs/toast/Toast.css.js +1 -1
- package/dist-cjs/toggle-button/ToggleButton.css.js +1 -1
- package/dist-cjs/toggle-button-group/ToggleButtonGroup.css.js +1 -1
- package/dist-cjs/tooltip/Tooltip.css.js +1 -1
- package/dist-cjs/tooltip/Tooltip.js.map +1 -1
- package/dist-es/accordion/Accordion.css.js +1 -1
- package/dist-es/accordion/AccordionGroup.css.js +1 -1
- package/dist-es/accordion/AccordionHeader.css.js +1 -1
- package/dist-es/banner/Banner.css.js +1 -1
- package/dist-es/border-item/BorderItem.js +33 -32
- package/dist-es/border-item/BorderItem.js.map +1 -1
- package/dist-es/border-layout/BorderLayout.js +3 -1
- package/dist-es/border-layout/BorderLayout.js.map +1 -1
- package/dist-es/button/Button.css.js +1 -1
- package/dist-es/button/Button.js +2 -1
- package/dist-es/button/Button.js.map +1 -1
- package/dist-es/card/Card.css.js +1 -1
- package/dist-es/checkbox/Checkbox.css.js +1 -1
- package/dist-es/checkbox/CheckboxIcon.css.js +1 -1
- package/dist-es/dialog/Dialog.css.js +1 -1
- package/dist-es/dialog/DialogContent.css.js +1 -1
- package/dist-es/divider/Divider.css.js +1 -1
- package/dist-es/dropdown/Dropdown.css.js +1 -1
- package/dist-es/file-drop-zone/FileDropZone.css.js +1 -1
- package/dist-es/flex-item/FlexItem.js +46 -48
- package/dist-es/flex-item/FlexItem.js.map +1 -1
- package/dist-es/flex-layout/FlexLayout.css.js +1 -1
- package/dist-es/flex-layout/FlexLayout.js +60 -62
- package/dist-es/flex-layout/FlexLayout.js.map +1 -1
- package/dist-es/flow-layout/FlowLayout.js +3 -5
- package/dist-es/flow-layout/FlowLayout.js.map +1 -1
- package/dist-es/form-field/FormField.js +7 -3
- package/dist-es/form-field/FormField.js.map +1 -1
- package/dist-es/form-field/FormFieldHelperText.css.js +1 -1
- package/dist-es/form-field/FormFieldHelperText.js +7 -1
- package/dist-es/form-field/FormFieldHelperText.js.map +1 -1
- package/dist-es/form-field/FormFieldLabel.js +15 -3
- package/dist-es/form-field/FormFieldLabel.js.map +1 -1
- package/dist-es/form-field-context/FormFieldContext.js.map +1 -1
- package/dist-es/grid-item/GridItem.js +51 -53
- package/dist-es/grid-item/GridItem.js.map +1 -1
- package/dist-es/grid-layout/GridLayout.js +49 -51
- package/dist-es/grid-layout/GridLayout.js.map +1 -1
- package/dist-es/input/Input.css.js +1 -1
- package/dist-es/interactable-card/InteractableCard.css.js +1 -1
- package/dist-es/link-card/LinkCard.css.js +1 -1
- package/dist-es/list-box/ListBox.css.js +1 -1
- package/dist-es/list-box/ListBox.js +5 -0
- package/dist-es/list-box/ListBox.js.map +1 -1
- package/dist-es/menu/MenuBase.js +1 -1
- package/dist-es/menu/MenuBase.js.map +1 -1
- package/dist-es/menu/MenuGroup.css.js +1 -1
- package/dist-es/menu/MenuItem.css.js +1 -1
- package/dist-es/menu/MenuPanel.css.js +1 -1
- package/dist-es/menu/MenuTrigger.js +33 -30
- package/dist-es/menu/MenuTrigger.js.map +1 -1
- package/dist-es/multiline-input/MultilineInput.css.js +1 -1
- package/dist-es/navigation-item/NavigationItem.css.js +1 -1
- package/dist-es/option/Option.css.js +1 -1
- package/dist-es/option/Option.js +1 -0
- package/dist-es/option/Option.js.map +1 -1
- package/dist-es/option/OptionGroup.css.js +1 -1
- package/dist-es/option/OptionList.css.js +1 -1
- package/dist-es/overlay/OverlayPanel.css.js +1 -1
- package/dist-es/overlay/OverlayPanelContent.css.js +1 -1
- package/dist-es/overlay/OverlayPanelContent.js +1 -1
- package/dist-es/overlay/OverlayPanelContent.js.map +1 -1
- package/dist-es/overlay/OverlayTrigger.js +18 -12
- package/dist-es/overlay/OverlayTrigger.js.map +1 -1
- package/dist-es/pagination/PageButton.css.js +1 -1
- package/dist-es/pill/Pill.css.js +1 -1
- package/dist-es/pill-input/PillInput.css.js +1 -1
- package/dist-es/pill-input/PillInput.js +5 -3
- package/dist-es/pill-input/PillInput.js.map +1 -1
- package/dist-es/progress/CircularProgress/CircularProgress.css.js +1 -1
- package/dist-es/progress/LinearProgress/LinearProgress.css.js +1 -1
- package/dist-es/radio-button/RadioButton.css.js +1 -1
- package/dist-es/radio-button/RadioButtonIcon.css.js +1 -1
- package/dist-es/segmented-button-group/SegmentedButtonGroup.css.js +1 -1
- package/dist-es/slider/internal/SliderThumb.css.js +1 -1
- package/dist-es/slider/internal/SliderTooltip.css.js +1 -1
- package/dist-es/slider/internal/SliderTrack.css.js +1 -1
- package/dist-es/spinner/Spinner.css.js +1 -1
- package/dist-es/split-layout/SplitLayout.js +2 -1
- package/dist-es/split-layout/SplitLayout.js.map +1 -1
- package/dist-es/stack-layout/StackLayout.css.js +1 -1
- package/dist-es/stack-layout/StackLayout.js +4 -2
- package/dist-es/stack-layout/StackLayout.js.map +1 -1
- package/dist-es/stepper/internal/StepConnector.css.js +1 -1
- package/dist-es/switch/Switch.css.js +1 -1
- package/dist-es/tag/Tag.css.js +1 -1
- package/dist-es/text/Text.js.map +1 -1
- package/dist-es/theme/Theme.js.map +1 -1
- package/dist-es/toast/Toast.css.js +1 -1
- package/dist-es/toggle-button/ToggleButton.css.js +1 -1
- package/dist-es/toggle-button-group/ToggleButtonGroup.css.js +1 -1
- package/dist-es/tooltip/Tooltip.css.js +1 -1
- package/dist-es/tooltip/Tooltip.js.map +1 -1
- package/dist-types/aria-announcer/AriaAnnouncerContext.d.ts +2 -2
- package/dist-types/aria-announcer/useAriaAnnouncer.d.ts +2 -2
- package/dist-types/avatar/Avatar.d.ts +1 -1
- package/dist-types/border-item/BorderItem.d.ts +4 -4
- package/dist-types/border-layout/BorderLayout.d.ts +3 -3
- package/dist-types/breakpoints/BreakpointProvider.d.ts +1 -1
- package/dist-types/button/Button.d.ts +3 -3
- package/dist-types/combo-box/ComboBox.d.ts +3 -12
- package/dist-types/combo-box/useComboBox.d.ts +3 -3
- package/dist-types/dialog/DialogContext.d.ts +3 -2
- package/dist-types/dropdown/Dropdown.d.ts +3 -52
- package/dist-types/flex-item/FlexItem.d.ts +4 -4
- package/dist-types/flex-layout/FlexLayout.d.ts +7 -7
- package/dist-types/flow-layout/FlowLayout.d.ts +3 -3
- package/dist-types/form-field/FormField.d.ts +1 -1
- package/dist-types/form-field/FormFieldLabel.d.ts +1 -1
- package/dist-types/form-field-context/FormFieldContext.d.ts +3 -1
- package/dist-types/grid-item/GridItem.d.ts +5 -5
- package/dist-types/grid-layout/GridLayout.d.ts +3 -3
- package/dist-types/interactable-card/InteractableCardGroupContext.d.ts +1 -1
- package/dist-types/list-box/ListBox.d.ts +3 -20
- package/dist-types/list-control/ListControlContext.d.ts +1 -1
- package/dist-types/list-control/ListControlState.d.ts +5 -5
- package/dist-types/menu/MenuContext.d.ts +1 -1
- package/dist-types/menu/MenuTrigger.d.ts +1 -1
- package/dist-types/overlay/OverlayContext.d.ts +1 -1
- package/dist-types/overlay/OverlayTrigger.d.ts +1 -1
- package/dist-types/pagination/usePagination.d.ts +1 -1
- package/dist-types/salt-provider/SaltProvider.d.ts +4 -4
- package/dist-types/semantic-icon-provider/SemanticIconProvider.d.ts +1 -1
- package/dist-types/slider/internal/useRangeSliderThumb.d.ts +1 -1
- package/dist-types/slider/internal/useSliderThumb.d.ts +1 -1
- package/dist-types/slider/internal/utils.d.ts +5 -5
- package/dist-types/spinner/Spinner.d.ts +2 -2
- package/dist-types/split-layout/SplitLayout.d.ts +3 -3
- package/dist-types/stack-layout/StackLayout.d.ts +3 -3
- package/dist-types/status-adornment/ErrorAdornment.d.ts +1 -1
- package/dist-types/status-adornment/StatusAdornment.d.ts +1 -1
- package/dist-types/status-adornment/SuccessAdornment.d.ts +1 -1
- package/dist-types/status-adornment/WarningAdornment.d.ts +1 -1
- package/dist-types/status-indicator/ValidationStatus.d.ts +1 -1
- package/dist-types/stepper/Step.d.ts +4 -4
- package/dist-types/stepper/Stepper.d.ts +1 -1
- package/dist-types/text/Text.d.ts +3 -3
- package/dist-types/theme/Accent.d.ts +2 -2
- package/dist-types/theme/ActionFont.d.ts +2 -2
- package/dist-types/theme/Corner.d.ts +2 -2
- package/dist-types/theme/Density.d.ts +1 -1
- package/dist-types/theme/HeadingFont.d.ts +2 -2
- package/dist-types/theme/Mode.d.ts +1 -1
- package/dist-types/theme/Theme.d.ts +3 -3
- package/dist-types/toggle-button-group/ToggleButtonGroupContext.d.ts +1 -1
- package/dist-types/tooltip/useAriaAnnounce.d.ts +1 -1
- package/dist-types/tooltip/useTooltip.d.ts +3 -3
- package/dist-types/types.d.ts +1 -1
- package/dist-types/utils/createChainedFunction.d.ts +1 -1
- package/dist-types/utils/inferElementType.d.ts +1 -1
- package/dist-types/utils/makePrefixer.d.ts +1 -1
- package/dist-types/utils/polymorphicTypes.d.ts +5 -5
- package/dist-types/utils/useFloatingUI/useFloatingUI.d.ts +3 -13
- package/dist-types/utils/useResponsiveProp.d.ts +2 -2
- package/dist-types/utils/useValueEffect.d.ts +1 -1
- package/dist-types/viewport/ViewportProvider.d.ts +1 -1
- package/package.json +2 -2
|
@@ -20,54 +20,52 @@ const FLEX_ITEM_ALIGNMENTS = [
|
|
|
20
20
|
"center",
|
|
21
21
|
"stretch"
|
|
22
22
|
];
|
|
23
|
-
const FlexItem = React.forwardRef(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
);
|
|
23
|
+
const FlexItem = React.forwardRef(function FlexItem2({
|
|
24
|
+
as,
|
|
25
|
+
align,
|
|
26
|
+
children,
|
|
27
|
+
className,
|
|
28
|
+
margin = 0,
|
|
29
|
+
padding = 0,
|
|
30
|
+
shrink,
|
|
31
|
+
grow,
|
|
32
|
+
basis,
|
|
33
|
+
style,
|
|
34
|
+
...rest
|
|
35
|
+
}, ref) {
|
|
36
|
+
const targetWindow = window.useWindow();
|
|
37
|
+
styles.useComponentCssInjection({
|
|
38
|
+
testId: "salt-flex-item",
|
|
39
|
+
css: FlexItem$1,
|
|
40
|
+
window: targetWindow
|
|
41
|
+
});
|
|
42
|
+
const { matchedBreakpoints } = BreakpointProvider.useBreakpoint();
|
|
43
|
+
const Component = as || "div";
|
|
44
|
+
const flexItemShrink = useResponsiveProp.resolveResponsiveValue(shrink, matchedBreakpoints);
|
|
45
|
+
const flexItemGrow = useResponsiveProp.resolveResponsiveValue(grow, matchedBreakpoints);
|
|
46
|
+
const flexItemBasis = useResponsiveProp.resolveResponsiveValue(basis, matchedBreakpoints);
|
|
47
|
+
const flexItemMargin = useResponsiveProp.resolveResponsiveValue(margin, matchedBreakpoints);
|
|
48
|
+
const flexItemPadding = useResponsiveProp.resolveResponsiveValue(padding, matchedBreakpoints);
|
|
49
|
+
const itemStyle = {
|
|
50
|
+
"--flexItem-margin": parseSpacing.parseSpacing(flexItemMargin),
|
|
51
|
+
"--flexItem-padding": parseSpacing.parseSpacing(flexItemPadding),
|
|
52
|
+
"--saltFlexItem-alignment": align,
|
|
53
|
+
"--saltFlexItem-shrink": flexItemShrink,
|
|
54
|
+
"--saltFlexItem-grow": flexItemGrow,
|
|
55
|
+
"--saltFlexItem-basis": flexItemBasis,
|
|
56
|
+
...style
|
|
57
|
+
};
|
|
58
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
59
|
+
Component,
|
|
60
|
+
{
|
|
61
|
+
className: clsx.clsx(withBaseName(), className),
|
|
62
|
+
ref,
|
|
63
|
+
style: itemStyle,
|
|
64
|
+
...rest,
|
|
65
|
+
children
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
});
|
|
71
69
|
|
|
72
70
|
exports.FLEX_ITEM_ALIGNMENTS = FLEX_ITEM_ALIGNMENTS;
|
|
73
71
|
exports.FlexItem = FlexItem;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FlexItem.js","sources":["../src/flex-item/FlexItem.tsx"],"sourcesContent":["import { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { clsx } from \"clsx\";\nimport {\n type CSSProperties,\n type ElementType,\n type
|
|
1
|
+
{"version":3,"file":"FlexItem.js","sources":["../src/flex-item/FlexItem.tsx"],"sourcesContent":["import { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { clsx } from \"clsx\";\nimport {\n type CSSProperties,\n type ElementType,\n type ForwardedRef,\n type FunctionComponent,\n forwardRef,\n} from \"react\";\nimport { useBreakpoint } from \"../breakpoints\";\nimport { parseSpacing } from \"../flex-layout/parseSpacing\";\nimport {\n type PolymorphicComponentPropWithRef,\n type PolymorphicRef,\n type ResponsiveProp,\n makePrefixer,\n resolveResponsiveValue,\n} from \"../utils\";\nimport flexItemCss from \"./FlexItem.css\";\n\nconst withBaseName = makePrefixer(\"saltFlexItem\");\nexport const FLEX_ITEM_ALIGNMENTS = [\n \"start\",\n \"end\",\n \"center\",\n \"stretch\",\n] as const;\n\nexport type flexItemAlignment = (typeof FLEX_ITEM_ALIGNMENTS)[number];\n\nexport type FlexItemProps<T extends ElementType> =\n PolymorphicComponentPropWithRef<\n T,\n {\n /**\n * Allows the alignment specified by parent to be overridden for individual items, default is \"start\".\n */\n align?: flexItemAlignment;\n /**\n * Defines the ability for an item to shrink x times more compared to its siblings, default is 1.\n */\n shrink?: ResponsiveProp<number>;\n /**\n * Defines the ability for an item to grow x times more compared to its siblings, default is 0.\n */\n grow?: ResponsiveProp<number>;\n /**\n * Sets the initial main size of a flex item, default is \"auto\".\n */\n basis?: ResponsiveProp<CSSProperties[\"flexBasis\"]>;\n /**\n * Defines the margin around the component. It can be specified as a number (which acts as a multiplier) or a string representing the margin value. Default is `0`.\n */\n margin?: ResponsiveProp<number | string>;\n /**\n * Defines the padding within the component. It can be specified as a number (which acts as a multiplier) or a string representing the padding value. Default is `0`.\n */\n padding?: ResponsiveProp<number | string>;\n }\n >;\n\ntype FlexItemComponent = <T extends ElementType = \"div\">(\n props: FlexItemProps<T>,\n) => ReturnType<FunctionComponent>;\n\nexport const FlexItem: FlexItemComponent = forwardRef(function FlexItem<\n T extends ElementType = \"div\",\n>(\n {\n as,\n align,\n children,\n className,\n margin = 0,\n padding = 0,\n shrink,\n grow,\n basis,\n style,\n ...rest\n }: FlexItemProps<T>,\n ref?: ForwardedRef<unknown>,\n) {\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-flex-item\",\n css: flexItemCss,\n window: targetWindow,\n });\n const { matchedBreakpoints } = useBreakpoint();\n\n const Component = as || \"div\";\n const flexItemShrink = resolveResponsiveValue(shrink, matchedBreakpoints);\n const flexItemGrow = resolveResponsiveValue(grow, matchedBreakpoints);\n const flexItemBasis = resolveResponsiveValue(basis, matchedBreakpoints);\n const flexItemMargin = resolveResponsiveValue(margin, matchedBreakpoints);\n const flexItemPadding = resolveResponsiveValue(padding, matchedBreakpoints);\n\n const itemStyle = {\n \"--flexItem-margin\": parseSpacing(flexItemMargin),\n \"--flexItem-padding\": parseSpacing(flexItemPadding),\n \"--saltFlexItem-alignment\": align,\n \"--saltFlexItem-shrink\": flexItemShrink,\n \"--saltFlexItem-grow\": flexItemGrow,\n \"--saltFlexItem-basis\": flexItemBasis,\n ...style,\n };\n return (\n <Component\n className={clsx(withBaseName(), className)}\n ref={ref as PolymorphicRef<T>}\n style={itemStyle}\n {...rest}\n >\n {children}\n </Component>\n );\n});\n"],"names":["makePrefixer","forwardRef","FlexItem","useWindow","useComponentCssInjection","flexItemCss","useBreakpoint","resolveResponsiveValue","parseSpacing","jsx","clsx"],"mappings":";;;;;;;;;;;;;;;AAqBA,MAAM,YAAA,GAAeA,0BAAa,cAAc,CAAA;AACzC,MAAM,oBAAuB,GAAA;AAAA,EAClC,OAAA;AAAA,EACA,KAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF;AAuCa,MAAA,QAAA,GAA8BC,gBAAW,CAAA,SAASC,SAG7D,CAAA;AAAA,EACE,EAAA;AAAA,EACA,KAAA;AAAA,EACA,QAAA;AAAA,EACA,SAAA;AAAA,EACA,MAAS,GAAA,CAAA;AAAA,EACT,OAAU,GAA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;AAAA,MAEH;AAAA;AAAA,GACH;AAEJ,CAAC;;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var css_248z = "/* Default variables applied to the root element */\n.saltFlexLayout {\n --flexLayout-layout-display: flex;\n --flexLayout-direction: row;\n --flexLayout-wrap: nowrap;\n --flexLayout-justify: flex-start;\n --flexLayout-align: stretch;\n --flexLayout-separator: var(--salt-size-
|
|
3
|
+
var css_248z = "/* Default variables applied to the root element */\n.saltFlexLayout {\n --flexLayout-layout-display: flex;\n --flexLayout-direction: row;\n --flexLayout-wrap: nowrap;\n --flexLayout-justify: flex-start;\n --flexLayout-align: stretch;\n --flexLayout-separator: var(--salt-size-fixed-100);\n}\n\n/* Style applied to the root element */\n.saltFlexLayout {\n gap: var(--flexLayout-gap);\n margin: var(--flexLayout-margin);\n padding: var(--flexLayout-padding);\n display: var(--flexLayout-layout-display);\n flex-direction: var(--flexLayout-direction);\n flex-wrap: var(--flexLayout-wrap);\n justify-content: var(--flexLayout-justify);\n align-items: var(--flexLayout-align);\n box-sizing: border-box;\n}\n\n.saltFlexLayout-separator {\n gap: calc(var(--flexLayout-gap) * 2);\n}\n\n.saltFlexLayout-separator > * {\n position: relative;\n}\n.saltFlexLayout-separator > *:not(:last-child)::after {\n position: absolute;\n display: block;\n content: \"\";\n background-color: var(--salt-separable-secondary-borderColor);\n}\n\n/* Row separator */\n\n.saltFlexLayout-separator-row > *:not(:last-child)::after {\n height: 100%;\n}\n\n.saltFlexLayout-separator-row > *:not(:last-child)::after {\n width: var(--flexLayout-separator);\n top: 0;\n}\n.saltFlexLayout-separator-row-start > *:not(:last-child)::after {\n right: 0;\n}\n.saltFlexLayout-separator-row-center > *:not(:last-child)::after {\n right: calc(var(--flexLayout-gap) * -1);\n}\n.saltFlexLayout-separator-row-end > *:not(:last-child)::after {\n right: calc(var(--flexLayout-gap) * -2);\n}\n\n/* Column separator */\n.saltFlexLayout-separator-column > *:not(:last-child)::after {\n width: 100%;\n}\n\n.saltFlexLayout-separator-column > *:not(:last-child)::after {\n height: var(--flexLayout-separator);\n left: 0;\n width: 100%;\n}\n.saltFlexLayout-separator-column-start > *:not(:last-child)::after {\n bottom: 0;\n}\n.saltFlexLayout-separator-column-center > *:not(:last-child)::after {\n bottom: calc(var(--flexLayout-gap) * -1);\n}\n.saltFlexLayout-separator-column-end > *:not(:last-child)::after {\n bottom: calc(var(--flexLayout-gap) * -2);\n}\n";
|
|
4
4
|
|
|
5
5
|
module.exports = css_248z;
|
|
6
6
|
//# sourceMappingURL=FlexLayout.css.js.map
|
|
@@ -24,68 +24,66 @@ const FLEX_CONTENT_ALIGNMENT_BASE = [
|
|
|
24
24
|
function parseAlignment(style) {
|
|
25
25
|
return style === "start" || style === "end" ? `flex-${style}` : style;
|
|
26
26
|
}
|
|
27
|
-
const FlexLayout = React.forwardRef(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
);
|
|
27
|
+
const FlexLayout = React.forwardRef(function FlexLayout2({
|
|
28
|
+
as,
|
|
29
|
+
align,
|
|
30
|
+
children,
|
|
31
|
+
className,
|
|
32
|
+
direction = "row",
|
|
33
|
+
gap = 3,
|
|
34
|
+
margin = 0,
|
|
35
|
+
padding = 0,
|
|
36
|
+
justify,
|
|
37
|
+
separators,
|
|
38
|
+
style,
|
|
39
|
+
wrap = false,
|
|
40
|
+
...rest
|
|
41
|
+
}, ref) {
|
|
42
|
+
const targetWindow = window.useWindow();
|
|
43
|
+
styles.useComponentCssInjection({
|
|
44
|
+
testId: "salt-flex-layout",
|
|
45
|
+
css: FlexLayout$1,
|
|
46
|
+
window: targetWindow
|
|
47
|
+
});
|
|
48
|
+
const Component = as || "div";
|
|
49
|
+
const separatorAlignment = separators === true ? "center" : separators;
|
|
50
|
+
const { matchedBreakpoints } = BreakpointProvider.useBreakpoint();
|
|
51
|
+
const flexGap = useResponsiveProp.resolveResponsiveValue(gap, matchedBreakpoints);
|
|
52
|
+
const flexMargin = useResponsiveProp.resolveResponsiveValue(margin, matchedBreakpoints);
|
|
53
|
+
const flexPadding = useResponsiveProp.resolveResponsiveValue(padding, matchedBreakpoints);
|
|
54
|
+
const flexDirection = useResponsiveProp.resolveResponsiveValue(direction, matchedBreakpoints);
|
|
55
|
+
const flexWrap = useResponsiveProp.resolveResponsiveValue(wrap, matchedBreakpoints);
|
|
56
|
+
const flexLayoutStyles = {
|
|
57
|
+
...style,
|
|
58
|
+
"--flexLayout-align": parseAlignment(align),
|
|
59
|
+
"--flexLayout-direction": flexDirection,
|
|
60
|
+
"--flexLayout-gap": parseSpacing.parseSpacing(flexGap),
|
|
61
|
+
"--flexLayout-margin": parseSpacing.parseSpacing(flexMargin),
|
|
62
|
+
"--flexLayout-padding": parseSpacing.parseSpacing(flexPadding),
|
|
63
|
+
"--flexLayout-justify": parseAlignment(justify),
|
|
64
|
+
"--flexLayout-wrap": flexWrap ? "wrap" : "nowrap"
|
|
65
|
+
};
|
|
66
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
67
|
+
Component,
|
|
68
|
+
{
|
|
69
|
+
className: clsx.clsx(
|
|
70
|
+
withBaseName(),
|
|
71
|
+
{
|
|
72
|
+
[withBaseName("separator")]: separatorAlignment && !wrap,
|
|
73
|
+
[withBaseName(
|
|
74
|
+
`separator-${flexDirection ?? "row"}-${separatorAlignment ?? "center"}`
|
|
75
|
+
)]: separatorAlignment && !wrap,
|
|
76
|
+
[withBaseName(`separator-${flexDirection ?? "row"}`)]: separatorAlignment && !wrap
|
|
77
|
+
},
|
|
78
|
+
className
|
|
79
|
+
),
|
|
80
|
+
ref,
|
|
81
|
+
style: flexLayoutStyles,
|
|
82
|
+
...rest,
|
|
83
|
+
children
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
});
|
|
89
87
|
|
|
90
88
|
exports.FLEX_ALIGNMENT_BASE = FLEX_ALIGNMENT_BASE;
|
|
91
89
|
exports.FLEX_CONTENT_ALIGNMENT_BASE = FLEX_CONTENT_ALIGNMENT_BASE;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FlexLayout.js","sources":["../src/flex-layout/FlexLayout.tsx"],"sourcesContent":["import { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { clsx } from \"clsx\";\nimport {
|
|
1
|
+
{"version":3,"file":"FlexLayout.js","sources":["../src/flex-layout/FlexLayout.tsx"],"sourcesContent":["import { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { clsx } from \"clsx\";\nimport {\n type ElementType,\n type ForwardedRef,\n type FunctionComponent,\n forwardRef,\n} from \"react\";\nimport { useBreakpoint } from \"../breakpoints\";\nimport {\n type PolymorphicComponentPropWithRef,\n type PolymorphicRef,\n type ResponsiveProp,\n makePrefixer,\n resolveResponsiveValue,\n} from \"../utils\";\nimport flexLayoutCss from \"./FlexLayout.css\";\nimport { parseSpacing } from \"./parseSpacing\";\n\nconst withBaseName = makePrefixer(\"saltFlexLayout\");\n\nexport type LayoutSeparator = \"start\" | \"center\" | \"end\";\nexport type LayoutDirection = \"row\" | \"column\";\n\nexport const FLEX_ALIGNMENT_BASE = [\"start\", \"end\", \"center\"] as const;\nexport const FLEX_CONTENT_ALIGNMENT_BASE = [\n ...FLEX_ALIGNMENT_BASE,\n \"space-between\",\n \"space-around\",\n \"space-evenly\",\n] as const;\n\nexport type FlexAlignment = (typeof FLEX_ALIGNMENT_BASE)[number];\nexport type FlexContentAlignment = (typeof FLEX_CONTENT_ALIGNMENT_BASE)[number];\n\nexport type FlexLayoutProps<T extends ElementType> =\n PolymorphicComponentPropWithRef<\n T,\n {\n /**\n * Defines the default behavior for how flex items are laid out along the cross axis on the current line, default is \"stretch\".\n */\n align?: FlexAlignment | \"stretch\" | \"baseline\";\n /**\n * Establishes the main-axis, defining the direction children are placed. Default is \"row\".\n */\n direction?: ResponsiveProp<LayoutDirection>;\n /**\n * Controls the space between items, default is 3.\n */\n gap?: ResponsiveProp<number | string>;\n /**\n * Defines the alignment along the main axis, default is \"start\".\n */\n justify?: FlexContentAlignment;\n /**\n * **Deprecated:** For separators see `StackLayout` component instead.\n *\n * Adds a separator between elements if wrap is not active, default is false.\n */\n separators?: LayoutSeparator | true;\n /**\n * Allow the items to wrap as needed, default is false.\n */\n wrap?: ResponsiveProp<boolean>;\n /**\n * Defines the margin around the component. It can be specified as a number (which acts as a multiplier) or a string representing the margin value. Default is `0`.\n */\n margin?: ResponsiveProp<number | string>;\n /**\n * Defines the padding within the component. It can be specified as a number (which acts as a multiplier) or a string representing the padding value. Default is `0`.\n */\n padding?: ResponsiveProp<number | string>;\n }\n >;\n\ntype FlexLayoutComponent = <T extends ElementType = \"div\">(\n props: FlexLayoutProps<T>,\n) => ReturnType<FunctionComponent>;\n\nfunction parseAlignment(style: string | undefined) {\n return style === \"start\" || style === \"end\" ? `flex-${style}` : style;\n}\n\nexport const FlexLayout: FlexLayoutComponent = forwardRef(function FlexLayout<\n T extends ElementType = \"div\",\n>(\n {\n as,\n align,\n children,\n className,\n direction = \"row\",\n gap = 3,\n margin = 0,\n padding = 0,\n justify,\n separators,\n style,\n wrap = false,\n ...rest\n }: FlexLayoutProps<T>,\n ref?: ForwardedRef<unknown>,\n) {\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-flex-layout\",\n css: flexLayoutCss,\n window: targetWindow,\n });\n\n const Component = as || \"div\";\n const separatorAlignment = separators === true ? \"center\" : separators;\n\n const { matchedBreakpoints } = useBreakpoint();\n const flexGap = resolveResponsiveValue(gap, matchedBreakpoints);\n const flexMargin = resolveResponsiveValue(margin, matchedBreakpoints);\n const flexPadding = resolveResponsiveValue(padding, matchedBreakpoints);\n const flexDirection = resolveResponsiveValue(direction, matchedBreakpoints);\n const flexWrap = resolveResponsiveValue(wrap, matchedBreakpoints);\n const flexLayoutStyles = {\n ...style,\n \"--flexLayout-align\": parseAlignment(align),\n \"--flexLayout-direction\": flexDirection,\n \"--flexLayout-gap\": parseSpacing(flexGap),\n \"--flexLayout-margin\": parseSpacing(flexMargin),\n \"--flexLayout-padding\": parseSpacing(flexPadding),\n \"--flexLayout-justify\": parseAlignment(justify),\n \"--flexLayout-wrap\": flexWrap ? \"wrap\" : \"nowrap\",\n };\n\n return (\n <Component\n className={clsx(\n withBaseName(),\n {\n [withBaseName(\"separator\")]: separatorAlignment && !wrap,\n [withBaseName(\n `separator-${flexDirection ?? \"row\"}-${\n separatorAlignment ?? \"center\"\n }`,\n )]: separatorAlignment && !wrap,\n [withBaseName(`separator-${flexDirection ?? \"row\"}`)]:\n separatorAlignment && !wrap,\n },\n className,\n )}\n ref={ref as PolymorphicRef<T>}\n style={flexLayoutStyles}\n {...rest}\n >\n {children}\n </Component>\n );\n});\n"],"names":["makePrefixer","forwardRef","FlexLayout","useWindow","useComponentCssInjection","flexLayoutC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A,GACH;AAEJ,CAAC;;;;;;"}
|
|
@@ -4,11 +4,9 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var FlexLayout = require('../flex-layout/FlexLayout.js');
|
|
6
6
|
|
|
7
|
-
const FlowLayout = React.forwardRef(
|
|
8
|
-
({
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
);
|
|
7
|
+
const FlowLayout = React.forwardRef(function FlowLayout2({ as, children, ...rest }, ref) {
|
|
8
|
+
return /* @__PURE__ */ jsxRuntime.jsx(FlexLayout.FlexLayout, { as, direction: "row", ref, wrap: true, ...rest, children });
|
|
9
|
+
});
|
|
12
10
|
|
|
13
11
|
exports.FlowLayout = FlowLayout;
|
|
14
12
|
//# sourceMappingURL=FlowLayout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FlowLayout.js","sources":["../src/flow-layout/FlowLayout.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"FlowLayout.js","sources":["../src/flow-layout/FlowLayout.tsx"],"sourcesContent":["import {\n type ElementType,\n type ForwardedRef,\n type FunctionComponent,\n forwardRef,\n} from \"react\";\nimport { FlexLayout, type FlexLayoutProps } from \"../flex-layout\";\nimport type { PolymorphicComponentPropWithRef } from \"../utils\";\n\nexport type FlowLayoutProps<T extends ElementType> =\n PolymorphicComponentPropWithRef<\n T,\n {\n /**\n * Defines the default behavior for how flex items are laid out along the cross axis on the current line, default is \"stretch\".\n */\n align?: FlexLayoutProps<ElementType>[\"align\"];\n /**\n * Controls the space between items, default is 3.\n */\n gap?: FlexLayoutProps<ElementType>[\"gap\"];\n /**\n * Defines the alignment along the main axis, default is \"start\"\n */\n justify?: FlexLayoutProps<ElementType>[\"justify\"];\n /**\n * Defines the margin around the component. It can be specified as a number (which acts as a multiplier) or a string representing the margin value. Default is `0`.\n */\n margin?: FlexLayoutProps<ElementType>[\"margin\"];\n /**\n * Defines the padding within the component. It can be specified as a number (which acts as a multiplier) or a string representing the padding value. Default is `0`.\n */\n padding?: FlexLayoutProps<ElementType>[\"padding\"];\n }\n >;\n\ntype FlowLayoutComponent = <T extends ElementType = \"div\">(\n props: FlowLayoutProps<T>,\n) => ReturnType<FunctionComponent>;\n\nexport const FlowLayout: FlowLayoutComponent = forwardRef(function FlowLayout<\n T extends ElementType = \"div\",\n>({ as, children, ...rest }: FlowLayoutProps<T>, ref?: ForwardedRef<unknown>) {\n return (\n <FlexLayout as={as as ElementType} direction=\"row\" ref={ref} wrap {...rest}>\n {children}\n </FlexLayout>\n );\n});\n"],"names":["forwardRef","FlowLayout","jsx","FlexLayout"],"mappings":";;;;;;AAwCa,MAAA,UAAA,GAAkCA,gBAAW,CAAA,SAASC,WAEjE,CAAA,EAAE,IAAI,QAAU,EAAA,GAAG,IAAK,EAAA,EAAuB,GAA6B,EAAA;AAC5E,EACE,uBAAAC,cAAA,CAACC,qBAAW,EAAA,EAAA,EAAA,EAAuB,SAAU,EAAA,KAAA,EAAM,KAAU,IAAI,EAAA,IAAA,EAAE,GAAG,IAAA,EACnE,QACH,EAAA,CAAA;AAEJ,CAAC;;;;"}
|
|
@@ -9,6 +9,7 @@ var FormFieldContext = require('../form-field-context/FormFieldContext.js');
|
|
|
9
9
|
var capitalize = require('../utils/capitalize.js');
|
|
10
10
|
var makePrefixer = require('../utils/makePrefixer.js');
|
|
11
11
|
require('../utils/useFloatingUI/useFloatingUI.js');
|
|
12
|
+
var useForkRef = require('../utils/useForkRef.js');
|
|
12
13
|
var useId = require('../utils/useId.js');
|
|
13
14
|
require('../salt-provider/SaltProvider.js');
|
|
14
15
|
require('../viewport/ViewportProvider.js');
|
|
@@ -33,13 +34,15 @@ const FormField = React.forwardRef(
|
|
|
33
34
|
css: FormField$1,
|
|
34
35
|
window: targetWindow
|
|
35
36
|
});
|
|
37
|
+
const formFieldRef = React.useRef(null);
|
|
38
|
+
const handleRef = useForkRef.useForkRef(ref, formFieldRef);
|
|
36
39
|
const formId = useId.useId(idProp);
|
|
37
40
|
const labelId = formId ? `label-${formId}` : void 0;
|
|
38
41
|
const helperTextId = formId ? `helperText-${formId}` : void 0;
|
|
39
42
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
40
43
|
"div",
|
|
41
44
|
{
|
|
42
|
-
ref,
|
|
45
|
+
ref: handleRef,
|
|
43
46
|
className: clsx.clsx(
|
|
44
47
|
withBaseName(),
|
|
45
48
|
{
|
|
@@ -60,7 +63,8 @@ const FormField = React.forwardRef(
|
|
|
60
63
|
disabled,
|
|
61
64
|
necessity,
|
|
62
65
|
readOnly,
|
|
63
|
-
validationStatus
|
|
66
|
+
validationStatus,
|
|
67
|
+
formFieldRef
|
|
64
68
|
},
|
|
65
69
|
children
|
|
66
70
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormField.js","sources":["../src/form-field/FormField.tsx"],"sourcesContent":["import { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { clsx } from \"clsx\";\nimport { type HTMLAttributes, forwardRef } from \"react\";\nimport { type A11yValueProps, FormFieldContext } from \"../form-field-context\";\nimport { capitalize, makePrefixer, useId } from \"../utils\";\n\nimport formFieldCss from \"./FormField.css\";\n\nexport type FormFieldLabelPlacement = \"top\" | \"left\" | \"right\";\n\nexport interface FormFieldProps\n extends HTMLAttributes<HTMLDivElement>,\n A11yValueProps {\n /**\n * If `true`, the field will be disabled.\n */\n disabled?: boolean;\n /**\n * Location of the label relative to the control.\n *\n * Either 'top', 'left', or 'right'`.\n */\n labelPlacement?: FormFieldLabelPlacement;\n /**\n * If `true`, the field will be read-only.\n */\n readOnly?: boolean;\n /**\n * Optional id prop\n *\n * Used as suffix of FormFieldLabel id: `label-{id}`\n * Used as suffix of FormFieldHelperText id: `helperText-{id}`\n */\n id?: string;\n /**\n * Displays necessity on label\n */\n necessity?: \"required\" | \"optional\" | \"asterisk\";\n /**\n * Validation status\n */\n validationStatus?: \"error\" | \"warning\" | \"success\";\n}\n\nconst withBaseName = makePrefixer(\"saltFormField\");\n\nexport const FormField = forwardRef<HTMLDivElement, FormFieldProps>(\n (\n {\n children,\n className,\n disabled = false,\n id: idProp,\n labelPlacement = \"top\",\n necessity,\n readOnly = false,\n validationStatus,\n ...restProps\n },\n ref,\n ) => {\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-form-field\",\n css: formFieldCss,\n window: targetWindow,\n });\n\n const formId = useId(idProp);\n\n const labelId = formId ? `label-${formId}` : undefined;\n const helperTextId = formId ? `helperText-${formId}` : undefined;\n\n return (\n <div\n ref={
|
|
1
|
+
{"version":3,"file":"FormField.js","sources":["../src/form-field/FormField.tsx"],"sourcesContent":["import { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { clsx } from \"clsx\";\nimport { type HTMLAttributes, forwardRef, useRef } from \"react\";\nimport { type A11yValueProps, FormFieldContext } from \"../form-field-context\";\nimport { capitalize, makePrefixer, useForkRef, useId } from \"../utils\";\n\nimport formFieldCss from \"./FormField.css\";\n\nexport type FormFieldLabelPlacement = \"top\" | \"left\" | \"right\";\n\nexport interface FormFieldProps\n extends HTMLAttributes<HTMLDivElement>,\n A11yValueProps {\n /**\n * If `true`, the field will be disabled.\n */\n disabled?: boolean;\n /**\n * Location of the label relative to the control.\n *\n * Either 'top', 'left', or 'right'`.\n */\n labelPlacement?: FormFieldLabelPlacement;\n /**\n * If `true`, the field will be read-only.\n */\n readOnly?: boolean;\n /**\n * Optional id prop\n *\n * Used as suffix of FormFieldLabel id: `label-{id}`\n * Used as suffix of FormFieldHelperText id: `helperText-{id}`\n */\n id?: string;\n /**\n * Displays necessity on label\n */\n necessity?: \"required\" | \"optional\" | \"asterisk\";\n /**\n * Validation status\n */\n validationStatus?: \"error\" | \"warning\" | \"success\";\n}\n\nconst withBaseName = makePrefixer(\"saltFormField\");\n\nexport const FormField = forwardRef<HTMLDivElement, FormFieldProps>(\n (\n {\n children,\n className,\n disabled = false,\n id: idProp,\n labelPlacement = \"top\",\n necessity,\n readOnly = false,\n validationStatus,\n ...restProps\n },\n ref,\n ) => {\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-form-field\",\n css: formFieldCss,\n window: targetWindow,\n });\n\n const formFieldRef = useRef<HTMLDivElement>(null);\n const handleRef = useForkRef(ref, formFieldRef);\n\n const formId = useId(idProp);\n\n const labelId = formId ? `label-${formId}` : undefined;\n const helperTextId = formId ? `helperText-${formId}` : undefined;\n\n return (\n <div\n ref={handleRef}\n className={clsx(\n withBaseName(),\n {\n [withBaseName(\"disabled\")]: disabled,\n [withBaseName(`label${capitalize(labelPlacement)}`)]:\n labelPlacement,\n },\n className,\n )}\n {...restProps}\n >\n <FormFieldContext.Provider\n value={{\n a11yProps: {\n \"aria-labelledby\": labelId,\n \"aria-describedby\": helperTextId,\n },\n disabled,\n necessity,\n readOnly,\n validationStatus,\n formFieldRef,\n }}\n >\n {children}\n </FormFieldContext.Provider>\n </div>\n );\n },\n);\n"],"names":["makePrefixer","forwardRef","useWindow","useComponentCssInjection","formFieldCss","useRef","useForkRef","useId","jsx","clsx","capitalize","FormFieldContext"],"mappings":";;;;;;;;;;;;;;;;;AA6CA,MAAM,YAAA,GAAeA,0BAAa,eAAe,CAAA;AAE1C,MAAM,SAAY,GAAAC,gBAAA;AAAA,EACvB,CACE;AAAA,IACE,QAAA;AAAA,IACA,SAAA;AAAA,IACA,QAAW,GAAA,KAAA;AAAA,IACX,EAAI,EAAA,MAAA;AAAA,IACJ,cAAiB,GAAA,KAAA;AAAA,IACjB,SAAA;AAAA,IACA,QAAW,GAAA,KAAA;AAAA,IACX,gBAAA;AAAA,IACA,GAAG;AAAA,KAEL,GACG,KAAA;AACH,IAAA,MAAM,eAAeC,gBAAU,EAAA;AAC/B,IAAyBC,+BAAA,CAAA;AAAA,MACvB,MAAQ,EAAA,iBAAA;AAAA,MACR,GAAK,EAAAC,WAAA;AAAA,MACL,MAAQ,EAAA;AAAA,KACT,CAAA;AAED,IAAM,MAAA,YAAA,GAAeC,aAAuB,IAAI,CAAA;AAChD,IAAM,MAAA,SAAA,GAAYC,qBAAW,CAAA,GAAA,EAAK,YAAY,CAAA;AAE9C,IAAM,MAAA,MAAA,GAASC,YAAM,MAAM,CAAA;AAE3B,IAAA,MAAM,OAAU,GAAA,MAAA,GAAS,CAAS,MAAA,EAAA,MAAM,CAAK,CAAA,GAAA,MAAA;AAC7C,IAAA,MAAM,YAAe,GAAA,MAAA,GAAS,CAAc,WAAA,EAAA,MAAM,CAAK,CAAA,GAAA,MAAA;AAEvD,IACE,uBAAAC,cAAA;AAAA,MAAC,KAAA;AAAA,MAAA;AAAA,QACC,GAAK,EAAA,SAAA;AAAA,QACL,SAAW,EAAAC,SAAA;AAAA,UACT,YAAa,EAAA;AAAA,UACb;AAAA,YACE,CAAC,YAAA,CAAa,UAAU,CAAC,GAAG,QAAA;AAAA,YAC5B,CAAC,aAAa,CAAQ,KAAA,EAAAC,qBAAA,CAAW,cAAc,CAAC,CAAA,CAAE,CAAC,GACjD;AAAA,WACJ;AAAA,UACA;AAAA,SACF;AAAA,QACC,GAAG,SAAA;AAAA,QAEJ,QAAA,kBAAAF,cAAA;AAAA,UAACG,iCAAiB,CAAA,QAAA;AAAA,UAAjB;AAAA,YACC,KAAO,EAAA;AAAA,cACL,SAAW,EAAA;AAAA,gBACT,iBAAmB,EAAA,OAAA;AAAA,gBACnB,kBAAoB,EAAA;AAAA,eACtB;AAAA,cACA,QAAA;AAAA,cACA,SAAA;AAAA,cACA,QAAA;AAAA,cACA,gBAAA;AAAA,cACA;AAAA,aACF;AAAA,YAEC;AAAA;AAAA;AACH;AAAA,KACF;AAAA;AAGN;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var css_248z = ".saltFormFieldHelperText {\n cursor: default;\n display: flex;\n flex-direction: row;\n width: 100%;\n}\n\n.saltFormFieldHelperText .saltText {\n font-style: var(--saltFormField-helperText-fontStyle, var(--salt-editable-help-fontStyle));\n}\n\n.saltFormFieldHelperText-withValidation {\n column-gap: var(--salt-spacing-75);\n}\n";
|
|
3
|
+
var css_248z = ".saltFormFieldHelperText {\n cursor: default;\n display: flex;\n flex-direction: row;\n width: 100%;\n}\n\n.saltFormFieldHelperText .saltText {\n font-style: var(--saltFormField-helperText-fontStyle, var(--salt-editable-help-fontStyle));\n}\n\n.saltFormFieldHelperText-withValidation {\n column-gap: var(--salt-spacing-75);\n}\n\n.saltFormFieldHelperText .saltFormFieldHelperText-statusIndicator {\n margin-top: calc((var(--salt-text-label-lineHeight) - max(var(--salt-size-icon), 12px)) / 2);\n}\n";
|
|
4
4
|
|
|
5
5
|
module.exports = css_248z;
|
|
6
6
|
//# sourceMappingURL=FormFieldHelperText.css.js.map
|
|
@@ -44,7 +44,13 @@ const FormFieldHelperText = ({
|
|
|
44
44
|
className
|
|
45
45
|
),
|
|
46
46
|
children: [
|
|
47
|
-
!disabled && !readOnly && validationStatus && /* @__PURE__ */ jsxRuntime.jsx(
|
|
47
|
+
!disabled && !readOnly && validationStatus && /* @__PURE__ */ jsxRuntime.jsx(
|
|
48
|
+
StatusIndicator.StatusIndicator,
|
|
49
|
+
{
|
|
50
|
+
className: withBaseName("statusIndicator"),
|
|
51
|
+
status: validationStatus
|
|
52
|
+
}
|
|
53
|
+
),
|
|
48
54
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
49
55
|
Text.Text,
|
|
50
56
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormFieldHelperText.js","sources":["../src/form-field/FormFieldHelperText.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { useFormFieldProps } from \"../form-field-context\";\nimport { StatusIndicator } from \"../status-indicator\";\nimport { Text, type TextProps } from \"../text\";\nimport { makePrefixer } from \"../utils\";\n\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\n\nimport formFieldHelperTextCss from \"./FormFieldHelperText.css\";\n\nconst withBaseName = makePrefixer(\"saltFormFieldHelperText\");\n\nexport interface FormFieldHelperTextProps\n extends Omit<TextProps<\"label\">, \"variant\" | \"styleAs\"> {}\n\nexport const FormFieldHelperText = ({\n className,\n children,\n ...restProps\n}: FormFieldHelperTextProps) => {\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-form-field-helper-text\",\n css: formFieldHelperTextCss,\n window: targetWindow,\n });\n\n const { a11yProps, disabled, readOnly, validationStatus } =\n useFormFieldProps();\n\n return (\n <div\n className={clsx(\n withBaseName(),\n { [withBaseName(\"withValidation\")]: validationStatus },\n className,\n )}\n >\n {!disabled && !readOnly && validationStatus && (\n <StatusIndicator
|
|
1
|
+
{"version":3,"file":"FormFieldHelperText.js","sources":["../src/form-field/FormFieldHelperText.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { useFormFieldProps } from \"../form-field-context\";\nimport { StatusIndicator } from \"../status-indicator\";\nimport { Text, type TextProps } from \"../text\";\nimport { makePrefixer } from \"../utils\";\n\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\n\nimport formFieldHelperTextCss from \"./FormFieldHelperText.css\";\n\nconst withBaseName = makePrefixer(\"saltFormFieldHelperText\");\n\nexport interface FormFieldHelperTextProps\n extends Omit<TextProps<\"label\">, \"variant\" | \"styleAs\"> {}\n\nexport const FormFieldHelperText = ({\n className,\n children,\n ...restProps\n}: FormFieldHelperTextProps) => {\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-form-field-helper-text\",\n css: formFieldHelperTextCss,\n window: targetWindow,\n });\n\n const { a11yProps, disabled, readOnly, validationStatus } =\n useFormFieldProps();\n\n return (\n <div\n className={clsx(\n withBaseName(),\n { [withBaseName(\"withValidation\")]: validationStatus },\n className,\n )}\n >\n {!disabled && !readOnly && validationStatus && (\n <StatusIndicator\n className={withBaseName(\"statusIndicator\")}\n status={validationStatus}\n />\n )}\n <Text\n disabled={disabled}\n id={a11yProps?.[\"aria-describedby\"]}\n styleAs=\"label\"\n color={validationStatus ?? \"secondary\"}\n {...restProps}\n >\n {children}\n </Text>\n </div>\n );\n};\n"],"names":["makePrefixer","useWindow","useComponentCssInjection","formFieldHelperTextCss","useFormFieldProps","jsxs","jsx","StatusIndicator","Text"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAWA,MAAM,YAAA,GAAeA,0BAAa,yBAAyB,CAAA;AAKpD,MAAM,sBAAsB,CAAC;AAAA,EAClC,SAAA;AAAA,EACA,QAAA;AAAA,EACA,GAAG;AACL,CAAgC,KAAA;AAC9B,EAAA,MAAM,eAAeC,gBAAU,EAAA;AAC/B,EAAyBC,+BAAA,CAAA;AAAA,IACvB,MAAQ,EAAA,6BAAA;AAAA,IACR,GAAK,EAAAC,qBAAA;AAAA,IACL,MAAQ,EAAA;AAAA,GACT,CAAA;AAED,EAAA,MAAM,EAAE,SAAW,EAAA,QAAA,EAAU,QAAU,EAAA,gBAAA,KACrCC,mCAAkB,EAAA;AAEpB,EACE,uBAAAC,eAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,SAAW,EAAA,IAAA;AAAA,QACT,YAAa,EAAA;AAAA,QACb,EAAE,CAAC,YAAA,CAAa,gBAAgB,CAAC,GAAG,gBAAiB,EAAA;AAAA,QACrD;AAAA,OACF;AAAA,MAEC,QAAA,EAAA;AAAA,QAAC,CAAA,QAAA,IAAY,CAAC,QAAA,IAAY,gBACzB,oBAAAC,cAAA;AAAA,UAACC,+BAAA;AAAA,UAAA;AAAA,YACC,SAAA,EAAW,aAAa,iBAAiB,CAAA;AAAA,YACzC,MAAQ,EAAA;AAAA;AAAA,SACV;AAAA,wBAEFD,cAAA;AAAA,UAACE,SAAA;AAAA,UAAA;AAAA,YACC,QAAA;AAAA,YACA,IAAI,SAAY,IAAA,IAAA,GAAA,MAAA,GAAA,SAAA,CAAA,kBAAA,CAAA;AAAA,YAChB,OAAQ,EAAA,OAAA;AAAA,YACR,OAAO,gBAAoB,IAAA,WAAA;AAAA,YAC1B,GAAG,SAAA;AAAA,YAEH;AAAA;AAAA;AACH;AAAA;AAAA,GACF;AAEJ;;;;"}
|
|
@@ -27,24 +27,36 @@ const FormFieldLabel = ({
|
|
|
27
27
|
className,
|
|
28
28
|
children,
|
|
29
29
|
intent = "label",
|
|
30
|
+
onClick,
|
|
30
31
|
...restProps
|
|
31
32
|
}) => {
|
|
32
|
-
const { a11yProps, disabled, necessity } = useFormFieldProps.useFormFieldProps();
|
|
33
|
+
const { a11yProps, disabled, necessity, formFieldRef } = useFormFieldProps.useFormFieldProps();
|
|
33
34
|
const targetWindow = window.useWindow();
|
|
34
35
|
styles.useComponentCssInjection({
|
|
35
36
|
testId: "salt-form-field-label",
|
|
36
37
|
css: FormFieldLabel$1,
|
|
37
38
|
window: targetWindow
|
|
38
39
|
});
|
|
40
|
+
const id = a11yProps == null ? void 0 : a11yProps["aria-labelledby"];
|
|
41
|
+
const handleClick = (event) => {
|
|
42
|
+
if (formFieldRef == null ? void 0 : formFieldRef.current) {
|
|
43
|
+
const element = formFieldRef.current.querySelector(
|
|
44
|
+
`[aria-labelledby*="${id}"]`
|
|
45
|
+
);
|
|
46
|
+
element == null ? void 0 : element.focus();
|
|
47
|
+
element == null ? void 0 : element.click();
|
|
48
|
+
}
|
|
49
|
+
onClick == null ? void 0 : onClick(event);
|
|
50
|
+
};
|
|
39
51
|
const necessityLabel = necessity ? necessity === "asterisk" ? " *" : ` (${capitalize.capitalize(necessity)})` : void 0;
|
|
40
52
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
41
53
|
Label.Label,
|
|
42
54
|
{
|
|
43
|
-
as: "label",
|
|
44
55
|
className: clsx.clsx(withBaseName(), withBaseName(intent), className),
|
|
45
|
-
id
|
|
56
|
+
id,
|
|
46
57
|
disabled,
|
|
47
58
|
variant: "secondary",
|
|
59
|
+
onClick: handleClick,
|
|
48
60
|
...restProps,
|
|
49
61
|
children: [
|
|
50
62
|
children,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormFieldLabel.js","sources":["../src/form-field/FormFieldLabel.tsx"],"sourcesContent":["import { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { clsx } from \"clsx\";\nimport { useFormFieldProps } from \"../form-field-context\";\nimport { Label, type TextProps } from \"../text\";\nimport { capitalize, makePrefixer } from \"../utils\";\n\nimport formFieldLabelCss from \"./FormFieldLabel.css\";\n\nconst withBaseName = makePrefixer(\"saltFormFieldLabel\");\n\nexport interface FormFieldLabelProps\n extends Omit<TextProps<\"label\">, \"variant\" | \"styleAs\"> {\n /**\n * Intent for the label.\n *\n * Defaults to \"label\"\n * Using \"sentence\" gives more prominent styling\n */\n intent?: \"label\" | \"sentence\";\n}\n\nexport const FormFieldLabel = ({\n className,\n children,\n intent = \"label\",\n ...restProps\n}: FormFieldLabelProps) => {\n const { a11yProps, disabled, necessity } = useFormFieldProps();\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-form-field-label\",\n css: formFieldLabelCss,\n window: targetWindow,\n });\n\n const necessityLabel = necessity\n ? necessity === \"asterisk\"\n ? \" *\"\n : ` (${capitalize(necessity)})`\n : undefined;\n\n return (\n <Label\n
|
|
1
|
+
{"version":3,"file":"FormFieldLabel.js","sources":["../src/form-field/FormFieldLabel.tsx"],"sourcesContent":["import { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { clsx } from \"clsx\";\nimport type { MouseEvent } from \"react\";\n\nimport { useFormFieldProps } from \"../form-field-context\";\nimport { Label, type TextProps } from \"../text\";\nimport { capitalize, makePrefixer } from \"../utils\";\n\nimport formFieldLabelCss from \"./FormFieldLabel.css\";\n\nconst withBaseName = makePrefixer(\"saltFormFieldLabel\");\n\nexport interface FormFieldLabelProps\n extends Omit<TextProps<\"label\">, \"variant\" | \"styleAs\"> {\n /**\n * Intent for the label.\n *\n * Defaults to \"label\"\n * Using \"sentence\" gives more prominent styling\n */\n intent?: \"label\" | \"sentence\";\n}\n\nexport const FormFieldLabel = ({\n className,\n children,\n intent = \"label\",\n onClick,\n ...restProps\n}: FormFieldLabelProps) => {\n const { a11yProps, disabled, necessity, formFieldRef } = useFormFieldProps();\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"salt-form-field-label\",\n css: formFieldLabelCss,\n window: targetWindow,\n });\n\n const id = a11yProps?.[\"aria-labelledby\"];\n\n const handleClick = (event: MouseEvent<HTMLLabelElement>) => {\n if (formFieldRef?.current) {\n const element = formFieldRef.current.querySelector<HTMLElement>(\n `[aria-labelledby*=\"${id}\"]`,\n );\n element?.focus();\n element?.click();\n }\n onClick?.(event);\n };\n\n const necessityLabel = necessity\n ? necessity === \"asterisk\"\n ? \" *\"\n : ` (${capitalize(necessity)})`\n : undefined;\n\n return (\n <Label\n className={clsx(withBaseName(), withBaseName(intent), className)}\n id={id}\n disabled={disabled}\n variant=\"secondary\"\n onClick={handleClick}\n {...restProps}\n >\n {children}\n {necessityLabel && (\n <span className={withBaseName(\"necessityLabel\")}>{necessityLabel}</span>\n )}\n </Label>\n );\n};\n"],"names":["makePrefixer","useFormFieldProps","useWindow","useComponentCssInjection","formFieldLabelCss","capitalize","jsxs","Label","clsx","jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAWA,MAAM,YAAA,GAAeA,0BAAa,oBAAoB,CAAA;AAa/C,MAAM,iBAAiB,CAAC;AAAA,EAC7B,SAAA;AAAA,EACA,QAAA;AAAA,EACA,MAAS,GAAA,OAAA;AAAA,EACT,OAAA;AAAA,EACA,GAAG;AACL,CAA2B,KAAA;AACzB,EAAA,MAAM,EAAE,SAAW,EAAA,QAAA,EAAU,SAAW,EAAA,YAAA,KAAiBC,mCAAkB,EAAA;AAC3E,EAAA,MAAM,eAAeC,gBAAU,EAAA;AAC/B,EAAyBC,+BAAA,CAAA;AAAA,IACvB,MAAQ,EAAA,uBAAA;A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-field-context/FormFieldContext.ts"],"sourcesContent":["import { createContext } from \"../utils\";\n\nexport interface A11yValueProps {\n /**\n * id for FormFieldHelperText\n */\n helperTextId?: string;\n /**\n * id for FormFieldLabel\n */\n labelId?: string;\n}\n\nexport type NecessityType = \"required\" | \"optional\" | \"asterisk\";\n\nexport interface a11yValueAriaProps {\n \"aria-labelledby\": A11yValueProps[\"labelId\"];\n \"aria-describedby\": A11yValueProps[\"helperTextId\"] | undefined;\n}\n\nexport interface FormFieldContextValue {\n a11yProps: a11yValueAriaProps;\n disabled: boolean;\n necessity: NecessityType | undefined;\n readOnly: boolean;\n validationStatus: \"error\" | \"warning\" | \"success\" | undefined;\n}\n\nexport const FormFieldContext = createContext(\n \"FormFieldContext\",\n {} as FormFieldContextValue,\n);\n"],"names":["createContext"],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"FormFieldContext.js","sources":["../src/form-field-context/FormFieldContext.ts"],"sourcesContent":["import type { RefObject } from \"react\";\nimport { createContext } from \"../utils\";\n\nexport interface A11yValueProps {\n /**\n * id for FormFieldHelperText\n */\n helperTextId?: string;\n /**\n * id for FormFieldLabel\n */\n labelId?: string;\n}\n\nexport type NecessityType = \"required\" | \"optional\" | \"asterisk\";\n\nexport interface a11yValueAriaProps {\n \"aria-labelledby\": A11yValueProps[\"labelId\"];\n \"aria-describedby\": A11yValueProps[\"helperTextId\"] | undefined;\n}\n\nexport interface FormFieldContextValue {\n a11yProps: a11yValueAriaProps;\n disabled: boolean;\n necessity: NecessityType | undefined;\n readOnly: boolean;\n validationStatus: \"error\" | \"warning\" | \"success\" | undefined;\n formFieldRef?: RefObject<HTMLDivElement>;\n}\n\nexport const FormFieldContext = createContext(\n \"FormFieldContext\",\n {} as FormFieldContextValue,\n);\n"],"names":["createContext"],"mappings":";;;;;;;;;;;AA8BO,MAAM,gBAAmB,GAAAA,2BAAA;AAAA,EAC9B,kBAAA;AAAA,EACA;AACF;;;;"}
|