@fluentui/react-slider 9.0.0-beta.12 → 9.0.0-beta.15
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 +174 -1
- package/CHANGELOG.md +184 -137
- package/dist/{react-slider.d.ts → index.d.ts} +27 -32
- package/{lib → dist}/tsdoc-metadata.json +0 -0
- package/lib/components/Slider/Slider.types.js.map +1 -1
- package/lib/components/Slider/useSlider.js +1 -20
- package/lib/components/Slider/useSlider.js.map +1 -1
- package/lib/components/Slider/useSliderState.js +7 -7
- package/lib/components/Slider/useSliderState.js.map +1 -1
- package/lib/components/Slider/useSliderStyles.js +15 -15
- package/lib/components/Slider/useSliderStyles.js.map +1 -1
- package/lib-commonjs/components/Slider/useSlider.js +1 -20
- package/lib-commonjs/components/Slider/useSlider.js.map +1 -1
- package/lib-commonjs/components/Slider/useSliderState.js +7 -7
- package/lib-commonjs/components/Slider/useSliderState.js.map +1 -1
- package/lib-commonjs/components/Slider/useSliderStyles.js +15 -15
- package/lib-commonjs/components/Slider/useSliderStyles.js.map +1 -1
- package/package.json +11 -11
- package/lib/Slider.d.ts +0 -1
- package/lib/components/Slider/Slider.d.ts +0 -6
- package/lib/components/Slider/Slider.types.d.ts +0 -93
- package/lib/components/Slider/index.d.ts +0 -6
- package/lib/components/Slider/renderSlider.d.ts +0 -5
- package/lib/components/Slider/useSlider.d.ts +0 -6
- package/lib/components/Slider/useSliderState.d.ts +0 -2
- package/lib/components/Slider/useSliderStyles.d.ts +0 -14
- package/lib/index.d.ts +0 -2
- package/lib-commonjs/Slider.d.ts +0 -1
- package/lib-commonjs/components/Slider/Slider.d.ts +0 -6
- package/lib-commonjs/components/Slider/Slider.types.d.ts +0 -93
- package/lib-commonjs/components/Slider/index.d.ts +0 -6
- package/lib-commonjs/components/Slider/renderSlider.d.ts +0 -5
- package/lib-commonjs/components/Slider/useSlider.d.ts +0 -6
- package/lib-commonjs/components/Slider/useSliderState.d.ts +0 -2
- package/lib-commonjs/components/Slider/useSliderStyles.d.ts +0 -14
- package/lib-commonjs/index.d.ts +0 -2
|
@@ -17,27 +17,42 @@ export declare const Slider: ForwardRefComponent<SliderProps>;
|
|
|
17
17
|
|
|
18
18
|
export declare const sliderClassNames: SlotClassNames<SliderSlots>;
|
|
19
19
|
|
|
20
|
-
declare type
|
|
20
|
+
export declare type SliderOnChangeData = {
|
|
21
|
+
value: number;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export declare type SliderProps = Omit<ComponentProps<Partial<SliderSlots>, 'input'>, 'defaultValue' | 'onChange' | 'size' | 'value'> & {
|
|
21
25
|
/**
|
|
22
26
|
* The starting value for an uncontrolled Slider.
|
|
23
27
|
* Mutually exclusive with `value` prop.
|
|
24
28
|
*/
|
|
25
29
|
defaultValue?: number;
|
|
26
30
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
31
|
+
* Whether to render the Slider as disabled.
|
|
32
|
+
*
|
|
33
|
+
* @default `false` (renders enabled)
|
|
29
34
|
*/
|
|
30
|
-
|
|
35
|
+
disabled?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* The max value of the Slider.
|
|
38
|
+
* @default 100
|
|
39
|
+
*/
|
|
40
|
+
max?: number;
|
|
31
41
|
/**
|
|
32
42
|
* The min value of the Slider.
|
|
33
43
|
* @default 0
|
|
34
44
|
*/
|
|
35
45
|
min?: number;
|
|
36
46
|
/**
|
|
37
|
-
* The
|
|
38
|
-
* @default
|
|
47
|
+
* The starting origin point for the Slider.
|
|
48
|
+
* @default min
|
|
39
49
|
*/
|
|
40
|
-
|
|
50
|
+
origin?: number;
|
|
51
|
+
/**
|
|
52
|
+
* The size of the Slider.
|
|
53
|
+
* @default 'medium'
|
|
54
|
+
*/
|
|
55
|
+
size?: 'small' | 'medium';
|
|
41
56
|
/**
|
|
42
57
|
* The number of steps that the Slider's `value` will increment upon change. When provided, the Slider
|
|
43
58
|
* will snap to the closest available value. This must be a positive value.
|
|
@@ -45,38 +60,21 @@ declare type SliderCommons = {
|
|
|
45
60
|
*/
|
|
46
61
|
step?: number;
|
|
47
62
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* @default `false` (renders enabled)
|
|
63
|
+
* The current value of the controlled Slider.
|
|
64
|
+
* Mutually exclusive with `defaultValue` prop.
|
|
51
65
|
*/
|
|
52
|
-
|
|
66
|
+
value?: number;
|
|
53
67
|
/**
|
|
54
68
|
* Render the Slider in a vertical orientation, smallest value on the bottom.
|
|
55
69
|
* @default `false`
|
|
56
70
|
*/
|
|
57
71
|
vertical?: boolean;
|
|
58
|
-
/**
|
|
59
|
-
* The starting origin point for the Slider.
|
|
60
|
-
* @default min
|
|
61
|
-
*/
|
|
62
|
-
origin?: number;
|
|
63
|
-
/**
|
|
64
|
-
* The size of the Slider.
|
|
65
|
-
* @default 'medium'
|
|
66
|
-
*/
|
|
67
|
-
size?: 'small' | 'medium';
|
|
68
72
|
/**
|
|
69
73
|
* Triggers a callback when the value has been changed. This will be called on every individual step.
|
|
70
74
|
*/
|
|
71
75
|
onChange?: (ev: React_2.ChangeEvent<HTMLInputElement>, data: SliderOnChangeData) => void;
|
|
72
76
|
};
|
|
73
77
|
|
|
74
|
-
export declare type SliderOnChangeData = {
|
|
75
|
-
value: number;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
export declare type SliderProps = Omit<ComponentProps<Partial<SliderSlots>, 'input'>, 'defaultValue' | 'onChange' | 'size' | 'value'> & SliderCommons;
|
|
79
|
-
|
|
80
78
|
export declare type SliderSlots = {
|
|
81
79
|
/**
|
|
82
80
|
* The root of the Slider.
|
|
@@ -110,14 +108,11 @@ export declare type SliderSlots = {
|
|
|
110
108
|
};
|
|
111
109
|
};
|
|
112
110
|
|
|
113
|
-
export declare type SliderState = ComponentState<SliderSlots> &
|
|
111
|
+
export declare type SliderState = ComponentState<SliderSlots> & Pick<SliderProps, 'disabled' | 'size' | 'vertical'>;
|
|
114
112
|
|
|
115
|
-
/**
|
|
116
|
-
* Given user props, returns state and render function for a Slider.
|
|
117
|
-
*/
|
|
118
113
|
export declare const useSlider_unstable: (props: SliderProps, ref: React_2.Ref<HTMLInputElement>) => SliderState;
|
|
119
114
|
|
|
120
|
-
export declare const useSliderState_unstable: (state: SliderState) => SliderState;
|
|
115
|
+
export declare const useSliderState_unstable: (state: SliderState, props: SliderProps) => SliderState;
|
|
121
116
|
|
|
122
117
|
/**
|
|
123
118
|
* Apply styling to the Slider slots based on the state
|
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Slider.types.js","sourceRoot":"../src/","sources":["components/Slider/Slider.types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\nimport type { ComponentState, ComponentProps, Slot } from '@fluentui/react-utilities';\n\nexport type SliderSlots = {\n /**\n * The root of the Slider.\n * The root slot receives the `className` and `style` specified directly on the `<Slider>`.\n * All other native props will be applied to the primary slot, `input`.\n */\n root: NonNullable<Slot<'div'>>;\n\n /**\n * The Slider's base. It is used to visibly display the min and max selectable values.\n */\n rail: NonNullable<Slot<'div'>>;\n\n /**\n * The draggable icon used to select a given value from the Slider.\n * This is the element containing `role = 'slider'`.\n */\n thumb: NonNullable<Slot<'div'>>;\n\n /**\n * The hidden input for the Slider.\n * This is the PRIMARY slot: all native properties specified directly on `<Slider>` will be applied to this slot,\n * except `className` and `style`, which remain on the root slot.\n *\n */\n input: NonNullable<Slot<'input'>> & {\n /**\n * Orient is a non standard attribute that allows for vertical orientation in Firefox. It is set internally\n * when `vertical` is set to true.\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/range#non_standard_attributes\n * Webkit/Chromium support for vertical inputs is provided via -webkit-appearance css property\n */\n orient?: 'horizontal' | 'vertical';\n };\n};\n\
|
|
1
|
+
{"version":3,"file":"Slider.types.js","sourceRoot":"../src/","sources":["components/Slider/Slider.types.ts"],"names":[],"mappings":"","sourcesContent":["import * as React from 'react';\nimport type { ComponentState, ComponentProps, Slot } from '@fluentui/react-utilities';\n\nexport type SliderSlots = {\n /**\n * The root of the Slider.\n * The root slot receives the `className` and `style` specified directly on the `<Slider>`.\n * All other native props will be applied to the primary slot, `input`.\n */\n root: NonNullable<Slot<'div'>>;\n\n /**\n * The Slider's base. It is used to visibly display the min and max selectable values.\n */\n rail: NonNullable<Slot<'div'>>;\n\n /**\n * The draggable icon used to select a given value from the Slider.\n * This is the element containing `role = 'slider'`.\n */\n thumb: NonNullable<Slot<'div'>>;\n\n /**\n * The hidden input for the Slider.\n * This is the PRIMARY slot: all native properties specified directly on `<Slider>` will be applied to this slot,\n * except `className` and `style`, which remain on the root slot.\n *\n */\n input: NonNullable<Slot<'input'>> & {\n /**\n * Orient is a non standard attribute that allows for vertical orientation in Firefox. It is set internally\n * when `vertical` is set to true.\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/range#non_standard_attributes\n * Webkit/Chromium support for vertical inputs is provided via -webkit-appearance css property\n */\n orient?: 'horizontal' | 'vertical';\n };\n};\n\nexport type SliderProps = Omit<\n ComponentProps<Partial<SliderSlots>, 'input'>,\n 'defaultValue' | 'onChange' | 'size' | 'value'\n> & {\n /**\n * The starting value for an uncontrolled Slider.\n * Mutually exclusive with `value` prop.\n */\n defaultValue?: number;\n\n /**\n * Whether to render the Slider as disabled.\n *\n * @default `false` (renders enabled)\n */\n disabled?: boolean;\n\n /**\n * The max value of the Slider.\n * @default 100\n */\n max?: number;\n\n /**\n * The min value of the Slider.\n * @default 0\n */\n min?: number;\n\n /**\n * The starting origin point for the Slider.\n * @default min\n */\n origin?: number;\n\n /**\n * The size of the Slider.\n * @default 'medium'\n */\n size?: 'small' | 'medium';\n\n /**\n * The number of steps that the Slider's `value` will increment upon change. When provided, the Slider\n * will snap to the closest available value. This must be a positive value.\n * @default 1\n */\n step?: number;\n\n /**\n * The current value of the controlled Slider.\n * Mutually exclusive with `defaultValue` prop.\n */\n value?: number;\n\n /**\n * Render the Slider in a vertical orientation, smallest value on the bottom.\n * @default `false`\n */\n vertical?: boolean;\n\n /**\n * Triggers a callback when the value has been changed. This will be called on every individual step.\n */\n onChange?: (ev: React.ChangeEvent<HTMLInputElement>, data: SliderOnChangeData) => void;\n};\n\nexport type SliderOnChangeData = {\n value: number;\n};\n\nexport type SliderState = ComponentState<SliderSlots> & Pick<SliderProps, 'disabled' | 'size' | 'vertical'>;\n"]}
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { getPartitionedNativeProps, resolveShorthand, useId } from '@fluentui/react-utilities';
|
|
2
2
|
import { useSliderState_unstable } from './useSliderState';
|
|
3
|
-
/**
|
|
4
|
-
* Given user props, returns state and render function for a Slider.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
3
|
export const useSlider_unstable = (props, ref) => {
|
|
8
4
|
const nativeProps = getPartitionedNativeProps({
|
|
9
5
|
props,
|
|
@@ -11,17 +7,9 @@ export const useSlider_unstable = (props, ref) => {
|
|
|
11
7
|
excludedPropNames: ['onChange', 'size']
|
|
12
8
|
});
|
|
13
9
|
const {
|
|
14
|
-
// Props
|
|
15
|
-
value,
|
|
16
|
-
defaultValue,
|
|
17
|
-
min = 0,
|
|
18
|
-
max = 100,
|
|
19
|
-
step,
|
|
20
10
|
disabled,
|
|
21
11
|
vertical,
|
|
22
12
|
size = 'medium',
|
|
23
|
-
origin,
|
|
24
|
-
onChange,
|
|
25
13
|
// Slots
|
|
26
14
|
root,
|
|
27
15
|
input,
|
|
@@ -29,16 +17,9 @@ export const useSlider_unstable = (props, ref) => {
|
|
|
29
17
|
thumb
|
|
30
18
|
} = props;
|
|
31
19
|
const state = {
|
|
32
|
-
defaultValue,
|
|
33
20
|
disabled,
|
|
34
|
-
max,
|
|
35
|
-
min,
|
|
36
|
-
origin,
|
|
37
21
|
size,
|
|
38
|
-
step,
|
|
39
22
|
vertical,
|
|
40
|
-
value,
|
|
41
|
-
onChange,
|
|
42
23
|
components: {
|
|
43
24
|
input: 'input',
|
|
44
25
|
rail: 'div',
|
|
@@ -67,7 +48,7 @@ export const useSlider_unstable = (props, ref) => {
|
|
|
67
48
|
required: true
|
|
68
49
|
})
|
|
69
50
|
};
|
|
70
|
-
useSliderState_unstable(state);
|
|
51
|
+
useSliderState_unstable(state, props);
|
|
71
52
|
return state;
|
|
72
53
|
};
|
|
73
54
|
//# sourceMappingURL=useSlider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["components/Slider/useSlider.ts"],"names":[],"mappings":"AACA,SAAS,yBAAT,EAAoC,gBAApC,EAAsD,KAAtD,QAAmE,2BAAnE;AACA,SAAS,uBAAT,QAAwC,kBAAxC;AAGA
|
|
1
|
+
{"version":3,"sources":["components/Slider/useSlider.ts"],"names":[],"mappings":"AACA,SAAS,yBAAT,EAAoC,gBAApC,EAAsD,KAAtD,QAAmE,2BAAnE;AACA,SAAS,uBAAT,QAAwC,kBAAxC;AAGA,OAAO,MAAM,kBAAkB,GAAG,CAAC,KAAD,EAAqB,GAArB,KAAsE;AACtG,QAAM,WAAW,GAAG,yBAAyB,CAAC;AAC5C,IAAA,KAD4C;AAE5C,IAAA,kBAAkB,EAAE,OAFwB;AAG5C,IAAA,iBAAiB,EAAE,CAAC,UAAD,EAAa,MAAb;AAHyB,GAAD,CAA7C;AAMA,QAAM;AACJ,IAAA,QADI;AAEJ,IAAA,QAFI;AAGJ,IAAA,IAAI,GAAG,QAHH;AAIJ;AACA,IAAA,IALI;AAMJ,IAAA,KANI;AAOJ,IAAA,IAPI;AAQJ,IAAA;AARI,MASF,KATJ;AAWA,QAAM,KAAK,GAAgB;AACzB,IAAA,QADyB;AAEzB,IAAA,IAFyB;AAGzB,IAAA,QAHyB;AAIzB,IAAA,UAAU,EAAE;AACV,MAAA,KAAK,EAAE,OADG;AAEV,MAAA,IAAI,EAAE,KAFI;AAGV,MAAA,IAAI,EAAE,KAHI;AAIV,MAAA,KAAK,EAAE;AAJG,KAJa;AAUzB,IAAA,IAAI,EAAE,gBAAgB,CAAC,IAAD,EAAO;AAC3B,MAAA,QAAQ,EAAE,IADiB;AAE3B,MAAA,YAAY,EAAE,EACZ,GAAG,WAAW,CAAC;AADH;AAFa,KAAP,CAVG;AAgBzB,IAAA,KAAK,EAAE,gBAAgB,CAAC,KAAD,EAAQ;AAC7B,MAAA,QAAQ,EAAE,IADmB;AAE7B,MAAA,YAAY,EAAE;AACZ,QAAA,EAAE,EAAE,KAAK,CAAC,SAAD,EAAY,KAAK,CAAC,EAAlB,CADG;AAEZ,QAAA,GAFY;AAGZ,WAAG,WAAW,CAAC,OAHH;AAIZ,QAAA,IAAI,EAAE,OAJM;AAKZ,QAAA,MAAM,EAAE,QAAQ,GAAG,UAAH,GAAgB;AALpB;AAFe,KAAR,CAhBE;AA0BzB,IAAA,IAAI,EAAE,gBAAgB,CAAC,IAAD,EAAO;AAAE,MAAA,QAAQ,EAAE;AAAZ,KAAP,CA1BG;AA2BzB,IAAA,KAAK,EAAE,gBAAgB,CAAC,KAAD,EAAQ;AAAE,MAAA,QAAQ,EAAE;AAAZ,KAAR;AA3BE,GAA3B;AA8BA,EAAA,uBAAuB,CAAC,KAAD,EAAQ,KAAR,CAAvB;AAEA,SAAO,KAAP;AACD,CAnDM","sourcesContent":["import * as React from 'react';\nimport { getPartitionedNativeProps, resolveShorthand, useId } from '@fluentui/react-utilities';\nimport { useSliderState_unstable } from './useSliderState';\nimport { SliderProps, SliderState } from './Slider.types';\n\nexport const useSlider_unstable = (props: SliderProps, ref: React.Ref<HTMLInputElement>): SliderState => {\n const nativeProps = getPartitionedNativeProps({\n props,\n primarySlotTagName: 'input',\n excludedPropNames: ['onChange', 'size'],\n });\n\n const {\n disabled,\n vertical,\n size = 'medium',\n // Slots\n root,\n input,\n rail,\n thumb,\n } = props;\n\n const state: SliderState = {\n disabled,\n size,\n vertical,\n components: {\n input: 'input',\n rail: 'div',\n root: 'div',\n thumb: 'div',\n },\n root: resolveShorthand(root, {\n required: true,\n defaultProps: {\n ...nativeProps.root,\n },\n }),\n input: resolveShorthand(input, {\n required: true,\n defaultProps: {\n id: useId('slider-', props.id),\n ref,\n ...nativeProps.primary,\n type: 'range',\n orient: vertical ? 'vertical' : undefined,\n },\n }),\n rail: resolveShorthand(rail, { required: true }),\n thumb: resolveShorthand(thumb, { required: true }),\n };\n\n useSliderState_unstable(state, props);\n\n return state;\n};\n"],"sourceRoot":"../src/"}
|
|
@@ -14,15 +14,15 @@ const getPercent = (value, min, max) => {
|
|
|
14
14
|
return max === min ? 0 : (value - min) / (max - min) * 100;
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
export const useSliderState_unstable = state => {
|
|
17
|
+
export const useSliderState_unstable = (state, props) => {
|
|
18
18
|
const {
|
|
19
|
-
value,
|
|
20
19
|
defaultValue = 0,
|
|
21
20
|
min = 0,
|
|
22
21
|
max = 100,
|
|
23
|
-
step
|
|
24
|
-
origin
|
|
25
|
-
|
|
22
|
+
step,
|
|
23
|
+
origin,
|
|
24
|
+
value
|
|
25
|
+
} = props;
|
|
26
26
|
const {
|
|
27
27
|
dir
|
|
28
28
|
} = useFluent();
|
|
@@ -36,7 +36,7 @@ export const useSliderState_unstable = state => {
|
|
|
36
36
|
return origin !== undefined ? getPercent(origin, min, max) : 0;
|
|
37
37
|
}, [max, min, origin]);
|
|
38
38
|
const inputOnChange = state.input.onChange;
|
|
39
|
-
const propsOnChange =
|
|
39
|
+
const propsOnChange = props.onChange;
|
|
40
40
|
const onChange = useEventCallback(ev => {
|
|
41
41
|
const newValue = Number(ev.target.value);
|
|
42
42
|
setCurrentValue(clamp(newValue, min, max));
|
|
@@ -52,7 +52,7 @@ export const useSliderState_unstable = state => {
|
|
|
52
52
|
const rootVariables = {
|
|
53
53
|
[railDirectionVar]: state.vertical ? '0deg' : dir === 'ltr' ? '90deg' : '270deg',
|
|
54
54
|
[thumbPositionVar]: valuePercent + '%',
|
|
55
|
-
[railStepsPercentVar]:
|
|
55
|
+
[railStepsPercentVar]: step && step > 0 ? `${step * 100 / (max - min)}%` : '',
|
|
56
56
|
[railOffsetVar]: origin !== undefined ? `${Math.min(valuePercent, originPercent)}%` : '0%',
|
|
57
57
|
[railProgressVar]: origin !== undefined ? `${Math.max(originPercent - valuePercent, valuePercent - originPercent)}%` : `${valuePercent}%`
|
|
58
58
|
}; // Root props
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["components/Slider/useSliderState.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,KAAT,EAAgB,oBAAhB,EAAsC,gBAAtC,QAA8D,2BAA9D;AACA,SAAS,SAAT,QAA0B,iCAA1B;AACA,SAAS,aAAT,QAA8B,mBAA9B;AAGA,MAAM;AAAE,EAAA,aAAF;AAAiB,EAAA,mBAAjB;AAAsC,EAAA,eAAtC;AAAuD,EAAA,gBAAvD;AAAyE,EAAA;AAAzE,IAA8F,aAApG;;AAEA,MAAM,UAAU,GAAG,CAAC,KAAD,EAAgB,GAAhB,EAA6B,GAA7B,KAA4C;AAC7D,SAAO,GAAG,KAAK,GAAR,GAAc,CAAd,GAAmB,CAAC,KAAK,GAAG,GAAT,KAAiB,GAAG,GAAG,GAAvB,CAAD,GAAgC,GAAzD;AACD,CAFD;;AAIA,OAAO,MAAM,uBAAuB,
|
|
1
|
+
{"version":3,"sources":["components/Slider/useSliderState.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,KAAT,EAAgB,oBAAhB,EAAsC,gBAAtC,QAA8D,2BAA9D;AACA,SAAS,SAAT,QAA0B,iCAA1B;AACA,SAAS,aAAT,QAA8B,mBAA9B;AAGA,MAAM;AAAE,EAAA,aAAF;AAAiB,EAAA,mBAAjB;AAAsC,EAAA,eAAtC;AAAuD,EAAA,gBAAvD;AAAyE,EAAA;AAAzE,IAA8F,aAApG;;AAEA,MAAM,UAAU,GAAG,CAAC,KAAD,EAAgB,GAAhB,EAA6B,GAA7B,KAA4C;AAC7D,SAAO,GAAG,KAAK,GAAR,GAAc,CA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ableState, useEventCallback } from '@fluentui/react-utilities';\nimport { useFluent } from '@fluentui/react-shared-contexts';\nimport { sliderCSSVars } from './useSliderStyles';\nimport type { SliderState, SliderProps } from './Slider.types';\n\nconst { railOffsetVar, railStepsPercentVar, railProgressVar, thumbPositionVar, railDirectionVar } = sliderCSSVars;\n\nconst getPercent = (value: number, min: number, max: number) => {\n return max === min ? 0 : ((value - min) / (max - min)) * 100;\n};\n\nexport const useSliderState_unstable = (state: SliderState, props: SliderProps) => {\n const { defaultValue = 0, min = 0, max = 100, step, origin, value } = props;\n const { dir } = useFluent();\n const [currentValue, setCurrentValue] = useControllableState({\n state: value !== undefined ? clamp(value, min, max) : undefined,\n defaultState: clamp(defaultValue, min, max),\n initialState: 0,\n });\n const valuePercent = getPercent(currentValue, min, max);\n const originPercent = React.useMemo(() => {\n return origin !== undefined ? getPercent(origin, min, max) : 0;\n }, [max, min, origin]);\n\n const inputOnChange = state.input.onChange;\n const propsOnChange = props.onChange;\n\n const onChange: React.ChangeEventHandler<HTMLInputElement> = useEventCallback(ev => {\n const newValue = Number(ev.target.value);\n setCurrentValue(clamp(newValue, min, max));\n\n if (inputOnChange && inputOnChange !== propsOnChange) {\n inputOnChange(ev);\n } else if (propsOnChange) {\n propsOnChange(ev, { value: newValue });\n }\n });\n\n const rootVariables = {\n [railDirectionVar]: state.vertical ? '0deg' : dir === 'ltr' ? '90deg' : '270deg',\n [thumbPositionVar]: valuePercent + '%',\n [railStepsPercentVar]: step && step > 0 ? `${(step * 100) / (max - min)}%` : '',\n [railOffsetVar]: origin !== undefined ? `${Math.min(valuePercent, originPercent)}%` : '0%',\n [railProgressVar]:\n origin !== undefined\n ? `${Math.max(originPercent - valuePercent, valuePercent - originPercent)}%`\n : `${valuePercent}%`,\n };\n\n // Root props\n state.root.style = {\n ...rootVariables,\n ...state.root.style,\n };\n\n // Input Props\n state.input.value = currentValue;\n state.input.onChange = onChange;\n\n return state;\n};\n"],"sourceRoot":"../src/"}
|
|
@@ -64,10 +64,10 @@ const useRootStyles = /*#__PURE__*/__styles({
|
|
|
64
64
|
"B7wi8oa": "f4l8x3l",
|
|
65
65
|
"B250r6j": "f671q34",
|
|
66
66
|
"Bpmy4es": "fvfzmw5",
|
|
67
|
-
"Buw9y6v": "
|
|
68
|
-
"Bq939m0": "
|
|
69
|
-
"gjzr1t": "
|
|
70
|
-
"tg7hqu": "
|
|
67
|
+
"Buw9y6v": "faw1t00",
|
|
68
|
+
"Bq939m0": "fxdgx5",
|
|
69
|
+
"gjzr1t": "fii04fa",
|
|
70
|
+
"tg7hqu": "f36hzz8",
|
|
71
71
|
"ypdvl1": "f1volkfw",
|
|
72
72
|
"Bw5jdd4": "f1xddb6",
|
|
73
73
|
"Bdjie01": "fcdikl",
|
|
@@ -108,10 +108,10 @@ const useRootStyles = /*#__PURE__*/__styles({
|
|
|
108
108
|
"Ba33l6n": ["f1horip2", "fgnx9ah"],
|
|
109
109
|
"va7z1g": "fkii2tb",
|
|
110
110
|
"Bmi6mq9": ["fgnx9ah", "f1horip2"],
|
|
111
|
-
"Bjkpy09": "
|
|
112
|
-
"Jxg1p8": "
|
|
113
|
-
"Bc94xmo": ["
|
|
114
|
-
"Bj23z95": ["
|
|
111
|
+
"Bjkpy09": "f11tdyqf",
|
|
112
|
+
"Jxg1p8": "f1blztld",
|
|
113
|
+
"Bc94xmo": ["fc3tncn", "f1veb610"],
|
|
114
|
+
"Bj23z95": ["f1veb610", "fc3tncn"]
|
|
115
115
|
},
|
|
116
116
|
"focusIndicatorVertical": {
|
|
117
117
|
"B486eqv": "f2hkw1w",
|
|
@@ -139,15 +139,15 @@ const useRootStyles = /*#__PURE__*/__styles({
|
|
|
139
139
|
"Ba33l6n": ["f1horip2", "fgnx9ah"],
|
|
140
140
|
"va7z1g": "fkii2tb",
|
|
141
141
|
"Bmi6mq9": ["fgnx9ah", "f1horip2"],
|
|
142
|
-
"Bjkpy09": "
|
|
143
|
-
"Jxg1p8": "
|
|
144
|
-
"Bc94xmo": ["
|
|
145
|
-
"Bj23z95": ["
|
|
142
|
+
"Bjkpy09": "f1n40nz3",
|
|
143
|
+
"Jxg1p8": "f1iimkc5",
|
|
144
|
+
"Bc94xmo": ["f1v1vptr", "f17zmyg5"],
|
|
145
|
+
"Bj23z95": ["f17zmyg5", "f1v1vptr"]
|
|
146
146
|
}
|
|
147
147
|
}, {
|
|
148
|
-
"d": [".f10pi13n{position:relative;}", ".fwk3njj{display:inline-grid;}", ".femm8af{grid-template-areas:\"slider\";}", ".f1xqy1su{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}", ".f1sdsnyy{touch-action:none;}", ".f122n59{-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}", ".f1oiokrs{justify-items:center;}", ".f1agqo6f{--fui-Slider__thumb--size:16px;}", ".f1i7ztpd{--fui-Slider__rail--size:2px;}", ".f1pha7fy{min-height:24px;}", ".f1a78h9h{--fui-Slider__thumb--size:20px;}", ".fuok0yf{--fui-Slider__rail--size:4px;}", ".f1nxs5xn{min-height:32px;}", ".fyvtabn{min-width:120px;}", ".f1yfdkfd{height:var(--fui-Slider__thumb--size);}", ".f174ca62{width:var(--fui-Slider__thumb--size);}", ".f1pzv1zu{min-height:120px;}", ".f13qjosx{grid-template-columns:var(--fui-Slider__thumb--size);}", ".f4l8x3l{--fui-Slider__rail--color:var(--colorNeutralStrokeAccessible);}", ".f671q34{--fui-Slider__progress--color:var(--colorCompoundBrandBackground);}", ".fvfzmw5{--fui-Slider__thumb--color:var(--colorCompoundBrandBackground);}", ".foojseg{--fui-Slider__thumb--color:var(--colorNeutralForegroundDisabled);}", ".f1lgdqhv{--fui-Slider__rail--color:var(--colorNeutralBackgroundDisabled);}", ".f1veetlj{--fui-Slider__progress--color:var(--colorNeutralForegroundDisabled);}", "[data-keyboard-nav] .fbiesyy:focus-within{border-top-color:transparent;}", "[data-keyboard-nav] .fq2kn9:focus-within{border-right-color:transparent;}", "[data-keyboard-nav] .f1jxwnad:focus-within{border-left-color:transparent;}", "[data-keyboard-nav] .f1il7mou:focus-within{border-bottom-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] .fskqmiq:focus-within:after{z-index:1;}", "[data-keyboard-nav] .f1kbdjx9:focus-within:after{border-top-style:solid;}", "[data-keyboard-nav] .fw1d893:focus-within:after{border-right-style:solid;}", "[data-keyboard-nav] .fpuz8dn:focus-within:after{border-left-style:solid;}", "[data-keyboard-nav] .f14hlsw1:focus-within:after{border-bottom-style:solid;}", "[data-keyboard-nav] .f1bkt4b4:focus-within:after{border-top-width:2px;}", "[data-keyboard-nav] .f16hf5f2:focus-within:after{border-right-width:2px;}", "[data-keyboard-nav] .f1qhqcal:focus-within:after{border-left-width:2px;}", "[data-keyboard-nav] .fyyqeim:focus-within:after{border-bottom-width:2px;}", "[data-keyboard-nav] .f1aneyfs:focus-within:after{border-bottom-right-radius:var(--borderRadiusMedium);}", "[data-keyboard-nav] .f15nmyc0:focus-within:after{border-bottom-left-radius:var(--borderRadiusMedium);}", "[data-keyboard-nav] .f3cpy5b:focus-within:after{border-top-right-radius:var(--borderRadiusMedium);}", "[data-keyboard-nav] .f13v6kgv:focus-within:after{border-top-left-radius:var(--borderRadiusMedium);}", "[data-keyboard-nav] .filx0we:focus-within:after{border-top-color:var(--colorStrokeFocus2);}", "[data-keyboard-nav] .f1horip2:focus-within:after{border-right-color:var(--colorStrokeFocus2);}", "[data-keyboard-nav] .fgnx9ah:focus-within:after{border-left-color:var(--colorStrokeFocus2);}", "[data-keyboard-nav] .fkii2tb:focus-within:after{border-bottom-color:var(--colorStrokeFocus2);}", "[data-keyboard-nav] .
|
|
149
|
-
"h": [".
|
|
150
|
-
"a": [".
|
|
148
|
+
"d": [".f10pi13n{position:relative;}", ".fwk3njj{display:inline-grid;}", ".femm8af{grid-template-areas:\"slider\";}", ".f1xqy1su{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}", ".f1sdsnyy{touch-action:none;}", ".f122n59{-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}", ".f1oiokrs{justify-items:center;}", ".f1agqo6f{--fui-Slider__thumb--size:16px;}", ".f1i7ztpd{--fui-Slider__rail--size:2px;}", ".f1pha7fy{min-height:24px;}", ".f1a78h9h{--fui-Slider__thumb--size:20px;}", ".fuok0yf{--fui-Slider__rail--size:4px;}", ".f1nxs5xn{min-height:32px;}", ".fyvtabn{min-width:120px;}", ".f1yfdkfd{height:var(--fui-Slider__thumb--size);}", ".f174ca62{width:var(--fui-Slider__thumb--size);}", ".f1pzv1zu{min-height:120px;}", ".f13qjosx{grid-template-columns:var(--fui-Slider__thumb--size);}", ".f4l8x3l{--fui-Slider__rail--color:var(--colorNeutralStrokeAccessible);}", ".f671q34{--fui-Slider__progress--color:var(--colorCompoundBrandBackground);}", ".fvfzmw5{--fui-Slider__thumb--color:var(--colorCompoundBrandBackground);}", ".foojseg{--fui-Slider__thumb--color:var(--colorNeutralForegroundDisabled);}", ".f1lgdqhv{--fui-Slider__rail--color:var(--colorNeutralBackgroundDisabled);}", ".f1veetlj{--fui-Slider__progress--color:var(--colorNeutralForegroundDisabled);}", "[data-keyboard-nav] .fbiesyy:focus-within{border-top-color:transparent;}", "[data-keyboard-nav] .fq2kn9:focus-within{border-right-color:transparent;}", "[data-keyboard-nav] .f1jxwnad:focus-within{border-left-color:transparent;}", "[data-keyboard-nav] .f1il7mou:focus-within{border-bottom-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] .fskqmiq:focus-within:after{z-index:1;}", "[data-keyboard-nav] .f1kbdjx9:focus-within:after{border-top-style:solid;}", "[data-keyboard-nav] .fw1d893:focus-within:after{border-right-style:solid;}", "[data-keyboard-nav] .fpuz8dn:focus-within:after{border-left-style:solid;}", "[data-keyboard-nav] .f14hlsw1:focus-within:after{border-bottom-style:solid;}", "[data-keyboard-nav] .f1bkt4b4:focus-within:after{border-top-width:2px;}", "[data-keyboard-nav] .f16hf5f2:focus-within:after{border-right-width:2px;}", "[data-keyboard-nav] .f1qhqcal:focus-within:after{border-left-width:2px;}", "[data-keyboard-nav] .fyyqeim:focus-within:after{border-bottom-width:2px;}", "[data-keyboard-nav] .f1aneyfs:focus-within:after{border-bottom-right-radius:var(--borderRadiusMedium);}", "[data-keyboard-nav] .f15nmyc0:focus-within:after{border-bottom-left-radius:var(--borderRadiusMedium);}", "[data-keyboard-nav] .f3cpy5b:focus-within:after{border-top-right-radius:var(--borderRadiusMedium);}", "[data-keyboard-nav] .f13v6kgv:focus-within:after{border-top-left-radius:var(--borderRadiusMedium);}", "[data-keyboard-nav] .filx0we:focus-within:after{border-top-color:var(--colorStrokeFocus2);}", "[data-keyboard-nav] .f1horip2:focus-within:after{border-right-color:var(--colorStrokeFocus2);}", "[data-keyboard-nav] .fgnx9ah:focus-within:after{border-left-color:var(--colorStrokeFocus2);}", "[data-keyboard-nav] .fkii2tb:focus-within:after{border-bottom-color:var(--colorStrokeFocus2);}", "[data-keyboard-nav] .f11tdyqf:focus-within:after{top:calc(0px - 2px - -2px);}", "[data-keyboard-nav] .f1blztld:focus-within:after{bottom:calc(0px - 2px - -2px);}", "[data-keyboard-nav] .fc3tncn:focus-within:after{left:calc(0px - 2px - 8px);}", "[data-keyboard-nav] .f1veb610:focus-within:after{right:calc(0px - 2px - 8px);}", "[data-keyboard-nav] .f1n40nz3:focus-within:after{top:calc(0px - 2px - 6px);}", "[data-keyboard-nav] .f1iimkc5:focus-within:after{bottom:calc(0px - 2px - 6px);}", "[data-keyboard-nav] .f1v1vptr:focus-within:after{left:calc(0px - 2px - 4px);}", "[data-keyboard-nav] .f17zmyg5:focus-within:after{right:calc(0px - 2px - 4px);}"],
|
|
149
|
+
"h": [".faw1t00:hover{--fui-Slider__thumb--color:var(--colorCompoundBrandBackgroundHover);}", ".fxdgx5:hover{--fui-Slider__progress--color:var(--colorCompoundBrandBackgroundHover);}"],
|
|
150
|
+
"a": [".fii04fa:active{--fui-Slider__thumb--color:var(--colorCompoundBrandBackgroundPressed);}", ".f36hzz8:active{--fui-Slider__progress--color:var(--colorCompoundBrandBackgroundPressed);}"],
|
|
151
151
|
"t": ["@media (forced-colors: active){.f1volkfw{--fui-Slider__rail--color:CanvasText;}}", "@media (forced-colors: active){.f1xddb6{--fui-Slider__thumb--color:Highlight;}}", "@media (forced-colors: active){.fcdikl{--fui-Slider__progress--color:Highlight;}}", "@media (forced-colors: active){.fhpzgm6:hover{--fui-Slider__thumb--color:Highlight;}}", "@media (forced-colors: active){.f1q6pm3h:hover{--fui-Slider__progress--color:Highlight;}}", "@media (forced-colors: active){.fu12m3e{--fui-Slider__rail--color:GrayText;}}", "@media (forced-colors: active){.fi9guym{--fui-Slider__thumb--color:GrayText;}}", "@media (forced-colors: active){.fcdjl4u{--fui-Slider__progress--color:GrayText;}}"],
|
|
152
152
|
"i": [".f2hkw1w:focus-visible{outline-style:none;}"]
|
|
153
153
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["components/Slider/useSliderStyles.ts"],"names":[],"mappings":"AAAA,SAAS,UAAT,YAAiC,YAAjC,QAAqD,gBAArD;AACA,SAAS,uBAAT,QAAwC,yBAAxC;AACA,SAAS,MAAT,QAAuB,uBAAvB;AAIA,OAAO,MAAM,gBAAgB,GAAgC;AAC3D,EAAA,IAAI,EAAE,YADqD;AAE3D,EAAA,IAAI,EAAE,kBAFqD;AAG3D,EAAA,KAAK,EAAE,mBAHoD;AAI3D,EAAA,KAAK,EAAE;AAJoD,CAAtD,C,CAOP;;AACA,MAAM,YAAY,GAAG,2BAArB;AACA,MAAM,WAAW,GAAG,0BAApB;AACA,MAAM,YAAY,GA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d,GAAuC,UAAU,CAAC,wBAH3B,EAIjC,UAAU,CAAC,KAAK,CAAC,IAAP,CAJuB,EAKjC,UAAU,GAAG,UAAU,CAAC,QAAd,GAAyB,UAAU,CAAC,UALb,EAMjC,KAAK,CAAC,QAAN,GAAiB,UAAU,CAAC,QAA5B,GAAuC,UAAU,CAAC,OANjB,EAOjC,KAAK,CAAC,IAAN,CAAW,SAPsB,CAAnC;AAUA,EAAA,KAAK,CAAC,IAAN,CAAW,SAAX,GAAuB,YAAY,CACjC,gBAAgB,CAAC,IADgB,EAEjC,UAAU,CAAC,IAFsB,EAGjC,UAAU,GAAG,UAAU,CAAC,QAAd,GAAyB,UAAU,CAAC,UAHb,EAIjC,KAAK,CAAC,IAAN,CAAW,SAJsB,CAAnC;AAOA,EAAA,KAAK,CAAC,KAAN,CAAY,SAAZ,GAAwB,YAAY,CAClC,gBAAgB,CAAC,KADiB,EAElC,WAAW,CAAC,KAFsB,EAGlC,UAAU,GAAG,WAAW,CAAC,QAAf,GAA0B,WAAW,CAAC,UAHd,EAIlC,KAAK,CAAC,QAAN,IAAkB,WAAW,CAAC,QAJI,EAKlC,KAAK,CAAC,KAAN,CAAY,SALsB,CAApC;AAQA,EAAA,KAAK,CAAC,KAAN,CAAY,SAAZ,GAAwB,YAAY,CAClC,gBAAgB,CAAC,KADiB,EAElC,WAAW,CAAC,KAFsB,EAGlC,UAAU,GAAG,WAAW,CAAC,QAAf,GAA0B,WAAW,CAAC,UAHd,EAIlC,KAAK,CAAC,KAAN,CAAY,SAJsB,CAApC;AAOA,SAAO,KAAP;AACD,CAxCM","sourcesContent":["import { shorthands, makeStyles, mergeClasses } from '@griffel/react';\nimport { createFocusOutlineStyle } from '@fluentui/react-tabster';\nimport { tokens } from '@fluentui/react-theme';\nimport type { SliderState, SliderSlots } from './Slider.types';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\n\nexport const sliderClassNames: SlotClassNames<SliderSlots> = {\n root: 'fui-Slider',\n rail: 'fui-Slider__rail',\n thumb: 'fui-Slider__thumb',\n input: 'fui-Slider__input',\n};\n\n// Internal CSS variables\nconst thumbSizeVar = `--fui-Slider__thumb--size`;\nconst railSizeVar = `--fui-Slider__rail--size`;\nconst railColorVar = `--fui-Slider__rail--color`;\nconst progressColorVar = `--fui-Slider__progress--color`;\nconst thumbColorVar = `--fui-Slider__thumb--color`;\n\nexport const sliderCSSVars = {\n railDirectionVar: `--fui-Slider__rail--direction`,\n railOffsetVar: `--fui-Slider__rail--offset`,\n railProgressVar: `--fui-Slider__rail--progress`,\n railStepsPercentVar: `--fui-Slider__rail--steps-percent`,\n thumbPositionVar: `--fui-Slider__thumb--position`,\n};\n\nconst { railDirectionVar, railOffsetVar, railStepsPercentVar, railProgressVar, thumbPositionVar } = sliderCSSVars;\n\n/**\n * Styles for the root slot\n */\nconst useRootStyles = makeStyles({\n root: {\n position: 'relative',\n display: 'inline-grid',\n gridTemplateAreas: '\"slider\"',\n userSelect: 'none',\n touchAction: 'none',\n alignItems: 'center',\n justifyItems: 'center',\n },\n\n small: {\n [thumbSizeVar]: '16px',\n [railSizeVar]: '2px',\n minHeight: '24px',\n },\n\n medium: {\n [thumbSizeVar]: '20px',\n [railSizeVar]: '4px',\n minHeight: '32px',\n },\n\n horizontal: {\n minWidth: '120px',\n height: `var(${thumbSizeVar})`,\n },\n\n vertical: {\n width: `var(${thumbSizeVar})`,\n minHeight: '120px',\n gridTemplateColumns: `var(${thumbSizeVar})`,\n },\n\n enabled: {\n [railColorVar]: tokens.colorNeutralStrokeAccessible,\n [progressColorVar]: tokens.colorCompoundBrandBackground,\n [thumbColorVar]: tokens.colorCompoundBrandBackground,\n ':hover': {\n [thumbColorVar]: tokens.colorBrandBackgroundHover,\n [progressColorVar]: tokens.colorBrandBackgroundHover,\n },\n ':active': {\n [thumbColorVar]: tokens.colorBrandBackgroundPressed,\n [progressColorVar]: tokens.colorBrandBackgroundPressed,\n },\n '@media (forced-colors: active)': {\n [railColorVar]: 'CanvasText',\n [thumbColorVar]: 'Highlight',\n [progressColorVar]: 'Highlight',\n ':hover': {\n [thumbColorVar]: 'Highlight',\n [progressColorVar]: 'Highlight',\n },\n },\n },\n\n disabled: {\n [thumbColorVar]: tokens.colorNeutralForegroundDisabled,\n [railColorVar]: tokens.colorNeutralBackgroundDisabled,\n [progressColorVar]: tokens.colorNeutralForegroundDisabled,\n '@media (forced-colors: active)': {\n [railColorVar]: 'GrayText',\n [thumbColorVar]: 'GrayText',\n [progressColorVar]: 'GrayText',\n },\n },\n\n focusIndicatorHorizontal: createFocusOutlineStyle({\n selector: 'focus-within',\n style: { outlineOffset: { top: '6px', bottom: '6px', left: '10px', right: '10px' } },\n }),\n\n focusIndicatorVertical: createFocusOutlineStyle({\n selector: 'focus-within',\n style: { outlineOffset: { top: '10px', bottom: '10px', left: '6px', right: '6px' } },\n }),\n});\n\n/**\n * Styles for the rail slot\n */\nconst useRailStyles = makeStyles({\n rail: {\n ...shorthands.borderRadius(tokens.borderRadiusXLarge),\n pointerEvents: 'none',\n gridRowStart: 'slider',\n gridRowEnd: 'slider',\n gridColumnStart: 'slider',\n gridColumnEnd: 'slider',\n position: 'relative',\n forcedColorAdjust: 'none',\n // Background gradient represents the progress of the slider\n backgroundImage: `linear-gradient(\n var(${railDirectionVar}),\n var(${railColorVar}) 0%,\n var(${railColorVar}) var(${railOffsetVar}),\n var(${progressColorVar}) var(${railOffsetVar}),\n var(${progressColorVar}) calc(var(${railOffsetVar}) + var(${railProgressVar})),\n var(${railColorVar}) calc(var(${railOffsetVar}) + var(${railProgressVar}))\n )`,\n outlineWidth: '1px',\n outlineStyle: 'solid',\n outlineColor: tokens.colorTransparentStroke,\n ':before': {\n content: \"''\",\n position: 'absolute',\n // Repeating gradient represents the steps if provided\n backgroundImage: `repeating-linear-gradient(\n var(${railDirectionVar}),\n #0000 0%,\n #0000 calc(var(${railStepsPercentVar}) - 1px),\n ${tokens.colorNeutralBackground1} calc(var(${railStepsPercentVar}) - 1px),\n ${tokens.colorNeutralBackground1} var(${railStepsPercentVar})\n )`,\n },\n },\n\n horizontal: {\n width: '100%',\n height: `var(${railSizeVar})`,\n ':before': {\n left: '-1px',\n right: '-1px',\n height: `var(${railSizeVar})`,\n },\n },\n\n vertical: {\n width: `var(${railSizeVar})`,\n height: '100%',\n ':before': {\n width: `var(${railSizeVar})`,\n top: '-1px',\n bottom: '1px',\n },\n },\n});\n\n/**\n * Styles for the thumb slot\n */\nconst useThumbStyles = makeStyles({\n thumb: {\n position: 'absolute',\n width: `var(${thumbSizeVar})`,\n height: `var(${thumbSizeVar})`,\n pointerEvents: 'none',\n outlineStyle: 'none',\n forcedColorAdjust: 'none',\n ...shorthands.borderRadius(tokens.borderRadiusCircular),\n boxShadow: `0 0 0 calc(var(${thumbSizeVar}) * .2) ${tokens.colorNeutralBackground1} inset`,\n backgroundColor: `var(${thumbColorVar})`,\n transform: 'translateX(-50%)',\n ':before': {\n position: 'absolute',\n top: '0px',\n left: '0px',\n bottom: '0px',\n right: '0px',\n ...shorthands.borderRadius(tokens.borderRadiusCircular),\n boxSizing: 'border-box',\n content: \"''\",\n ...shorthands.border(`calc(var(${thumbSizeVar}) * .05)`, 'solid', tokens.colorNeutralStroke1),\n },\n },\n disabled: {\n ':before': {\n ...shorthands.border(`calc(var(${thumbSizeVar}) * .05)`, 'solid', tokens.colorNeutralForegroundDisabled),\n },\n },\n horizontal: {\n left: `var(${thumbPositionVar})`,\n },\n vertical: {\n transform: 'translateY(50%)',\n bottom: `var(${thumbPositionVar})`,\n },\n});\n\n/**\n * Styles for the Input slot\n */\nconst useInputStyles = makeStyles({\n input: {\n opacity: 0,\n gridRowStart: 'slider',\n gridRowEnd: 'slider',\n gridColumnStart: 'slider',\n gridColumnEnd: 'slider',\n ...shorthands.padding(0),\n ...shorthands.margin(0),\n },\n horizontal: {\n height: `var(${thumbSizeVar})`,\n width: `calc(100% + var(${thumbSizeVar}))`,\n },\n vertical: {\n height: `calc(100% + var(${thumbSizeVar}))`,\n width: `var(${thumbSizeVar})`,\n '-webkit-appearance': 'slider-vertical',\n },\n});\n\n/**\n * Apply styling to the Slider slots based on the state\n */\nexport const useSliderStyles_unstable = (state: SliderState): SliderState => {\n const rootStyles = useRootStyles();\n const railStyles = useRailStyles();\n const thumbStyles = useThumbStyles();\n const inputStyles = useInputStyles();\n const isVertical = state.vertical;\n\n state.root.className = mergeClasses(\n sliderClassNames.root,\n rootStyles.root,\n isVertical ? rootStyles.focusIndicatorVertical : rootStyles.focusIndicatorHorizontal,\n rootStyles[state.size!],\n isVertical ? rootStyles.vertical : rootStyles.horizontal,\n state.disabled ? rootStyles.disabled : rootStyles.enabled,\n state.root.className,\n );\n\n state.rail.className = mergeClasses(\n sliderClassNames.rail,\n railStyles.rail,\n isVertical ? railStyles.vertical : railStyles.horizontal,\n state.rail.className,\n );\n\n state.thumb.className = mergeClasses(\n sliderClassNames.thumb,\n thumbStyles.thumb,\n isVertical ? thumbStyles.vertical : thumbStyles.horizontal,\n state.disabled && thumbStyles.disabled,\n state.thumb.className,\n );\n\n state.input.className = mergeClasses(\n sliderClassNames.input,\n inputStyles.input,\n isVertical ? inputStyles.vertical : inputStyles.horizontal,\n state.input.className,\n );\n\n return state;\n};\n"],"sourceRoot":"../src/"}
|
|
1
|
+
{"version":3,"sources":["components/Slider/useSliderStyles.ts"],"names":[],"mappings":"AAAA,SAAS,UAAT,YAAiC,YAAjC,QAAqD,gBAArD;AACA,SAAS,uBAAT,QAAwC,yBAAxC;AACA,SAAS,MAAT,QAAuB,uBAAvB;AAIA,OAAO,MAAM,gBAAgB,GAAgC;AAC3D,EAAA,IAAI,EAAE,YADqD;AAE3D,EAAA,IAAI,EAAE,kBAFqD;AAG3D,EAAA,KAAK,EAAE,mBAHoD;AAI3D,EAAA,KAAK,EAAE;AAJoD,CAAtD,C,CAOP;;AACA,MAAM,YAAY,GAAG,2BAArB;AACA,MAAM,WAAW,GAAG,0BAApB;AACA,MAAM,YAAY,GAAG,2BAArB;AACA,MAAM,gBAAgB,GAAG,+BAA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U,CAAC,KAAK,CAAC,IAAP,CAJuB,EAKjC,UAAU,GAAG,UAAU,CAAC,QAAd,GAAyB,UAAU,CAAC,UALb,EAMjC,KAAK,CAAC,QAAN,GAAiB,UAAU,CAAC,QAA5B,GAAuC,UAAU,CAAC,OANjB,EAOjC,KAAK,CAAC,IAAN,CAAW,SAPsB,CAAnC;AAUA,EAAA,KAAK,CAAC,IAAN,CAAW,SAAX,GAAuB,YAAY,CACjC,gBAAgB,CAAC,IADgB,EAEjC,UAAU,CAAC,IAFsB,EAGjC,UAAU,GAAG,UAAU,CAAC,QAAd,GAAyB,UAAU,CAAC,UAHb,EAIjC,KAAK,CAAC,IAAN,CAAW,SAJsB,CAAnC;AAOA,EAAA,KAAK,CAAC,KAAN,CAAY,SAAZ,GAAwB,YAAY,CAClC,gBAAgB,CAAC,KADiB,EAElC,WAAW,CAAC,KAFsB,EAGlC,UAAU,GAAG,WAAW,CAAC,QAAf,GAA0B,WAAW,CAAC,UAHd,EAIlC,KAAK,CAAC,QAAN,IAAkB,WAAW,CAAC,QAJI,EAKlC,KAAK,CAAC,KAAN,CAAY,SALsB,CAApC;AAQA,EAAA,KAAK,CAAC,KAAN,CAAY,SAAZ,GAAwB,YAAY,CAClC,gBAAgB,CAAC,KADiB,EAElC,WAAW,CAAC,KAFsB,EAGlC,UAAU,GAAG,WAAW,CAAC,QAAf,GAA0B,WAAW,CAAC,UAHd,EAIlC,KAAK,CAAC,KAAN,CAAY,SAJsB,CAApC;AAOA,SAAO,KAAP;AACD,CAxCM","sourcesContent":["import { shorthands, makeStyles, mergeClasses } from '@griffel/react';\nimport { createFocusOutlineStyle } from '@fluentui/react-tabster';\nimport { tokens } from '@fluentui/react-theme';\nimport type { SliderState, SliderSlots } from './Slider.types';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\n\nexport const sliderClassNames: SlotClassNames<SliderSlots> = {\n root: 'fui-Slider',\n rail: 'fui-Slider__rail',\n thumb: 'fui-Slider__thumb',\n input: 'fui-Slider__input',\n};\n\n// Internal CSS variables\nconst thumbSizeVar = `--fui-Slider__thumb--size`;\nconst railSizeVar = `--fui-Slider__rail--size`;\nconst railColorVar = `--fui-Slider__rail--color`;\nconst progressColorVar = `--fui-Slider__progress--color`;\nconst thumbColorVar = `--fui-Slider__thumb--color`;\n\nexport const sliderCSSVars = {\n railDirectionVar: `--fui-Slider__rail--direction`,\n railOffsetVar: `--fui-Slider__rail--offset`,\n railProgressVar: `--fui-Slider__rail--progress`,\n railStepsPercentVar: `--fui-Slider__rail--steps-percent`,\n thumbPositionVar: `--fui-Slider__thumb--position`,\n};\n\nconst { railDirectionVar, railOffsetVar, railStepsPercentVar, railProgressVar, thumbPositionVar } = sliderCSSVars;\n\n/**\n * Styles for the root slot\n */\nconst useRootStyles = makeStyles({\n root: {\n position: 'relative',\n display: 'inline-grid',\n gridTemplateAreas: '\"slider\"',\n userSelect: 'none',\n touchAction: 'none',\n alignItems: 'center',\n justifyItems: 'center',\n },\n\n small: {\n [thumbSizeVar]: '16px',\n [railSizeVar]: '2px',\n minHeight: '24px',\n },\n\n medium: {\n [thumbSizeVar]: '20px',\n [railSizeVar]: '4px',\n minHeight: '32px',\n },\n\n horizontal: {\n minWidth: '120px',\n height: `var(${thumbSizeVar})`,\n },\n\n vertical: {\n width: `var(${thumbSizeVar})`,\n minHeight: '120px',\n gridTemplateColumns: `var(${thumbSizeVar})`,\n },\n\n enabled: {\n [railColorVar]: tokens.colorNeutralStrokeAccessible,\n [progressColorVar]: tokens.colorCompoundBrandBackground,\n [thumbColorVar]: tokens.colorCompoundBrandBackground,\n ':hover': {\n [thumbColorVar]: tokens.colorCompoundBrandBackgroundHover,\n [progressColorVar]: tokens.colorCompoundBrandBackgroundHover,\n },\n ':active': {\n [thumbColorVar]: tokens.colorCompoundBrandBackgroundPressed,\n [progressColorVar]: tokens.colorCompoundBrandBackgroundPressed,\n },\n '@media (forced-colors: active)': {\n [railColorVar]: 'CanvasText',\n [thumbColorVar]: 'Highlight',\n [progressColorVar]: 'Highlight',\n ':hover': {\n [thumbColorVar]: 'Highlight',\n [progressColorVar]: 'Highlight',\n },\n },\n },\n\n disabled: {\n [thumbColorVar]: tokens.colorNeutralForegroundDisabled,\n [railColorVar]: tokens.colorNeutralBackgroundDisabled,\n [progressColorVar]: tokens.colorNeutralForegroundDisabled,\n '@media (forced-colors: active)': {\n [railColorVar]: 'GrayText',\n [thumbColorVar]: 'GrayText',\n [progressColorVar]: 'GrayText',\n },\n },\n\n focusIndicatorHorizontal: createFocusOutlineStyle({\n selector: 'focus-within',\n style: { outlineOffset: { top: '-2px', bottom: '-2px', left: '8px', right: '8px' } },\n }),\n\n focusIndicatorVertical: createFocusOutlineStyle({\n selector: 'focus-within',\n style: { outlineOffset: { top: '6px', bottom: '6px', left: '4px', right: '4px' } },\n }),\n});\n\n/**\n * Styles for the rail slot\n */\nconst useRailStyles = makeStyles({\n rail: {\n ...shorthands.borderRadius(tokens.borderRadiusXLarge),\n pointerEvents: 'none',\n gridRowStart: 'slider',\n gridRowEnd: 'slider',\n gridColumnStart: 'slider',\n gridColumnEnd: 'slider',\n position: 'relative',\n forcedColorAdjust: 'none',\n // Background gradient represents the progress of the slider\n backgroundImage: `linear-gradient(\n var(${railDirectionVar}),\n var(${railColorVar}) 0%,\n var(${railColorVar}) var(${railOffsetVar}),\n var(${progressColorVar}) var(${railOffsetVar}),\n var(${progressColorVar}) calc(var(${railOffsetVar}) + var(${railProgressVar})),\n var(${railColorVar}) calc(var(${railOffsetVar}) + var(${railProgressVar}))\n )`,\n outlineWidth: '1px',\n outlineStyle: 'solid',\n outlineColor: tokens.colorTransparentStroke,\n ':before': {\n content: \"''\",\n position: 'absolute',\n // Repeating gradient represents the steps if provided\n backgroundImage: `repeating-linear-gradient(\n var(${railDirectionVar}),\n #0000 0%,\n #0000 calc(var(${railStepsPercentVar}) - 1px),\n ${tokens.colorNeutralBackground1} calc(var(${railStepsPercentVar}) - 1px),\n ${tokens.colorNeutralBackground1} var(${railStepsPercentVar})\n )`,\n },\n },\n\n horizontal: {\n width: '100%',\n height: `var(${railSizeVar})`,\n ':before': {\n left: '-1px',\n right: '-1px',\n height: `var(${railSizeVar})`,\n },\n },\n\n vertical: {\n width: `var(${railSizeVar})`,\n height: '100%',\n ':before': {\n width: `var(${railSizeVar})`,\n top: '-1px',\n bottom: '1px',\n },\n },\n});\n\n/**\n * Styles for the thumb slot\n */\nconst useThumbStyles = makeStyles({\n thumb: {\n position: 'absolute',\n width: `var(${thumbSizeVar})`,\n height: `var(${thumbSizeVar})`,\n pointerEvents: 'none',\n outlineStyle: 'none',\n forcedColorAdjust: 'none',\n ...shorthands.borderRadius(tokens.borderRadiusCircular),\n boxShadow: `0 0 0 calc(var(${thumbSizeVar}) * .2) ${tokens.colorNeutralBackground1} inset`,\n backgroundColor: `var(${thumbColorVar})`,\n transform: 'translateX(-50%)',\n ':before': {\n position: 'absolute',\n top: '0px',\n left: '0px',\n bottom: '0px',\n right: '0px',\n ...shorthands.borderRadius(tokens.borderRadiusCircular),\n boxSizing: 'border-box',\n content: \"''\",\n ...shorthands.border(`calc(var(${thumbSizeVar}) * .05)`, 'solid', tokens.colorNeutralStroke1),\n },\n },\n disabled: {\n ':before': {\n ...shorthands.border(`calc(var(${thumbSizeVar}) * .05)`, 'solid', tokens.colorNeutralForegroundDisabled),\n },\n },\n horizontal: {\n left: `var(${thumbPositionVar})`,\n },\n vertical: {\n transform: 'translateY(50%)',\n bottom: `var(${thumbPositionVar})`,\n },\n});\n\n/**\n * Styles for the Input slot\n */\nconst useInputStyles = makeStyles({\n input: {\n opacity: 0,\n gridRowStart: 'slider',\n gridRowEnd: 'slider',\n gridColumnStart: 'slider',\n gridColumnEnd: 'slider',\n ...shorthands.padding(0),\n ...shorthands.margin(0),\n },\n horizontal: {\n height: `var(${thumbSizeVar})`,\n width: `calc(100% + var(${thumbSizeVar}))`,\n },\n vertical: {\n height: `calc(100% + var(${thumbSizeVar}))`,\n width: `var(${thumbSizeVar})`,\n '-webkit-appearance': 'slider-vertical',\n },\n});\n\n/**\n * Apply styling to the Slider slots based on the state\n */\nexport const useSliderStyles_unstable = (state: SliderState): SliderState => {\n const rootStyles = useRootStyles();\n const railStyles = useRailStyles();\n const thumbStyles = useThumbStyles();\n const inputStyles = useInputStyles();\n const isVertical = state.vertical;\n\n state.root.className = mergeClasses(\n sliderClassNames.root,\n rootStyles.root,\n isVertical ? rootStyles.focusIndicatorVertical : rootStyles.focusIndicatorHorizontal,\n rootStyles[state.size!],\n isVertical ? rootStyles.vertical : rootStyles.horizontal,\n state.disabled ? rootStyles.disabled : rootStyles.enabled,\n state.root.className,\n );\n\n state.rail.className = mergeClasses(\n sliderClassNames.rail,\n railStyles.rail,\n isVertical ? railStyles.vertical : railStyles.horizontal,\n state.rail.className,\n );\n\n state.thumb.className = mergeClasses(\n sliderClassNames.thumb,\n thumbStyles.thumb,\n isVertical ? thumbStyles.vertical : thumbStyles.horizontal,\n state.disabled && thumbStyles.disabled,\n state.thumb.className,\n );\n\n state.input.className = mergeClasses(\n sliderClassNames.input,\n inputStyles.input,\n isVertical ? inputStyles.vertical : inputStyles.horizontal,\n state.input.className,\n );\n\n return state;\n};\n"],"sourceRoot":"../src/"}
|
|
@@ -8,10 +8,6 @@ exports.useSlider_unstable = void 0;
|
|
|
8
8
|
const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
|
|
9
9
|
|
|
10
10
|
const useSliderState_1 = /*#__PURE__*/require("./useSliderState");
|
|
11
|
-
/**
|
|
12
|
-
* Given user props, returns state and render function for a Slider.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
11
|
|
|
16
12
|
const useSlider_unstable = (props, ref) => {
|
|
17
13
|
const nativeProps = react_utilities_1.getPartitionedNativeProps({
|
|
@@ -20,17 +16,9 @@ const useSlider_unstable = (props, ref) => {
|
|
|
20
16
|
excludedPropNames: ['onChange', 'size']
|
|
21
17
|
});
|
|
22
18
|
const {
|
|
23
|
-
// Props
|
|
24
|
-
value,
|
|
25
|
-
defaultValue,
|
|
26
|
-
min = 0,
|
|
27
|
-
max = 100,
|
|
28
|
-
step,
|
|
29
19
|
disabled,
|
|
30
20
|
vertical,
|
|
31
21
|
size = 'medium',
|
|
32
|
-
origin,
|
|
33
|
-
onChange,
|
|
34
22
|
// Slots
|
|
35
23
|
root,
|
|
36
24
|
input,
|
|
@@ -38,16 +26,9 @@ const useSlider_unstable = (props, ref) => {
|
|
|
38
26
|
thumb
|
|
39
27
|
} = props;
|
|
40
28
|
const state = {
|
|
41
|
-
defaultValue,
|
|
42
29
|
disabled,
|
|
43
|
-
max,
|
|
44
|
-
min,
|
|
45
|
-
origin,
|
|
46
30
|
size,
|
|
47
|
-
step,
|
|
48
31
|
vertical,
|
|
49
|
-
value,
|
|
50
|
-
onChange,
|
|
51
32
|
components: {
|
|
52
33
|
input: 'input',
|
|
53
34
|
rail: 'div',
|
|
@@ -76,7 +57,7 @@ const useSlider_unstable = (props, ref) => {
|
|
|
76
57
|
required: true
|
|
77
58
|
})
|
|
78
59
|
};
|
|
79
|
-
useSliderState_1.useSliderState_unstable(state);
|
|
60
|
+
useSliderState_1.useSliderState_unstable(state, props);
|
|
80
61
|
return state;
|
|
81
62
|
};
|
|
82
63
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["components/Slider/useSlider.ts"],"names":[],"mappings":";;;;;;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AACA,MAAA,gBAAA,gBAAA,OAAA,CAAA,kBAAA,CAAA
|
|
1
|
+
{"version":3,"sources":["components/Slider/useSlider.ts"],"names":[],"mappings":";;;;;;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AACA,MAAA,gBAAA,gBAAA,OAAA,CAAA,kBAAA,CAAA;;AAGO,MAAM,kBAAkB,GAAG,CAAC,KAAD,EAAqB,GAArB,KAAsE;AACtG,QAAM,WAAW,GAAG,iBAAA,CAAA,yBAAA,CAA0B;AAC5C,IAAA,KAD4C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AAjB,EAAwB;AAAE,MAAA,QAAQ,EAAE;AAAZ,KAAxB;AA3BkB,GAA3B;AA8BA,EAAA,gBAAA,CAAA,uBAAA,CAAwB,KAAxB,EAA+B,KAA/B;AAEA,SAAO,KAAP;AACD,CAnDM;;AAAM,OAAA,CAAA,kBAAA,GAAkB,kBAAlB","sourcesContent":["import * as React from 'react';\nimport { getPartitionedNativeProps, resolveShorthand, useId } from '@fluentui/react-utilities';\nimport { useSliderState_unstable } from './useSliderState';\nimport { SliderProps, SliderState } from './Slider.types';\n\nexport const useSlider_unstable = (props: SliderProps, ref: React.Ref<HTMLInputElement>): SliderState => {\n const nativeProps = getPartitionedNativeProps({\n props,\n primarySlotTagName: 'input',\n excludedPropNames: ['onChange', 'size'],\n });\n\n const {\n disabled,\n vertical,\n size = 'medium',\n // Slots\n root,\n input,\n rail,\n thumb,\n } = props;\n\n const state: SliderState = {\n disabled,\n size,\n vertical,\n components: {\n input: 'input',\n rail: 'div',\n root: 'div',\n thumb: 'div',\n },\n root: resolveShorthand(root, {\n required: true,\n defaultProps: {\n ...nativeProps.root,\n },\n }),\n input: resolveShorthand(input, {\n required: true,\n defaultProps: {\n id: useId('slider-', props.id),\n ref,\n ...nativeProps.primary,\n type: 'range',\n orient: vertical ? 'vertical' : undefined,\n },\n }),\n rail: resolveShorthand(rail, { required: true }),\n thumb: resolveShorthand(thumb, { required: true }),\n };\n\n useSliderState_unstable(state, props);\n\n return state;\n};\n"],"sourceRoot":"../src/"}
|
|
@@ -25,15 +25,15 @@ const getPercent = (value, min, max) => {
|
|
|
25
25
|
return max === min ? 0 : (value - min) / (max - min) * 100;
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
const useSliderState_unstable = state => {
|
|
28
|
+
const useSliderState_unstable = (state, props) => {
|
|
29
29
|
const {
|
|
30
|
-
value,
|
|
31
30
|
defaultValue = 0,
|
|
32
31
|
min = 0,
|
|
33
32
|
max = 100,
|
|
34
|
-
step
|
|
35
|
-
origin
|
|
36
|
-
|
|
33
|
+
step,
|
|
34
|
+
origin,
|
|
35
|
+
value
|
|
36
|
+
} = props;
|
|
37
37
|
const {
|
|
38
38
|
dir
|
|
39
39
|
} = react_shared_contexts_1.useFluent();
|
|
@@ -47,7 +47,7 @@ const useSliderState_unstable = state => {
|
|
|
47
47
|
return origin !== undefined ? getPercent(origin, min, max) : 0;
|
|
48
48
|
}, [max, min, origin]);
|
|
49
49
|
const inputOnChange = state.input.onChange;
|
|
50
|
-
const propsOnChange =
|
|
50
|
+
const propsOnChange = props.onChange;
|
|
51
51
|
const onChange = react_utilities_1.useEventCallback(ev => {
|
|
52
52
|
const newValue = Number(ev.target.value);
|
|
53
53
|
setCurrentValue(react_utilities_1.clamp(newValue, min, max));
|
|
@@ -63,7 +63,7 @@ const useSliderState_unstable = state => {
|
|
|
63
63
|
const rootVariables = {
|
|
64
64
|
[railDirectionVar]: state.vertical ? '0deg' : dir === 'ltr' ? '90deg' : '270deg',
|
|
65
65
|
[thumbPositionVar]: valuePercent + '%',
|
|
66
|
-
[railStepsPercentVar]:
|
|
66
|
+
[railStepsPercentVar]: step && step > 0 ? `${step * 100 / (max - min)}%` : '',
|
|
67
67
|
[railOffsetVar]: origin !== undefined ? `${Math.min(valuePercent, originPercent)}%` : '0%',
|
|
68
68
|
[railProgressVar]: origin !== undefined ? `${Math.max(originPercent - valuePercent, valuePercent - originPercent)}%` : `${valuePercent}%`
|
|
69
69
|
}; // Root props
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["components/Slider/useSliderState.tsx"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AACA,MAAA,uBAAA,gBAAA,OAAA,CAAA,iCAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,mBAAA,CAAA;;AAGA,MAAM;AAAE,EAAA,aAAF;AAAiB,EAAA,mBAA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pB,KAAC,gBAAD,GAAoB,KAAK,CAAC,QAAN,GAAiB,MAAjB,GAA0B,GAAG,KAAK,KAAR,GAAgB,OAAhB,GAA0B,QADpD;AAEpB,KAAC,gBAAD,GAAoB,YAAY,GAAG,GAFf;AAGpB,KAAC,mBAAD,GAAuB,IAAI,IAAI,IAAI,GAAG,CAAf,GAAmB,GAAI,IAAI,GAAG,GAAR,IAAgB,GAAG,GAAG,GAAtB,CAA0B,GAAhD,GAAsD,EAHzD;AAIpB,KAAC,aAAD,GAAiB,MAAM,KAAK,SAAX,GAAuB,GAAG,IAAI,CAAC,GAAL,CAAS,YAAT,EAAuB,aAAvB,CAAqC,GAA/D,GAAqE,IAJlE;AAKpB,KAAC,eAAD,GACE,MAAM,KAAK,SAAX,GACI,GAAG,IAAI,CAAC,GAAL,CAAS,aAAa,GAAG,YAAzB,EAAuC,YAAY,GAAG,aAAtD,CAAoE,GAD3E,GAEI,GAAG,YAAY;AARD,GAAtB,CA3BgF,CAsChF;;AACA,EAAA,KAAK,CAAC,IAAN,CAAW,KAAX,GAAmB,EACjB,GAAG,aADc;AAEjB,OAAG,KAAK,CAAC,IAAN,CAAW;AAFG,GAAnB,CAvCgF,CA4ChF;;AACA,EAAA,KAAK,CAAC,KAAN,CAAY,KAAZ,GAAoB,YAApB;AACA,EAAA,KAAK,CAAC,KAAN,CAAY,QAAZ,GAAuB,QAAvB;AAEA,SAAO,KAAP;AACD,CAjDM;;AAAM,OAAA,CAAA,uBAAA,GAAuB,uBAAvB","sourcesContent":["import * as React from 'react';\nimport { clamp, useControllableState, useEventCallback } from '@fluentui/react-utilities';\nimport { useFluent } from '@fluentui/react-shared-contexts';\nimport { sliderCSSVars } from './useSliderStyles';\nimport type { SliderState, SliderProps } from './Slider.types';\n\nconst { railOffsetVar, railStepsPercentVar, railProgressVar, thumbPositionVar, railDirectionVar } = sliderCSSVars;\n\nconst getPercent = (value: number, min: number, max: number) => {\n return max === min ? 0 : ((value - min) / (max - min)) * 100;\n};\n\nexport const useSliderState_unstable = (state: SliderState, props: SliderProps) => {\n const { defaultValue = 0, min = 0, max = 100, step, origin, value } = props;\n const { dir } = useFluent();\n const [currentValue, setCurrentValue] = useControllableState({\n state: value !== undefined ? clamp(value, min, max) : undefined,\n defaultState: clamp(defaultValue, min, max),\n initialState: 0,\n });\n const valuePercent = getPercent(currentValue, min, max);\n const originPercent = React.useMemo(() => {\n return origin !== undefined ? getPercent(origin, min, max) : 0;\n }, [max, min, origin]);\n\n const inputOnChange = state.input.onChange;\n const propsOnChange = props.onChange;\n\n const onChange: React.ChangeEventHandler<HTMLInputElement> = useEventCallback(ev => {\n const newValue = Number(ev.target.value);\n setCurrentValue(clamp(newValue, min, max));\n\n if (inputOnChange && inputOnChange !== propsOnChange) {\n inputOnChange(ev);\n } else if (propsOnChange) {\n propsOnChange(ev, { value: newValue });\n }\n });\n\n const rootVariables = {\n [railDirectionVar]: state.vertical ? '0deg' : dir === 'ltr' ? '90deg' : '270deg',\n [thumbPositionVar]: valuePercent + '%',\n [railStepsPercentVar]: step && step > 0 ? `${(step * 100) / (max - min)}%` : '',\n [railOffsetVar]: origin !== undefined ? `${Math.min(valuePercent, originPercent)}%` : '0%',\n [railProgressVar]:\n origin !== undefined\n ? `${Math.max(originPercent - valuePercent, valuePercent - originPercent)}%`\n : `${valuePercent}%`,\n };\n\n // Root props\n state.root.style = {\n ...rootVariables,\n ...state.root.style,\n };\n\n // Input Props\n state.input.value = currentValue;\n state.input.onChange = onChange;\n\n return state;\n};\n"],"sourceRoot":"../src/"}
|
|
@@ -74,10 +74,10 @@ const useRootStyles = /*#__PURE__*/react_1.__styles({
|
|
|
74
74
|
"B7wi8oa": "f4l8x3l",
|
|
75
75
|
"B250r6j": "f671q34",
|
|
76
76
|
"Bpmy4es": "fvfzmw5",
|
|
77
|
-
"Buw9y6v": "
|
|
78
|
-
"Bq939m0": "
|
|
79
|
-
"gjzr1t": "
|
|
80
|
-
"tg7hqu": "
|
|
77
|
+
"Buw9y6v": "faw1t00",
|
|
78
|
+
"Bq939m0": "fxdgx5",
|
|
79
|
+
"gjzr1t": "fii04fa",
|
|
80
|
+
"tg7hqu": "f36hzz8",
|
|
81
81
|
"ypdvl1": "f1volkfw",
|
|
82
82
|
"Bw5jdd4": "f1xddb6",
|
|
83
83
|
"Bdjie01": "fcdikl",
|
|
@@ -118,10 +118,10 @@ const useRootStyles = /*#__PURE__*/react_1.__styles({
|
|
|
118
118
|
"Ba33l6n": ["f1horip2", "fgnx9ah"],
|
|
119
119
|
"va7z1g": "fkii2tb",
|
|
120
120
|
"Bmi6mq9": ["fgnx9ah", "f1horip2"],
|
|
121
|
-
"Bjkpy09": "
|
|
122
|
-
"Jxg1p8": "
|
|
123
|
-
"Bc94xmo": ["
|
|
124
|
-
"Bj23z95": ["
|
|
121
|
+
"Bjkpy09": "f11tdyqf",
|
|
122
|
+
"Jxg1p8": "f1blztld",
|
|
123
|
+
"Bc94xmo": ["fc3tncn", "f1veb610"],
|
|
124
|
+
"Bj23z95": ["f1veb610", "fc3tncn"]
|
|
125
125
|
},
|
|
126
126
|
"focusIndicatorVertical": {
|
|
127
127
|
"B486eqv": "f2hkw1w",
|
|
@@ -149,15 +149,15 @@ const useRootStyles = /*#__PURE__*/react_1.__styles({
|
|
|
149
149
|
"Ba33l6n": ["f1horip2", "fgnx9ah"],
|
|
150
150
|
"va7z1g": "fkii2tb",
|
|
151
151
|
"Bmi6mq9": ["fgnx9ah", "f1horip2"],
|
|
152
|
-
"Bjkpy09": "
|
|
153
|
-
"Jxg1p8": "
|
|
154
|
-
"Bc94xmo": ["
|
|
155
|
-
"Bj23z95": ["
|
|
152
|
+
"Bjkpy09": "f1n40nz3",
|
|
153
|
+
"Jxg1p8": "f1iimkc5",
|
|
154
|
+
"Bc94xmo": ["f1v1vptr", "f17zmyg5"],
|
|
155
|
+
"Bj23z95": ["f17zmyg5", "f1v1vptr"]
|
|
156
156
|
}
|
|
157
157
|
}, {
|
|
158
|
-
"d": [".f10pi13n{position:relative;}", ".fwk3njj{display:inline-grid;}", ".femm8af{grid-template-areas:\"slider\";}", ".f1xqy1su{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}", ".f1sdsnyy{touch-action:none;}", ".f122n59{-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}", ".f1oiokrs{justify-items:center;}", ".f1agqo6f{--fui-Slider__thumb--size:16px;}", ".f1i7ztpd{--fui-Slider__rail--size:2px;}", ".f1pha7fy{min-height:24px;}", ".f1a78h9h{--fui-Slider__thumb--size:20px;}", ".fuok0yf{--fui-Slider__rail--size:4px;}", ".f1nxs5xn{min-height:32px;}", ".fyvtabn{min-width:120px;}", ".f1yfdkfd{height:var(--fui-Slider__thumb--size);}", ".f174ca62{width:var(--fui-Slider__thumb--size);}", ".f1pzv1zu{min-height:120px;}", ".f13qjosx{grid-template-columns:var(--fui-Slider__thumb--size);}", ".f4l8x3l{--fui-Slider__rail--color:var(--colorNeutralStrokeAccessible);}", ".f671q34{--fui-Slider__progress--color:var(--colorCompoundBrandBackground);}", ".fvfzmw5{--fui-Slider__thumb--color:var(--colorCompoundBrandBackground);}", ".foojseg{--fui-Slider__thumb--color:var(--colorNeutralForegroundDisabled);}", ".f1lgdqhv{--fui-Slider__rail--color:var(--colorNeutralBackgroundDisabled);}", ".f1veetlj{--fui-Slider__progress--color:var(--colorNeutralForegroundDisabled);}", "[data-keyboard-nav] .fbiesyy:focus-within{border-top-color:transparent;}", "[data-keyboard-nav] .fq2kn9:focus-within{border-right-color:transparent;}", "[data-keyboard-nav] .f1jxwnad:focus-within{border-left-color:transparent;}", "[data-keyboard-nav] .f1il7mou:focus-within{border-bottom-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] .fskqmiq:focus-within:after{z-index:1;}", "[data-keyboard-nav] .f1kbdjx9:focus-within:after{border-top-style:solid;}", "[data-keyboard-nav] .fw1d893:focus-within:after{border-right-style:solid;}", "[data-keyboard-nav] .fpuz8dn:focus-within:after{border-left-style:solid;}", "[data-keyboard-nav] .f14hlsw1:focus-within:after{border-bottom-style:solid;}", "[data-keyboard-nav] .f1bkt4b4:focus-within:after{border-top-width:2px;}", "[data-keyboard-nav] .f16hf5f2:focus-within:after{border-right-width:2px;}", "[data-keyboard-nav] .f1qhqcal:focus-within:after{border-left-width:2px;}", "[data-keyboard-nav] .fyyqeim:focus-within:after{border-bottom-width:2px;}", "[data-keyboard-nav] .f1aneyfs:focus-within:after{border-bottom-right-radius:var(--borderRadiusMedium);}", "[data-keyboard-nav] .f15nmyc0:focus-within:after{border-bottom-left-radius:var(--borderRadiusMedium);}", "[data-keyboard-nav] .f3cpy5b:focus-within:after{border-top-right-radius:var(--borderRadiusMedium);}", "[data-keyboard-nav] .f13v6kgv:focus-within:after{border-top-left-radius:var(--borderRadiusMedium);}", "[data-keyboard-nav] .filx0we:focus-within:after{border-top-color:var(--colorStrokeFocus2);}", "[data-keyboard-nav] .f1horip2:focus-within:after{border-right-color:var(--colorStrokeFocus2);}", "[data-keyboard-nav] .fgnx9ah:focus-within:after{border-left-color:var(--colorStrokeFocus2);}", "[data-keyboard-nav] .fkii2tb:focus-within:after{border-bottom-color:var(--colorStrokeFocus2);}", "[data-keyboard-nav] .
|
|
159
|
-
"h": [".
|
|
160
|
-
"a": [".
|
|
158
|
+
"d": [".f10pi13n{position:relative;}", ".fwk3njj{display:inline-grid;}", ".femm8af{grid-template-areas:\"slider\";}", ".f1xqy1su{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}", ".f1sdsnyy{touch-action:none;}", ".f122n59{-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}", ".f1oiokrs{justify-items:center;}", ".f1agqo6f{--fui-Slider__thumb--size:16px;}", ".f1i7ztpd{--fui-Slider__rail--size:2px;}", ".f1pha7fy{min-height:24px;}", ".f1a78h9h{--fui-Slider__thumb--size:20px;}", ".fuok0yf{--fui-Slider__rail--size:4px;}", ".f1nxs5xn{min-height:32px;}", ".fyvtabn{min-width:120px;}", ".f1yfdkfd{height:var(--fui-Slider__thumb--size);}", ".f174ca62{width:var(--fui-Slider__thumb--size);}", ".f1pzv1zu{min-height:120px;}", ".f13qjosx{grid-template-columns:var(--fui-Slider__thumb--size);}", ".f4l8x3l{--fui-Slider__rail--color:var(--colorNeutralStrokeAccessible);}", ".f671q34{--fui-Slider__progress--color:var(--colorCompoundBrandBackground);}", ".fvfzmw5{--fui-Slider__thumb--color:var(--colorCompoundBrandBackground);}", ".foojseg{--fui-Slider__thumb--color:var(--colorNeutralForegroundDisabled);}", ".f1lgdqhv{--fui-Slider__rail--color:var(--colorNeutralBackgroundDisabled);}", ".f1veetlj{--fui-Slider__progress--color:var(--colorNeutralForegroundDisabled);}", "[data-keyboard-nav] .fbiesyy:focus-within{border-top-color:transparent;}", "[data-keyboard-nav] .fq2kn9:focus-within{border-right-color:transparent;}", "[data-keyboard-nav] .f1jxwnad:focus-within{border-left-color:transparent;}", "[data-keyboard-nav] .f1il7mou:focus-within{border-bottom-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] .fskqmiq:focus-within:after{z-index:1;}", "[data-keyboard-nav] .f1kbdjx9:focus-within:after{border-top-style:solid;}", "[data-keyboard-nav] .fw1d893:focus-within:after{border-right-style:solid;}", "[data-keyboard-nav] .fpuz8dn:focus-within:after{border-left-style:solid;}", "[data-keyboard-nav] .f14hlsw1:focus-within:after{border-bottom-style:solid;}", "[data-keyboard-nav] .f1bkt4b4:focus-within:after{border-top-width:2px;}", "[data-keyboard-nav] .f16hf5f2:focus-within:after{border-right-width:2px;}", "[data-keyboard-nav] .f1qhqcal:focus-within:after{border-left-width:2px;}", "[data-keyboard-nav] .fyyqeim:focus-within:after{border-bottom-width:2px;}", "[data-keyboard-nav] .f1aneyfs:focus-within:after{border-bottom-right-radius:var(--borderRadiusMedium);}", "[data-keyboard-nav] .f15nmyc0:focus-within:after{border-bottom-left-radius:var(--borderRadiusMedium);}", "[data-keyboard-nav] .f3cpy5b:focus-within:after{border-top-right-radius:var(--borderRadiusMedium);}", "[data-keyboard-nav] .f13v6kgv:focus-within:after{border-top-left-radius:var(--borderRadiusMedium);}", "[data-keyboard-nav] .filx0we:focus-within:after{border-top-color:var(--colorStrokeFocus2);}", "[data-keyboard-nav] .f1horip2:focus-within:after{border-right-color:var(--colorStrokeFocus2);}", "[data-keyboard-nav] .fgnx9ah:focus-within:after{border-left-color:var(--colorStrokeFocus2);}", "[data-keyboard-nav] .fkii2tb:focus-within:after{border-bottom-color:var(--colorStrokeFocus2);}", "[data-keyboard-nav] .f11tdyqf:focus-within:after{top:calc(0px - 2px - -2px);}", "[data-keyboard-nav] .f1blztld:focus-within:after{bottom:calc(0px - 2px - -2px);}", "[data-keyboard-nav] .fc3tncn:focus-within:after{left:calc(0px - 2px - 8px);}", "[data-keyboard-nav] .f1veb610:focus-within:after{right:calc(0px - 2px - 8px);}", "[data-keyboard-nav] .f1n40nz3:focus-within:after{top:calc(0px - 2px - 6px);}", "[data-keyboard-nav] .f1iimkc5:focus-within:after{bottom:calc(0px - 2px - 6px);}", "[data-keyboard-nav] .f1v1vptr:focus-within:after{left:calc(0px - 2px - 4px);}", "[data-keyboard-nav] .f17zmyg5:focus-within:after{right:calc(0px - 2px - 4px);}"],
|
|
159
|
+
"h": [".faw1t00:hover{--fui-Slider__thumb--color:var(--colorCompoundBrandBackgroundHover);}", ".fxdgx5:hover{--fui-Slider__progress--color:var(--colorCompoundBrandBackgroundHover);}"],
|
|
160
|
+
"a": [".fii04fa:active{--fui-Slider__thumb--color:var(--colorCompoundBrandBackgroundPressed);}", ".f36hzz8:active{--fui-Slider__progress--color:var(--colorCompoundBrandBackgroundPressed);}"],
|
|
161
161
|
"t": ["@media (forced-colors: active){.f1volkfw{--fui-Slider__rail--color:CanvasText;}}", "@media (forced-colors: active){.f1xddb6{--fui-Slider__thumb--color:Highlight;}}", "@media (forced-colors: active){.fcdikl{--fui-Slider__progress--color:Highlight;}}", "@media (forced-colors: active){.fhpzgm6:hover{--fui-Slider__thumb--color:Highlight;}}", "@media (forced-colors: active){.f1q6pm3h:hover{--fui-Slider__progress--color:Highlight;}}", "@media (forced-colors: active){.fu12m3e{--fui-Slider__rail--color:GrayText;}}", "@media (forced-colors: active){.fi9guym{--fui-Slider__thumb--color:GrayText;}}", "@media (forced-colors: active){.fcdjl4u{--fui-Slider__progress--color:GrayText;}}"],
|
|
162
162
|
"i": [".f2hkw1w:focus-visible{outline-style:none;}"]
|
|
163
163
|
});
|