@fluentui/react-slider 9.1.4 → 9.1.6
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/.swcrc +30 -0
- package/CHANGELOG.json +97 -1
- package/CHANGELOG.md +31 -2
- package/lib/Slider.js.map +1 -1
- package/lib/SliderField.js.map +1 -1
- package/lib/components/Slider/Slider.js.map +1 -1
- package/lib/components/Slider/Slider.types.js +1 -1
- package/lib/components/Slider/Slider.types.js.map +1 -1
- package/lib/components/Slider/index.js.map +1 -1
- package/lib/components/Slider/renderSlider.js +1 -9
- package/lib/components/Slider/renderSlider.js.map +1 -1
- package/lib/components/Slider/useSlider.js +1 -0
- package/lib/components/Slider/useSlider.js.map +1 -1
- package/lib/components/Slider/useSliderState.js +1 -0
- package/lib/components/Slider/useSliderState.js.map +1 -1
- package/lib/components/Slider/useSliderStyles.js.map +1 -1
- package/lib/components/SliderField/SliderField.js +1 -2
- package/lib/components/SliderField/SliderField.js.map +1 -1
- package/lib/components/SliderField/index.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib-commonjs/Slider.js +5 -4
- package/lib-commonjs/Slider.js.map +1 -1
- package/lib-commonjs/SliderField.js +5 -4
- package/lib-commonjs/SliderField.js.map +1 -1
- package/lib-commonjs/components/Slider/Slider.js +19 -20
- package/lib-commonjs/components/Slider/Slider.js.map +1 -1
- package/lib-commonjs/components/Slider/Slider.types.js +5 -2
- package/lib-commonjs/components/Slider/Slider.types.js.map +1 -1
- package/lib-commonjs/components/Slider/index.js +21 -33
- package/lib-commonjs/components/Slider/index.js.map +1 -1
- package/lib-commonjs/components/Slider/renderSlider.js +13 -24
- package/lib-commonjs/components/Slider/renderSlider.js.map +1 -1
- package/lib-commonjs/components/Slider/useSlider.js +57 -58
- package/lib-commonjs/components/Slider/useSlider.js.map +1 -1
- package/lib-commonjs/components/Slider/useSliderState.js +51 -59
- package/lib-commonjs/components/Slider/useSliderState.js.map +1 -1
- package/lib-commonjs/components/Slider/useSliderStyles.js +697 -311
- package/lib-commonjs/components/Slider/useSliderStyles.js.map +1 -1
- package/lib-commonjs/components/SliderField/SliderField.js +17 -11
- package/lib-commonjs/components/SliderField/SliderField.js.map +1 -1
- package/lib-commonjs/components/SliderField/index.js +5 -4
- package/lib-commonjs/components/SliderField/index.js.map +1 -1
- package/lib-commonjs/index.js +23 -61
- package/lib-commonjs/index.js.map +1 -1
- package/package.json +11 -10
- package/lib-amd/Slider.js +0 -6
- package/lib-amd/Slider.js.map +0 -1
- package/lib-amd/SliderField.js +0 -6
- package/lib-amd/SliderField.js.map +0 -1
- package/lib-amd/components/Slider/Slider.js +0 -17
- package/lib-amd/components/Slider/Slider.js.map +0 -1
- package/lib-amd/components/Slider/Slider.types.js +0 -5
- package/lib-amd/components/Slider/Slider.types.js.map +0 -1
- package/lib-amd/components/Slider/index.js +0 -14
- package/lib-amd/components/Slider/index.js.map +0 -1
- package/lib-amd/components/Slider/renderSlider.js +0 -17
- package/lib-amd/components/Slider/renderSlider.js.map +0 -1
- package/lib-amd/components/Slider/useSlider.js +0 -41
- package/lib-amd/components/Slider/useSlider.js.map +0 -1
- package/lib-amd/components/Slider/useSliderState.js +0 -45
- package/lib-amd/components/Slider/useSliderState.js.map +0 -1
- package/lib-amd/components/Slider/useSliderStyles.js +0 -185
- package/lib-amd/components/Slider/useSliderStyles.js.map +0 -1
- package/lib-amd/components/SliderField/SliderField.js +0 -10
- package/lib-amd/components/SliderField/SliderField.js.map +0 -1
- package/lib-amd/components/SliderField/index.js +0 -6
- package/lib-amd/components/SliderField/index.js.map +0 -1
- package/lib-amd/index.js +0 -15
- package/lib-amd/index.js.map +0 -1
|
@@ -1,38 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
exports.useSliderStyles_unstable = exports.sliderCSSVars = exports.sliderClassNames = exports.useSliderState_unstable = void 0;
|
|
7
|
-
const tslib_1 = /*#__PURE__*/require("tslib");
|
|
8
|
-
tslib_1.__exportStar(require("./Slider"), exports);
|
|
9
|
-
tslib_1.__exportStar(require("./Slider.types"), exports);
|
|
10
|
-
tslib_1.__exportStar(require("./renderSlider"), exports);
|
|
11
|
-
tslib_1.__exportStar(require("./useSlider"), exports);
|
|
12
|
-
var useSliderState_1 = /*#__PURE__*/require("./useSliderState");
|
|
13
|
-
Object.defineProperty(exports, "useSliderState_unstable", {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
get: function () {
|
|
16
|
-
return useSliderState_1.useSliderState_unstable;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
var useSliderStyles_1 = /*#__PURE__*/require("./useSliderStyles");
|
|
20
|
-
Object.defineProperty(exports, "sliderClassNames", {
|
|
21
|
-
enumerable: true,
|
|
22
|
-
get: function () {
|
|
23
|
-
return useSliderStyles_1.sliderClassNames;
|
|
24
|
-
}
|
|
3
|
+
value: true
|
|
25
4
|
});
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
useSliderState_unstable: ()=>_useSliderState.useSliderState_unstable,
|
|
13
|
+
sliderClassNames: ()=>_useSliderStyles.sliderClassNames,
|
|
14
|
+
sliderCSSVars: ()=>_useSliderStyles.sliderCSSVars,
|
|
15
|
+
useSliderStyles_unstable: ()=>_useSliderStyles.useSliderStyles_unstable
|
|
37
16
|
});
|
|
17
|
+
const _exportStar = require("@swc/helpers/lib/_export_star.js").default;
|
|
18
|
+
_exportStar(require("./Slider"), exports);
|
|
19
|
+
_exportStar(require("./Slider.types"), exports);
|
|
20
|
+
_exportStar(require("./renderSlider"), exports);
|
|
21
|
+
_exportStar(require("./useSlider"), exports);
|
|
22
|
+
const _useSliderState = require("./useSliderState");
|
|
23
|
+
const _useSliderStyles = require("./useSliderStyles");
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
25
|
+
|
|
38
26
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../../lib/components/Slider/index.js"],"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//# sourceMappingURL=index.js.map"],"names":["useSliderState_unstable","sliderClassNames","sliderCSSVars","useSliderStyles_unstable"],"mappings":";;;;;;;;;;;IAISA,uBAAuB,MAAvBA,uCAAuB;IACvBC,gBAAgB,MAAhBA,iCAAgB;IAAEC,aAAa,MAAbA,8BAAa;IAAEC,wBAAwB,MAAxBA,yCAAwB;;;oBALpD;oBACA;oBACA;oBACA;gCAC0B;iCACkC;CAC1E,iCAAiC"}
|
|
@@ -1,28 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "renderSlider_unstable", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>renderSlider_unstable
|
|
5
8
|
});
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
slots,
|
|
15
|
-
slotProps
|
|
16
|
-
} = react_utilities_1.getSlots(state);
|
|
17
|
-
return React.createElement(slots.root, {
|
|
18
|
-
...slotProps.root
|
|
19
|
-
}, React.createElement(slots.input, {
|
|
20
|
-
...slotProps.input
|
|
21
|
-
}), React.createElement(slots.rail, {
|
|
22
|
-
...slotProps.rail
|
|
23
|
-
}), React.createElement(slots.thumb, {
|
|
24
|
-
...slotProps.thumb
|
|
25
|
-
}));
|
|
26
|
-
};
|
|
27
|
-
exports.renderSlider_unstable = renderSlider_unstable;
|
|
9
|
+
const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
|
|
10
|
+
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
|
11
|
+
const _reactUtilities = require("@fluentui/react-utilities");
|
|
12
|
+
const renderSlider_unstable = (state)=>{
|
|
13
|
+
const { slots , slotProps } = (0, _reactUtilities.getSlots)(state);
|
|
14
|
+
return /*#__PURE__*/ _react.createElement(slots.root, slotProps.root, /*#__PURE__*/ _react.createElement(slots.input, slotProps.input), /*#__PURE__*/ _react.createElement(slots.rail, slotProps.rail), /*#__PURE__*/ _react.createElement(slots.thumb, slotProps.thumb));
|
|
15
|
+
}; //# sourceMappingURL=renderSlider.js.map
|
|
16
|
+
|
|
28
17
|
//# sourceMappingURL=renderSlider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../../lib/components/Slider/renderSlider.js"],"sourcesContent":["import * as React from 'react';\nimport { getSlots } from '@fluentui/react-utilities';\n/**\n * Render the final JSX of Slider\n */\nexport const renderSlider_unstable = state => {\n const {\n slots,\n slotProps\n } = getSlots(state);\n return /*#__PURE__*/React.createElement(slots.root, slotProps.root, /*#__PURE__*/React.createElement(slots.input, slotProps.input), /*#__PURE__*/React.createElement(slots.rail, slotProps.rail), /*#__PURE__*/React.createElement(slots.thumb, slotProps.thumb));\n};\n//# sourceMappingURL=renderSlider.js.map"],"names":["renderSlider_unstable","state","slots","slotProps","getSlots","React","createElement","root","input","rail","thumb"],"mappings":";;;;+BAKaA;;aAAAA;;;6DALU;gCACE;AAIlB,MAAMA,wBAAwBC,CAAAA,QAAS;IAC5C,MAAM,EACJC,MAAK,EACLC,UAAS,EACV,GAAGC,IAAAA,wBAAQ,EAACH;IACb,OAAO,WAAW,GAAEI,OAAMC,aAAa,CAACJ,MAAMK,IAAI,EAAEJ,UAAUI,IAAI,EAAE,WAAW,GAAEF,OAAMC,aAAa,CAACJ,MAAMM,KAAK,EAAEL,UAAUK,KAAK,GAAG,WAAW,GAAEH,OAAMC,aAAa,CAACJ,MAAMO,IAAI,EAAEN,UAAUM,IAAI,GAAG,WAAW,GAAEJ,OAAMC,aAAa,CAACJ,MAAMQ,KAAK,EAAEP,UAAUO,KAAK;AACjQ,GACA,wCAAwC"}
|
|
@@ -1,62 +1,61 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "useSlider_unstable", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>useSlider_unstable
|
|
5
8
|
});
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
// Slots
|
|
21
|
-
root,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
useSliderState_1.useSliderState_unstable(state, props);
|
|
59
|
-
return state;
|
|
60
|
-
};
|
|
61
|
-
exports.useSlider_unstable = useSlider_unstable;
|
|
9
|
+
const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
|
|
10
|
+
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
|
11
|
+
const _reactUtilities = require("@fluentui/react-utilities");
|
|
12
|
+
const _useSliderState = require("./useSliderState");
|
|
13
|
+
const _reactTabster = require("@fluentui/react-tabster");
|
|
14
|
+
const useSlider_unstable = (props, ref)=>{
|
|
15
|
+
const nativeProps = (0, _reactUtilities.getPartitionedNativeProps)({
|
|
16
|
+
props,
|
|
17
|
+
primarySlotTagName: 'input',
|
|
18
|
+
excludedPropNames: [
|
|
19
|
+
'onChange',
|
|
20
|
+
'size'
|
|
21
|
+
]
|
|
22
|
+
});
|
|
23
|
+
const { disabled , vertical , size ='medium' , // Slots
|
|
24
|
+
root , input , rail , thumb } = props;
|
|
25
|
+
const state = {
|
|
26
|
+
disabled,
|
|
27
|
+
size,
|
|
28
|
+
vertical,
|
|
29
|
+
components: {
|
|
30
|
+
input: 'input',
|
|
31
|
+
rail: 'div',
|
|
32
|
+
root: 'div',
|
|
33
|
+
thumb: 'div'
|
|
34
|
+
},
|
|
35
|
+
root: (0, _reactUtilities.resolveShorthand)(root, {
|
|
36
|
+
required: true,
|
|
37
|
+
defaultProps: nativeProps.root
|
|
38
|
+
}),
|
|
39
|
+
input: (0, _reactUtilities.resolveShorthand)(input, {
|
|
40
|
+
required: true,
|
|
41
|
+
defaultProps: {
|
|
42
|
+
id: (0, _reactUtilities.useId)('slider-', props.id),
|
|
43
|
+
ref,
|
|
44
|
+
...nativeProps.primary,
|
|
45
|
+
type: 'range',
|
|
46
|
+
orient: vertical ? 'vertical' : undefined
|
|
47
|
+
}
|
|
48
|
+
}),
|
|
49
|
+
rail: (0, _reactUtilities.resolveShorthand)(rail, {
|
|
50
|
+
required: true
|
|
51
|
+
}),
|
|
52
|
+
thumb: (0, _reactUtilities.resolveShorthand)(thumb, {
|
|
53
|
+
required: true
|
|
54
|
+
})
|
|
55
|
+
};
|
|
56
|
+
state.root.ref = (0, _reactUtilities.useMergedRefs)(state.root.ref, (0, _reactTabster.useFocusWithin)());
|
|
57
|
+
(0, _useSliderState.useSliderState_unstable)(state, props);
|
|
58
|
+
return state;
|
|
59
|
+
}; //# sourceMappingURL=useSlider.js.map
|
|
60
|
+
|
|
62
61
|
//# sourceMappingURL=useSlider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../../lib/components/Slider/useSlider.js"],"sourcesContent":["import * as React from 'react';\nimport { getPartitionedNativeProps, resolveShorthand, useId, useMergedRefs } from '@fluentui/react-utilities';\nimport { useSliderState_unstable } from './useSliderState';\nimport { useFocusWithin } from '@fluentui/react-tabster';\nexport const useSlider_unstable = (props, ref) => {\n const nativeProps = getPartitionedNativeProps({\n props,\n primarySlotTagName: 'input',\n excludedPropNames: ['onChange', 'size']\n });\n const {\n disabled,\n vertical,\n size = 'medium',\n // Slots\n root,\n input,\n rail,\n thumb\n } = props;\n const state = {\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: nativeProps.root\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, {\n required: true\n }),\n thumb: resolveShorthand(thumb, {\n required: true\n })\n };\n state.root.ref = useMergedRefs(state.root.ref, useFocusWithin());\n useSliderState_unstable(state, props);\n return state;\n};\n//# sourceMappingURL=useSlider.js.map"],"names":["useSlider_unstable","props","ref","nativeProps","getPartitionedNativeProps","primarySlotTagName","excludedPropNames","disabled","vertical","size","root","input","rail","thumb","state","components","resolveShorthand","required","defaultProps","id","useId","primary","type","orient","undefined","useMergedRefs","useFocusWithin","useSliderState_unstable"],"mappings":";;;;+BAIaA;;aAAAA;;;6DAJU;gCAC2D;gCAC1C;8BACT;AACxB,MAAMA,qBAAqB,CAACC,OAAOC,MAAQ;IAChD,MAAMC,cAAcC,IAAAA,yCAAyB,EAAC;QAC5CH;QACAI,oBAAoB;QACpBC,mBAAmB;YAAC;YAAY;SAAO;IACzC;IACA,MAAM,EACJC,SAAQ,EACRC,SAAQ,EACRC,MAAO,SAAQ,EACf,QAAQ;IACRC,KAAI,EACJC,MAAK,EACLC,KAAI,EACJC,MAAK,EACN,GAAGZ;IACJ,MAAMa,QAAQ;QACZP;QACAE;QACAD;QACAO,YAAY;YACVJ,OAAO;YACPC,MAAM;YACNF,MAAM;YACNG,OAAO;QACT;QACAH,MAAMM,IAAAA,gCAAgB,EAACN,MAAM;YAC3BO,UAAU,IAAI;YACdC,cAAcf,YAAYO,IAAI;QAChC;QACAC,OAAOK,IAAAA,gCAAgB,EAACL,OAAO;YAC7BM,UAAU,IAAI;YACdC,cAAc;gBACZC,IAAIC,IAAAA,qBAAK,EAAC,WAAWnB,MAAMkB,EAAE;gBAC7BjB;gBACA,GAAGC,YAAYkB,OAAO;gBACtBC,MAAM;gBACNC,QAAQf,WAAW,aAAagB,SAAS;YAC3C;QACF;QACAZ,MAAMI,IAAAA,gCAAgB,EAACJ,MAAM;YAC3BK,UAAU,IAAI;QAChB;QACAJ,OAAOG,IAAAA,gCAAgB,EAACH,OAAO;YAC7BI,UAAU,IAAI;QAChB;IACF;IACAH,MAAMJ,IAAI,CAACR,GAAG,GAAGuB,IAAAA,6BAAa,EAACX,MAAMJ,IAAI,CAACR,GAAG,EAAEwB,IAAAA,4BAAc;IAC7DC,IAAAA,uCAAuB,EAACb,OAAOb;IAC/B,OAAOa;AACT,GACA,qCAAqC"}
|
|
@@ -1,64 +1,56 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
5
4
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const useSliderState_unstable = (state, props) => {
|
|
19
|
-
const {
|
|
20
|
-
defaultValue = 0,
|
|
21
|
-
min = 0,
|
|
22
|
-
max = 100,
|
|
23
|
-
step,
|
|
24
|
-
value
|
|
25
|
-
} = props;
|
|
26
|
-
const {
|
|
27
|
-
dir
|
|
28
|
-
} = react_shared_contexts_1.useFluent_unstable();
|
|
29
|
-
const [currentValue, setCurrentValue] = react_utilities_1.useControllableState({
|
|
30
|
-
state: value !== undefined ? react_utilities_1.clamp(value, min, max) : undefined,
|
|
31
|
-
defaultState: react_utilities_1.clamp(defaultValue, min, max),
|
|
32
|
-
initialState: 0
|
|
33
|
-
});
|
|
34
|
-
const valuePercent = getPercent(currentValue, min, max);
|
|
35
|
-
const inputOnChange = state.input.onChange;
|
|
36
|
-
const propsOnChange = props.onChange;
|
|
37
|
-
const onChange = react_utilities_1.useEventCallback(ev => {
|
|
38
|
-
const newValue = Number(ev.target.value);
|
|
39
|
-
setCurrentValue(react_utilities_1.clamp(newValue, min, max));
|
|
40
|
-
if (inputOnChange && inputOnChange !== propsOnChange) {
|
|
41
|
-
inputOnChange(ev);
|
|
42
|
-
} else if (propsOnChange) {
|
|
43
|
-
propsOnChange(ev, {
|
|
44
|
-
value: newValue
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
const rootVariables = {
|
|
49
|
-
[sliderDirectionVar]: state.vertical ? '0deg' : dir === 'ltr' ? '90deg' : '270deg',
|
|
50
|
-
[sliderStepsPercentVar]: step && step > 0 ? `${step * 100 / (max - min)}%` : '',
|
|
51
|
-
[sliderProgressVar]: `${valuePercent}%`
|
|
52
|
-
};
|
|
53
|
-
// Root props
|
|
54
|
-
state.root.style = {
|
|
55
|
-
...rootVariables,
|
|
56
|
-
...state.root.style
|
|
57
|
-
};
|
|
58
|
-
// Input Props
|
|
59
|
-
state.input.value = currentValue;
|
|
60
|
-
state.input.onChange = onChange;
|
|
61
|
-
return state;
|
|
5
|
+
Object.defineProperty(exports, "useSliderState_unstable", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>useSliderState_unstable
|
|
8
|
+
});
|
|
9
|
+
const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
|
|
10
|
+
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
|
11
|
+
const _reactUtilities = require("@fluentui/react-utilities");
|
|
12
|
+
const _reactSharedContexts = require("@fluentui/react-shared-contexts");
|
|
13
|
+
const _useSliderStyles = require("./useSliderStyles");
|
|
14
|
+
const { sliderStepsPercentVar , sliderProgressVar , sliderDirectionVar } = _useSliderStyles.sliderCSSVars;
|
|
15
|
+
const getPercent = (value, min, max)=>{
|
|
16
|
+
return max === min ? 0 : (value - min) / (max - min) * 100;
|
|
62
17
|
};
|
|
63
|
-
|
|
18
|
+
const useSliderState_unstable = (state, props)=>{
|
|
19
|
+
const { defaultValue =0 , min =0 , max =100 , step , value } = props;
|
|
20
|
+
const { dir } = (0, _reactSharedContexts.useFluent_unstable)();
|
|
21
|
+
const [currentValue, setCurrentValue] = (0, _reactUtilities.useControllableState)({
|
|
22
|
+
state: value !== undefined ? (0, _reactUtilities.clamp)(value, min, max) : undefined,
|
|
23
|
+
defaultState: (0, _reactUtilities.clamp)(defaultValue, min, max),
|
|
24
|
+
initialState: 0
|
|
25
|
+
});
|
|
26
|
+
const valuePercent = getPercent(currentValue, min, max);
|
|
27
|
+
const inputOnChange = state.input.onChange;
|
|
28
|
+
const propsOnChange = props.onChange;
|
|
29
|
+
const onChange = (0, _reactUtilities.useEventCallback)((ev)=>{
|
|
30
|
+
const newValue = Number(ev.target.value);
|
|
31
|
+
setCurrentValue((0, _reactUtilities.clamp)(newValue, min, max));
|
|
32
|
+
if (inputOnChange && inputOnChange !== propsOnChange) {
|
|
33
|
+
inputOnChange(ev);
|
|
34
|
+
} else if (propsOnChange) {
|
|
35
|
+
propsOnChange(ev, {
|
|
36
|
+
value: newValue
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
const rootVariables = {
|
|
41
|
+
[sliderDirectionVar]: state.vertical ? '0deg' : dir === 'ltr' ? '90deg' : '270deg',
|
|
42
|
+
[sliderStepsPercentVar]: step && step > 0 ? `${step * 100 / (max - min)}%` : '',
|
|
43
|
+
[sliderProgressVar]: `${valuePercent}%`
|
|
44
|
+
};
|
|
45
|
+
// Root props
|
|
46
|
+
state.root.style = {
|
|
47
|
+
...rootVariables,
|
|
48
|
+
...state.root.style
|
|
49
|
+
};
|
|
50
|
+
// Input Props
|
|
51
|
+
state.input.value = currentValue;
|
|
52
|
+
state.input.onChange = onChange;
|
|
53
|
+
return state;
|
|
54
|
+
}; //# sourceMappingURL=useSliderState.js.map
|
|
55
|
+
|
|
64
56
|
//# sourceMappingURL=useSliderState.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../../lib/components/Slider/useSliderState.js"],"sourcesContent":["import * as React from 'react';\nimport { clamp, useControllableState, useEventCallback } from '@fluentui/react-utilities';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { sliderCSSVars } from './useSliderStyles';\nconst {\n sliderStepsPercentVar,\n sliderProgressVar,\n sliderDirectionVar\n} = sliderCSSVars;\nconst getPercent = (value, min, max) => {\n return max === min ? 0 : (value - min) / (max - min) * 100;\n};\nexport const useSliderState_unstable = (state, props) => {\n const {\n defaultValue = 0,\n min = 0,\n max = 100,\n step,\n value\n } = props;\n const {\n dir\n } = 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 inputOnChange = state.input.onChange;\n const propsOnChange = props.onChange;\n const onChange = useEventCallback(ev => {\n const newValue = Number(ev.target.value);\n setCurrentValue(clamp(newValue, min, max));\n if (inputOnChange && inputOnChange !== propsOnChange) {\n inputOnChange(ev);\n } else if (propsOnChange) {\n propsOnChange(ev, {\n 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 // Root props\n state.root.style = {\n ...rootVariables,\n ...state.root.style\n };\n // Input Props\n state.input.value = currentValue;\n state.input.onChange = onChange;\n return state;\n};\n//# sourceMappingURL=useSliderState.js.map"],"names":["useSliderState_unstable","sliderStepsPercentVar","sliderProgressVar","sliderDirectionVar","sliderCSSVars","getPercent","value","min","max","state","props","defaultValue","step","dir","useFluent","currentValue","setCurrentValue","useControllableState","undefined","clamp","defaultState","initialState","valuePercent","inputOnChange","input","onChange","propsOnChange","useEventCallback","ev","newValue","Number","target","rootVariables","vertical","root","style"],"mappings":";;;;+BAYaA;;aAAAA;;;6DAZU;gCACuC;qCACd;iCAClB;AAC9B,MAAM,EACJC,sBAAqB,EACrBC,kBAAiB,EACjBC,mBAAkB,EACnB,GAAGC,8BAAa;AACjB,MAAMC,aAAa,CAACC,OAAOC,KAAKC,MAAQ;IACtC,OAAOA,QAAQD,MAAM,IAAI,AAACD,CAAAA,QAAQC,GAAE,IAAMC,CAAAA,MAAMD,GAAE,IAAK,GAAG;AAC5D;AACO,MAAMP,0BAA0B,CAACS,OAAOC,QAAU;IACvD,MAAM,EACJC,cAAe,EAAC,EAChBJ,KAAM,EAAC,EACPC,KAAM,IAAG,EACTI,KAAI,EACJN,MAAK,EACN,GAAGI;IACJ,MAAM,EACJG,IAAG,EACJ,GAAGC,IAAAA,uCAAS;IACb,MAAM,CAACC,cAAcC,gBAAgB,GAAGC,IAAAA,oCAAoB,EAAC;QAC3DR,OAAOH,UAAUY,YAAYC,IAAAA,qBAAK,EAACb,OAAOC,KAAKC,OAAOU,SAAS;QAC/DE,cAAcD,IAAAA,qBAAK,EAACR,cAAcJ,KAAKC;QACvCa,cAAc;IAChB;IACA,MAAMC,eAAejB,WAAWU,cAAcR,KAAKC;IACnD,MAAMe,gBAAgBd,MAAMe,KAAK,CAACC,QAAQ;IAC1C,MAAMC,gBAAgBhB,MAAMe,QAAQ;IACpC,MAAMA,WAAWE,IAAAA,gCAAgB,EAACC,CAAAA,KAAM;QACtC,MAAMC,WAAWC,OAAOF,GAAGG,MAAM,CAACzB,KAAK;QACvCU,gBAAgBG,IAAAA,qBAAK,EAACU,UAAUtB,KAAKC;QACrC,IAAIe,iBAAiBA,kBAAkBG,eAAe;YACpDH,cAAcK;QAChB,OAAO,IAAIF,eAAe;YACxBA,cAAcE,IAAI;gBAChBtB,OAAOuB;YACT;QACF,CAAC;IACH;IACA,MAAMG,gBAAgB;QACpB,CAAC7B,mBAAmB,EAAEM,MAAMwB,QAAQ,GAAG,SAASpB,QAAQ,QAAQ,UAAU,QAAQ;QAClF,CAACZ,sBAAsB,EAAEW,QAAQA,OAAO,IAAI,CAAC,EAAEA,OAAO,MAAOJ,CAAAA,MAAMD,GAAE,EAAG,CAAC,CAAC,GAAG,EAAE;QAC/E,CAACL,kBAAkB,EAAE,CAAC,EAAEoB,aAAa,CAAC,CAAC;IACzC;IACA,aAAa;IACbb,MAAMyB,IAAI,CAACC,KAAK,GAAG;QACjB,GAAGH,aAAa;QAChB,GAAGvB,MAAMyB,IAAI,CAACC,KAAK;IACrB;IACA,cAAc;IACd1B,MAAMe,KAAK,CAAClB,KAAK,GAAGS;IACpBN,MAAMe,KAAK,CAACC,QAAQ,GAAGA;IACvB,OAAOhB;AACT,GACA,0CAA0C"}
|