@fluentui/react-slider 9.0.0-beta.14 → 9.0.0-beta.17

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.
Files changed (46) hide show
  1. package/CHANGELOG.json +148 -1
  2. package/CHANGELOG.md +46 -2
  3. package/MIGRATION.md +1 -0
  4. package/Spec.md +1 -0
  5. package/dist/index.d.ts +28 -32
  6. package/{lib → dist}/tsdoc-metadata.json +0 -0
  7. package/lib/components/Slider/Slider.types.js.map +1 -1
  8. package/lib/components/Slider/index.js +1 -1
  9. package/lib/components/Slider/index.js.map +1 -1
  10. package/lib/components/Slider/useSlider.js +1 -20
  11. package/lib/components/Slider/useSlider.js.map +1 -1
  12. package/lib/components/Slider/useSliderState.js +11 -20
  13. package/lib/components/Slider/useSliderState.js.map +1 -1
  14. package/lib/components/Slider/useSliderStyles.js +17 -19
  15. package/lib/components/Slider/useSliderStyles.js.map +1 -1
  16. package/lib/index.js +1 -1
  17. package/lib/index.js.map +1 -1
  18. package/lib-commonjs/components/Slider/index.js +7 -1
  19. package/lib-commonjs/components/Slider/index.js.map +1 -1
  20. package/lib-commonjs/components/Slider/useSlider.js +1 -20
  21. package/lib-commonjs/components/Slider/useSlider.js.map +1 -1
  22. package/lib-commonjs/components/Slider/useSliderState.js +11 -21
  23. package/lib-commonjs/components/Slider/useSliderState.js.map +1 -1
  24. package/lib-commonjs/components/Slider/useSliderStyles.js +17 -19
  25. package/lib-commonjs/components/Slider/useSliderStyles.js.map +1 -1
  26. package/lib-commonjs/index.js +7 -1
  27. package/lib-commonjs/index.js.map +1 -1
  28. package/package.json +9 -9
  29. package/lib/Slider.d.ts +0 -1
  30. package/lib/components/Slider/Slider.d.ts +0 -6
  31. package/lib/components/Slider/Slider.types.d.ts +0 -93
  32. package/lib/components/Slider/index.d.ts +0 -6
  33. package/lib/components/Slider/renderSlider.d.ts +0 -5
  34. package/lib/components/Slider/useSlider.d.ts +0 -6
  35. package/lib/components/Slider/useSliderState.d.ts +0 -2
  36. package/lib/components/Slider/useSliderStyles.d.ts +0 -14
  37. package/lib/index.d.ts +0 -2
  38. package/lib-commonjs/Slider.d.ts +0 -1
  39. package/lib-commonjs/components/Slider/Slider.d.ts +0 -6
  40. package/lib-commonjs/components/Slider/Slider.types.d.ts +0 -93
  41. package/lib-commonjs/components/Slider/index.d.ts +0 -6
  42. package/lib-commonjs/components/Slider/renderSlider.d.ts +0 -5
  43. package/lib-commonjs/components/Slider/useSlider.d.ts +0 -6
  44. package/lib-commonjs/components/Slider/useSliderState.d.ts +0 -2
  45. package/lib-commonjs/components/Slider/useSliderStyles.d.ts +0 -14
  46. package/lib-commonjs/index.d.ts +0 -2
package/CHANGELOG.json CHANGED
@@ -2,7 +2,154 @@
2
2
  "name": "@fluentui/react-slider",
