@react-spectrum/s2 3.0.0-nightly-5ed06068e-241105 → 3.0.0-nightly-09ccc53e7-241107
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/ActionButton.cjs +54 -11
- package/dist/ActionButton.cjs.map +1 -1
- package/dist/ActionButton.css +47 -3
- package/dist/ActionButton.css.map +1 -1
- package/dist/ActionButton.mjs +55 -12
- package/dist/ActionButton.mjs.map +1 -1
- package/dist/ActionButtonGroup.cjs +77 -0
- package/dist/ActionButtonGroup.cjs.map +1 -0
- package/dist/ActionButtonGroup.css +44 -0
- package/dist/ActionButtonGroup.css.map +1 -0
- package/dist/ActionButtonGroup.mjs +70 -0
- package/dist/ActionButtonGroup.mjs.map +1 -0
- package/dist/Badge.cjs +42 -42
- package/dist/Badge.css +35 -35
- package/dist/Badge.mjs +42 -42
- package/dist/Card.cjs +1 -1
- package/dist/Card.css +1 -1
- package/dist/Card.mjs +1 -1
- package/dist/Content.cjs +1 -0
- package/dist/Content.cjs.map +1 -1
- package/dist/Content.mjs +1 -0
- package/dist/Content.mjs.map +1 -1
- package/dist/ContextualHelp.cjs +1 -1
- package/dist/ContextualHelp.cjs.map +1 -1
- package/dist/ContextualHelp.css +32 -16
- package/dist/ContextualHelp.css.map +1 -1
- package/dist/ContextualHelp.mjs +1 -1
- package/dist/ContextualHelp.mjs.map +1 -1
- package/dist/IllustratedMessage.cjs +6 -2
- package/dist/IllustratedMessage.cjs.map +1 -1
- package/dist/IllustratedMessage.css +2 -2
- package/dist/IllustratedMessage.css.map +1 -1
- package/dist/IllustratedMessage.mjs +6 -2
- package/dist/IllustratedMessage.mjs.map +1 -1
- package/dist/InlineAlert.cjs +8 -8
- package/dist/InlineAlert.css +6 -6
- package/dist/InlineAlert.mjs +8 -8
- package/dist/Meter.cjs +4 -17
- package/dist/Meter.cjs.map +1 -1
- package/dist/Meter.css +7 -19
- package/dist/Meter.css.map +1 -1
- package/dist/Meter.mjs +4 -17
- package/dist/Meter.mjs.map +1 -1
- package/dist/Modal.cjs +1 -1
- package/dist/Modal.css +1 -1
- package/dist/Modal.mjs +1 -1
- package/dist/Picker.cjs +3 -0
- package/dist/Picker.cjs.map +1 -1
- package/dist/Picker.css +12 -0
- package/dist/Picker.css.map +1 -1
- package/dist/Picker.mjs +3 -0
- package/dist/Picker.mjs.map +1 -1
- package/dist/Popover.cjs +1 -1
- package/dist/Popover.css +1 -1
- package/dist/Popover.mjs +1 -1
- package/dist/ProgressBar.cjs +19 -3
- package/dist/ProgressBar.cjs.map +1 -1
- package/dist/ProgressBar.css +14 -0
- package/dist/ProgressBar.css.map +1 -1
- package/dist/ProgressBar.mjs +19 -3
- package/dist/ProgressBar.mjs.map +1 -1
- package/dist/Provider.cjs +1 -1
- package/dist/Provider.css +1 -1
- package/dist/Provider.mjs +1 -1
- package/dist/Radio.cjs +2 -2
- package/dist/Radio.cjs.map +1 -1
- package/dist/Radio.css +4 -8
- package/dist/Radio.css.map +1 -1
- package/dist/Radio.mjs +2 -2
- package/dist/Radio.mjs.map +1 -1
- package/dist/SegmentedControl.cjs +76 -62
- package/dist/SegmentedControl.cjs.map +1 -1
- package/dist/SegmentedControl.css +110 -69
- package/dist/SegmentedControl.css.map +1 -1
- package/dist/SegmentedControl.mjs +77 -63
- package/dist/SegmentedControl.mjs.map +1 -1
- package/dist/ToggleButton.cjs +13 -6
- package/dist/ToggleButton.cjs.map +1 -1
- package/dist/ToggleButton.css +16 -0
- package/dist/ToggleButton.css.map +1 -1
- package/dist/ToggleButton.mjs +14 -7
- package/dist/ToggleButton.mjs.map +1 -1
- package/dist/ToggleButtonGroup.cjs +54 -0
- package/dist/ToggleButtonGroup.cjs.map +1 -0
- package/dist/ToggleButtonGroup.mjs +48 -0
- package/dist/ToggleButtonGroup.mjs.map +1 -0
- package/dist/main.cjs +8 -0
- package/dist/main.cjs.map +1 -1
- package/dist/module.mjs +5 -1
- package/dist/module.mjs.map +1 -1
- package/dist/types.d.ts +57 -12
- package/dist/types.d.ts.map +1 -1
- package/package.json +17 -17
- package/src/ActionButton.tsx +88 -8
- package/src/ActionButtonGroup.tsx +106 -0
- package/src/Content.tsx +2 -1
- package/src/ContextualHelp.tsx +1 -1
- package/src/IllustratedMessage.tsx +1 -3
- package/src/Meter.tsx +4 -4
- package/src/Picker.tsx +10 -1
- package/src/ProgressBar.tsx +20 -3
- package/src/Radio.tsx +1 -3
- package/src/SegmentedControl.tsx +56 -45
- package/src/ToggleButton.tsx +23 -7
- package/src/ToggleButtonGroup.tsx +55 -0
- package/src/index.ts +4 -0
- package/style/dist/spectrum-theme.cjs +5 -0
- package/style/dist/spectrum-theme.cjs.map +1 -1
- package/style/dist/spectrum-theme.mjs +5 -0
- package/style/dist/spectrum-theme.mjs.map +1 -1
- package/style/dist/types.d.ts +2 -2
- package/style/dist/types.d.ts.map +1 -1
- package/style/spectrum-theme.ts +5 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;AA0CM,MAAM,0DAA0B,CAAA,GAAA,0BAAY,EAAoE;AAEvH,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQN,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCN,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCN,MAAM,sEAAkC,CAAA,GAAA,0BAAY,EAAwC,CAAC;AAE7F,SAAS,uCAAiB,KAA4B,EAAE,GAA2B;IACjF,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,iDAAsB,EAAE,OAAO,KAAK;IACnD,IAAI,sBACF,kBAAkB,eAClB,WAAW,qBACX,iBAAiB,EAClB,GAAG;IACJ,IAAI,SAAS,CAAA,GAAA,mCAAQ,EAAE;IAEvB,IAAI,UAAU,CAAA,GAAA,mBAAK,EAAW;IAC9B,IAAI,qBAA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D;;oBACG,4BAAc,gCAAC;wBAAI,WAAW,6BAAO;4CAAC;wCAAgB;wBAAU;wBAAI,KAAK;;kCAC1E,gCAAC,CAAA,GAAA,mCAAO;wBACN,QAAQ;4BACN;gCAAC,CAAA,GAAA,qCAAU;gCAAG;oCACZ,QAAQ,CAAA,GAAA,wCAAa,EAAE;wCAAC,MAAM;wCAAQ,MAAM;oCAAkC;gCAChF;6BAAE;4BACF;gCAAC,CAAA,GAAA,sCAAa;gCAAG;oCAAC,OAAO;wCAAC,CAAC,CAAA,GAAA,uCAAW,EAAE,EAAE,CAAC;oCAAC;gCAAC;6BAAE;4BAC/C;gCAAC,CAAA,GAAA,qCAAU;gCAAG;oCAAC,MAAM;gCAAmC;6BAAE;yBAC3D;kCACD,cAAA,gCAAC;4BAAI,KAAK;4BAAQ,OAAO,CAAA,GAAA,oCAAS,EAAE,QAAQ;2CAAC;4BAAS;4BAAI,SAAS;sCAChE,OAAO,MAAM,QAAQ,KAAK,yBAAW,gCAAC,CAAA,GAAA,8BAAG;0CAAG,MAAM,QAAQ;iCAAW,MAAM,QAAQ;;;;;;AAQlG;AAEA;;CAEC,GACD,MAAM,4CAAwB,WAAW,GAAG,CAAA,GAAA,uBAAS,EAAE;AAGvD;;CAEC,GACD,MAAM,4CAAoB,WAAW,GAAG,CAAA,GAAA,uBAAS,EAAE","sources":["packages/@react-spectrum/s2/src/SegmentedControl.tsx"],"sourcesContent":["/*\n * Copyright 2024 Adobe. 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 http://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 {AriaLabelingProps, DOMRef, DOMRefValue, FocusableRef} from '@react-types/shared';\nimport {centerBaseline} from './CenterBaseline';\nimport {ContextValue, DEFAULT_SLOT, Provider, TextContext as RACTextContext, Radio, RadioGroup, RadioGroupStateContext, SlotProps} from 'react-aria-components';\nimport {createContext, forwardRef, ReactNode, RefObject, useCallback, useContext, useRef} from 'react';\nimport {focusRing, size, style} from '../style' with {type: 'macro'};\nimport {getAllowedOverrides, StyleProps} from './style-utils' with {type: 'macro'};\nimport {IconContext} from './Icon';\nimport {pressScale} from './pressScale';\nimport {Text, TextContext} from './Content';\nimport {useDOMRef, useFocusableRef} from '@react-spectrum/utils';\nimport {useLayoutEffect} from '@react-aria/utils';\nimport {useSpectrumContextProps} from './useSpectrumContextProps';\n\nexport interface SegmentedControlProps extends AriaLabelingProps, StyleProps, SlotProps {\n /**\n * The content to display in the segmented control.\n */\n children: ReactNode,\n /**\n * Whether the segmented control is disabled.\n */\n isDisabled?: boolean,\n /** The id of the currently selected item (controlled). */\n selectedKey?: string | null,\n /** The id of the initial selected item (uncontrolled). */\n defaultSelectedKey?: string,\n /** Handler that is called when the selection changes. */\n onSelectionChange?: (id: string) => void\n}\nexport interface SegmentedControlItemProps extends AriaLabelingProps, StyleProps {\n /**\n * The content to display in the segmented control item.\n */\n children: ReactNode,\n /** The id of the item, matching the value used in SegmentedControl's `selectedKey` prop. */\n id: string,\n /** Whether the item is disabled or not. */\n isDisabled?: boolean\n}\n\nexport const SegmentedControlContext = createContext<ContextValue<SegmentedControlProps, DOMRefValue<HTMLDivElement>>>(null);\n\nconst segmentedControl = style<{size: string}>({\n font: 'control',\n display: 'flex',\n backgroundColor: 'gray-100',\n borderRadius: 'lg',\n width: 'full'\n}, getAllowedOverrides());\n\nconst controlItem = style({\n position: 'relative',\n display: 'flex',\n forcedColorAdjust: 'none',\n color: {\n default: 'gray-700',\n isHovered: 'neutral-subdued',\n isSelected: 'neutral',\n isDisabled: 'disabled',\n forcedColors: {\n default: 'ButtonText',\n isDisabled: 'GrayText',\n isSelected: 'HighlightText'\n }\n },\n // TODO: update this padding for icon-only items when we introduce the non-track style back\n paddingX: {\n default: 'edge-to-text',\n ':has([slot=icon]:only-child)': size(6)\n },\n height: 32,\n alignItems: 'center',\n flexBasis: 0,\n flexGrow: 1,\n flexShrink: 0,\n minWidth: 0,\n justifyContent: 'center',\n whiteSpace: 'nowrap',\n disableTapHighlight: true,\n '--iconPrimary': {\n type: 'fill',\n value: 'currentColor'\n }\n}, getAllowedOverrides());\n\nconst slider = style({\n ...focusRing(),\n backgroundColor: {\n default: 'gray-25',\n forcedColors: {\n default: 'Highlight',\n isDisabled: 'GrayText'\n }\n },\n left: 0,\n width: 'full',\n height: 'full',\n position: 'absolute',\n boxSizing: 'border-box',\n borderStyle: 'solid',\n borderWidth: 2,\n borderColor: {\n default: 'gray-900',\n isDisabled: 'disabled',\n forcedColors: {\n default: 'Highlight',\n isDisabled: 'GrayText'\n }\n },\n borderRadius: 'lg'\n});\n\ninterface InternalSegmentedControlContextProps {\n register?: (value: string, isDisabled?: boolean) => void,\n prevRef?: RefObject<DOMRect | null>,\n currentSelectedRef?: RefObject<HTMLDivElement | null>\n}\n\ninterface DefaultSelectionTrackProps {\n defaultValue?: string | null,\n value?: string | null,\n children?: ReactNode,\n prevRef: RefObject<DOMRect | null>,\n currentSelectedRef: RefObject<HTMLDivElement | null>\n}\n\nconst InternalSegmentedControlContext = createContext<InternalSegmentedControlContextProps>({});\n\nfunction SegmentedControl(props: SegmentedControlProps, ref: DOMRef<HTMLDivElement>) {\n [props, ref] = useSpectrumContextProps(props, ref, SegmentedControlContext);\n let {\n defaultSelectedKey,\n selectedKey,\n onSelectionChange\n } = props;\n let domRef = useDOMRef(ref);\n\n let prevRef = useRef<DOMRect>(null);\n let currentSelectedRef = useRef<HTMLDivElement>(null);\n\n let onChange = (value: string) => {\n if (currentSelectedRef.current) {\n prevRef.current = currentSelectedRef?.current.getBoundingClientRect();\n }\n \n if (onSelectionChange) {\n onSelectionChange(value);\n }\n };\n\n return (\n <RadioGroup \n {...props}\n value={selectedKey}\n defaultValue={defaultSelectedKey}\n ref={domRef}\n orientation=\"horizontal\"\n style={props.UNSAFE_style}\n onChange={onChange}\n className={(props.UNSAFE_className || '') + segmentedControl({size: 'M'}, props.styles)}\n aria-label={props['aria-label']}>\n <DefaultSelectionTracker defaultValue={defaultSelectedKey} value={selectedKey} prevRef={prevRef} currentSelectedRef={currentSelectedRef}>\n {props.children}\n </DefaultSelectionTracker>\n </RadioGroup>\n );\n}\n\nfunction DefaultSelectionTracker(props: DefaultSelectionTrackProps) {\n let state = useContext(RadioGroupStateContext);\n let isRegistered = useRef(!(props.defaultValue == null && props.value == null));\n\n // default select the first available item\n let register = useCallback((value: string) => {\n if (state && !isRegistered.current) {\n isRegistered.current = true;\n state.setSelectedValue(value);\n }\n }, []);\n\n return (\n <Provider\n values={[\n [InternalSegmentedControlContext, {register: register, prevRef: props.prevRef, currentSelectedRef: props.currentSelectedRef}]\n ]}> \n {props.children}\n </Provider>\n );\n}\n\nfunction SegmentedControlItem(props: SegmentedControlItemProps, ref: FocusableRef<HTMLLabelElement>) {\n let inputRef = useRef<HTMLInputElement>(null);\n let domRef = useFocusableRef(ref, inputRef);\n let divRef = useRef<HTMLDivElement>(null);\n let {register, prevRef, currentSelectedRef} = useContext(InternalSegmentedControlContext);\n let state = useContext(RadioGroupStateContext);\n let isSelected = props.id === state?.selectedValue;\n // do not apply animation if a user has the prefers-reduced-motion setting\n let isReduced = false;\n if (window?.matchMedia) {\n isReduced = window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n }\n\n useLayoutEffect(() => {\n register?.(props.id);\n }, []);\n\n useLayoutEffect(() => {\n if (isSelected && prevRef?.current && currentSelectedRef?.current && !isReduced) {\n let currentItem = currentSelectedRef?.current.getBoundingClientRect();\n\n let deltaX = prevRef?.current.left - currentItem?.left;\n\n currentSelectedRef.current.animate(\n [\n {transform: `translateX(${deltaX}px)`, width: `${prevRef?.current.width}px`},\n {transform: 'translateX(0px)', width: `${currentItem.width}px`}\n ],\n {\n duration: 200,\n easing: 'ease-out'\n }\n );\n\n prevRef.current = null;\n }\n }, [isSelected]);\n\n return (\n <Radio \n {...props}\n value={props.id}\n ref={domRef} \n inputRef={inputRef}\n style={props.UNSAFE_style}\n className={renderProps => (props.UNSAFE_className || '') + controlItem({...renderProps}, props.styles)} >\n {({isSelected, isFocusVisible, isPressed, isDisabled}) => (\n <>\n {isSelected && <div className={slider({isFocusVisible, isDisabled})} ref={currentSelectedRef} />}\n <Provider \n values={[\n [IconContext, {\n render: centerBaseline({slot: 'icon', styles: style({order: 0, flexShrink: 0})})\n }],\n [RACTextContext, {slots: {[DEFAULT_SLOT]: {}}}],\n [TextContext, {styles: style({order: 1, truncate: true})}]\n ]}>\n <div ref={divRef} style={pressScale(divRef)({isPressed})} className={style({zIndex: 1, display: 'flex', gap: 'text-to-visual', transition: 'default', alignItems: 'center', minWidth: 0})}>\n {typeof props.children === 'string' ? <Text>{props.children}</Text> : props.children}\n </div>\n </Provider>\n </>\n )\n }\n </Radio>\n );\n}\n\n/**\n * A SegmentedControlItem represents an option within a SegmentedControl.\n */\nconst _SegmentedControlItem = /*#__PURE__*/ forwardRef(SegmentedControlItem);\nexport {_SegmentedControlItem as SegmentedControlItem};\n\n/**\n * A SegmentedControl is a mutually exclusive group of buttons used for view switching.\n */\nconst _SegmentedControl = /*#__PURE__*/ forwardRef(SegmentedControl);\nexport {_SegmentedControl as SegmentedControl};\n"],"names":[],"version":3,"file":"SegmentedControl.cjs.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;AA4CM,MAAM,0DAA0B,CAAA,GAAA,0BAAY,EAAoE;AAEvH,MAAM;;;;;;;;;;;;;;;;;AAQN,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CN,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;AA0CN,M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AE","sources":["packages/@react-spectrum/s2/src/SegmentedControl.tsx"],"sourcesContent":["/*\n * Copyright 2024 Adobe. 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 http://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 {AriaLabelingProps, DOMRef, DOMRefValue, FocusableRef, Key} from '@react-types/shared';\nimport {centerBaseline} from './CenterBaseline';\nimport {ContextValue, DEFAULT_SLOT, Provider, TextContext as RACTextContext, SlotProps, ToggleButton, ToggleButtonGroup, ToggleGroupStateContext} from 'react-aria-components';\nimport {createContext, forwardRef, ReactNode, RefObject, useCallback, useContext, useRef} from 'react';\nimport {focusRing, size, style} from '../style' with {type: 'macro'};\nimport {getAllowedOverrides, StyleProps} from './style-utils' with {type: 'macro'};\nimport {IconContext} from './Icon';\nimport {pressScale} from './pressScale';\nimport {Text, TextContext} from './Content';\nimport {useDOMRef, useFocusableRef} from '@react-spectrum/utils';\nimport {useLayoutEffect} from '@react-aria/utils';\nimport {useSpectrumContextProps} from './useSpectrumContextProps';\n\nexport interface SegmentedControlProps extends AriaLabelingProps, StyleProps, SlotProps {\n /**\n * The content to display in the segmented control.\n */\n children: ReactNode,\n /**\n * Whether the segmented control is disabled.\n */\n isDisabled?: boolean,\n /** Whether the items should divide the container width equally. */\n isJustified?: boolean,\n /** The id of the currently selected item (controlled). */\n selectedKey?: Key | null,\n /** The id of the initial selected item (uncontrolled). */\n defaultSelectedKey?: Key,\n /** Handler that is called when the selection changes. */\n onSelectionChange?: (id: Key) => void\n}\nexport interface SegmentedControlItemProps extends AriaLabelingProps, StyleProps {\n /**\n * The content to display in the segmented control item.\n */\n children: ReactNode,\n /** The id of the item, matching the value used in SegmentedControl's `selectedKey` prop. */\n id: Key,\n /** Whether the item is disabled or not. */\n isDisabled?: boolean\n}\n\nexport const SegmentedControlContext = createContext<ContextValue<SegmentedControlProps, DOMRefValue<HTMLDivElement>>>(null);\n\nconst segmentedControl = style({\n display: 'flex',\n gap: 4,\n backgroundColor: 'gray-100',\n borderRadius: 'default',\n width: 'fit'\n}, getAllowedOverrides());\n\nconst controlItem = style({\n ...focusRing(),\n position: 'relative',\n display: 'flex',\n forcedColorAdjust: 'none',\n font: 'control',\n color: {\n default: 'gray-700',\n isHovered: 'neutral-subdued',\n isSelected: 'neutral',\n isDisabled: 'disabled',\n forcedColors: {\n default: 'ButtonText',\n isDisabled: 'GrayText',\n isSelected: 'HighlightText'\n }\n },\n // TODO: update this padding for icon-only items when we introduce the non-track style back\n paddingX: {\n default: 'edge-to-text',\n ':has([slot=icon]):not(:has([data-rsp-slot=text]))': size(6)\n },\n height: 32,\n alignItems: 'center',\n flexGrow: {\n isJustified: 1\n },\n flexBasis: {\n isJustified: 0\n },\n flexShrink: 0,\n minWidth: 0,\n justifyContent: 'center',\n whiteSpace: 'nowrap',\n disableTapHighlight: true,\n userSelect: 'none',\n backgroundColor: 'transparent',\n borderStyle: 'none',\n borderRadius: 'default',\n '--iconPrimary': {\n type: 'fill',\n value: 'currentColor'\n }\n}, getAllowedOverrides());\n\nconst slider = style({\n backgroundColor: {\n default: 'gray-25',\n forcedColors: {\n default: 'Highlight',\n isDisabled: 'GrayText'\n }\n },\n left: 0,\n width: 'full',\n height: 'full',\n position: 'absolute',\n boxSizing: 'border-box',\n borderStyle: 'solid',\n borderWidth: 2,\n borderColor: {\n default: 'gray-900',\n isDisabled: 'disabled',\n forcedColors: {\n default: 'Highlight',\n isDisabled: 'GrayText'\n }\n },\n borderRadius: 'lg'\n});\n\ninterface InternalSegmentedControlContextProps {\n register?: (value: Key, isDisabled?: boolean) => void,\n prevRef?: RefObject<DOMRect | null>,\n currentSelectedRef?: RefObject<HTMLDivElement | null>,\n isJustified?: boolean\n}\n\ninterface DefaultSelectionTrackProps {\n defaultValue?: Key | null,\n value?: Key | null,\n children?: ReactNode,\n prevRef: RefObject<DOMRect | null>,\n currentSelectedRef: RefObject<HTMLDivElement | null>,\n isJustified?: boolean\n}\n\nconst InternalSegmentedControlContext = createContext<InternalSegmentedControlContextProps>({});\n\nfunction SegmentedControl(props: SegmentedControlProps, ref: DOMRef<HTMLDivElement>) {\n [props, ref] = useSpectrumContextProps(props, ref, SegmentedControlContext);\n let {\n defaultSelectedKey,\n selectedKey,\n onSelectionChange\n } = props;\n let domRef = useDOMRef(ref);\n\n let prevRef = useRef<DOMRect>(null);\n let currentSelectedRef = useRef<HTMLDivElement>(null);\n\n let onChange = (values: Set<Key>) => {\n if (currentSelectedRef.current) {\n prevRef.current = currentSelectedRef?.current.getBoundingClientRect();\n }\n \n if (onSelectionChange) {\n onSelectionChange(values.values().next().value);\n }\n };\n\n return (\n <ToggleButtonGroup \n {...props}\n selectedKeys={selectedKey != null ? [selectedKey] : undefined}\n defaultSelectedKeys={defaultSelectedKey != null ? [defaultSelectedKey] : undefined}\n disallowEmptySelection\n ref={domRef}\n orientation=\"horizontal\"\n style={props.UNSAFE_style}\n onSelectionChange={onChange}\n className={(props.UNSAFE_className || '') + segmentedControl(null, props.styles)}\n aria-label={props['aria-label']}>\n <DefaultSelectionTracker defaultValue={defaultSelectedKey} value={selectedKey} prevRef={prevRef} currentSelectedRef={currentSelectedRef} isJustified={props.isJustified}>\n {props.children}\n </DefaultSelectionTracker>\n </ToggleButtonGroup>\n );\n}\n\nfunction DefaultSelectionTracker(props: DefaultSelectionTrackProps) {\n let state = useContext(ToggleGroupStateContext);\n let isRegistered = useRef(!(props.defaultValue == null && props.value == null));\n\n // default select the first available item\n let register = useCallback((value: Key) => {\n if (state && !isRegistered.current) {\n isRegistered.current = true;\n state.toggleKey(value);\n }\n }, []);\n\n return (\n <Provider\n values={[\n [InternalSegmentedControlContext, {register: register, prevRef: props.prevRef, currentSelectedRef: props.currentSelectedRef, isJustified: props.isJustified}]\n ]}> \n {props.children}\n </Provider>\n );\n}\n\nfunction SegmentedControlItem(props: SegmentedControlItemProps, ref: FocusableRef<HTMLButtonElement>) {\n let domRef = useFocusableRef(ref);\n let divRef = useRef<HTMLDivElement>(null);\n let {register, prevRef, currentSelectedRef, isJustified} = useContext(InternalSegmentedControlContext);\n let state = useContext(ToggleGroupStateContext);\n let isSelected = state?.selectedKeys.has(props.id);\n // do not apply animation if a user has the prefers-reduced-motion setting\n let isReduced = false;\n if (window?.matchMedia) {\n isReduced = window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n }\n\n useLayoutEffect(() => {\n register?.(props.id);\n }, []);\n\n useLayoutEffect(() => {\n if (isSelected && prevRef?.current && currentSelectedRef?.current && !isReduced) {\n let currentItem = currentSelectedRef?.current.getBoundingClientRect();\n\n let deltaX = prevRef?.current.left - currentItem?.left;\n\n currentSelectedRef.current.animate(\n [\n {transform: `translateX(${deltaX}px)`, width: `${prevRef?.current.width}px`},\n {transform: 'translateX(0px)', width: `${currentItem.width}px`}\n ],\n {\n duration: 200,\n easing: 'ease-out'\n }\n );\n\n prevRef.current = null;\n }\n }, [isSelected]);\n\n return (\n <ToggleButton \n {...props}\n ref={domRef} \n style={props.UNSAFE_style}\n className={renderProps => (props.UNSAFE_className || '') + controlItem({...renderProps, isJustified}, props.styles)} >\n {({isSelected, isPressed, isDisabled}) => (\n <>\n {isSelected && <div className={slider({isDisabled})} ref={currentSelectedRef} />}\n <Provider \n values={[\n [IconContext, {\n render: centerBaseline({slot: 'icon', styles: style({order: 0, flexShrink: 0})})\n }],\n [RACTextContext, {slots: {[DEFAULT_SLOT]: {}}}],\n [TextContext, {styles: style({order: 1, truncate: true})}]\n ]}>\n <div ref={divRef} style={pressScale(divRef)({isPressed})} className={style({zIndex: 1, display: 'flex', gap: 'text-to-visual', transition: 'default', alignItems: 'center', minWidth: 0})}>\n {typeof props.children === 'string' ? <Text>{props.children}</Text> : props.children}\n </div>\n </Provider>\n </>\n )\n }\n </ToggleButton>\n );\n}\n\n/**\n * A SegmentedControlItem represents an option within a SegmentedControl.\n */\nconst _SegmentedControlItem = /*#__PURE__*/ forwardRef(SegmentedControlItem);\nexport {_SegmentedControlItem as SegmentedControlItem};\n\n/**\n * A SegmentedControl is a mutually exclusive group of buttons used for view switching.\n */\nconst _SegmentedControl = /*#__PURE__*/ forwardRef(SegmentedControl);\nexport {_SegmentedControl as SegmentedControl};\n"],"names":[],"version":3,"file":"SegmentedControl.cjs.map"}
|
|
@@ -1,4 +1,48 @@
|
|
|
1
1
|
@layer _.a {
|
|
2
|
+
.ic {
|
|
3
|
+
row-gap: .25rem;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.jc {
|
|
7
|
+
column-gap: .25rem;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.bg {
|
|
11
|
+
background-color: var(--lightningcss-light, #e9e9e9) var(--lightningcss-dark, #2c2c2c);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.lJ {
|
|
15
|
+
width: fit-content;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
._La {
|
|
19
|
+
outline-style: none;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
._Lb {
|
|
23
|
+
outline-style: solid;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.dx {
|
|
27
|
+
outline-color: var(--lightningcss-light, #4b75ff) var(--lightningcss-dark, #4069fd);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
._Nc {
|
|
31
|
+
outline-width: 2px;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
._M-3t1z {
|
|
35
|
+
outline-offset: 2px;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.Uc {
|
|
39
|
+
position: relative;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
._zb {
|
|
43
|
+
forced-color-adjust: none;
|
|
44
|
+
}
|
|
45
|
+
|
|
2
46
|
._ca {
|
|
3
47
|
font-family: adobe-clean-variable, adobe-clean, ui-sans-serif, system-ui, sans-serif;
|
|
4
48
|
}
|
|
@@ -33,18 +77,6 @@
|
|
|
33
77
|
line-height: 1.3;
|
|
34
78
|
}
|
|
35
79
|
|
|
36
|
-
.bg {
|
|
37
|
-
background-color: var(--lightningcss-light, #e9e9e9) var(--lightningcss-dark, #2c2c2c);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.Uc {
|
|
41
|
-
position: relative;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
._zb {
|
|
45
|
-
forced-color-adjust: none;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
80
|
.am {
|
|
49
81
|
color: var(--lightningcss-light, #505050) var(--lightningcss-dark, #afafaf);
|
|
50
82
|
}
|
|
@@ -73,14 +105,14 @@
|
|
|
73
105
|
height: var(--k);
|
|
74
106
|
}
|
|
75
107
|
|
|
76
|
-
.ha {
|
|
77
|
-
flex-basis: 0;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
108
|
._9-3t1y {
|
|
81
109
|
flex-grow: 1;
|
|
82
110
|
}
|
|
83
111
|
|
|
112
|
+
.ha {
|
|
113
|
+
flex-basis: 0;
|
|
114
|
+
}
|
|
115
|
+
|
|
84
116
|
._2d {
|
|
85
117
|
justify-content: center;
|
|
86
118
|
}
|
|
@@ -89,32 +121,41 @@
|
|
|
89
121
|
-webkit-tap-highlight-color: #0000;
|
|
90
122
|
}
|
|
91
123
|
|
|
92
|
-
|
|
93
|
-
|
|
124
|
+
.__Da {
|
|
125
|
+
-webkit-user-select: none;
|
|
126
|
+
user-select: none;
|
|
94
127
|
}
|
|
95
128
|
|
|
96
|
-
|
|
97
|
-
|
|
129
|
+
.ba {
|
|
130
|
+
background-color: #0000;
|
|
98
131
|
}
|
|
99
132
|
|
|
100
|
-
.
|
|
101
|
-
|
|
133
|
+
.wf {
|
|
134
|
+
border-style: none;
|
|
102
135
|
}
|
|
103
136
|
|
|
104
|
-
.
|
|
105
|
-
|
|
137
|
+
._vc {
|
|
138
|
+
border-start-start-radius: .5rem;
|
|
106
139
|
}
|
|
107
140
|
|
|
108
|
-
.
|
|
109
|
-
|
|
141
|
+
._wc {
|
|
142
|
+
border-start-end-radius: .5rem;
|
|
110
143
|
}
|
|
111
144
|
|
|
112
|
-
.
|
|
113
|
-
|
|
145
|
+
._xc {
|
|
146
|
+
border-end-start-radius: .5rem;
|
|
114
147
|
}
|
|
115
148
|
|
|
116
|
-
.
|
|
117
|
-
|
|
149
|
+
._yc {
|
|
150
|
+
border-end-end-radius: .5rem;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.-rwx0fg_e-b {
|
|
154
|
+
--iconPrimary: currentColor;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.-_375toq_k-j {
|
|
158
|
+
--k: calc(2rem * var(--s2-scale));
|
|
118
159
|
}
|
|
119
160
|
|
|
120
161
|
.bd {
|
|
@@ -259,15 +300,17 @@
|
|
|
259
300
|
line-height: 1.5;
|
|
260
301
|
}
|
|
261
302
|
|
|
262
|
-
.C-
|
|
303
|
+
.C-soocic-ve8p9e:has([slot="icon"]):not(:has([data-rsp-slot="text"])) {
|
|
263
304
|
padding-inline-start: calc(.375rem * var(--s2-scale));
|
|
264
305
|
}
|
|
265
306
|
|
|
266
|
-
.D-
|
|
307
|
+
.D-soocic-ve8p9e:has([slot="icon"]):not(:has([data-rsp-slot="text"])) {
|
|
267
308
|
padding-inline-end: calc(.375rem * var(--s2-scale));
|
|
268
309
|
}
|
|
269
310
|
}
|
|
270
311
|
|
|
312
|
+
@layer UNSAFE_overrides;
|
|
313
|
+
|
|
271
314
|
@layer _.c {
|
|
272
315
|
._c-enzwzjc:lang(he) {
|
|
273
316
|
font-family: myriad-hebrew, ui-sans-serif, system-ui, sans-serif;
|
|
@@ -304,72 +347,70 @@
|
|
|
304
347
|
}
|
|
305
348
|
}
|
|
306
349
|
|
|
307
|
-
@layer
|
|
350
|
+
@layer _.b.a {
|
|
351
|
+
@media (forced-colors: active) {
|
|
352
|
+
.da_____z {
|
|
353
|
+
outline-color: highlight;
|
|
354
|
+
}
|
|
308
355
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
._dbf {
|
|
312
|
-
font-size: 1.0625rem;
|
|
356
|
+
.aa_____x {
|
|
357
|
+
color: buttontext;
|
|
313
358
|
}
|
|
314
359
|
|
|
315
|
-
.
|
|
316
|
-
|
|
360
|
+
.aa_____B {
|
|
361
|
+
color: graytext;
|
|
317
362
|
}
|
|
318
363
|
|
|
319
|
-
.
|
|
320
|
-
|
|
364
|
+
.aa_____A {
|
|
365
|
+
color: highlighttext;
|
|
321
366
|
}
|
|
322
367
|
|
|
323
|
-
.
|
|
324
|
-
|
|
368
|
+
.ba_____z {
|
|
369
|
+
background-color: highlight;
|
|
325
370
|
}
|
|
326
371
|
|
|
327
|
-
.
|
|
328
|
-
|
|
372
|
+
.ba_____B {
|
|
373
|
+
background-color: graytext;
|
|
329
374
|
}
|
|
330
375
|
|
|
331
|
-
.
|
|
332
|
-
|
|
376
|
+
.ca_____z {
|
|
377
|
+
border-color: highlight;
|
|
333
378
|
}
|
|
334
379
|
|
|
335
|
-
.
|
|
336
|
-
|
|
380
|
+
.ca_____B {
|
|
381
|
+
border-color: graytext;
|
|
337
382
|
}
|
|
338
383
|
}
|
|
339
384
|
}
|
|
340
385
|
|
|
341
|
-
@layer _.b.
|
|
342
|
-
@media (
|
|
343
|
-
.
|
|
344
|
-
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
.aa_____B {
|
|
348
|
-
color: graytext;
|
|
386
|
+
@layer _.b.b {
|
|
387
|
+
@media not ((hover: hover) and (pointer: fine)) {
|
|
388
|
+
._dbf {
|
|
389
|
+
font-size: 1.0625rem;
|
|
349
390
|
}
|
|
350
391
|
|
|
351
|
-
.
|
|
352
|
-
|
|
392
|
+
._dbb {
|
|
393
|
+
font-size: .8125rem;
|
|
353
394
|
}
|
|
354
395
|
|
|
355
|
-
.
|
|
356
|
-
|
|
396
|
+
._dbd {
|
|
397
|
+
font-size: .9375rem;
|
|
357
398
|
}
|
|
358
399
|
|
|
359
|
-
.
|
|
360
|
-
|
|
400
|
+
._dbh {
|
|
401
|
+
font-size: 1.1875rem;
|
|
361
402
|
}
|
|
362
403
|
|
|
363
|
-
.
|
|
364
|
-
|
|
404
|
+
._dbj {
|
|
405
|
+
font-size: 1.375rem;
|
|
365
406
|
}
|
|
366
407
|
|
|
367
|
-
.
|
|
368
|
-
|
|
408
|
+
.ibH {
|
|
409
|
+
row-gap: .470588em;
|
|
369
410
|
}
|
|
370
411
|
|
|
371
|
-
.
|
|
372
|
-
|
|
412
|
+
.jbH {
|
|
413
|
+
column-gap: .470588em;
|
|
373
414
|
}
|
|
374
415
|
}
|
|
375
416
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"ACsDyB;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;;;EAAA;;;;EAAA;;;;EAQL;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAmCL;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EA6J+C;;;;EAAA;;;;EAGzB;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAE4C;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;;AA7MxD;EAAA;;;;EAAA;;;;EAQL;;;;EAAA;;;;;AARK;EAAA;;;;;AAAA;EAAA;;;;;AAAA;EAAA;;;;;AAAA;EAAA;;;;;AAAA;EAAA;;;;;AAAA;EAAA;;;;;AAAA;;AAAA;EAAA;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IA6MwD;;;;IAAA;;;;;;AArM7D;EAAA;IAAA;;;;IAAA;;;;IAAA;;;;IAmCL;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;;;AAAA","sources":["90909571be522c78","packages/@react-spectrum/s2/src/SegmentedControl.tsx"],"sourcesContent":["@import \"3076f581d900045a\";\n@import \"37c2fdb040131115\";\n@import \"d075b97bae773d34\";\n@import \"6903fca31535b056\";\n@import \"a6b79b4602e6c53c\";\n@import \"c3f3a2eb3541e76f\";\n","/*\n * Copyright 2024 Adobe. 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 http://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 {AriaLabelingProps, DOMRef, DOMRefValue, FocusableRef} from '@react-types/shared';\nimport {centerBaseline} from './CenterBaseline';\nimport {ContextValue, DEFAULT_SLOT, Provider, TextContext as RACTextContext, Radio, RadioGroup, RadioGroupStateContext, SlotProps} from 'react-aria-components';\nimport {createContext, forwardRef, ReactNode, RefObject, useCallback, useContext, useRef} from 'react';\nimport {focusRing, size, style} from '../style' with {type: 'macro'};\nimport {getAllowedOverrides, StyleProps} from './style-utils' with {type: 'macro'};\nimport {IconContext} from './Icon';\nimport {pressScale} from './pressScale';\nimport {Text, TextContext} from './Content';\nimport {useDOMRef, useFocusableRef} from '@react-spectrum/utils';\nimport {useLayoutEffect} from '@react-aria/utils';\nimport {useSpectrumContextProps} from './useSpectrumContextProps';\n\nexport interface SegmentedControlProps extends AriaLabelingProps, StyleProps, SlotProps {\n /**\n * The content to display in the segmented control.\n */\n children: ReactNode,\n /**\n * Whether the segmented control is disabled.\n */\n isDisabled?: boolean,\n /** The id of the currently selected item (controlled). */\n selectedKey?: string | null,\n /** The id of the initial selected item (uncontrolled). */\n defaultSelectedKey?: string,\n /** Handler that is called when the selection changes. */\n onSelectionChange?: (id: string) => void\n}\nexport interface SegmentedControlItemProps extends AriaLabelingProps, StyleProps {\n /**\n * The content to display in the segmented control item.\n */\n children: ReactNode,\n /** The id of the item, matching the value used in SegmentedControl's `selectedKey` prop. */\n id: string,\n /** Whether the item is disabled or not. */\n isDisabled?: boolean\n}\n\nexport const SegmentedControlContext = createContext<ContextValue<SegmentedControlProps, DOMRefValue<HTMLDivElement>>>(null);\n\nconst segmentedControl = style<{size: string}>({\n font: 'control',\n display: 'flex',\n backgroundColor: 'gray-100',\n borderRadius: 'lg',\n width: 'full'\n}, getAllowedOverrides());\n\nconst controlItem = style({\n position: 'relative',\n display: 'flex',\n forcedColorAdjust: 'none',\n color: {\n default: 'gray-700',\n isHovered: 'neutral-subdued',\n isSelected: 'neutral',\n isDisabled: 'disabled',\n forcedColors: {\n default: 'ButtonText',\n isDisabled: 'GrayText',\n isSelected: 'HighlightText'\n }\n },\n // TODO: update this padding for icon-only items when we introduce the non-track style back\n paddingX: {\n default: 'edge-to-text',\n ':has([slot=icon]:only-child)': size(6)\n },\n height: 32,\n alignItems: 'center',\n flexBasis: 0,\n flexGrow: 1,\n flexShrink: 0,\n minWidth: 0,\n justifyContent: 'center',\n whiteSpace: 'nowrap',\n disableTapHighlight: true,\n '--iconPrimary': {\n type: 'fill',\n value: 'currentColor'\n }\n}, getAllowedOverrides());\n\nconst slider = style({\n ...focusRing(),\n backgroundColor: {\n default: 'gray-25',\n forcedColors: {\n default: 'Highlight',\n isDisabled: 'GrayText'\n }\n },\n left: 0,\n width: 'full',\n height: 'full',\n position: 'absolute',\n boxSizing: 'border-box',\n borderStyle: 'solid',\n borderWidth: 2,\n borderColor: {\n default: 'gray-900',\n isDisabled: 'disabled',\n forcedColors: {\n default: 'Highlight',\n isDisabled: 'GrayText'\n }\n },\n borderRadius: 'lg'\n});\n\ninterface InternalSegmentedControlContextProps {\n register?: (value: string, isDisabled?: boolean) => void,\n prevRef?: RefObject<DOMRect | null>,\n currentSelectedRef?: RefObject<HTMLDivElement | null>\n}\n\ninterface DefaultSelectionTrackProps {\n defaultValue?: string | null,\n value?: string | null,\n children?: ReactNode,\n prevRef: RefObject<DOMRect | null>,\n currentSelectedRef: RefObject<HTMLDivElement | null>\n}\n\nconst InternalSegmentedControlContext = createContext<InternalSegmentedControlContextProps>({});\n\nfunction SegmentedControl(props: SegmentedControlProps, ref: DOMRef<HTMLDivElement>) {\n [props, ref] = useSpectrumContextProps(props, ref, SegmentedControlContext);\n let {\n defaultSelectedKey,\n selectedKey,\n onSelectionChange\n } = props;\n let domRef = useDOMRef(ref);\n\n let prevRef = useRef<DOMRect>(null);\n let currentSelectedRef = useRef<HTMLDivElement>(null);\n\n let onChange = (value: string) => {\n if (currentSelectedRef.current) {\n prevRef.current = currentSelectedRef?.current.getBoundingClientRect();\n }\n \n if (onSelectionChange) {\n onSelectionChange(value);\n }\n };\n\n return (\n <RadioGroup \n {...props}\n value={selectedKey}\n defaultValue={defaultSelectedKey}\n ref={domRef}\n orientation=\"horizontal\"\n style={props.UNSAFE_style}\n onChange={onChange}\n className={(props.UNSAFE_className || '') + segmentedControl({size: 'M'}, props.styles)}\n aria-label={props['aria-label']}>\n <DefaultSelectionTracker defaultValue={defaultSelectedKey} value={selectedKey} prevRef={prevRef} currentSelectedRef={currentSelectedRef}>\n {props.children}\n </DefaultSelectionTracker>\n </RadioGroup>\n );\n}\n\nfunction DefaultSelectionTracker(props: DefaultSelectionTrackProps) {\n let state = useContext(RadioGroupStateContext);\n let isRegistered = useRef(!(props.defaultValue == null && props.value == null));\n\n // default select the first available item\n let register = useCallback((value: string) => {\n if (state && !isRegistered.current) {\n isRegistered.current = true;\n state.setSelectedValue(value);\n }\n }, []);\n\n return (\n <Provider\n values={[\n [InternalSegmentedControlContext, {register: register, prevRef: props.prevRef, currentSelectedRef: props.currentSelectedRef}]\n ]}> \n {props.children}\n </Provider>\n );\n}\n\nfunction SegmentedControlItem(props: SegmentedControlItemProps, ref: FocusableRef<HTMLLabelElement>) {\n let inputRef = useRef<HTMLInputElement>(null);\n let domRef = useFocusableRef(ref, inputRef);\n let divRef = useRef<HTMLDivElement>(null);\n let {register, prevRef, currentSelectedRef} = useContext(InternalSegmentedControlContext);\n let state = useContext(RadioGroupStateContext);\n let isSelected = props.id === state?.selectedValue;\n // do not apply animation if a user has the prefers-reduced-motion setting\n let isReduced = false;\n if (window?.matchMedia) {\n isReduced = window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n }\n\n useLayoutEffect(() => {\n register?.(props.id);\n }, []);\n\n useLayoutEffect(() => {\n if (isSelected && prevRef?.current && currentSelectedRef?.current && !isReduced) {\n let currentItem = currentSelectedRef?.current.getBoundingClientRect();\n\n let deltaX = prevRef?.current.left - currentItem?.left;\n\n currentSelectedRef.current.animate(\n [\n {transform: `translateX(${deltaX}px)`, width: `${prevRef?.current.width}px`},\n {transform: 'translateX(0px)', width: `${currentItem.width}px`}\n ],\n {\n duration: 200,\n easing: 'ease-out'\n }\n );\n\n prevRef.current = null;\n }\n }, [isSelected]);\n\n return (\n <Radio \n {...props}\n value={props.id}\n ref={domRef} \n inputRef={inputRef}\n style={props.UNSAFE_style}\n className={renderProps => (props.UNSAFE_className || '') + controlItem({...renderProps}, props.styles)} >\n {({isSelected, isFocusVisible, isPressed, isDisabled}) => (\n <>\n {isSelected && <div className={slider({isFocusVisible, isDisabled})} ref={currentSelectedRef} />}\n <Provider \n values={[\n [IconContext, {\n render: centerBaseline({slot: 'icon', styles: style({order: 0, flexShrink: 0})})\n }],\n [RACTextContext, {slots: {[DEFAULT_SLOT]: {}}}],\n [TextContext, {styles: style({order: 1, truncate: true})}]\n ]}>\n <div ref={divRef} style={pressScale(divRef)({isPressed})} className={style({zIndex: 1, display: 'flex', gap: 'text-to-visual', transition: 'default', alignItems: 'center', minWidth: 0})}>\n {typeof props.children === 'string' ? <Text>{props.children}</Text> : props.children}\n </div>\n </Provider>\n </>\n )\n }\n </Radio>\n );\n}\n\n/**\n * A SegmentedControlItem represents an option within a SegmentedControl.\n */\nconst _SegmentedControlItem = /*#__PURE__*/ forwardRef(SegmentedControlItem);\nexport {_SegmentedControlItem as SegmentedControlItem};\n\n/**\n * A SegmentedControl is a mutually exclusive group of buttons used for view switching.\n */\nconst _SegmentedControl = /*#__PURE__*/ forwardRef(SegmentedControl);\nexport {_SegmentedControl as SegmentedControl};\n"],"names":[],"version":3,"file":"SegmentedControl.css.map"}
|
|
1
|
+
{"mappings":"ACwDyB;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAQL;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EA6CL;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EA4J+C;;;;EAAA;;;;EAGzB;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAE4C;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;EAAA;;;;;AAtNxD;EAQL;;;;EAAA;;;;EAAA;;;;EAAA;;;;;AARK;;AAQL;EAAA;;;;;AAAA;EAAA;;;;;AAAA;EAAA;;;;;AAAA;EAAA;;;;;AAAA;EAAA;;;;;AAAA;EAAA;;;;;AAAA;EAAA;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IA6CL;;;;IAAA;;;;IAAA;;;;IAAA;;;;;;AA7CK;EAAA;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IAAA;;;;IA8M6D;;;;IAAA;;;;;;AAjKlE","sources":["90909571be522c78","packages/@react-spectrum/s2/src/SegmentedControl.tsx"],"sourcesContent":["@import \"3076f581d900045a\";\n@import \"37c2fdb040131115\";\n@import \"d075b97bae773d34\";\n@import \"6903fca31535b056\";\n@import \"a6b79b4602e6c53c\";\n@import \"c3f3a2eb3541e76f\";\n","/*\n * Copyright 2024 Adobe. 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 http://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 {AriaLabelingProps, DOMRef, DOMRefValue, FocusableRef, Key} from '@react-types/shared';\nimport {centerBaseline} from './CenterBaseline';\nimport {ContextValue, DEFAULT_SLOT, Provider, TextContext as RACTextContext, SlotProps, ToggleButton, ToggleButtonGroup, ToggleGroupStateContext} from 'react-aria-components';\nimport {createContext, forwardRef, ReactNode, RefObject, useCallback, useContext, useRef} from 'react';\nimport {focusRing, size, style} from '../style' with {type: 'macro'};\nimport {getAllowedOverrides, StyleProps} from './style-utils' with {type: 'macro'};\nimport {IconContext} from './Icon';\nimport {pressScale} from './pressScale';\nimport {Text, TextContext} from './Content';\nimport {useDOMRef, useFocusableRef} from '@react-spectrum/utils';\nimport {useLayoutEffect} from '@react-aria/utils';\nimport {useSpectrumContextProps} from './useSpectrumContextProps';\n\nexport interface SegmentedControlProps extends AriaLabelingProps, StyleProps, SlotProps {\n /**\n * The content to display in the segmented control.\n */\n children: ReactNode,\n /**\n * Whether the segmented control is disabled.\n */\n isDisabled?: boolean,\n /** Whether the items should divide the container width equally. */\n isJustified?: boolean,\n /** The id of the currently selected item (controlled). */\n selectedKey?: Key | null,\n /** The id of the initial selected item (uncontrolled). */\n defaultSelectedKey?: Key,\n /** Handler that is called when the selection changes. */\n onSelectionChange?: (id: Key) => void\n}\nexport interface SegmentedControlItemProps extends AriaLabelingProps, StyleProps {\n /**\n * The content to display in the segmented control item.\n */\n children: ReactNode,\n /** The id of the item, matching the value used in SegmentedControl's `selectedKey` prop. */\n id: Key,\n /** Whether the item is disabled or not. */\n isDisabled?: boolean\n}\n\nexport const SegmentedControlContext = createContext<ContextValue<SegmentedControlProps, DOMRefValue<HTMLDivElement>>>(null);\n\nconst segmentedControl = style({\n display: 'flex',\n gap: 4,\n backgroundColor: 'gray-100',\n borderRadius: 'default',\n width: 'fit'\n}, getAllowedOverrides());\n\nconst controlItem = style({\n ...focusRing(),\n position: 'relative',\n display: 'flex',\n forcedColorAdjust: 'none',\n font: 'control',\n color: {\n default: 'gray-700',\n isHovered: 'neutral-subdued',\n isSelected: 'neutral',\n isDisabled: 'disabled',\n forcedColors: {\n default: 'ButtonText',\n isDisabled: 'GrayText',\n isSelected: 'HighlightText'\n }\n },\n // TODO: update this padding for icon-only items when we introduce the non-track style back\n paddingX: {\n default: 'edge-to-text',\n ':has([slot=icon]):not(:has([data-rsp-slot=text]))': size(6)\n },\n height: 32,\n alignItems: 'center',\n flexGrow: {\n isJustified: 1\n },\n flexBasis: {\n isJustified: 0\n },\n flexShrink: 0,\n minWidth: 0,\n justifyContent: 'center',\n whiteSpace: 'nowrap',\n disableTapHighlight: true,\n userSelect: 'none',\n backgroundColor: 'transparent',\n borderStyle: 'none',\n borderRadius: 'default',\n '--iconPrimary': {\n type: 'fill',\n value: 'currentColor'\n }\n}, getAllowedOverrides());\n\nconst slider = style({\n backgroundColor: {\n default: 'gray-25',\n forcedColors: {\n default: 'Highlight',\n isDisabled: 'GrayText'\n }\n },\n left: 0,\n width: 'full',\n height: 'full',\n position: 'absolute',\n boxSizing: 'border-box',\n borderStyle: 'solid',\n borderWidth: 2,\n borderColor: {\n default: 'gray-900',\n isDisabled: 'disabled',\n forcedColors: {\n default: 'Highlight',\n isDisabled: 'GrayText'\n }\n },\n borderRadius: 'lg'\n});\n\ninterface InternalSegmentedControlContextProps {\n register?: (value: Key, isDisabled?: boolean) => void,\n prevRef?: RefObject<DOMRect | null>,\n currentSelectedRef?: RefObject<HTMLDivElement | null>,\n isJustified?: boolean\n}\n\ninterface DefaultSelectionTrackProps {\n defaultValue?: Key | null,\n value?: Key | null,\n children?: ReactNode,\n prevRef: RefObject<DOMRect | null>,\n currentSelectedRef: RefObject<HTMLDivElement | null>,\n isJustified?: boolean\n}\n\nconst InternalSegmentedControlContext = createContext<InternalSegmentedControlContextProps>({});\n\nfunction SegmentedControl(props: SegmentedControlProps, ref: DOMRef<HTMLDivElement>) {\n [props, ref] = useSpectrumContextProps(props, ref, SegmentedControlContext);\n let {\n defaultSelectedKey,\n selectedKey,\n onSelectionChange\n } = props;\n let domRef = useDOMRef(ref);\n\n let prevRef = useRef<DOMRect>(null);\n let currentSelectedRef = useRef<HTMLDivElement>(null);\n\n let onChange = (values: Set<Key>) => {\n if (currentSelectedRef.current) {\n prevRef.current = currentSelectedRef?.current.getBoundingClientRect();\n }\n \n if (onSelectionChange) {\n onSelectionChange(values.values().next().value);\n }\n };\n\n return (\n <ToggleButtonGroup \n {...props}\n selectedKeys={selectedKey != null ? [selectedKey] : undefined}\n defaultSelectedKeys={defaultSelectedKey != null ? [defaultSelectedKey] : undefined}\n disallowEmptySelection\n ref={domRef}\n orientation=\"horizontal\"\n style={props.UNSAFE_style}\n onSelectionChange={onChange}\n className={(props.UNSAFE_className || '') + segmentedControl(null, props.styles)}\n aria-label={props['aria-label']}>\n <DefaultSelectionTracker defaultValue={defaultSelectedKey} value={selectedKey} prevRef={prevRef} currentSelectedRef={currentSelectedRef} isJustified={props.isJustified}>\n {props.children}\n </DefaultSelectionTracker>\n </ToggleButtonGroup>\n );\n}\n\nfunction DefaultSelectionTracker(props: DefaultSelectionTrackProps) {\n let state = useContext(ToggleGroupStateContext);\n let isRegistered = useRef(!(props.defaultValue == null && props.value == null));\n\n // default select the first available item\n let register = useCallback((value: Key) => {\n if (state && !isRegistered.current) {\n isRegistered.current = true;\n state.toggleKey(value);\n }\n }, []);\n\n return (\n <Provider\n values={[\n [InternalSegmentedControlContext, {register: register, prevRef: props.prevRef, currentSelectedRef: props.currentSelectedRef, isJustified: props.isJustified}]\n ]}> \n {props.children}\n </Provider>\n );\n}\n\nfunction SegmentedControlItem(props: SegmentedControlItemProps, ref: FocusableRef<HTMLButtonElement>) {\n let domRef = useFocusableRef(ref);\n let divRef = useRef<HTMLDivElement>(null);\n let {register, prevRef, currentSelectedRef, isJustified} = useContext(InternalSegmentedControlContext);\n let state = useContext(ToggleGroupStateContext);\n let isSelected = state?.selectedKeys.has(props.id);\n // do not apply animation if a user has the prefers-reduced-motion setting\n let isReduced = false;\n if (window?.matchMedia) {\n isReduced = window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n }\n\n useLayoutEffect(() => {\n register?.(props.id);\n }, []);\n\n useLayoutEffect(() => {\n if (isSelected && prevRef?.current && currentSelectedRef?.current && !isReduced) {\n let currentItem = currentSelectedRef?.current.getBoundingClientRect();\n\n let deltaX = prevRef?.current.left - currentItem?.left;\n\n currentSelectedRef.current.animate(\n [\n {transform: `translateX(${deltaX}px)`, width: `${prevRef?.current.width}px`},\n {transform: 'translateX(0px)', width: `${currentItem.width}px`}\n ],\n {\n duration: 200,\n easing: 'ease-out'\n }\n );\n\n prevRef.current = null;\n }\n }, [isSelected]);\n\n return (\n <ToggleButton \n {...props}\n ref={domRef} \n style={props.UNSAFE_style}\n className={renderProps => (props.UNSAFE_className || '') + controlItem({...renderProps, isJustified}, props.styles)} >\n {({isSelected, isPressed, isDisabled}) => (\n <>\n {isSelected && <div className={slider({isDisabled})} ref={currentSelectedRef} />}\n <Provider \n values={[\n [IconContext, {\n render: centerBaseline({slot: 'icon', styles: style({order: 0, flexShrink: 0})})\n }],\n [RACTextContext, {slots: {[DEFAULT_SLOT]: {}}}],\n [TextContext, {styles: style({order: 1, truncate: true})}]\n ]}>\n <div ref={divRef} style={pressScale(divRef)({isPressed})} className={style({zIndex: 1, display: 'flex', gap: 'text-to-visual', transition: 'default', alignItems: 'center', minWidth: 0})}>\n {typeof props.children === 'string' ? <Text>{props.children}</Text> : props.children}\n </div>\n </Provider>\n </>\n )\n }\n </ToggleButton>\n );\n}\n\n/**\n * A SegmentedControlItem represents an option within a SegmentedControl.\n */\nconst _SegmentedControlItem = /*#__PURE__*/ forwardRef(SegmentedControlItem);\nexport {_SegmentedControlItem as SegmentedControlItem};\n\n/**\n * A SegmentedControl is a mutually exclusive group of buttons used for view switching.\n */\nconst _SegmentedControl = /*#__PURE__*/ forwardRef(SegmentedControl);\nexport {_SegmentedControl as SegmentedControl};\n"],"names":[],"version":3,"file":"SegmentedControl.css.map"}
|
|
@@ -5,7 +5,7 @@ import {pressScale as $10ea7662e51a285b$export$56e8cba416805d8d} from "./pressSc
|
|
|
5
5
|
import {Text as $8e847109a6ab556d$export$5f1af8db9871e1d6, TextContext as $8e847109a6ab556d$export$9afb8bc826b033ea} from "./Content.mjs";
|
|
6
6
|
import {useSpectrumContextProps as $5ce63c423902f47d$export$764f6146fadd77f7} from "../icons/useSpectrumContextProps.mjs";
|
|
7
7
|
import {jsx as $ae3Tm$jsx, jsxs as $ae3Tm$jsxs, Fragment as $ae3Tm$Fragment} from "react/jsx-runtime";
|
|
8
|
-
import {
|
|
8
|
+
import {ToggleButtonGroup as $ae3Tm$ToggleButtonGroup, ToggleGroupStateContext as $ae3Tm$ToggleGroupStateContext, Provider as $ae3Tm$Provider, ToggleButton as $ae3Tm$ToggleButton, TextContext as $ae3Tm$TextContext, DEFAULT_SLOT as $ae3Tm$DEFAULT_SLOT} from "react-aria-components";
|
|
9
9
|
import {createContext as $ae3Tm$createContext, useRef as $ae3Tm$useRef, useContext as $ae3Tm$useContext, useCallback as $ae3Tm$useCallback, forwardRef as $ae3Tm$forwardRef} from "react";
|
|
10
10
|
import {useDOMRef as $ae3Tm$useDOMRef, useFocusableRef as $ae3Tm$useFocusableRef} from "@react-spectrum/utils";
|
|
11
11
|
import {useLayoutEffect as $ae3Tm$useLayoutEffect} from "@react-aria/utils";
|
|
@@ -37,6 +37,42 @@ const $c679c2152e03f8bf$var$segmentedControl = function anonymous(props, overrid
|
|
|
37
37
|
rules += matches.join('');
|
|
38
38
|
let $l = false;
|
|
39
39
|
for (let p of matches)if (/^\s*l/.test(p)) $l = true;
|
|
40
|
+
rules += ' _Zd';
|
|
41
|
+
rules += ' ic';
|
|
42
|
+
rules += ' jc';
|
|
43
|
+
rules += ' bg';
|
|
44
|
+
rules += ' _vc';
|
|
45
|
+
rules += ' _wc';
|
|
46
|
+
rules += ' _xc';
|
|
47
|
+
rules += ' _yc';
|
|
48
|
+
if (!$l) rules += ' lJ';
|
|
49
|
+
return rules;
|
|
50
|
+
};
|
|
51
|
+
const $c679c2152e03f8bf$var$controlItem = function anonymous(props, overrides) {
|
|
52
|
+
let rules = " .";
|
|
53
|
+
let matches = (overrides || '').match(/(?:^|\s)(?:y|z|A|B|_9|_8|h|_5|_4|__A|__c|__d|__a|__b|U|__Q|X|Z|V|W|l|q|r)[^\s]+/g) || [];
|
|
54
|
+
rules += matches.join('');
|
|
55
|
+
let $U = false;
|
|
56
|
+
let $_9 = false;
|
|
57
|
+
let $h = false;
|
|
58
|
+
let $_8 = false;
|
|
59
|
+
let $q = false;
|
|
60
|
+
for (let p of matches){
|
|
61
|
+
if (/^\s*U/.test(p)) $U = true;
|
|
62
|
+
if (/^\s*_9/.test(p)) $_9 = true;
|
|
63
|
+
if (/^\s*h/.test(p)) $h = true;
|
|
64
|
+
if (/^\s*_8/.test(p)) $_8 = true;
|
|
65
|
+
if (/^\s*q/.test(p)) $q = true;
|
|
66
|
+
}
|
|
67
|
+
if (props.isFocusVisible) rules += ' _Lb';
|
|
68
|
+
else rules += ' _La';
|
|
69
|
+
rules += ' da_____z';
|
|
70
|
+
rules += ' dx';
|
|
71
|
+
rules += ' _Nc';
|
|
72
|
+
rules += ' _M-3t1z';
|
|
73
|
+
if (!$U) rules += ' Uc';
|
|
74
|
+
rules += ' _Zd';
|
|
75
|
+
rules += ' _zb';
|
|
40
76
|
rules += ' _c-bc1l9oh';
|
|
41
77
|
rules += ' _c-1uotwbwg';
|
|
42
78
|
rules += ' _c-eo0c6sf';
|
|
@@ -64,35 +100,6 @@ const $c679c2152e03f8bf$var$segmentedControl = function anonymous(props, overrid
|
|
|
64
100
|
rules += ' _eb';
|
|
65
101
|
rules += ' _f-1x99dlob';
|
|
66
102
|
rules += ' _fa';
|
|
67
|
-
rules += ' an';
|
|
68
|
-
rules += ' _Zd';
|
|
69
|
-
rules += ' bg';
|
|
70
|
-
rules += ' _vd';
|
|
71
|
-
rules += ' _wd';
|
|
72
|
-
rules += ' _xd';
|
|
73
|
-
rules += ' _yd';
|
|
74
|
-
if (!$l) rules += ' lG';
|
|
75
|
-
return rules;
|
|
76
|
-
};
|
|
77
|
-
const $c679c2152e03f8bf$var$controlItem = function anonymous(props, overrides) {
|
|
78
|
-
let rules = " .";
|
|
79
|
-
let matches = (overrides || '').match(/(?:^|\s)(?:y|z|A|B|_9|_8|h|_5|_4|__A|__c|__d|__a|__b|U|__Q|X|Z|V|W|l|q|r)[^\s]+/g) || [];
|
|
80
|
-
rules += matches.join('');
|
|
81
|
-
let $U = false;
|
|
82
|
-
let $h = false;
|
|
83
|
-
let $_9 = false;
|
|
84
|
-
let $_8 = false;
|
|
85
|
-
let $q = false;
|
|
86
|
-
for (let p of matches){
|
|
87
|
-
if (/^\s*U/.test(p)) $U = true;
|
|
88
|
-
if (/^\s*h/.test(p)) $h = true;
|
|
89
|
-
if (/^\s*_9/.test(p)) $_9 = true;
|
|
90
|
-
if (/^\s*_8/.test(p)) $_8 = true;
|
|
91
|
-
if (/^\s*q/.test(p)) $q = true;
|
|
92
|
-
}
|
|
93
|
-
if (!$U) rules += ' Uc';
|
|
94
|
-
rules += ' _Zd';
|
|
95
|
-
rules += ' _zb';
|
|
96
103
|
if (props.isSelected) rules += ' aa_____A';
|
|
97
104
|
else if (props.isDisabled) rules += ' aa_____B';
|
|
98
105
|
else rules += ' aa_____x';
|
|
@@ -108,31 +115,36 @@ const $c679c2152e03f8bf$var$controlItem = function anonymous(props, overrides) {
|
|
|
108
115
|
else if (props.isHovered) rules += ' an';
|
|
109
116
|
else rules += ' am';
|
|
110
117
|
} else rules += ' am';
|
|
111
|
-
rules += ' C-
|
|
118
|
+
rules += ' C-soocic-ve8p9e';
|
|
112
119
|
rules += ' CI';
|
|
113
|
-
rules += ' D-
|
|
120
|
+
rules += ' D-soocic-ve8p9e';
|
|
114
121
|
rules += ' DI';
|
|
115
122
|
rules += ' k-375toq';
|
|
116
123
|
rules += ' _1c';
|
|
117
|
-
if (!$
|
|
118
|
-
|
|
124
|
+
if (!$_9) {
|
|
125
|
+
if (props.isJustified) rules += ' _9-3t1y';
|
|
126
|
+
}
|
|
127
|
+
if (!$h) {
|
|
128
|
+
if (props.isJustified) rules += ' ha';
|
|
129
|
+
}
|
|
119
130
|
if (!$_8) rules += ' _8-3t1x';
|
|
120
131
|
if (!$q) rules += ' qa';
|
|
121
132
|
rules += ' _2d';
|
|
122
133
|
rules += ' _pb';
|
|
123
134
|
rules += ' __R-yksgrp';
|
|
135
|
+
rules += ' __Da';
|
|
136
|
+
rules += ' ba';
|
|
137
|
+
rules += ' wf';
|
|
138
|
+
rules += ' _vc';
|
|
139
|
+
rules += ' _wc';
|
|
140
|
+
rules += ' _xc';
|
|
141
|
+
rules += ' _yc';
|
|
124
142
|
rules += ' -rwx0fg_e-b';
|
|
125
143
|
rules += ' -_375toq_k-j';
|
|
126
144
|
return rules;
|
|
127
145
|
};
|
|
128
146
|
const $c679c2152e03f8bf$var$slider = function anonymous(props) {
|
|
129
147
|
let rules = " .";
|
|
130
|
-
if (props.isFocusVisible) rules += ' _Lb';
|
|
131
|
-
else rules += ' _La';
|
|
132
|
-
rules += ' da_____z';
|
|
133
|
-
rules += ' dx';
|
|
134
|
-
rules += ' _Nc';
|
|
135
|
-
rules += ' _M-3t1z';
|
|
136
148
|
if (props.isDisabled) rules += ' ba_____B';
|
|
137
149
|
else rules += ' ba_____z';
|
|
138
150
|
rules += ' bd';
|
|
@@ -163,39 +175,43 @@ function $c679c2152e03f8bf$var$SegmentedControl(props, ref) {
|
|
|
163
175
|
let domRef = (0, $ae3Tm$useDOMRef)(ref);
|
|
164
176
|
let prevRef = (0, $ae3Tm$useRef)(null);
|
|
165
177
|
let currentSelectedRef = (0, $ae3Tm$useRef)(null);
|
|
166
|
-
let onChange = (
|
|
178
|
+
let onChange = (values)=>{
|
|
167
179
|
if (currentSelectedRef.current) prevRef.current = currentSelectedRef?.current.getBoundingClientRect();
|
|
168
|
-
if (onSelectionChange) onSelectionChange(value);
|
|
180
|
+
if (onSelectionChange) onSelectionChange(values.values().next().value);
|
|
169
181
|
};
|
|
170
|
-
return /*#__PURE__*/ (0, $ae3Tm$jsx)((0, $ae3Tm$
|
|
182
|
+
return /*#__PURE__*/ (0, $ae3Tm$jsx)((0, $ae3Tm$ToggleButtonGroup), {
|
|
171
183
|
...props,
|
|
172
|
-
|
|
173
|
-
|
|
184
|
+
selectedKeys: selectedKey != null ? [
|
|
185
|
+
selectedKey
|
|
186
|
+
] : undefined,
|
|
187
|
+
defaultSelectedKeys: defaultSelectedKey != null ? [
|
|
188
|
+
defaultSelectedKey
|
|
189
|
+
] : undefined,
|
|
190
|
+
disallowEmptySelection: true,
|
|
174
191
|
ref: domRef,
|
|
175
192
|
orientation: "horizontal",
|
|
176
193
|
style: props.UNSAFE_style,
|
|
177
|
-
|
|
178
|
-
className: (props.UNSAFE_className || '') + $c679c2152e03f8bf$var$segmentedControl(
|
|
179
|
-
size: 'M'
|
|
180
|
-
}, props.styles),
|
|
194
|
+
onSelectionChange: onChange,
|
|
195
|
+
className: (props.UNSAFE_className || '') + $c679c2152e03f8bf$var$segmentedControl(null, props.styles),
|
|
181
196
|
"aria-label": props['aria-label'],
|
|
182
197
|
children: /*#__PURE__*/ (0, $ae3Tm$jsx)($c679c2152e03f8bf$var$DefaultSelectionTracker, {
|
|
183
198
|
defaultValue: defaultSelectedKey,
|
|
184
199
|
value: selectedKey,
|
|
185
200
|
prevRef: prevRef,
|
|
186
201
|
currentSelectedRef: currentSelectedRef,
|
|
202
|
+
isJustified: props.isJustified,
|
|
187
203
|
children: props.children
|
|
188
204
|
})
|
|
189
205
|
});
|
|
190
206
|
}
|
|
191
207
|
function $c679c2152e03f8bf$var$DefaultSelectionTracker(props) {
|
|
192
|
-
let state = (0, $ae3Tm$useContext)((0, $ae3Tm$
|
|
208
|
+
let state = (0, $ae3Tm$useContext)((0, $ae3Tm$ToggleGroupStateContext));
|
|
193
209
|
let isRegistered = (0, $ae3Tm$useRef)(!(props.defaultValue == null && props.value == null));
|
|
194
210
|
// default select the first available item
|
|
195
211
|
let register = (0, $ae3Tm$useCallback)((value)=>{
|
|
196
212
|
if (state && !isRegistered.current) {
|
|
197
213
|
isRegistered.current = true;
|
|
198
|
-
state.
|
|
214
|
+
state.toggleKey(value);
|
|
199
215
|
}
|
|
200
216
|
}, []);
|
|
201
217
|
return /*#__PURE__*/ (0, $ae3Tm$jsx)((0, $ae3Tm$Provider), {
|
|
@@ -205,7 +221,8 @@ function $c679c2152e03f8bf$var$DefaultSelectionTracker(props) {
|
|
|
205
221
|
{
|
|
206
222
|
register: register,
|
|
207
223
|
prevRef: props.prevRef,
|
|
208
|
-
currentSelectedRef: props.currentSelectedRef
|
|
224
|
+
currentSelectedRef: props.currentSelectedRef,
|
|
225
|
+
isJustified: props.isJustified
|
|
209
226
|
}
|
|
210
227
|
]
|
|
211
228
|
],
|
|
@@ -213,12 +230,11 @@ function $c679c2152e03f8bf$var$DefaultSelectionTracker(props) {
|
|
|
213
230
|
});
|
|
214
231
|
}
|
|
215
232
|
function $c679c2152e03f8bf$var$SegmentedControlItem(props, ref) {
|
|
216
|
-
let
|
|
217
|
-
let domRef = (0, $ae3Tm$useFocusableRef)(ref, inputRef);
|
|
233
|
+
let domRef = (0, $ae3Tm$useFocusableRef)(ref);
|
|
218
234
|
let divRef = (0, $ae3Tm$useRef)(null);
|
|
219
|
-
let { register: register, prevRef: prevRef, currentSelectedRef: currentSelectedRef } = (0, $ae3Tm$useContext)($c679c2152e03f8bf$var$InternalSegmentedControlContext);
|
|
220
|
-
let state = (0, $ae3Tm$useContext)((0, $ae3Tm$
|
|
221
|
-
let isSelected = props.id
|
|
235
|
+
let { register: register, prevRef: prevRef, currentSelectedRef: currentSelectedRef, isJustified: isJustified } = (0, $ae3Tm$useContext)($c679c2152e03f8bf$var$InternalSegmentedControlContext);
|
|
236
|
+
let state = (0, $ae3Tm$useContext)((0, $ae3Tm$ToggleGroupStateContext));
|
|
237
|
+
let isSelected = state?.selectedKeys.has(props.id);
|
|
222
238
|
// do not apply animation if a user has the prefers-reduced-motion setting
|
|
223
239
|
let isReduced = false;
|
|
224
240
|
if (window?.matchMedia) isReduced = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
@@ -247,20 +263,18 @@ function $c679c2152e03f8bf$var$SegmentedControlItem(props, ref) {
|
|
|
247
263
|
}, [
|
|
248
264
|
isSelected
|
|
249
265
|
]);
|
|
250
|
-
return /*#__PURE__*/ (0, $ae3Tm$jsx)((0, $ae3Tm$
|
|
266
|
+
return /*#__PURE__*/ (0, $ae3Tm$jsx)((0, $ae3Tm$ToggleButton), {
|
|
251
267
|
...props,
|
|
252
|
-
value: props.id,
|
|
253
268
|
ref: domRef,
|
|
254
|
-
inputRef: inputRef,
|
|
255
269
|
style: props.UNSAFE_style,
|
|
256
270
|
className: (renderProps)=>(props.UNSAFE_className || '') + $c679c2152e03f8bf$var$controlItem({
|
|
257
|
-
...renderProps
|
|
271
|
+
...renderProps,
|
|
272
|
+
isJustified: isJustified
|
|
258
273
|
}, props.styles),
|
|
259
|
-
children: ({ isSelected: isSelected,
|
|
274
|
+
children: ({ isSelected: isSelected, isPressed: isPressed, isDisabled: isDisabled })=>/*#__PURE__*/ (0, $ae3Tm$jsxs)((0, $ae3Tm$Fragment), {
|
|
260
275
|
children: [
|
|
261
276
|
isSelected && /*#__PURE__*/ (0, $ae3Tm$jsx)("div", {
|
|
262
277
|
className: $c679c2152e03f8bf$var$slider({
|
|
263
|
-
isFocusVisible: isFocusVisible,
|
|
264
278
|
isDisabled: isDisabled
|
|
265
279
|
}),
|
|
266
280
|
ref: currentSelectedRef
|