@fluentui/react-switch 0.0.0-nightly627ad67f1120211109.1 → 0.0.0-nightly6faffd280a20220221.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.json +270 -26
- package/CHANGELOG.md +75 -15
- package/dist/react-switch.d.ts +12 -17
- package/lib/Switch.js.map +1 -1
- package/lib/components/Switch/Switch.js +6 -6
- package/lib/components/Switch/Switch.js.map +1 -1
- package/lib/components/Switch/Switch.types.d.ts +10 -9
- package/lib/components/Switch/Switch.types.js.map +1 -1
- package/lib/components/Switch/index.js.map +1 -1
- package/lib/components/Switch/renderSwitch.d.ts +1 -1
- package/lib/components/Switch/renderSwitch.js +9 -4
- package/lib/components/Switch/renderSwitch.js.map +1 -1
- package/lib/components/Switch/useSwitch.d.ts +2 -6
- package/lib/components/Switch/useSwitch.js +1 -6
- package/lib/components/Switch/useSwitch.js.map +1 -1
- package/lib/components/Switch/useSwitchState.js +1 -1
- package/lib/components/Switch/useSwitchState.js.map +1 -1
- package/lib/components/Switch/useSwitchStyles.d.ts +1 -1
- package/lib/components/Switch/useSwitchStyles.js +49 -44
- package/lib/components/Switch/useSwitchStyles.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib-commonjs/Switch.js.map +1 -1
- package/lib-commonjs/components/Switch/Switch.js +3 -3
- package/lib-commonjs/components/Switch/Switch.js.map +1 -1
- package/lib-commonjs/components/Switch/Switch.types.d.ts +10 -9
- package/lib-commonjs/components/Switch/Switch.types.js.map +1 -1
- package/lib-commonjs/components/Switch/index.js.map +1 -1
- package/lib-commonjs/components/Switch/renderSwitch.d.ts +1 -1
- package/lib-commonjs/components/Switch/renderSwitch.js +11 -7
- package/lib-commonjs/components/Switch/renderSwitch.js.map +1 -1
- package/lib-commonjs/components/Switch/useSwitch.d.ts +2 -6
- package/lib-commonjs/components/Switch/useSwitch.js +4 -9
- package/lib-commonjs/components/Switch/useSwitch.js.map +1 -1
- package/lib-commonjs/components/Switch/useSwitchState.js +1 -1
- package/lib-commonjs/components/Switch/useSwitchState.js.map +1 -1
- package/lib-commonjs/components/Switch/useSwitchStyles.d.ts +1 -1
- package/lib-commonjs/components/Switch/useSwitchStyles.js +64 -58
- package/lib-commonjs/components/Switch/useSwitchStyles.js.map +1 -1
- package/lib-commonjs/index.js.map +1 -1
- package/package.json +10 -15
- package/lib/common/isConformant.d.ts +0 -4
- package/lib/common/isConformant.js +0 -12
- package/lib/common/isConformant.js.map +0 -1
- package/lib-commonjs/common/isConformant.d.ts +0 -4
- package/lib-commonjs/common/isConformant.js +0 -23
- package/lib-commonjs/common/isConformant.js.map +0 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Switch.types.js","sourceRoot":"","sources":["
|
1
|
+
{"version":3,"file":"Switch.types.js","sourceRoot":"../src/","sources":["components/Switch/Switch.types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\nimport type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\n\nexport type SwitchSlots = {\n /**\n * The root of the Switch.\n */\n root: Slot<'div'>;\n\n /**\n * The bar indicating the status of the Switch.\n */\n track: NonNullable<Slot<'div'>>;\n\n /**\n * The wrapper around the thumb. It is used as the active area for the thumb to position itself.\n */\n thumbWrapper: NonNullable<Slot<'div'>>;\n\n /**\n * The circular icon indicating the status of the Switch.\n */\n thumb: NonNullable<Slot<'div'>>;\n\n /**\n * The hidden input that handles the Switch's internal functionality.\n */\n input: NonNullable<Slot<'input'>>;\n\n /**\n * The area in which the Switch's rail allows for the thumb to be dragged.\n */\n activeRail: NonNullable<Slot<'div'>>;\n};\n\ninterface SwitchCommons {\n /**\n * The starting value for a uncontrolled Switch. If `true` then the Switch will be enabled.\n * Mutually exclusive with `checked` prop.\n *\n * @default false\n */\n defaultChecked?: boolean;\n\n /**\n * The current value for a controlled Switch. If `true` then the Switch will be enabled.\n * Mutually exclusive with `defaultChecked` prop.\n */\n checked?: boolean;\n\n /**\n * Whether the Switch should be disabled.\n *\n * @default false\n */\n disabled?: boolean;\n\n /**\n * Callback to be called when the `checked` value changes.\n */\n onChange?: (\n ev: React.PointerEvent<HTMLDivElement> | React.KeyboardEvent<HTMLDivElement>,\n data: {\n checked: boolean;\n },\n ) => void;\n}\n\nexport interface SwitchProps extends Omit<ComponentProps<Partial<SwitchSlots>>, 'onChange'>, SwitchCommons {}\n\nexport interface SwitchState extends ComponentState<SwitchSlots>, SwitchCommons {}\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["components/Switch/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC","sourcesContent":["export * from './Switch';\nexport * from './Switch.types';\nexport * from './renderSwitch';\nexport * from './useSwitch';\nexport * from './useSwitchStyles';\n"]}
|
@@ -1,15 +1,20 @@
|
|
1
1
|
import * as React from 'react';
|
2
2
|
import { getSlots } from '@fluentui/react-utilities';
|
3
|
-
import { switchShorthandProps } from './useSwitch';
|
4
3
|
/**
|
5
4
|
* Render the final JSX of Switch
|
6
5
|
*/
|
7
6
|
|
8
|
-
export const
|
7
|
+
export const renderSwitch_unstable = state => {
|
9
8
|
const {
|
10
9
|
slots,
|
11
10
|
slotProps
|
12
|
-
} = getSlots(state
|
13
|
-
return /*#__PURE__*/React.createElement(slots.root,
|
11
|
+
} = getSlots(state);
|
12
|
+
return /*#__PURE__*/React.createElement(slots.root, { ...slotProps.root
|
13
|
+
}, /*#__PURE__*/React.createElement(slots.track, { ...slotProps.track
|
14
|
+
}), /*#__PURE__*/React.createElement(slots.thumbWrapper, { ...slotProps.thumbWrapper
|
15
|
+
}, /*#__PURE__*/React.createElement(slots.thumb, { ...slotProps.thumb
|
16
|
+
})), /*#__PURE__*/React.createElement(slots.input, { ...slotProps.input
|
17
|
+
}), /*#__PURE__*/React.createElement(slots.activeRail, { ...slotProps.activeRail
|
18
|
+
}));
|
14
19
|
};
|
15
20
|
//# sourceMappingURL=renderSwitch.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["components/Switch/renderSwitch.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,QAAT,QAAyB,2BAAzB;AAGA;;AAEG;;AACH,OAAO,MAAM,qBAAqB,GAAI,KAAD,IAAuB;AAC1D,QAAM;AAAE,IAAA,KAAF;AAAS,IAAA;AAAT,MAAuB,QAAQ,CAAc,KAAd,CAArC;AAEA,sBACE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,IAAP,EAAW,EAAA,GAAK,SAAS,CAAC;AAAf,GAAX,eACE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,KAAP,EAAY,EAAA,GAAK,SAAS,CAAC;AAAf,GAAZ,CADF,eAEE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,YAAP,EAAmB,EAAA,GAAK,SAAS,CAAC;AAAf,GAAnB,eACE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,KAAP,EAAY,EAAA,GAAK,SAAS,CAAC;AAAf,GAAZ,CADF,CAFF,eAKE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,KAAP,EAAY,EAAA,GAAK,SAAS,CAAC;AAAf,GAAZ,CALF,eAME,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,UAAP,EAAiB,EAAA,GAAK,SAAS,CAAC;AAAf,GAAjB,CANF,CADF;AAUD,CAbM","sourcesContent":["import * as React from 'react';\nimport { getSlots } from '@fluentui/react-utilities';\nimport type { SwitchState, SwitchSlots } from './Switch.types';\n\n/**\n * Render the final JSX of Switch\n */\nexport const renderSwitch_unstable = (state: SwitchState) => {\n const { slots, slotProps } = getSlots<SwitchSlots>(state);\n\n return (\n <slots.root {...slotProps.root}>\n <slots.track {...slotProps.track} />\n <slots.thumbWrapper {...slotProps.thumbWrapper}>\n <slots.thumb {...slotProps.thumb} />\n </slots.thumbWrapper>\n <slots.input {...slotProps.input} />\n <slots.activeRail {...slotProps.activeRail} />\n </slots.root>\n );\n};\n"],"sourceRoot":"../src/"}
|
@@ -1,10 +1,6 @@
|
|
1
1
|
import * as React from 'react';
|
2
|
-
import type { SwitchProps,
|
3
|
-
/**
|
4
|
-
* Array of all shorthand properties listed in SwitchSlots
|
5
|
-
*/
|
6
|
-
export declare const switchShorthandProps: (keyof SwitchSlots)[];
|
2
|
+
import type { SwitchProps, SwitchState } from './Switch.types';
|
7
3
|
/**
|
8
4
|
* Given user props, returns state and render function for a Switch.
|
9
5
|
*/
|
10
|
-
export declare const
|
6
|
+
export declare const useSwitch_unstable: (props: SwitchProps, ref: React.Ref<HTMLElement>) => SwitchState;
|
@@ -1,15 +1,10 @@
|
|
1
1
|
import { getNativeElementProps, resolveShorthand, useId } from '@fluentui/react-utilities';
|
2
2
|
import { useSwitchState } from './useSwitchState';
|
3
|
-
/**
|
4
|
-
* Array of all shorthand properties listed in SwitchSlots
|
5
|
-
*/
|
6
|
-
|
7
|
-
export const switchShorthandProps = ['root', 'track', 'thumbWrapper', 'thumb', 'activeRail', 'input'];
|
8
3
|
/**
|
9
4
|
* Given user props, returns state and render function for a Switch.
|
10
5
|
*/
|
11
6
|
|
12
|
-
export const
|
7
|
+
export const useSwitch_unstable = (props, ref) => {
|
13
8
|
const {
|
14
9
|
track,
|
15
10
|
thumbWrapper,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["components/Switch/useSwitch.ts"],"names":[],"mappings":"AACA,SAAS,qBAAT,EAAgC,gBAAhC,EAAkD,KAAlD,QAA+D,2BAA/D;AACA,SAAS,cAAT,QAA+B,kBAA/B;AAGA;;AAEG;;AACH,OAAO,MAAM,kBAAkB,GAAG,CAAC,K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AA,IAAI,EAAE;AADM;AAFe,KAAR;AAtBE,GAA3B;AA8BA,EAAA,cAAc,CAAC,KAAD,CAAd;AAEA,SAAO,KAAP;AACD,CAnCM","sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps, resolveShorthand, useId } from '@fluentui/react-utilities';\nimport { useSwitchState } from './useSwitchState';\nimport type { SwitchProps, SwitchState } from './Switch.types';\n\n/**\n * Given user props, returns state and render function for a Switch.\n */\nexport const useSwitch_unstable = (props: SwitchProps, ref: React.Ref<HTMLElement>): SwitchState => {\n const { track, thumbWrapper, thumb, activeRail, input, defaultChecked, checked, disabled, onChange } = props;\n const state: SwitchState = {\n defaultChecked,\n checked,\n disabled,\n onChange,\n root: getNativeElementProps('span', {\n ref,\n ...props,\n id: useId('switch-', props.id),\n }),\n components: {\n root: 'div',\n track: 'div',\n thumbWrapper: 'div',\n thumb: 'div',\n activeRail: 'div',\n input: 'input',\n },\n track: resolveShorthand(track, { required: true }),\n thumbWrapper: resolveShorthand(thumbWrapper, { required: true }),\n thumb: resolveShorthand(thumb, { required: true }),\n activeRail: resolveShorthand(activeRail, { required: true }),\n input: resolveShorthand(input, {\n required: true,\n defaultProps: {\n type: 'checkbox',\n },\n }),\n };\n\n useSwitchState(state);\n\n return state;\n};\n"],"sourceRoot":"../src/"}
|
@@ -38,7 +38,7 @@ export const useSwitchState = state => {
|
|
38
38
|
setTrue: showThumbAnimation,
|
39
39
|
setFalse: hideThumbAnimation
|
40
40
|
}] = useBoolean(true);
|
41
|
-
const [renderedPosition, setRenderedPosition] = React.useState(
|
41
|
+
const [renderedPosition, setRenderedPosition] = React.useState(undefined);
|
42
42
|
const setChecked = useEventCallback((ev, incomingValue) => {
|
43
43
|
ev.stopPropagation();
|
44
44
|
ev.preventDefault();
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/components/Switch/useSwitchState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,KAAT,E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AC,IAAN,CAAW,aAAX,GAA2B,aAA3B;AACA,IAAA,KAAK,CAAC,IAAN,CAAW,OAAX,GAAqB,OAArB;AACD,GArIkD,CAuInD;;;AACA,EAAA,KAAK,CAAC,KAAN,CAAY,OAAZ,GAAsB,YAAtB;AACA,EAAA,KAAK,CAAC,KAAN,CAAY,QAAZ,GAAuB,QAAvB;AACA,EAAA,KAAK,CAAC,KAAN,CAAY,GAAZ,GAAkB,QAAlB;AACA,EAAA,KAAK,CAAC,KAAN,CAAY,QAAZ,GAAuB,IAAvB;AACA,EAAA,KAAK,CAAC,KAAN,CAAY,IAAZ,GAAmB,QAAnB,CA5ImD,CA8InD;;AACA,EAAA,KAAK,CAAC,YAAN,CAAmB,KAAnB,GAA2B,kBAA3B,CA/ImD,CAiJnD;;AACA,EAAA,KAAK,CAAC,UAAN,CAAiB,GAAjB,GAAuB,OAAvB;AAEA,SAAO,KAAP;AACD,CArJM","sourcesContent":["import * as React from 'react';\nimport { clamp, useBoolean, useControllableState, useEventCallback, useMergedRefs } from '@fluentui/react-utilities';\nimport { useFluent } from '@fluentui/react-shared-contexts';\nimport type { SwitchState } from './Switch.types';\n\ntype SwitchInternalState = {\n /**\n * The internal rendered value of the Switch.\n */\n internalValue: boolean;\n\n /**\n * Whether the thumb is currently being dragged.\n */\n thumbIsDragging: boolean;\n\n /**\n * Disposable events for the Switch.\n */\n disposables: (() => void)[];\n};\n\n// TODO: This should be replaced with a useEvent hook\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst on = (element: Element, eventName: string, callback: (ev: any) => void) => {\n element.addEventListener(eventName, callback);\n return () => element.removeEventListener(eventName, callback);\n};\n\nexport const useSwitchState = (state: SwitchState) => {\n const { defaultChecked = false, checked, disabled = false, onChange } = state;\n const { onPointerDown: onPointerDownCallback, onKeyUp: onKeyUpCallback } = state.root;\n\n const { dir } = useFluent();\n const inputRef = useMergedRefs(state.input.ref);\n const railRef = React.useRef<HTMLDivElement>(null);\n const internalState = React.useRef<SwitchInternalState>({\n internalValue: checked ? checked : defaultChecked,\n thumbIsDragging: false,\n disposables: [],\n });\n\n const [currentValue, setCurrentValue] = useControllableState({\n defaultState: defaultChecked,\n state: checked,\n initialState: false,\n });\n const [thumbAnimation, { setTrue: showThumbAnimation, setFalse: hideThumbAnimation }] = useBoolean(true);\n const [renderedPosition, setRenderedPosition] = React.useState<number | undefined>(undefined);\n\n const setChecked = useEventCallback(\n (ev: React.PointerEvent<HTMLDivElement> | React.KeyboardEvent<HTMLDivElement>, incomingValue: boolean) => {\n ev.stopPropagation();\n ev.preventDefault();\n internalState.current.internalValue = incomingValue;\n onChange?.(ev, { checked: incomingValue });\n setCurrentValue(incomingValue);\n setRenderedPosition(undefined);\n },\n );\n\n const calculatePosition = React.useCallback(\n (ev: React.PointerEvent<HTMLDivElement>): number => {\n const currentBounds = railRef?.current?.getBoundingClientRect();\n const railWidth = currentBounds!.width;\n const railPosition = dir === 'rtl' ? currentBounds!.right : currentBounds!.left;\n const distance = dir === 'rtl' ? railPosition - ev.clientX : ev.clientX - railPosition;\n return clamp((distance / railWidth) * 100, 0, 100);\n },\n [dir],\n );\n\n const onPointerMove = React.useCallback(\n (ev: React.PointerEvent<HTMLDivElement>): void => {\n const incomingPosition = calculatePosition(ev);\n\n internalState.current.thumbIsDragging = true;\n hideThumbAnimation();\n setRenderedPosition(incomingPosition);\n\n // If the Switch reaches a new position of 0% or 100%, update the state and fire change.\n if (incomingPosition === 100 && internalState.current.internalValue !== true) {\n setChecked(ev, true);\n } else if (incomingPosition === 0 && internalState.current.internalValue !== false) {\n setChecked(ev, false);\n }\n },\n [calculatePosition, hideThumbAnimation, setChecked],\n );\n\n const onPointerUp = React.useCallback(\n (ev: React.PointerEvent<HTMLDivElement>): void => {\n internalState.current.disposables.forEach(dispose => dispose());\n internalState.current.disposables = [];\n inputRef.current!.focus();\n\n if (internalState.current.thumbIsDragging) {\n const roundedPosition = Math.round(calculatePosition(ev)! / 100) * 100;\n\n showThumbAnimation();\n if (roundedPosition === 100) {\n setChecked(ev, true);\n } else if (roundedPosition === 0) {\n setChecked(ev, false);\n }\n } else {\n setChecked(ev, !internalState.current.internalValue);\n }\n },\n [calculatePosition, inputRef, setChecked, showThumbAnimation],\n );\n\n const onPointerDown = React.useCallback(\n (ev: React.PointerEvent<HTMLDivElement>): void => {\n const { pointerId } = ev;\n const target = ev.target as HTMLElement;\n\n onPointerDownCallback?.(ev);\n showThumbAnimation();\n target.setPointerCapture?.(pointerId);\n internalState.current.thumbIsDragging = false;\n\n internalState.current.disposables.push(\n on(target, 'pointermove', onPointerMove),\n on(target, 'pointerup', onPointerUp),\n () => {\n target.releasePointerCapture?.(pointerId);\n },\n );\n },\n [onPointerDownCallback, onPointerMove, onPointerUp, showThumbAnimation],\n );\n\n const onKeyUp = React.useCallback(\n (ev: React.KeyboardEvent<HTMLDivElement>): void => {\n onKeyUpCallback?.(ev);\n if (ev.key === ' ') {\n setChecked(ev, !internalState.current.internalValue);\n }\n },\n [onKeyUpCallback, setChecked],\n );\n\n const currentPosition = renderedPosition !== undefined ? renderedPosition : currentValue ? 100 : 0;\n\n const rootStyles = {\n '--switch-checked-opacity': currentPosition / 100,\n '--switch-unchecked-opacity': (100 - currentPosition) / 100,\n } as React.CSSProperties;\n\n const thumbWrapperStyles = {\n transform: `translate(${dir === 'rtl' ? -currentPosition : currentPosition}%)`,\n transition: thumbAnimation\n ? 'transform .1s cubic-bezier(0.33, 0.0, 0.67, 1), opacity .1s cubic-bezier(0.33, 0.0, 0.67, 1)'\n : 'none',\n };\n\n // Root Props\n state.root.style = rootStyles;\n if (!disabled) {\n state.root.onPointerDown = onPointerDown;\n state.root.onKeyUp = onKeyUp;\n }\n\n // Input Props\n state.input.checked = currentValue;\n state.input.disabled = disabled;\n state.input.ref = inputRef;\n state.input.readOnly = true;\n state.input.role = 'switch';\n\n // Thumb Container Props\n state.thumbWrapper.style = thumbWrapperStyles;\n\n // Active Rail Props\n state.activeRail.ref = railRef;\n\n return state;\n};\n"],"sourceRoot":"../src/"}
|
@@ -3,4 +3,4 @@ export declare const switchClassName = "fui-Switch";
|
|
3
3
|
/**
|
4
4
|
* Apply styling to the Switch slots based on the state
|
5
5
|
*/
|
6
|
-
export declare const
|
6
|
+
export declare const useSwitchStyles_unstable: (state: SwitchState) => SwitchState;
|
@@ -1,5 +1,6 @@
|
|
1
|
-
import { __styles, mergeClasses } from '@
|
1
|
+
import { shorthands, __styles, mergeClasses } from '@griffel/react';
|
2
2
|
import { createFocusOutlineStyle } from '@fluentui/react-tabster';
|
3
|
+
import { tokens } from '@fluentui/react-theme';
|
3
4
|
export const switchClassName = 'fui-Switch';
|
4
5
|
const trackClassName = `${switchClassName}-track`;
|
5
6
|
const thumbClassName = `${switchClassName}-thumb`;
|
@@ -23,15 +24,12 @@ const useRootStyles = /*#__PURE__*/__styles({
|
|
23
24
|
"ha4doy": "f1qdqbpl"
|
24
25
|
},
|
25
26
|
"unchecked": {
|
26
|
-
"
|
27
|
-
"
|
28
|
-
"Hdeks4": ["f1cjufhn", "f1395m7v"],
|
29
|
-
"sn1se1": "fyo9fdn",
|
30
|
-
"Bspkfwm": ["f1395m7v", "f1cjufhn"]
|
27
|
+
"d48c0s": "frinyyk",
|
28
|
+
"Bc6qnd8": "f1g8lwx2"
|
31
29
|
},
|
32
30
|
"checked": {
|
33
|
-
"
|
34
|
-
"
|
31
|
+
"Banj4pq": "fpfyfb6",
|
32
|
+
"Brktkwq": "f3vtzeg"
|
35
33
|
},
|
36
34
|
"enabled": {
|
37
35
|
"H36rlo": "felqjlh",
|
@@ -43,37 +41,25 @@ const useRootStyles = /*#__PURE__*/__styles({
|
|
43
41
|
},
|
44
42
|
"focusIndicator": {
|
45
43
|
"B486eqv": "f2hkw1w",
|
46
|
-
"
|
47
|
-
"ozrjjd": ["fq2kn9", "f1jxwnad"],
|
48
|
-
"B7lelfh": "f1il7mou",
|
49
|
-
"Bp3tz3o": ["f1jxwnad", "fq2kn9"],
|
44
|
+
"c2y4jd": "fsofd9k",
|
50
45
|
"B8vm7ur": "f12sql3b",
|
51
46
|
"f4hv8x": "f1i4q40k",
|
52
47
|
"Gpan81": "fcrbge9",
|
53
48
|
"z7afg": "ft464mn",
|
54
49
|
"rsjj6t": "fskqmiq",
|
55
|
-
"
|
56
|
-
"
|
57
|
-
"Bhtq6h7": "f14hlsw1",
|
58
|
-
"Bubk9yy": ["fpuz8dn", "fw1d893"],
|
59
|
-
"dzajus": "f1bkt4b4",
|
60
|
-
"B8gmrwi": ["f16hf5f2", "f1qhqcal"],
|
61
|
-
"Byq6oy9": "fyyqeim",
|
62
|
-
"Bdy2j38": ["f1qhqcal", "f16hf5f2"],
|
50
|
+
"Bqsd8kq": "f2gy8jn",
|
51
|
+
"sfhsbh": "f1pke3uf",
|
63
52
|
"Bugh3ej": "f18xdlq9",
|
64
|
-
"
|
65
|
-
"Ba33l6n": ["f1horip2", "fgnx9ah"],
|
66
|
-
"va7z1g": "fkii2tb",
|
67
|
-
"Bmi6mq9": ["fgnx9ah", "f1horip2"],
|
53
|
+
"hpanx6": "f1114nks",
|
68
54
|
"Bjkpy09": "f1rh66yx",
|
69
55
|
"Jxg1p8": "f19ibq92",
|
70
56
|
"Bc94xmo": ["fc3tncn", "f1veb610"],
|
71
57
|
"Bj23z95": ["f1veb610", "fc3tncn"]
|
72
58
|
}
|
73
59
|
}, {
|
74
|
-
"d": [".frxo1y7{--switch-width:40px;}", ".fe5s2ct{--switch-height:20px;}", ".f1n6k660{--switch-thumb-size:14px;}", ".f17m95gg{--switch-checked-opacity:0;}", ".fp7zjh8{--switch-unchecked-opacity:0;}", ".f10pi13n{position:relative;}", ".fnceurk{width:var(--switch-width);}", ".f15da5dy{height:var(--switch-height);}", ".f14t3ns0{display:inline-block;}", ".f1xqy1su{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}", ".f1sdsnyy{touch-action:none;}", ".f1qdqbpl{vertical-align:bottom;}", ".felqjlh{-webkit-tap-highlight-color:rgba(0,0,0,0);}", ".f1k6fduh{cursor:pointer;}", ".fdrzuqr{cursor:not-allowed;}", ".f1aehjj5{pointer-events:none;}", "[data-keyboard-nav] .
|
75
|
-
"h": [".
|
76
|
-
"a": [".
|
60
|
+
"d": [".frxo1y7{--switch-width:40px;}", ".fe5s2ct{--switch-height:20px;}", ".f1n6k660{--switch-thumb-size:14px;}", ".f17m95gg{--switch-checked-opacity:0;}", ".fp7zjh8{--switch-unchecked-opacity:0;}", ".f10pi13n{position:relative;}", ".fnceurk{width:var(--switch-width);}", ".f15da5dy{height:var(--switch-height);}", ".f14t3ns0{display:inline-block;}", ".f1xqy1su{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}", ".f1sdsnyy{touch-action:none;}", ".f1qdqbpl{vertical-align:bottom;}", ".felqjlh{-webkit-tap-highlight-color:rgba(0,0,0,0);}", ".f1k6fduh{cursor:pointer;}", ".fdrzuqr{cursor:not-allowed;}", ".f1aehjj5{pointer-events:none;}", "[data-keyboard-nav] .fsofd9k:focus-within{border-color:transparent;}", "[data-keyboard-nav] .f12sql3b:focus-within:after{content:\"\";}", "[data-keyboard-nav] .f1i4q40k:focus-within:after{position:absolute;}", "[data-keyboard-nav] .fcrbge9:focus-within:after{pointer-events:none;}", "[data-keyboard-nav] .ft464mn:focus-within:after{box-sizing:outline-box;}", "[data-keyboard-nav] .fskqmiq:focus-within:after{z-index:1;}", "[data-keyboard-nav] .f2gy8jn:focus-within:after{border-style:solid;}", "[data-keyboard-nav] .f1pke3uf:focus-within:after{border-width:2px;}", "[data-keyboard-nav] .f18xdlq9:focus-within:after{border-radius:var(--borderRadiusMedium);}", "[data-keyboard-nav] .f1114nks:focus-within:after{border-color:var(--colorStrokeFocus2);}", "[data-keyboard-nav] .f1rh66yx:focus-within:after{top:calc(0px - 2px - 8px);}", "[data-keyboard-nav] .f19ibq92:focus-within:after{bottom:calc(0px - 2px - 8px);}", "[data-keyboard-nav] .fc3tncn:focus-within:after{left:calc(0px - 2px - 8px);}", "[data-keyboard-nav] .f1veb610:focus-within:after{right:calc(0px - 2px - 8px);}"],
|
61
|
+
"h": [".frinyyk:hover .fui-Switch-thumb:before{background-color:var(--colorNeutralStrokeAccessibleHover);}", ".f1g8lwx2:hover .fui-Switch-track:before{border-color:var(--colorNeutralStrokeAccessibleHover);}", ".fpfyfb6:hover .fui-Switch-track:after{background-color:var(--colorBrandBackgroundHover);}"],
|
62
|
+
"a": [".f3vtzeg:active .fui-Switch-track:after{background-color:var(--colorBrandBackgroundPressed);}"],
|
77
63
|
"i": [".f2hkw1w:focus-visible{outline-style:none;}"]
|
78
64
|
});
|
79
65
|
/**
|
@@ -86,7 +72,9 @@ const useTrackStyles = /*#__PURE__*/__styles({
|
|
86
72
|
"qhf8xq": "f1euv43f",
|
87
73
|
"a9b677": "fly5x3f",
|
88
74
|
"Bqenvij": "f1l02sjl",
|
89
|
-
"
|
75
|
+
"Bmy1vo4": "fmslzlq",
|
76
|
+
"B3o57yi": "f15vu5tu",
|
77
|
+
"Bkqvd7p": "f1e1a42z",
|
90
78
|
"lpbzjs": "f1sdsnyy",
|
91
79
|
"Bkecrkj": "f1aehjj5",
|
92
80
|
"xx9plb": "fxf9f1y",
|
@@ -95,7 +83,10 @@ const useTrackStyles = /*#__PURE__*/__styles({
|
|
95
83
|
"Bj2wrql": "f3zr33r",
|
96
84
|
"qd6xl9": ["ff0gctb", "f8g0ba1"],
|
97
85
|
"Bmqnesq": "f170vdtw",
|
98
|
-
"
|
86
|
+
"px8gyy": ["f7lyffi", "fmk9c8u"],
|
87
|
+
"B5c9fhp": ["fmk9c8u", "f7lyffi"],
|
88
|
+
"Bhe99jt": ["f1nat4im", "fw5qzmy"],
|
89
|
+
"B2r1szc": ["fw5qzmy", "f1nat4im"],
|
99
90
|
"rurcny": "f99sooz",
|
100
91
|
"ngabwx": "f1uhpfti",
|
101
92
|
"Hdbjpj": "f11ef69",
|
@@ -104,7 +95,10 @@ const useTrackStyles = /*#__PURE__*/__styles({
|
|
104
95
|
"Bj55yzk": "f13gddrr",
|
105
96
|
"cnmfks": ["f1oarbwq", "f1bp8q63"],
|
106
97
|
"oqd9ik": "ffdc0f3",
|
107
|
-
"
|
98
|
+
"frdscb": ["f1xuwyw0", "f12j4hro"],
|
99
|
+
"B9nohqn": ["f12j4hro", "f1xuwyw0"],
|
100
|
+
"B1dhsta": ["f1mf29j", "f1nzm45q"],
|
101
|
+
"Bjdmjzx": ["f1nzm45q", "f1mf29j"],
|
108
102
|
"Bs6t6z0": "f77y9vx",
|
109
103
|
"Bmyypfa": "frd86tk"
|
110
104
|
},
|
@@ -121,10 +115,10 @@ const useTrackStyles = /*#__PURE__*/__styles({
|
|
121
115
|
"I89eb": ["f149mt9j", "fs3bzhx"],
|
122
116
|
"Bp1vogq": "f14z72z2",
|
123
117
|
"Bohd3ja": ["fs3bzhx", "f149mt9j"],
|
124
|
-
"
|
118
|
+
"B1dvbpk": "f1k1dzc6"
|
125
119
|
},
|
126
120
|
"checked": {
|
127
|
-
"
|
121
|
+
"Bkbwdz4": "f8mks4l",
|
128
122
|
"rskduk": "f1so6udy",
|
129
123
|
"Dctjco": ["f1faxgr0", "f1wf3et7"],
|
130
124
|
"J4s2b0": "f124kgxn",
|
@@ -157,10 +151,10 @@ const useTrackStyles = /*#__PURE__*/__styles({
|
|
157
151
|
"B13j16c": ["f11zx3qq", "fqewq1t"],
|
158
152
|
"Bk8j60v": "fmewjpk",
|
159
153
|
"Bpbi4o9": ["fqewq1t", "f11zx3qq"],
|
160
|
-
"
|
154
|
+
"Bkbwdz4": "f132yvl5"
|
161
155
|
}
|
162
156
|
}, {
|
163
|
-
"d": [".f1euv43f{position:absolute;}", ".fly5x3f{width:100%;}", ".f1l02sjl{height:100%;}", ".
|
157
|
+
"d": [".f1euv43f{position:absolute;}", ".fly5x3f{width:100%;}", ".f1l02sjl{height:100%;}", ".fmslzlq{transition-property:backgroundColor;}", ".f15vu5tu{transition-duration:0.1s;}", ".f1e1a42z{transition-timing-function:cubic-bezier(0.33, 0, 0.67, 1);}", ".f1sdsnyy{touch-action:none;}", ".f1aehjj5{pointer-events:none;}", ".fxf9f1y:before{position:absolute;}", ".frdto5n:before{top:0px;}", ".f8g0ba1:before{left:0px;}", ".ff0gctb:before{right:0px;}", ".f3zr33r:before{bottom:0px;}", ".f170vdtw:before{box-sizing:border-box;}", ".f7lyffi:before{border-bottom-right-radius:999px;}", ".fmk9c8u:before{border-bottom-left-radius:999px;}", ".f1nat4im:before{border-top-right-radius:999px;}", ".fw5qzmy:before{border-top-left-radius:999px;}", ".f99sooz:before{content:'';}", ".f1uhpfti:before{opacity:var(--switch-unchecked-opacity);}", ".f11ef69:after{position:absolute;}", ".f1yuyem3:after{top:0px;}", ".f1bp8q63:after{left:0px;}", ".f1oarbwq:after{right:0px;}", ".f13gddrr:after{bottom:0px;}", ".ffdc0f3:after{box-sizing:border-box;}", ".f1xuwyw0:after{border-bottom-right-radius:999px;}", ".f12j4hro:after{border-bottom-left-radius:999px;}", ".f1mf29j:after{border-top-right-radius:999px;}", ".f1nzm45q:after{border-top-left-radius:999px;}", ".f77y9vx:after{content:'';}", ".frd86tk:after{opacity:var(--switch-checked-opacity);}", ".f199l62q:before{border-top-width:1px;}", ".f1pa2qi2:before{border-right-width:1px;}", ".f1ooiv2t:before{border-left-width:1px;}", ".fyqop9u:before{border-bottom-width:1px;}", ".f1bwkb58:before{border-top-style:solid;}", ".fiio4mc:before{border-right-style:solid;}", ".fc8z0qo:before{border-left-style:solid;}", ".f1m5ya7j:before{border-bottom-style:solid;}", ".f1gqzwee:before{border-top-color:var(--colorNeutralStrokeAccessible);}", ".f149mt9j:before{border-right-color:var(--colorNeutralStrokeAccessible);}", ".fs3bzhx:before{border-left-color:var(--colorNeutralStrokeAccessible);}", ".f14z72z2:before{border-bottom-color:var(--colorNeutralStrokeAccessible);}", ".f1k1dzc6:before{background-color:transparent;}", ".f8mks4l:after{background-color:var(--colorBrandBackground);}", ".f1so6udy:after{border-top-style:none;}", ".f1faxgr0:after{border-right-style:none;}", ".f1wf3et7:after{border-left-style:none;}", ".f124kgxn:after{border-bottom-style:none;}", ".fntj282:before{border-top-color:var(--colorNeutralStrokeDisabled);}", ".fzta9nb:before{border-right-color:var(--colorNeutralStrokeDisabled);}", ".f17m9iy5:before{border-left-color:var(--colorNeutralStrokeDisabled);}", ".f1k4exvn:before{border-bottom-color:var(--colorNeutralStrokeDisabled);}", ".f1l5cenb:after{border-top-width:1px;}", ".f1jvubu3:after{border-right-width:1px;}", ".f1q1uvzd:after{border-left-width:1px;}", ".f2fxry3:after{border-bottom-width:1px;}", ".f1iq3fds:after{border-top-style:solid;}", ".f1r2jemi:after{border-right-style:solid;}", ".f11olovk:after{border-left-style:solid;}", ".fd0py6g:after{border-bottom-style:solid;}", ".f2uxs13:after{border-top-color:var(--colorTransparentStrokeDisabled);}", ".f11zx3qq:after{border-right-color:var(--colorTransparentStrokeDisabled);}", ".fqewq1t:after{border-left-color:var(--colorTransparentStrokeDisabled);}", ".fmewjpk:after{border-bottom-color:var(--colorTransparentStrokeDisabled);}", ".f132yvl5:after{background-color:var(--colorNeutralBackgroundDisabled);}"]
|
164
158
|
});
|
165
159
|
/**
|
166
160
|
* Styles for the thumb wrapper slot
|
@@ -191,10 +185,15 @@ const useThumbStyles = /*#__PURE__*/__styles({
|
|
191
185
|
"a9b677": "fcjrtee",
|
192
186
|
"Bqenvij": "fili5n9",
|
193
187
|
"B7ck84d": "f1ewtqcl",
|
194
|
-
"
|
188
|
+
"Bbmb7ep": ["f8fbkgy", "f1nfllo7"],
|
189
|
+
"Beyfa6y": ["f1nfllo7", "f8fbkgy"],
|
190
|
+
"B7oj6ja": ["f1djnp8u", "f1s8kh49"],
|
191
|
+
"Btl43ni": ["f1s8kh49", "f1djnp8u"],
|
195
192
|
"Bhzewxz": "f1i1t8d1",
|
196
193
|
"Bz10aip": ["foouk8k", "fd9rb4b"],
|
197
|
-
"
|
194
|
+
"Bmy1vo4": "fmslzlq",
|
195
|
+
"B3o57yi": "f15vu5tu",
|
196
|
+
"Bkqvd7p": "f1e1a42z",
|
198
197
|
"lpbzjs": "f1sdsnyy",
|
199
198
|
"Bkecrkj": "f1aehjj5",
|
200
199
|
"xx9plb": "fxf9f1y",
|
@@ -202,7 +201,10 @@ const useThumbStyles = /*#__PURE__*/__styles({
|
|
202
201
|
"Byque4d": ["f8g0ba1", "ff0gctb"],
|
203
202
|
"Bj2wrql": "f3zr33r",
|
204
203
|
"qd6xl9": ["ff0gctb", "f8g0ba1"],
|
205
|
-
"
|
204
|
+
"px8gyy": ["fu724ry", "f1ufhb3r"],
|
205
|
+
"B5c9fhp": ["f1ufhb3r", "fu724ry"],
|
206
|
+
"Bhe99jt": ["fiow2ne", "f13lz1i8"],
|
207
|
+
"B2r1szc": ["f13lz1i8", "fiow2ne"],
|
206
208
|
"rurcny": "f99sooz",
|
207
209
|
"ngabwx": "f1uhpfti",
|
208
210
|
"Hdbjpj": "f11ef69",
|
@@ -210,15 +212,18 @@ const useThumbStyles = /*#__PURE__*/__styles({
|
|
210
212
|
"jc51t6": ["f1bp8q63", "f1oarbwq"],
|
211
213
|
"Bj55yzk": "f13gddrr",
|
212
214
|
"cnmfks": ["f1oarbwq", "f1bp8q63"],
|
213
|
-
"
|
215
|
+
"frdscb": ["fc4gh2t", "flndy84"],
|
216
|
+
"B9nohqn": ["flndy84", "fc4gh2t"],
|
217
|
+
"B1dhsta": ["fxgx2h0", "fh20ihy"],
|
218
|
+
"Bjdmjzx": ["fh20ihy", "fxgx2h0"],
|
214
219
|
"Bs6t6z0": "f77y9vx",
|
215
220
|
"Bmyypfa": "frd86tk"
|
216
221
|
},
|
217
222
|
"unchecked": {
|
218
|
-
"
|
223
|
+
"B1dvbpk": "f1n7m28n"
|
219
224
|
},
|
220
225
|
"checked": {
|
221
|
-
"
|
226
|
+
"Bkbwdz4": "f1261hx1"
|
222
227
|
},
|
223
228
|
"disabledUnchecked": {
|
224
229
|
"dj0dih": "f199l62q",
|
@@ -233,13 +238,13 @@ const useThumbStyles = /*#__PURE__*/__styles({
|
|
233
238
|
"I89eb": ["f1yueqd5", "f16ep8jm"],
|
234
239
|
"Bp1vogq": "flh92r5",
|
235
240
|
"Bohd3ja": ["f16ep8jm", "f1yueqd5"],
|
236
|
-
"
|
241
|
+
"B1dvbpk": "fj528n6"
|
237
242
|
},
|
238
243
|
"disabledChecked": {
|
239
|
-
"
|
244
|
+
"Bkbwdz4": "f18jltdj"
|
240
245
|
}
|
241
246
|
}, {
|
242
|
-
"d": [".f1euv43f{position:absolute;}", ".fcjrtee{width:var(--switch-thumb-size);}", ".fili5n9{height:var(--switch-thumb-size);}", ".f1ewtqcl{box-sizing:border-box;}", ".
|
247
|
+
"d": [".f1euv43f{position:absolute;}", ".fcjrtee{width:var(--switch-thumb-size);}", ".fili5n9{height:var(--switch-thumb-size);}", ".f1ewtqcl{box-sizing:border-box;}", ".f8fbkgy{border-bottom-right-radius:var(--borderRadiusCircular);}", ".f1nfllo7{border-bottom-left-radius:var(--borderRadiusCircular);}", ".f1djnp8u{border-top-right-radius:var(--borderRadiusCircular);}", ".f1s8kh49{border-top-left-radius:var(--borderRadiusCircular);}", ".f1i1t8d1{top:50%;}", ".foouk8k{-webkit-transform:translate(-50%, -50%);-moz-transform:translate(-50%, -50%);-ms-transform:translate(-50%, -50%);transform:translate(-50%, -50%);}", ".fd9rb4b{-webkit-transform:translate(50%, -50%);-moz-transform:translate(50%, -50%);-ms-transform:translate(50%, -50%);transform:translate(50%, -50%);}", ".fmslzlq{transition-property:backgroundColor;}", ".f15vu5tu{transition-duration:0.1s;}", ".f1e1a42z{transition-timing-function:cubic-bezier(0.33, 0, 0.67, 1);}", ".f1sdsnyy{touch-action:none;}", ".f1aehjj5{pointer-events:none;}", ".fxf9f1y:before{position:absolute;}", ".frdto5n:before{top:0px;}", ".f8g0ba1:before{left:0px;}", ".ff0gctb:before{right:0px;}", ".f3zr33r:before{bottom:0px;}", ".fu724ry:before{border-bottom-right-radius:var(--borderRadiusCircular);}", ".f1ufhb3r:before{border-bottom-left-radius:var(--borderRadiusCircular);}", ".fiow2ne:before{border-top-right-radius:var(--borderRadiusCircular);}", ".f13lz1i8:before{border-top-left-radius:var(--borderRadiusCircular);}", ".f99sooz:before{content:'';}", ".f1uhpfti:before{opacity:var(--switch-unchecked-opacity);}", ".f11ef69:after{position:absolute;}", ".f1yuyem3:after{top:0px;}", ".f1bp8q63:after{left:0px;}", ".f1oarbwq:after{right:0px;}", ".f13gddrr:after{bottom:0px;}", ".fc4gh2t:after{border-bottom-right-radius:var(--borderRadiusCircular);}", ".flndy84:after{border-bottom-left-radius:var(--borderRadiusCircular);}", ".fxgx2h0:after{border-top-right-radius:var(--borderRadiusCircular);}", ".fh20ihy:after{border-top-left-radius:var(--borderRadiusCircular);}", ".f77y9vx:after{content:'';}", ".frd86tk:after{opacity:var(--switch-checked-opacity);}", ".f1n7m28n:before{background-color:var(--colorNeutralStrokeAccessible);}", ".f1261hx1:after{background-color:var(--colorNeutralForegroundOnBrand);}", ".f199l62q:before{border-top-width:1px;}", ".f1pa2qi2:before{border-right-width:1px;}", ".f1ooiv2t:before{border-left-width:1px;}", ".fyqop9u:before{border-bottom-width:1px;}", ".f1bwkb58:before{border-top-style:solid;}", ".fiio4mc:before{border-right-style:solid;}", ".fc8z0qo:before{border-left-style:solid;}", ".f1m5ya7j:before{border-bottom-style:solid;}", ".f1k21dld:before{border-top-color:var(--colorNeutralForegroundDisabled);}", ".f1yueqd5:before{border-right-color:var(--colorNeutralForegroundDisabled);}", ".f16ep8jm:before{border-left-color:var(--colorNeutralForegroundDisabled);}", ".flh92r5:before{border-bottom-color:var(--colorNeutralForegroundDisabled);}", ".fj528n6:before{background-color:var(--colorNeutralBackground1);}", ".f18jltdj:after{background-color:var(--colorNeutralForegroundDisabled);}"]
|
243
248
|
});
|
244
249
|
/**
|
245
250
|
* Styles for the activeRail slot
|
@@ -285,7 +290,7 @@ const useInputStyle = /*#__PURE__*/__styles({
|
|
285
290
|
*/
|
286
291
|
|
287
292
|
|
288
|
-
export const
|
293
|
+
export const useSwitchStyles_unstable = state => {
|
289
294
|
const {
|
290
295
|
checked,
|
291
296
|
disabled
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/components/Switch/useSwitchStyles.ts"],"names":[],"mappings":"AAAA,mBAAqB,YAArB,QAAyC,6BAAzC;AACA,SAAS,uBAAT,QAAwC,yBAAxC;AAGA,OAAO,MAAM,eAAe,GAAG,YAAxB;AACP,MAAM,cAAc,GAAG,GAAG,eAAe,QAAzC;AACA,MAAM,cAAc,GAAG,GAAG,eAAe,QAAzC;AAEA;;AAEG;;AACH,MAAM,aAAa,gBAAG;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAAtB;AA2DA;;AAEG;;;AACH,MAAM,cAAc,gBAAG;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A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,CAAiB,SAAjB,GAA6B,YAAY,CAAC,gBAAgB,CAAC,UAAlB,EAA8B,KAAK,CAAC,UAAN,CAAiB,SAA/C,CAAzC;AAEA,EAAA,KAAK,CAAC,KAAN,CAAY,SAAZ,GAAwB,YAAY,CAAC,WAAW,CAAC,KAAb,EAAoB,KAAK,CAAC,KAAN,CAAY,SAAhC,CAApC;AAEA,SAAO,KAAP;AACD,CA/CM","sourcesContent":["import { shorthands, makeStyles, mergeClasses } from '@griffel/react';\nimport { createFocusOutlineStyle } from '@fluentui/react-tabster';\nimport { tokens } from '@fluentui/react-theme';\nimport type { SwitchState } from './Switch.types';\n\nexport const switchClassName = 'fui-Switch';\nconst trackClassName = `${switchClassName}-track`;\nconst thumbClassName = `${switchClassName}-thumb`;\n\n/**\n * Styles for the root slot\n */\nconst useRootStyles = makeStyles({\n root: {\n '--switch-width': '40px',\n '--switch-height': '20px',\n '--switch-thumb-size': '14px',\n '--switch-checked-opacity': '0',\n '--switch-unchecked-opacity': '0',\n\n position: 'relative',\n width: 'var(--switch-width)',\n height: 'var(--switch-height)',\n display: 'inline-block',\n userSelect: 'none',\n touchAction: 'none',\n verticalAlign: 'bottom',\n },\n\n unchecked: {\n [`:hover .${thumbClassName}`]: {\n ':before': {\n backgroundColor: tokens.colorNeutralStrokeAccessibleHover,\n },\n },\n\n [`:hover .${trackClassName}`]: {\n ':before': {\n borderColor: tokens.colorNeutralStrokeAccessibleHover,\n },\n },\n },\n\n checked: {\n [`:hover .${trackClassName}`]: {\n ':after': {\n backgroundColor: tokens.colorBrandBackgroundHover,\n },\n },\n\n [`:active .${trackClassName}`]: {\n ':after': {\n backgroundColor: tokens.colorBrandBackgroundPressed,\n },\n },\n },\n\n enabled: {\n '-webkit-tap-highlight-color': 'rgba(0,0,0,0)',\n cursor: 'pointer',\n },\n\n disabled: {\n cursor: 'not-allowed',\n pointerEvents: 'none',\n },\n\n focusIndicator: createFocusOutlineStyle({ selector: 'focus-within', style: { outlineOffset: '8px' } }),\n});\n\n/**\n * Styles for the track slot\n */\nconst useTrackStyles = makeStyles({\n track: {\n position: 'absolute',\n width: '100%',\n height: '100%',\n transitionProperty: 'backgroundColor',\n transitionDuration: '0.1s',\n transitionTimingFunction: 'cubic-bezier(0.33, 0, 0.67, 1)',\n touchAction: 'none',\n pointerEvents: 'none',\n\n ':before': {\n position: 'absolute',\n top: '0px',\n left: '0px',\n bottom: '0px',\n right: '0px',\n boxSizing: 'border-box',\n ...shorthands.borderRadius('999px'),\n content: \"''\",\n opacity: 'var(--switch-unchecked-opacity)',\n },\n\n ':after': {\n position: 'absolute',\n top: '0px',\n left: '0px',\n bottom: '0px',\n right: '0px',\n boxSizing: 'border-box',\n ...shorthands.borderRadius('999px'),\n content: \"''\",\n opacity: 'var(--switch-checked-opacity)',\n },\n },\n\n unchecked: {\n ':before': {\n ...shorthands.border('1px', 'solid', tokens.colorNeutralStrokeAccessible),\n backgroundColor: 'transparent',\n },\n },\n\n checked: {\n ':after': {\n backgroundColor: tokens.colorBrandBackground,\n ...shorthands.borderStyle('none'),\n },\n },\n\n disabledUnchecked: {\n ':before': {\n ...shorthands.border('1px', 'solid', tokens.colorNeutralStrokeDisabled),\n },\n },\n\n disabledChecked: {\n ':after': {\n ...shorthands.border('1px', 'solid', tokens.colorTransparentStrokeDisabled),\n backgroundColor: tokens.colorNeutralBackgroundDisabled,\n },\n },\n});\n\n/**\n * Styles for the thumb wrapper slot\n */\nconst useThumbWrapperStyles = makeStyles({\n thumbWrapper: {\n position: 'absolute',\n top: '0',\n bottom: '0',\n left: 'calc(var(--switch-thumb-size) * .7)',\n right: 'calc(var(--switch-thumb-size) * .7)',\n touchAction: 'none',\n pointerEvents: 'none',\n },\n});\n\n/**\n * Styles for the thumb slot\n */\nconst useThumbStyles = makeStyles({\n thumb: {\n position: 'absolute',\n width: 'var(--switch-thumb-size)',\n height: 'var(--switch-thumb-size)',\n boxSizing: 'border-box',\n ...shorthands.borderRadius(tokens.borderRadiusCircular),\n top: '50%',\n transform: 'translate(-50%, -50%)',\n transitionProperty: 'backgroundColor',\n transitionDuration: '0.1s',\n transitionTimingFunction: 'cubic-bezier(0.33, 0, 0.67, 1)',\n touchAction: 'none',\n pointerEvents: 'none',\n\n ':before': {\n position: 'absolute',\n top: '0px',\n left: '0px',\n bottom: '0px',\n right: '0px',\n ...shorthands.borderRadius(tokens.borderRadiusCircular),\n content: \"''\",\n opacity: 'var(--switch-unchecked-opacity)',\n },\n\n ':after': {\n position: 'absolute',\n top: '0px',\n left: '0px',\n bottom: '0px',\n right: '0px',\n ...shorthands.borderRadius(tokens.borderRadiusCircular),\n content: \"''\",\n opacity: 'var(--switch-checked-opacity)',\n },\n },\n\n unchecked: {\n ':before': {\n backgroundColor: tokens.colorNeutralStrokeAccessible,\n },\n },\n\n checked: {\n ':after': {\n backgroundColor: tokens.colorNeutralForegroundOnBrand,\n },\n },\n\n disabledUnchecked: {\n ':before': {\n ...shorthands.border('1px', 'solid', tokens.colorNeutralForegroundDisabled),\n backgroundColor: tokens.colorNeutralBackground1,\n },\n },\n\n disabledChecked: {\n ':after': {\n backgroundColor: tokens.colorNeutralForegroundDisabled,\n },\n },\n});\n\n/**\n * Styles for the activeRail slot\n */\nconst useActiveRailStyles = makeStyles({\n activeRail: {\n position: 'absolute',\n left: 'calc(var(--switch-thumb-size) * .7)',\n right: 'calc(var(--switch-thumb-size) * .7)',\n },\n});\n\n/**\n * Styles for the hidden input slot\n */\nconst useInputStyle = makeStyles({\n input: {\n opacity: 0,\n position: 'absolute',\n ...shorthands.padding(0),\n ...shorthands.margin(0),\n width: '100%',\n height: '100%',\n touchAction: 'none',\n pointerEvents: 'none',\n },\n});\n\n/**\n * Apply styling to the Switch slots based on the state\n */\nexport const useSwitchStyles_unstable = (state: SwitchState): SwitchState => {\n const { checked, disabled } = state.input;\n\n const rootStyles = useRootStyles();\n const trackStyles = useTrackStyles();\n const thumbWrapperStyles = useThumbWrapperStyles();\n const thumbStyles = useThumbStyles();\n const activeRailStyles = useActiveRailStyles();\n const inputStyles = useInputStyle();\n\n state.root.className = mergeClasses(\n switchClassName + (checked ? ' checked' : ''),\n rootStyles.root,\n rootStyles.focusIndicator,\n !disabled && rootStyles.checked,\n !disabled && rootStyles.unchecked,\n disabled ? rootStyles.disabled : rootStyles.enabled,\n state.root.className,\n );\n\n state.track.className = mergeClasses(\n trackClassName,\n trackStyles.track,\n !disabled && trackStyles.checked,\n !disabled && trackStyles.unchecked,\n disabled && trackStyles.disabledChecked,\n disabled && trackStyles.disabledUnchecked,\n state.track.className,\n );\n\n state.thumbWrapper.className = mergeClasses(thumbWrapperStyles.thumbWrapper, state.thumbWrapper.className);\n\n state.thumb.className = mergeClasses(\n thumbClassName,\n thumbStyles.thumb,\n !disabled && thumbStyles.checked,\n !disabled && thumbStyles.unchecked,\n disabled && thumbStyles.disabledChecked,\n disabled && thumbStyles.disabledUnchecked,\n state.thumb.className,\n );\n\n state.activeRail.className = mergeClasses(activeRailStyles.activeRail, state.activeRail.className);\n\n state.input.className = mergeClasses(inputStyles.input, state.input.className);\n\n return state;\n};\n"],"sourceRoot":"../src/"}
|
package/lib/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["index.ts"],"names":[],"mappings":"AACA,cAAc,UAAU,CAAC","sourcesContent":["export {};\nexport * from './Switch';\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["Switch.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,2BAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './components/Switch/index';\n"],"sourceRoot":"../src/"}
|
@@ -18,9 +18,9 @@ const useSwitchStyles_1 = /*#__PURE__*/require("./useSwitchStyles");
|
|
18
18
|
|
19
19
|
|
20
20
|
exports.Switch = /*#__PURE__*/React.forwardRef((props, ref) => {
|
21
|
-
const state = useSwitch_1.
|
22
|
-
useSwitchStyles_1.
|
23
|
-
return renderSwitch_1.
|
21
|
+
const state = useSwitch_1.useSwitch_unstable(props, ref);
|
22
|
+
useSwitchStyles_1.useSwitchStyles_unstable(state);
|
23
|
+
return renderSwitch_1.renderSwitch_unstable(state);
|
24
24
|
});
|
25
25
|
exports.Switch.displayName = 'Switch';
|
26
26
|
//# sourceMappingURL=Switch.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["components/Switch/Switch.tsx"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,WAAA,gBAAA,OAAA,CAAA,aAAA,CAAA;;AACA,MAAA,cAAA,gBAAA,OAAA,CAAA,gBAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,mBAAA,CAAA;AAIA;;AAEG;;;AACU,OAAA,CAAA,MAAA,gBAA2C,KAAK,CAAC,UAAN,CAAiB,CAAC,KAAD,EAAQ,GAAR,KAAe;AACtF,QAAM,KAAK,GAAG,WAAA,CAAA,kBAAA,CAAmB,KAAnB,EAA0B,GAA1B,CAAd;AAEA,EAAA,iBAAA,CAAA,wBAAA,CAAyB,KAAzB;AAEA,SAAO,cAAA,CAAA,qBAAA,CAAsB,KAAtB,CAAP;AACD,CANuD,CAA3C;AAQb,OAAA,CAAA,MAAA,CAAO,WAAP,GAAqB,QAArB","sourcesContent":["import * as React from 'react';\nimport { useSwitch_unstable } from './useSwitch';\nimport { renderSwitch_unstable } from './renderSwitch';\nimport { useSwitchStyles_unstable } from './useSwitchStyles';\nimport type { SwitchProps } from './Switch.types';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\n\n/**\n * The Switch control enables users to trigger an option on or off through pressing on the component.\n */\nexport const Switch: ForwardRefComponent<SwitchProps> = React.forwardRef((props, ref) => {\n const state = useSwitch_unstable(props, ref);\n\n useSwitchStyles_unstable(state);\n\n return renderSwitch_unstable(state);\n});\n\nSwitch.displayName = 'Switch';\n"],"sourceRoot":"../src/"}
|
@@ -1,32 +1,32 @@
|
|
1
1
|
import * as React from 'react';
|
2
|
-
import type { ComponentProps, ComponentState,
|
2
|
+
import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';
|
3
3
|
export declare type SwitchSlots = {
|
4
4
|
/**
|
5
5
|
* The root of the Switch.
|
6
6
|
*/
|
7
|
-
root:
|
7
|
+
root: Slot<'div'>;
|
8
8
|
/**
|
9
9
|
* The bar indicating the status of the Switch.
|
10
10
|
*/
|
11
|
-
track:
|
11
|
+
track: NonNullable<Slot<'div'>>;
|
12
12
|
/**
|
13
13
|
* The wrapper around the thumb. It is used as the active area for the thumb to position itself.
|
14
14
|
*/
|
15
|
-
thumbWrapper:
|
15
|
+
thumbWrapper: NonNullable<Slot<'div'>>;
|
16
16
|
/**
|
17
17
|
* The circular icon indicating the status of the Switch.
|
18
18
|
*/
|
19
|
-
thumb:
|
19
|
+
thumb: NonNullable<Slot<'div'>>;
|
20
20
|
/**
|
21
21
|
* The hidden input that handles the Switch's internal functionality.
|
22
22
|
*/
|
23
|
-
input:
|
23
|
+
input: NonNullable<Slot<'input'>>;
|
24
24
|
/**
|
25
25
|
* The area in which the Switch's rail allows for the thumb to be dragged.
|
26
26
|
*/
|
27
|
-
activeRail:
|
27
|
+
activeRail: NonNullable<Slot<'div'>>;
|
28
28
|
};
|
29
|
-
|
29
|
+
interface SwitchCommons {
|
30
30
|
/**
|
31
31
|
* The starting value for a uncontrolled Switch. If `true` then the Switch will be enabled.
|
32
32
|
* Mutually exclusive with `checked` prop.
|
@@ -52,7 +52,8 @@ export interface SwitchCommons {
|
|
52
52
|
checked: boolean;
|
53
53
|
}) => void;
|
54
54
|
}
|
55
|
-
export interface SwitchProps extends Omit<ComponentProps<SwitchSlots
|
55
|
+
export interface SwitchProps extends Omit<ComponentProps<Partial<SwitchSlots>>, 'onChange'>, SwitchCommons {
|
56
56
|
}
|
57
57
|
export interface SwitchState extends ComponentState<SwitchSlots>, SwitchCommons {
|
58
58
|
}
|
59
|
+
export {};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":""}
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":"../src/"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["components/Switch/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,UAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,gBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,gBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,aAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,mBAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './Switch';\nexport * from './Switch.types';\nexport * from './renderSwitch';\nexport * from './useSwitch';\nexport * from './useSwitchStyles';\n"],"sourceRoot":"../src/"}
|
@@ -3,25 +3,29 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.
|
6
|
+
exports.renderSwitch_unstable = void 0;
|
7
7
|
|
8
8
|
const React = /*#__PURE__*/require("react");
|
9
9
|
|
10
10
|
const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
|
11
|
-
|
12
|
-
const useSwitch_1 = /*#__PURE__*/require("./useSwitch");
|
13
11
|
/**
|
14
12
|
* Render the final JSX of Switch
|
15
13
|
*/
|
16
14
|
|
17
15
|
|
18
|
-
const
|
16
|
+
const renderSwitch_unstable = state => {
|
19
17
|
const {
|
20
18
|
slots,
|
21
19
|
slotProps
|
22
|
-
} = react_utilities_1.getSlots(state
|
23
|
-
return React.createElement(slots.root,
|
20
|
+
} = react_utilities_1.getSlots(state);
|
21
|
+
return React.createElement(slots.root, { ...slotProps.root
|
22
|
+
}, React.createElement(slots.track, { ...slotProps.track
|
23
|
+
}), React.createElement(slots.thumbWrapper, { ...slotProps.thumbWrapper
|
24
|
+
}, React.createElement(slots.thumb, { ...slotProps.thumb
|
25
|
+
})), React.createElement(slots.input, { ...slotProps.input
|
26
|
+
}), React.createElement(slots.activeRail, { ...slotProps.activeRail
|
27
|
+
}));
|
24
28
|
};
|
25
29
|
|
26
|
-
exports.
|
30
|
+
exports.renderSwitch_unstable = renderSwitch_unstable;
|
27
31
|
//# sourceMappingURL=renderSwitch.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["components/Switch/renderSwitch.tsx"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;AAGA;;AAEG;;;AACI,MAAM,qBAAqB,GAAI,KAAD,IAAuB;AAC1D,QAAM;AAAE,IAAA,KAAF;AAAS,IAAA;AAAT,MAAuB,iBAAA,CAAA,QAAA,CAAsB,KAAtB,CAA7B;AAEA,SACE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,IAAP,EAAW,EAAA,GAAK,SAAS,CAAC;AAAf,GAAX,EACE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,KAAP,EAAY,EAAA,GAAK,SAAS,CAAC;AAAf,GAAZ,CADF,EAEE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,YAAP,EAAmB,EAAA,GAAK,SAAS,CAAC;AAAf,GAAnB,EACE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,KAAP,EAAY,EAAA,GAAK,SAAS,CAAC;AAAf,GAAZ,CADF,CAFF,EAKE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,KAAP,EAAY,EAAA,GAAK,SAAS,CAAC;AAAf,GAAZ,CALF,EAME,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,UAAP,EAAiB,EAAA,GAAK,SAAS,CAAC;AAAf,GAAjB,CANF,CADF;AAUD,CAbM;;AAAM,OAAA,CAAA,qBAAA,GAAqB,qBAArB","sourcesContent":["import * as React from 'react';\nimport { getSlots } from '@fluentui/react-utilities';\nimport type { SwitchState, SwitchSlots } from './Switch.types';\n\n/**\n * Render the final JSX of Switch\n */\nexport const renderSwitch_unstable = (state: SwitchState) => {\n const { slots, slotProps } = getSlots<SwitchSlots>(state);\n\n return (\n <slots.root {...slotProps.root}>\n <slots.track {...slotProps.track} />\n <slots.thumbWrapper {...slotProps.thumbWrapper}>\n <slots.thumb {...slotProps.thumb} />\n </slots.thumbWrapper>\n <slots.input {...slotProps.input} />\n <slots.activeRail {...slotProps.activeRail} />\n </slots.root>\n );\n};\n"],"sourceRoot":"../src/"}
|