3
3
  "entries": [
4
4
  {
5
- "date": "Thu, 05 May 2022 18:24:37 GMT",
5
+ "date": "Thu, 26 May 2022 21:00:04 GMT",
6
+ "tag": "@fluentui/react-slider_v9.0.0-beta.17",
7
+ "version": "9.0.0-beta.17",
8
+ "comments": {
9
+ "prerelease": [
10
+ {
11
+ "author": "mgodbolt@microsoft.com",
12
+ "package": "@fluentui/react-slider",
13
+ "commit": "c17653d2a37e0bbe0fd84298221db3738cb43a23",
14
+ "comment": "new high contrast styles for slider steps"
15
+ },
16
+ {
17
+ "author": "mgodbolt@microsoft.com",
18
+ "package": "@fluentui/react-slider",
19
+ "commit": "5c6366a3d97cdc612535c299f8dd27bf79c4c842",
20
+ "comment": "BREAKING: Remove slider origin to align with design and avoid inaccessible design"
21
+ },
22
+ {
23
+ "author": "beachball",
24
+ "package": "@fluentui/react-slider",
25
+ "comment": "Bump @fluentui/react-tabster to v9.0.0-rc.12",
26
+ "commit": "3cf55ce998048554bf6a550de44403843ea8ede0"
27
+ },
28
+ {
29
+ "author": "beachball",
30
+ "package": "@fluentui/react-slider",
31
+ "comment": "Bump @fluentui/react-label to v9.0.0-rc.4",
32
+ "commit": "3cf55ce998048554bf6a550de44403843ea8ede0"
33
+ }
34
+ ]
35
+ }
36
+ },
37
+ {
38
+ "date": "Mon, 23 May 2022 18:56:51 GMT",
39
+ "tag": "@fluentui/react-slider_v9.0.0-beta.16",
40
+ "version": "9.0.0-beta.16",
41
+ "comments": {
42
+ "prerelease": [
43
+ {
44
+ "author": "beachball",
45
+ "package": "@fluentui/react-slider",
46
+ "comment": "Bump @fluentui/react-shared-contexts to v9.0.0-rc.9",
47
+ "commit": "d4f80b17690e962d6a24e68959608d1ffe84aef6"
48
+ },
49
+ {
50
+ "author": "beachball",
51
+ "package": "@fluentui/react-slider",
52
+ "comment": "Bump @fluentui/react-tabster to v9.0.0-rc.11",
53
+ "commit": "d4f80b17690e962d6a24e68959608d1ffe84aef6"
54
+ },
55
+ {
56
+ "author": "beachball",
57
+ "package": "@fluentui/react-slider",
58
+ "comment": "Bump @fluentui/react-theme to v9.0.0-rc.9",
59
+ "commit": "d4f80b17690e962d6a24e68959608d1ffe84aef6"
60
+ },
61
+ {
62
+ "author": "beachball",
63
+ "package": "@fluentui/react-slider",
64
+ "comment": "Bump @fluentui/react-conformance-griffel to v9.0.0-beta.7",
65
+ "commit": "d4f80b17690e962d6a24e68959608d1ffe84aef6"
66
+ },
67
+ {
68
+ "author": "beachball",
69
+ "package": "@fluentui/react-slider",
70
+ "comment": "Bump @fluentui/react-label to v9.0.0-rc.3",
71
+ "commit": "d4f80b17690e962d6a24e68959608d1ffe84aef6"
72
+ }
73
+ ]
74
+ }
75
+ },
76
+ {
77
+ "date": "Mon, 23 May 2022 12:13:38 GMT",
78
+ "tag": "@fluentui/react-slider_v9.0.0-beta.15",
79
+ "version": "9.0.0-beta.15",
80
+ "comments": {
81
+ "prerelease": [
82
+ {
83
+ "author": "mgodbolt@microsoft.com",
84
+ "package": "@fluentui/react-slider",
85
+ "commit": "4a05a4a5a3f0b7724ac81be01795e1572b048fd9",
86
+ "comment": "move slider commons into props and pick into state"
87
+ },
88
+ {
89
+ "author": "olfedias@microsoft.com",
90
+ "package": "@fluentui/react-slider",
91
+ "commit": "60804cec07a495b8a5d1fc66338bf0443b212144",
92
+ "comment": "chore: Update Griffel to latest version"
93
+ },
94
+ {
95
+ "author": "esteban.230@hotmail.com",
96
+ "package": "@fluentui/react-slider",
97
+ "commit": "0fac2d7a6f35c5fcebaf30da68b9604410fe0eb9",
98
+ "comment": "Updated react-label package version to RC."
99
+ },
100
+ {
101
+ "author": "olfedias@microsoft.com",
102
+ "package": "@fluentui/react-slider",
103
+ "commit": "f120fe9160ad7311a87af0cfacd8d2fb26275e34",
104
+ "comment": "chore: Update Griffel to latest version"
105
+ },
106
+ {
107
+ "author": "martinhochel@microsoft.com",
108
+ "package": "@fluentui/react-slider",
109
+ "commit": "e7b70cb06f4422e5574993fd2ad44d9073647417",
110
+ "comment": "feat: ship rolluped only dts"
111
+ },
112
+ {
113
+ "author": "beachball",
114
+ "package": "@fluentui/react-slider",
115
+ "comment": "Bump @fluentui/react-shared-contexts to v9.0.0-rc.8",
116
+ "commit": "8d58f08997acf595e3eb7f628123e7fa7830c394"
117
+ },
118
+ {
119
+ "author": "beachball",
120
+ "package": "@fluentui/react-slider",
121
+ "comment": "Bump @fluentui/react-tabster to v9.0.0-rc.10",
122
+ "commit": "8d58f08997acf595e3eb7f628123e7fa7830c394"
123
+ },
124
+ {
125
+ "author": "beachball",
126
+ "package": "@fluentui/react-slider",
127
+ "comment": "Bump @fluentui/react-theme to v9.0.0-rc.8",
128
+ "commit": "8d58f08997acf595e3eb7f628123e7fa7830c394"
129
+ },
130
+ {
131
+ "author": "beachball",
132
+ "package": "@fluentui/react-slider",
133
+ "comment": "Bump @fluentui/react-utilities to v9.0.0-rc.9",
134
+ "commit": "8d58f08997acf595e3eb7f628123e7fa7830c394"
135
+ },
136
+ {
137
+ "author": "beachball",
138
+ "package": "@fluentui/react-slider",
139
+ "comment": "Bump @fluentui/react-conformance-griffel to v9.0.0-beta.6",
140
+ "commit": "8d58f08997acf595e3eb7f628123e7fa7830c394"
141
+ },
142
+ {
143
+ "author": "beachball",
144
+ "package": "@fluentui/react-slider",
145
+ "comment": "Bump @fluentui/react-label to v9.0.0-rc.2",
146
+ "commit": "8d58f08997acf595e3eb7f628123e7fa7830c394"
147
+ }
148
+ ]
149
+ }
150
+ },
151
+ {
152
+ "date": "Thu, 05 May 2022 18:26:30 GMT",
6
153
  "tag": "@fluentui/react-slider_v9.0.0-beta.14",
7
154
  "version": "9.0.0-beta.14",
8
155
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,56 @@
1
1
  # Change Log - @fluentui/react-slider
2
2
 
3
- This log was last generated on Thu, 05 May 2022 18:24:37 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 26 May 2022 21:00:04 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [9.0.0-beta.17](https://github.com/microsoft/fluentui/tree/@fluentui/react-slider_v9.0.0-beta.17)
8
+
9
+ Thu, 26 May 2022 21:00:04 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-slider_v9.0.0-beta.16..@fluentui/react-slider_v9.0.0-beta.17)
11
+
12
+ ### Changes
13
+
14
+ - new high contrast styles for slider steps ([PR #23253](https://github.com/microsoft/fluentui/pull/23253) by mgodbolt@microsoft.com)
15
+ - BREAKING: Remove slider origin to align with design and avoid inaccessible design ([PR #23257](https://github.com/microsoft/fluentui/pull/23257) by mgodbolt@microsoft.com)
16
+ - Bump @fluentui/react-tabster to v9.0.0-rc.12 ([PR #23267](https://github.com/microsoft/fluentui/pull/23267) by beachball)
17
+ - Bump @fluentui/react-label to v9.0.0-rc.4 ([PR #23267](https://github.com/microsoft/fluentui/pull/23267) by beachball)
18
+
19
+ ## [9.0.0-beta.16](https://github.com/microsoft/fluentui/tree/@fluentui/react-slider_v9.0.0-beta.16)
20
+
21
+ Mon, 23 May 2022 18:56:51 GMT
22
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-slider_v9.0.0-beta.15..@fluentui/react-slider_v9.0.0-beta.16)
23
+
24
+ ### Changes
25
+
26
+ - Bump @fluentui/react-shared-contexts to v9.0.0-rc.9 ([PR #23146](https://github.com/microsoft/fluentui/pull/23146) by beachball)
27
+ - Bump @fluentui/react-tabster to v9.0.0-rc.11 ([PR #23146](https://github.com/microsoft/fluentui/pull/23146) by beachball)
28
+ - Bump @fluentui/react-theme to v9.0.0-rc.9 ([PR #23146](https://github.com/microsoft/fluentui/pull/23146) by beachball)
29
+ - Bump @fluentui/react-conformance-griffel to v9.0.0-beta.7 ([PR #23146](https://github.com/microsoft/fluentui/pull/23146) by beachball)
30
+ - Bump @fluentui/react-label to v9.0.0-rc.3 ([PR #23146](https://github.com/microsoft/fluentui/pull/23146) by beachball)
31
+
32
+ ## [9.0.0-beta.15](https://github.com/microsoft/fluentui/tree/@fluentui/react-slider_v9.0.0-beta.15)
33
+
34
+ Mon, 23 May 2022 12:13:38 GMT
35
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-slider_v9.0.0-beta.14..@fluentui/react-slider_v9.0.0-beta.15)
36
+
37
+ ### Changes
38
+
39
+ - move slider commons into props and pick into state ([PR #22879](https://github.com/microsoft/fluentui/pull/22879) by mgodbolt@microsoft.com)
40
+ - chore: Update Griffel to latest version ([PR #23029](https://github.com/microsoft/fluentui/pull/23029) by olfedias@microsoft.com)
41
+ - Updated react-label package version to RC. ([PR #22865](https://github.com/microsoft/fluentui/pull/22865) by esteban.230@hotmail.com)
42
+ - chore: Update Griffel to latest version ([PR #22894](https://github.com/microsoft/fluentui/pull/22894) by olfedias@microsoft.com)
43
+ - feat: ship rolluped only dts ([PR #22828](https://github.com/microsoft/fluentui/pull/22828) by martinhochel@microsoft.com)
44
+ - Bump @fluentui/react-shared-contexts to v9.0.0-rc.8 ([PR #23030](https://github.com/microsoft/fluentui/pull/23030) by beachball)
45
+ - Bump @fluentui/react-tabster to v9.0.0-rc.10 ([PR #23030](https://github.com/microsoft/fluentui/pull/23030) by beachball)
46
+ - Bump @fluentui/react-theme to v9.0.0-rc.8 ([PR #23030](https://github.com/microsoft/fluentui/pull/23030) by beachball)
47
+ - Bump @fluentui/react-utilities to v9.0.0-rc.9 ([PR #23030](https://github.com/microsoft/fluentui/pull/23030) by beachball)
48
+ - Bump @fluentui/react-conformance-griffel to v9.0.0-beta.6 ([PR #23030](https://github.com/microsoft/fluentui/pull/23030) by beachball)
49
+ - Bump @fluentui/react-label to v9.0.0-rc.2 ([PR #23030](https://github.com/microsoft/fluentui/pull/23030) by beachball)
50
+
7
51
  ## [9.0.0-beta.14](https://github.com/microsoft/fluentui/tree/@fluentui/react-slider_v9.0.0-beta.14)
8
52
 
9
- Thu, 05 May 2022 18:24:37 GMT
53
+ Thu, 05 May 2022 18:26:30 GMT
10
54
  [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-slider_v9.0.0-beta.13..@fluentui/react-slider_v9.0.0-beta.14)
11
55
 
12
56
  ### Changes
package/MIGRATION.md CHANGED
@@ -12,6 +12,7 @@ The Slider control is a thin wrapper around an `<input type="range"/>`. Addition
12
12
  - `showValue` and `valueFormat` => use explicitly rendered value instead
13
13
  - `onChanged` => use onChange and onMouse events
14
14
  - `ranged`, `defaultLowerValue` and `lowerValue` => Not supported. Multi value slider will be future work in separate control.
15
+ - `origin` => no longer supported
15
16
  - `snapToStep` => use `step` instead
16
17
  - `originFromZero` => `origin`
17
18
  - `buttonProps` => Slider props, other than className and id, are passed to `input` element
package/Spec.md CHANGED
@@ -79,3 +79,4 @@ https://open-ui.org/components/slider.research
79
79
 
80
80
  - built in marks
81
81
  - dual thumb 'ranged' slider
82
+ - origin
package/dist/index.d.ts CHANGED
@@ -17,27 +17,43 @@ export declare const Slider: ForwardRefComponent<SliderProps>;
17
17
 
18
18
  export declare const sliderClassNames: SlotClassNames<SliderSlots>;
19
19
 
20
- declare type SliderCommons = {
20
+ export declare const sliderCSSVars: {
21
+ sliderDirectionVar: string;
22
+ sliderProgressVar: string;
23
+ sliderStepsPercentVar: string;
24
+ };
25
+
26
+ export declare type SliderOnChangeData = {
27
+ value: number;
28
+ };
29
+
30
+ export declare type SliderProps = Omit<ComponentProps<Partial<SliderSlots>, 'input'>, 'defaultValue' | 'onChange' | 'size' | 'value'> & {
21
31
  /**
22
32
  * The starting value for an uncontrolled Slider.
23
33
  * Mutually exclusive with `value` prop.
24
34
  */
25
35
  defaultValue?: number;
26
36
  /**
27
- * The current value of the controlled Slider.
28
- * Mutually exclusive with `defaultValue` prop.
37
+ * Whether to render the Slider as disabled.
38
+ *
39
+ * @default `false` (renders enabled)
29
40
  */
30
- value?: number;
41
+ disabled?: boolean;
42
+ /**
43
+ * The max value of the Slider.
44
+ * @default 100
45
+ */
46
+ max?: number;
31
47
  /**
32
48
  * The min value of the Slider.
33
49
  * @default 0
34
50
  */
35
51
  min?: number;
36
52
  /**
37
- * The max value of the Slider.
38
- * @default 100
53
+ * The size of the Slider.
54
+ * @default 'medium'
39
55
  */
40
- max?: number;
56
+ size?: 'small' | 'medium';
41
57
  /**
42
58
  * The number of steps that the Slider's `value` will increment upon change. When provided, the Slider
43
59
  * will snap to the closest available value. This must be a positive value.
@@ -45,38 +61,21 @@ declare type SliderCommons = {
45
61
  */
46
62
  step?: number;
47
63
  /**
48
- * Whether to render the Slider as disabled.
49
- *
50
- * @default `false` (renders enabled)
64
+ * The current value of the controlled Slider.
65
+ * Mutually exclusive with `defaultValue` prop.
51
66
  */
52
- disabled?: boolean;
67
+ value?: number;
53
68
  /**
54
69
  * Render the Slider in a vertical orientation, smallest value on the bottom.
55
70
  * @default `false`
56
71
  */
57
72
  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
73
  /**
69
74
  * Triggers a callback when the value has been changed. This will be called on every individual step.
70
75
  */
71
76
  onChange?: (ev: React_2.ChangeEvent<HTMLInputElement>, data: SliderOnChangeData) => void;
72
77
  };
73
78
 
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
79
  export declare type SliderSlots = {
81
80
  /**
82
81
  * The root of the Slider.
@@ -110,14 +109,11 @@ export declare type SliderSlots = {
110
109
  };
111
110
  };
112
111
 
113
- export declare type SliderState = ComponentState<SliderSlots> & SliderCommons;
112
+ export declare type SliderState = ComponentState<SliderSlots> & Pick<SliderProps, 'disabled' | 'size' | 'vertical'>;
114
113
 
115
- /**
116
- * Given user props, returns state and render function for a Slider.
117
- */
118
114
  export declare const useSlider_unstable: (props: SliderProps, ref: React_2.Ref<HTMLInputElement>) => SliderState;
119
115
 
120
- export declare const useSliderState_unstable: (state: SliderState) => SliderState;
116
+ export declare const useSliderState_unstable: (state: SliderState, props: SliderProps) => SliderState;
121
117
 
122
118
  /**
123
119
  * 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\ntype SliderCommons = {\n /**\n * The starting value for an uncontrolled Slider.\n * Mutually exclusive with `value` prop.\n */\n defaultValue?: number;\n\n /**\n * The current value of the controlled Slider.\n * Mutually exclusive with `defaultValue` prop.\n */\n value?: number;\n\n /**\n * The min value of the Slider.\n * @default 0\n */\n min?: number;\n\n /**\n * The max value of the Slider.\n * @default 100\n */\n max?: number;\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 * Whether to render the Slider as disabled.\n *\n * @default `false` (renders enabled)\n */\n disabled?: boolean;\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 * 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 * 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 SliderProps = Omit<\n ComponentProps<Partial<SliderSlots>, 'input'>,\n 'defaultValue' | 'onChange' | 'size' | 'value'\n> &\n SliderCommons;\n\nexport type SliderState = ComponentState<SliderSlots> & SliderCommons;\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 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"]}
@@ -3,5 +3,5 @@ export * from './Slider.types';
3
3
  export * from './renderSlider';
4
4
  export * from './useSlider';
5
5
  export { useSliderState_unstable } from './useSliderState';
6
- export { sliderClassNames, useSliderStyles_unstable } from './useSliderStyles';
6
+ export { sliderClassNames, sliderCSSVars, useSliderStyles_unstable } from './useSliderStyles';
7
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["components/Slider/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC","sourcesContent":["export * from './Slider';\nexport * from './Slider.types';\nexport * from './renderSlider';\nexport * from './useSlider';\nexport { useSliderState_unstable } from './useSliderState';\nexport { sliderClassNames, useSliderStyles_unstable } from './useSliderStyles';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["components/Slider/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC","sourcesContent":["export * from './Slider';\nexport * from './Slider.types';\nexport * from './renderSlider';\nexport * from './useSlider';\nexport { useSliderState_unstable } from './useSliderState';\nexport { sliderClassNames, sliderCSSVars, useSliderStyles_unstable } from './useSliderStyles';\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;;AAEG;;AACH,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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gB,CAAC,IAAD,EAAO;AAAE,MAAA,QAAQ,EAAE;AAAZ,KAAP,CAjCG;AAkCzB,IAAA,KAAK,EAAE,gBAAgB,CAAC,KAAD,EAAQ;AAAE,MAAA,QAAQ,EAAE;AAAZ,KAAR;AAlCE,GAA3B;AAqCA,EAAA,uBAAuB,CAAC,KAAD,CAAvB;AAEA,SAAO,KAAP;AACD,CAlEM","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\n/**\n * Given user props, returns state and render function for a Slider.\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 // Props\n value,\n defaultValue,\n min = 0,\n max = 100,\n step,\n disabled,\n vertical,\n size = 'medium',\n origin,\n onChange,\n // Slots\n root,\n input,\n rail,\n thumb,\n } = props;\n\n const state: SliderState = {\n defaultValue,\n disabled,\n max,\n min,\n origin,\n size,\n step,\n vertical,\n value,\n onChange,\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);\n\n return state;\n};\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"sources":["components/Slider/useSlider.ts"],"names":[],"mappings":"AACA,SAAS,yBAAT,EAAoC,gBAApC,EAAsD,KAAtD,QAAmE,2BAAnE;AACA,SAAS,uBAAT,QAAwC,kBAAxC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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/"}
@@ -1,28 +1,24 @@
1
- import * as React from 'react';
2
1
  import { clamp, useControllableState, useEventCallback } from '@fluentui/react-utilities';
3
2
  import { useFluent } from '@fluentui/react-shared-contexts';
4
3
  import { sliderCSSVars } from './useSliderStyles';
5
4
  const {
6
- railOffsetVar,
7
- railStepsPercentVar,
8
- railProgressVar,
9
- thumbPositionVar,
10
- railDirectionVar
5
+ sliderStepsPercentVar,
6
+ sliderProgressVar,
7
+ sliderDirectionVar
11
8
  } = sliderCSSVars;
12
9
 
13
10
  const getPercent = (value, min, max) => {
14
11
  return max === min ? 0 : (value - min) / (max - min) * 100;
15
12
  };
16
13
 
17
- export const useSliderState_unstable = state => {
14
+ export const useSliderState_unstable = (state, props) => {
18
15
  const {
19
- value,
20
16
  defaultValue = 0,
21
17
  min = 0,
22
18
  max = 100,
23
- step = 1,
24
- origin
25
- } = state;
19
+ step,
20
+ value
21
+ } = props;
26
22
  const {
27
23
  dir
28
24
  } = useFluent();
@@ -32,11 +28,8 @@ export const useSliderState_unstable = state => {
32
28
  initialState: 0
33
29
  });
34
30
  const valuePercent = getPercent(currentValue, min, max);
35
- const originPercent = React.useMemo(() => {
36
- return origin !== undefined ? getPercent(origin, min, max) : 0;
37
- }, [max, min, origin]);
38
31
  const inputOnChange = state.input.onChange;
39
- const propsOnChange = state.onChange;
32
+ const propsOnChange = props.onChange;
40
33
  const onChange = useEventCallback(ev => {
41
34
  const newValue = Number(ev.target.value);
42
35
  setCurrentValue(clamp(newValue, min, max));
@@ -50,11 +43,9 @@ export const useSliderState_unstable = state => {
50
43
  }
51
44
  });
52
45
  const rootVariables = {
53
- [railDirectionVar]: state.vertical ? '0deg' : dir === 'ltr' ? '90deg' : '270deg',
54
- [thumbPositionVar]: valuePercent + '%',
55
- [railStepsPercentVar]: state.step && state.step > 0 ? `${step * 100 / (max - min)}%` : '',
56
- [railOffsetVar]: origin !== undefined ? `${Math.min(valuePercent, originPercent)}%` : '0%',
57
- [railProgressVar]: origin !== undefined ? `${Math.max(originPercent - valuePercent, valuePercent - originPercent)}%` : `${valuePercent}%`
46
+ [sliderDirectionVar]: state.vertical ? '0deg' : dir === 'ltr' ? '90deg' : '270deg',
47
+ [sliderStepsPercentVar]: step && step > 0 ? `${step * 100 / (max - min)}%` : '',
48
+ [sliderProgressVar]: `${valuePercent}%`
58
49
  }; // Root props
59
50
 
60
51
  state.root.style = { ...rootVariables,
@@ -1 +1 @@
1
- {"version":3,"sources":["components/Slider/useSliderState.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,K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,YAAzB,EAAuC,YAAY,GAAG,aAAtD,CAAoE,GAD3E,GAEI,GAAG,YAAY;AARD,GAAtB,CA3B4D,CAsC5D;;AACA,EAAA,KAAK,CAAC,IAAN,CAAW,KAAX,GAAmB,EACjB,GAAG,aADc;AAEjB,OAAG,KAAK,CAAC,IAAN,CAAW;AAFG,GAAnB,CAvC4D,CA4C5D;;AACA,EAAA,KAAK,CAAC,KAAN,CAAY,KAAZ,GAAoB,YAApB;AACA,EAAA,KAAK,CAAC,KAAN,CAAY,QAAZ,GAAuB,QAAvB;AAEA,SAAO,KAAP;AACD,CAjDM","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 } 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) => {\n const { value, defaultValue = 0, min = 0, max = 100, step = 1, origin } = state;\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 = state.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]: state.step && state.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/"}
1
+ {"version":3,"sources":["components/Slider/useSliderState.tsx"],"names":[],"mappings":"AACA,SAAS,KAAT,EAAgB,oBAAhB,EAAsC,gBAAtC,QAA8D,2BAA9D;AACA,SAAS,SAAT,QAA0B,iCAA1B;AACA,SAAS,aAAT,QAA8B,mBAA9B;AAGA,MAAM;AAAE,EAAA,qBAAF;AAAyB,EAAA,iBAAzB;AAA4C,EAAA;AAA5C,IAAmE,aAAzE;;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,GAAG,CAAC,KAAD,EAAqB,KAArB,KAA2C;AAChF,QAAM;AAAE,IAAA,YAAY,GAAG,CAAjB;AAAoB,IAAA,GAAG,GAAG,CAA1B;AAA6B,IAAA,GAAG,GAAG,GAAnC;AAAwC,IAAA,IAAxC;AAA8C,IAAA;AAA9C,MAAwD,KAA9D;AACA,QAAM;AAAE,IAAA;AAAF,MAAU,SAAS,EAAzB;AACA,QAAM,CAAC,YAAD,EAAe,eAAf,IAAkC,oBAAoB,CAAC;AAC3D,IAAA,KAAK,EAAE,KAAK,KAAK,SAA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AAK,CAAC,IAAN,CAAW;AAFG,GAAnB,CA/BgF,CAoChF;;AACA,EAAA,KAAK,CAAC,KAAN,CAAY,KAAZ,GAAoB,YAApB;AACA,EAAA,KAAK,CAAC,KAAN,CAAY,QAAZ,GAAuB,QAAvB;AAEA,SAAO,KAAP;AACD,CAzCM","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 { sliderStepsPercentVar, sliderProgressVar, sliderDirectionVar } = 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, 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\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 [sliderDirectionVar]: state.vertical ? '0deg' : dir === 'ltr' ? '90deg' : '270deg',\n [sliderStepsPercentVar]: step && step > 0 ? `${(step * 100) / (max - min)}%` : '',\n [sliderProgressVar]: `${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/"}