@veeqo/ui 13.11.2 → 13.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/dist/components/Slider/Slider.cjs +71 -109
  2. package/dist/components/Slider/Slider.cjs.map +1 -1
  3. package/dist/components/Slider/Slider.d.ts +6 -2
  4. package/dist/components/Slider/Slider.js +72 -110
  5. package/dist/components/Slider/Slider.js.map +1 -1
  6. package/dist/components/Slider/Slider.module.scss.cjs +9 -0
  7. package/dist/components/Slider/Slider.module.scss.cjs.map +1 -0
  8. package/dist/components/Slider/Slider.module.scss.js +7 -0
  9. package/dist/components/Slider/Slider.module.scss.js.map +1 -0
  10. package/dist/components/Slider/components/SliderHandle/SliderHandle.cjs +26 -0
  11. package/dist/components/Slider/components/SliderHandle/SliderHandle.cjs.map +1 -0
  12. package/dist/components/Slider/components/SliderHandle/SliderHandle.d.ts +7 -0
  13. package/dist/components/Slider/components/SliderHandle/SliderHandle.js +20 -0
  14. package/dist/components/Slider/components/SliderHandle/SliderHandle.js.map +1 -0
  15. package/dist/components/Slider/components/SliderHandle/SliderHandle.module.scss.cjs +9 -0
  16. package/dist/components/Slider/components/SliderHandle/SliderHandle.module.scss.cjs.map +1 -0
  17. package/dist/components/Slider/components/SliderHandle/SliderHandle.module.scss.js +7 -0
  18. package/dist/components/Slider/components/SliderHandle/SliderHandle.module.scss.js.map +1 -0
  19. package/dist/components/Slider/components/SliderHandle/index.d.ts +1 -0
  20. package/dist/components/Slider/components/SliderHandle/types.d.ts +19 -0
  21. package/dist/components/Slider/components/SliderTrack/SliderTrack.cjs +18 -0
  22. package/dist/components/Slider/components/SliderTrack/SliderTrack.cjs.map +1 -0
  23. package/dist/components/Slider/components/SliderTrack/SliderTrack.d.ts +7 -0
  24. package/dist/components/Slider/components/SliderTrack/SliderTrack.js +12 -0
  25. package/dist/components/Slider/components/SliderTrack/SliderTrack.js.map +1 -0
  26. package/dist/components/Slider/components/SliderTrack/SliderTrack.module.scss.cjs +9 -0
  27. package/dist/components/Slider/components/SliderTrack/SliderTrack.module.scss.cjs.map +1 -0
  28. package/dist/components/Slider/components/SliderTrack/SliderTrack.module.scss.js +7 -0
  29. package/dist/components/Slider/components/SliderTrack/SliderTrack.module.scss.js.map +1 -0
  30. package/dist/components/Slider/components/SliderTrack/index.d.ts +1 -0
  31. package/dist/components/Slider/components/SliderTrack/types.d.ts +6 -0
  32. package/dist/components/Slider/hooks/index.d.ts +2 -0
  33. package/dist/components/Slider/hooks/types.d.ts +24 -0
  34. package/dist/components/Slider/hooks/useSliderDrag.cjs +85 -0
  35. package/dist/components/Slider/hooks/useSliderDrag.cjs.map +1 -0
  36. package/dist/components/Slider/hooks/useSliderDrag.d.ts +11 -0
  37. package/dist/components/Slider/hooks/useSliderDrag.js +83 -0
  38. package/dist/components/Slider/hooks/useSliderDrag.js.map +1 -0
  39. package/dist/components/Slider/hooks/useSliderKeyboard.cjs +85 -0
  40. package/dist/components/Slider/hooks/useSliderKeyboard.cjs.map +1 -0
  41. package/dist/components/Slider/hooks/useSliderKeyboard.d.ts +9 -0
  42. package/dist/components/Slider/hooks/useSliderKeyboard.js +83 -0
  43. package/dist/components/Slider/hooks/useSliderKeyboard.js.map +1 -0
  44. package/dist/components/Slider/types.d.ts +7 -8
  45. package/dist/components/Slider/utils/calculateSliderValue.cjs +32 -0
  46. package/dist/components/Slider/utils/calculateSliderValue.cjs.map +1 -0
  47. package/dist/components/Slider/utils/calculateSliderValue.d.ts +5 -0
  48. package/dist/components/Slider/utils/calculateSliderValue.js +30 -0
  49. package/dist/components/Slider/utils/calculateSliderValue.js.map +1 -0
  50. package/dist/components/Slider/utils/index.d.ts +1 -0
  51. package/dist/components/Slider/utils/types.d.ts +7 -0
  52. package/package.json +1 -1
  53. package/dist/components/Slider/styled.cjs +0 -23
  54. package/dist/components/Slider/styled.cjs.map +0 -1
  55. package/dist/components/Slider/styled.d.ts +0 -8
  56. package/dist/components/Slider/styled.js +0 -14
  57. package/dist/components/Slider/styled.js.map +0 -1
@@ -0,0 +1,83 @@
1
+ import { useCallback } from 'react';
2
+ import { calculateSliderValue } from '../utils/calculateSliderValue.js';
3
+
4
+ /**
5
+ * Hook that manages keyboard navigation for slider handles.
6
+ * Handles arrow keys, Home, and End keys with proper boundary constraints.
7
+ * Returns a keyboard event handler to attach to slider handles.
8
+ */
9
+ const useSliderKeyboard = ({ value, min, max, step, disabled, onChange, setFocusedHandle, startHandleRef, endHandleRef, }) => {
10
+ const handleKeyDown = useCallback((handle) => (e) => {
11
+ var _a;
12
+ if (disabled)
13
+ return;
14
+ let currentValue;
15
+ if (Array.isArray(value)) {
16
+ currentValue = handle === 'start' ? value[0] : value[1];
17
+ }
18
+ else {
19
+ currentValue = value;
20
+ }
21
+ let newValue;
22
+ switch (e.key) {
23
+ case 'ArrowRight':
24
+ case 'ArrowUp':
25
+ e.preventDefault();
26
+ newValue = calculateSliderValue({
27
+ currentValue,
28
+ targetValue: currentValue + step,
29
+ min,
30
+ max,
31
+ step,
32
+ });
33
+ break;
34
+ case 'ArrowLeft':
35
+ case 'ArrowDown':
36
+ e.preventDefault();
37
+ newValue = calculateSliderValue({
38
+ currentValue,
39
+ targetValue: currentValue - step,
40
+ min,
41
+ max,
42
+ step,
43
+ });
44
+ break;
45
+ case 'Home':
46
+ e.preventDefault();
47
+ newValue = min;
48
+ break;
49
+ case 'End':
50
+ e.preventDefault();
51
+ newValue = max;
52
+ break;
53
+ default:
54
+ return;
55
+ }
56
+ let resultValue;
57
+ if (Array.isArray(value)) {
58
+ const newStart = handle === 'start' ? newValue : value[0];
59
+ const newEnd = handle === 'end' ? newValue : value[1];
60
+ // If handles cross, swap them and switch focus to continue movement
61
+ if (newStart > newEnd) {
62
+ resultValue = [newEnd, newStart];
63
+ const newHandle = handle === 'start' ? 'end' : 'start';
64
+ setFocusedHandle(newHandle);
65
+ const targetRef = newHandle === 'start' ? startHandleRef : endHandleRef;
66
+ (_a = targetRef.current) === null || _a === undefined ? undefined : _a.focus();
67
+ }
68
+ else {
69
+ resultValue = [newStart, newEnd];
70
+ }
71
+ }
72
+ else {
73
+ resultValue = newValue;
74
+ }
75
+ onChange(resultValue);
76
+ }, [value, min, max, step, disabled, onChange, setFocusedHandle, startHandleRef, endHandleRef]);
77
+ return {
78
+ handleKeyDown,
79
+ };
80
+ };
81
+
82
+ export { useSliderKeyboard };
83
+ //# sourceMappingURL=useSliderKeyboard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSliderKeyboard.js","sources":["../../../../src/components/Slider/hooks/useSliderKeyboard.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { calculateSliderValue } from '../utils';\nimport { UseSliderKeyboardProps } from './types';\n\n/**\n * Hook that manages keyboard navigation for slider handles.\n * Handles arrow keys, Home, and End keys with proper boundary constraints.\n * Returns a keyboard event handler to attach to slider handles.\n */\nexport const useSliderKeyboard = ({\n value,\n min,\n max,\n step,\n disabled,\n onChange,\n setFocusedHandle,\n startHandleRef,\n endHandleRef,\n}: UseSliderKeyboardProps) => {\n const handleKeyDown = useCallback(\n (handle: 'start' | 'end') => (e: React.KeyboardEvent) => {\n if (disabled) return;\n\n let currentValue: number;\n if (Array.isArray(value)) {\n currentValue = handle === 'start' ? value[0] : value[1];\n } else {\n currentValue = value as number;\n }\n\n let newValue: number;\n\n switch (e.key) {\n case 'ArrowRight':\n case 'ArrowUp':\n e.preventDefault();\n newValue = calculateSliderValue({\n currentValue,\n targetValue: currentValue + step,\n min,\n max,\n step,\n });\n break;\n case 'ArrowLeft':\n case 'ArrowDown':\n e.preventDefault();\n newValue = calculateSliderValue({\n currentValue,\n targetValue: currentValue - step,\n min,\n max,\n step,\n });\n break;\n case 'Home':\n e.preventDefault();\n newValue = min;\n break;\n case 'End':\n e.preventDefault();\n newValue = max;\n break;\n default:\n return;\n }\n\n let resultValue: number | number[];\n\n if (Array.isArray(value)) {\n const newStart = handle === 'start' ? newValue : value[0];\n const newEnd = handle === 'end' ? newValue : value[1];\n\n // If handles cross, swap them and switch focus to continue movement\n if (newStart > newEnd) {\n resultValue = [newEnd, newStart];\n const newHandle = handle === 'start' ? 'end' : 'start';\n setFocusedHandle(newHandle);\n const targetRef = newHandle === 'start' ? startHandleRef : endHandleRef;\n targetRef.current?.focus();\n } else {\n resultValue = [newStart, newEnd];\n }\n } else {\n resultValue = newValue;\n }\n\n onChange(resultValue);\n },\n [value, min, max, step, disabled, onChange, setFocusedHandle, startHandleRef, endHandleRef],\n );\n\n return {\n handleKeyDown,\n };\n};\n"],"names":[],"mappings":";;;AAIA;;;;AAIG;AACU,MAAA,iBAAiB,GAAG,CAAC,EAChC,KAAK,EACL,GAAG,EACH,GAAG,EACH,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,gBAAgB,EAChB,cAAc,EACd,YAAY,GACW,KAAI;AAC3B,IAAA,MAAM,aAAa,GAAG,WAAW,CAC/B,CAAC,MAAuB,KAAK,CAAC,CAAsB,KAAI;;AACtD,QAAA,IAAI,QAAQ;YAAE;AAEd,QAAA,IAAI,YAAoB;AACxB,QAAA,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;AACxB,YAAA,YAAY,GAAG,MAAM,KAAK,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;AACxD;AAAM,aAAA;YACL,YAAY,GAAG,KAAe;AAC/B;AAED,QAAA,IAAI,QAAgB;QAEpB,QAAQ,CAAC,CAAC,GAAG;AACX,YAAA,KAAK,YAAY;AACjB,YAAA,KAAK,SAAS;gBACZ,CAAC,CAAC,cAAc,EAAE;gBAClB,QAAQ,GAAG,oBAAoB,CAAC;oBAC9B,YAAY;oBACZ,WAAW,EAAE,YAAY,GAAG,IAAI;oBAChC,GAAG;oBACH,GAAG;oBACH,IAAI;AACL,iBAAA,CAAC;gBACF;AACF,YAAA,KAAK,WAAW;AAChB,YAAA,KAAK,WAAW;gBACd,CAAC,CAAC,cAAc,EAAE;gBAClB,QA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Q,EAAE,QAAQ,EAAE,gBAAgB,EAAE,cAAc,EAAE,YAAY,CAAC,CAC5F;IAED,OAAO;QACL,aAAa;KACd;AACH;;;;"}
@@ -1,4 +1,4 @@
1
- export type SliderComponentPropTypes = {
1
+ export type SliderComponentProps = {
2
2
  id?: string;
3
3
  value: number | number[];
4
4
  min: number;
@@ -6,6 +6,11 @@ export type SliderComponentPropTypes = {
6
6
  step?: number;
7
7
  className?: string;
8
8
  e2eClassName?: string;
9
+ showFill?: boolean;
10
+ showValueLabel?: boolean;
11
+ disabled?: boolean;
12
+ ariaLabel?: string;
13
+ ariaLabelledBy?: string;
9
14
  onChange: (value: number | number[]) => void;
10
15
  onSlideStart?: () => void;
11
16
  onSlideEnd?: () => void;
@@ -17,10 +22,4 @@ export type ClassNamesReturnPayload = {
17
22
  startSlider?: string;
18
23
  endSlider?: string;
19
24
  };
20
- export type DraggingSliderIndex = -1 | 0 | 1;
21
- export type SliderPropTypes = {
22
- left: number;
23
- };
24
- export type SliderRangePropTypes = SliderPropTypes & {
25
- width: number;
26
- };
25
+ export type DraggingHandle = null | 'start' | 'end';
@@ -0,0 +1,32 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Calculates a new slider value with step snapping, boundary constraints, and decimal precision.
5
+ */
6
+ const calculateSliderValue = ({ currentValue, targetValue, min, max, step, }) => {
7
+ var _a, _b;
8
+ // Fix floating point precision on inputs
9
+ const decimalPlaces = (_b = (_a = step.toString().split('.')[1]) === null || _a === undefined ? undefined : _a.length) !== null && _b !== undefined ? _b : 0;
10
+ const fixedCurrentValue = Number(currentValue.toFixed(decimalPlaces));
11
+ const fixedTargetValue = Number(targetValue.toFixed(decimalPlaces));
12
+ let newValue = fixedTargetValue;
13
+ // Apply step snapping with directional bias
14
+ const diff = Number((fixedCurrentValue - newValue).toFixed(decimalPlaces + 1));
15
+ if (diff > 0) {
16
+ // Moving left/down: use ceil to snap in the direction of movement
17
+ const deltaValue = Number((newValue - fixedCurrentValue).toFixed(decimalPlaces + 1));
18
+ newValue = fixedCurrentValue + Math.ceil(deltaValue / step) * step;
19
+ }
20
+ else if (diff < 0) {
21
+ // Moving right/up: use floor to snap in the direction of movement
22
+ const deltaValue = Number((newValue - fixedCurrentValue).toFixed(decimalPlaces + 1));
23
+ newValue = fixedCurrentValue + Math.floor(deltaValue / step) * step;
24
+ }
25
+ // Apply boundary constraints
26
+ newValue = Math.max(min, Math.min(max, newValue));
27
+ // Fix floating point precision after calculations
28
+ return Number(newValue.toFixed(decimalPlaces));
29
+ };
30
+
31
+ exports.calculateSliderValue = calculateSliderValue;
32
+ //# sourceMappingURL=calculateSliderValue.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calculateSliderValue.cjs","sources":["../../../../src/components/Slider/utils/calculateSliderValue.ts"],"sourcesContent":["import { CalculateSliderValueProps } from './types';\n\n/**\n * Calculates a new slider value with step snapping, boundary constraints, and decimal precision.\n */\nexport const calculateSliderValue = ({\n currentValue,\n targetValue,\n min,\n max,\n step,\n}: CalculateSliderValueProps): number => {\n // Fix floating point precision on inputs\n const decimalPlaces = step.toString().split('.')[1]?.length ?? 0;\n const fixedCurrentValue = Number(currentValue.toFixed(decimalPlaces));\n const fixedTargetValue = Number(targetValue.toFixed(decimalPlaces));\n\n let newValue = fixedTargetValue;\n\n // Apply step snapping with directional bias\n const diff = Number((fixedCurrentValue - newValue).toFixed(decimalPlaces + 1));\n\n if (diff > 0) {\n // Moving left/down: use ceil to snap in the direction of movement\n const deltaValue = Number((newValue - fixedCurrentValue).toFixed(decimalPlaces + 1));\n newValue = fixedCurrentValue + Math.ceil(deltaValue / step) * step;\n } else if (diff < 0) {\n // Moving right/up: use floor to snap in the direction of movement\n const deltaValue = Number((newValue - fixedCurrentValue).toFixed(decimalPlaces + 1));\n newValue = fixedCurrentValue + Math.floor(deltaValue / step) * step;\n }\n\n // Apply boundary constraints\n newValue = Math.max(min, Math.min(max, newValue));\n\n // Fix floating point precision after calculations\n return Number(newValue.toFixed(decimalPla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AG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;;IAGjD,OAAO,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;AAChD;;;;"}
@@ -0,0 +1,5 @@
1
+ import { CalculateSliderValueProps } from './types';
2
+ /**
3
+ * Calculates a new slider value with step snapping, boundary constraints, and decimal precision.
4
+ */
5
+ export declare const calculateSliderValue: ({ currentValue, targetValue, min, max, step, }: CalculateSliderValueProps) => number;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Calculates a new slider value with step snapping, boundary constraints, and decimal precision.
3
+ */
4
+ const calculateSliderValue = ({ currentValue, targetValue, min, max, step, }) => {
5
+ var _a, _b;
6
+ // Fix floating point precision on inputs
7
+ const decimalPlaces = (_b = (_a = step.toString().split('.')[1]) === null || _a === undefined ? undefined : _a.length) !== null && _b !== undefined ? _b : 0;
8
+ const fixedCurrentValue = Number(currentValue.toFixed(decimalPlaces));
9
+ const fixedTargetValue = Number(targetValue.toFixed(decimalPlaces));
10
+ let newValue = fixedTargetValue;
11
+ // Apply step snapping with directional bias
12
+ const diff = Number((fixedCurrentValue - newValue).toFixed(decimalPlaces + 1));
13
+ if (diff > 0) {
14
+ // Moving left/down: use ceil to snap in the direction of movement
15
+ const deltaValue = Number((newValue - fixedCurrentValue).toFixed(decimalPlaces + 1));
16
+ newValue = fixedCurrentValue + Math.ceil(deltaValue / step) * step;
17
+ }
18
+ else if (diff < 0) {
19
+ // Moving right/up: use floor to snap in the direction of movement
20
+ const deltaValue = Number((newValue - fixedCurrentValue).toFixed(decimalPlaces + 1));
21
+ newValue = fixedCurrentValue + Math.floor(deltaValue / step) * step;
22
+ }
23
+ // Apply boundary constraints
24
+ newValue = Math.max(min, Math.min(max, newValue));
25
+ // Fix floating point precision after calculations
26
+ return Number(newValue.toFixed(decimalPlaces));
27
+ };
28
+
29
+ export { calculateSliderValue };
30
+ //# sourceMappingURL=calculateSliderValue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calculateSliderValue.js","sources":["../../../../src/components/Slider/utils/calculateSliderValue.ts"],"sourcesContent":["import { CalculateSliderValueProps } from './types';\n\n/**\n * Calculates a new slider value with step snapping, boundary constraints, and decimal precision.\n */\nexport const calculateSliderValue = ({\n currentValue,\n targetValue,\n min,\n max,\n step,\n}: CalculateSliderValueProps): number => {\n // Fix floating point precision on inputs\n const decimalPlaces = step.toString().split('.')[1]?.length ?? 0;\n const fixedCurrentValue = Number(currentValue.toFixed(decimalPlaces));\n const fixedTargetValue = Number(targetValue.toFixed(decimalPlaces));\n\n let newValue = fixedTargetValue;\n\n // Apply step snapping with directional bias\n const diff = Number((fixedCurrentValue - newValue).toFixed(decimalPlaces + 1));\n\n if (diff > 0) {\n // Moving left/down: use ceil to snap in the direction of movement\n const deltaValue = Number((newValue - fixedCurrentValue).toFixed(decimalPlaces + 1));\n newValue = fixedCurrentValue + Math.ceil(deltaValue / step) * step;\n } else if (diff < 0) {\n // Moving right/up: use floor to snap in the direction of movement\n const deltaValue = Number((newValue - fixedCurrentValue).toFixed(decimalPlaces + 1));\n newValue = fixedCurrentValue + Math.floor(deltaValue / step) * step;\n }\n\n // Apply boundary constraints\n newValue = Math.max(min, Math.min(max, newValue));\n\n // Fix floating point precision after calculations\n return Number(newValue.toFixed(decimalPlaces));\n};\n"],"names":[],"mappings":"AAEA;;AAEG;AACU,MAAA,oBAAoB,GAAG,CAAC,EACnC,YAAY,EACZ,WAAW,EACX,GAAG,EACH,GAAG,EACH,IAAI,GACsB,KAAY;;;IAEtC,MAAM,aAAa,GAAG,CAAA,EAAA,GAAA,CAAA,EAAA,GAAA,IAAI,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,gDAAE,MAAM,MAAA,IAAA,IAAA,EAAA,KAAA,SAAA,GAAA,EAAA,GAAI,CAAC;IAChE,MAAM,iBAAiB,GAAG,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IACrE,MAAM,gBAAgB,GAAG,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAEnE,IAAI,QAAQ,GAAG,gBAAgB;;AAG/B,IAAA,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,iBAAiB,GAAG,QAAQ,EAAE,OAAO,CAAC,aAAa,GAAG,CAAC,CAAC,CAAC;IAE9E,IAAI,IAAI,GAAG,CAAC,EAAE;;AAEZ,QAAA,MAAM,UAAU,GAAG,MAAM,CAAC,CAAC,QAAQ,GAAG,iBAAiB,EAAE,OAAO,CAAC,aAAa,GAAG,CAAC,CAAC,CAAC;AACpF,QAAA,QAAQ,GAAG,iBAAiB,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,IAAI;AACnE;SAAM,IAAI,IAAI,GAAG,CAAC,EAAE;;AAEnB,QAAA,MAAM,UAAU,GAAG,MAAM,CAAC,CAAC,QAAQ,GAAG,iBAAiB,EAAE,OAAO,CAAC,aAAa,GAAG,CAAC,CAAC,CAAC;AACpF,QAAA,QAAQ,GAAG,iBAAiB,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,IAAI;AACpE;;AAGD,IAAA,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;;IAGjD,OAAO,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;AAChD;;;;"}
@@ -0,0 +1 @@
1
+ export { calculateSliderValue } from './calculateSliderValue';
@@ -0,0 +1,7 @@
1
+ export type CalculateSliderValueProps = {
2
+ currentValue: number;
3
+ targetValue: number;
4
+ min: number;
5
+ max: number;
6
+ step: number;
7
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veeqo/ui",
3
- "version": "13.11.2",
3
+ "version": "13.12.1",
4
4
  "description": "New optimised component library for Veeqo.",
5
5
  "author": "Robert Wealthall",
6
6
  "license": "ISC",
@@ -1,23 +0,0 @@
1
- 'use strict';
2
-
3
- var styled = require('styled-components');
4
- var index = require('../../theme/index.cjs');
5
-
6
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
7
-
8
- var styled__default = /*#__PURE__*/_interopDefaultCompat(styled);
9
-
10
- const TRACK_HEIGHT = 4;
11
- const BORDER_SIZE = 4;
12
- const SLIDER_SIZE = 12;
13
- const ADDITIONAL_PADDING = 2;
14
- const SliderContainer = styled__default.default.div.withConfig({ displayName: "vui--SliderContainer", componentId: "vui--103oce3" }) `min-width:128px;display:inline-block;position:relative;padding:${SLIDER_SIZE / 2 + ADDITIONAL_PADDING}px 0px;`;
15
- const SliderTrack = styled__default.default.div.withConfig({ displayName: "vui--SliderTrack", componentId: "vui--1ctzbzj" }) `background:${index.theme.colors.neutral.grey.base};height:${TRACK_HEIGHT}px;border-radius:20px;`;
16
- const SliderDiv = styled__default.default.div.withConfig({ displayName: "vui--SliderDiv", componentId: "vui--1tltjvk" }) `position:absolute;top:-${(SLIDER_SIZE - TRACK_HEIGHT) / 2 - ADDITIONAL_PADDING * 2}px;left:${(props) => `${props.left}%`};width:${SLIDER_SIZE}px;height:${SLIDER_SIZE}px;background:white;border:${BORDER_SIZE}px solid ${index.theme.colors.secondary.blue.base};border-radius:50%;touch-action:none;cursor:pointer;margin-left:-${SLIDER_SIZE}px;&:active,&:focus,&:focus-visible,&:focus-within{box-shadow:0 0 0 4px ${index.theme.colors.secondary.blue.light};}`;
17
- const SliderRange = styled__default.default(SliderTrack).withConfig({ displayName: "vui--SliderRange", componentId: "vui--t3v3py" }) `position:relative;width:${(props) => `${props.width}%`};left:${(props) => `${props.left}%`};background:${index.theme.colors.secondary.blue.light};bottom:${TRACK_HEIGHT}px;border-radius:0;`;
18
-
19
- exports.SliderContainer = SliderContainer;
20
- exports.SliderDiv = SliderDiv;
21
- exports.SliderRange = SliderRange;
22
- exports.SliderTrack = SliderTrack;
23
- //# sourceMappingURL=styled.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"styled.cjs","sources":["../../../src/components/Slider/styled.ts"],"sourcesContent":["import styled from 'styled-components';\nimport { theme } from '../../theme';\nimport { SliderPropTypes, SliderRangePropTypes } from './types';\n\nconst TRACK_HEIGHT = 4;\nconst BORDER_SIZE = 4;\nconst SLIDER_SIZE = 12;\nconst ADDITIONAL_PADDING = 2;\n\nconst SliderContainer = styled.div`\n min-width: 128px;\n display: inline-block;\n position: relative;\n padding: ${SLIDER_SIZE / 2 + ADDITIONAL_PADDING}px 0px;\n`;\n\nconst SliderTrack = styled.div`\n background: ${theme.colors.neutral.grey.base};\n height: ${TRACK_HEIGHT}px;\n border-radius: 20px;\n`;\n\nconst SliderDiv = styled.div<SliderPropTypes>`\n position: absolute;\n top: -${(SLIDER_SIZE - TRACK_HEIGHT) / 2 - ADDITIONAL_PADDING * 2}px;\n left: ${(props) => `${props.left}%`};\n width: ${SLIDER_SIZE}px;\n height: ${SLIDER_SIZE}px;\n background: white;\n border: ${BORDER_SIZE}px solid ${theme.colors.secondary.blue.base};\n border-radius: 50%;\n touch-action: none;\n cursor: pointer;\n margin-left: -${SLIDER_SIZE}px;\n\n &:active,\n &:focus,\n &:focus-visible,\n &:focus-within {\n box-shadow: 0 0 0 4px ${theme.colors.secondary.blue.light};\n }\n`;\n\nconst SliderRange = styled(SliderTrack)<SliderRangePropTypes>`\n position: relative;\n width: ${(props) => `${props.width}%`};\n left: ${(props) => `${props.left}%`};\n background: ${theme.colors.secondary.blue.light};\n bottom: ${TRACK_HEIGHT}px;\n border-radius: 0;\n`;\n\nexport { SliderContainer, SliderTrack, SliderRange, SliderDiv };\n"],"names":["styled","theme"],"mappings":";;;;;;;;;AAIA,MAAM,YAAY,GAAG,CAAC;AACtB,MAAM,WAAW,GAAG,CAAC;AACrB,MAAM,WAAW,GA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AM,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CACrC,QAAA,EAAA,YAAY;;;;;;;"}
@@ -1,8 +0,0 @@
1
- import { SliderPropTypes } from './types';
2
- declare const SliderContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
3
- declare const SliderTrack: import("styled-components").StyledComponent<"div", any, {}, never>;
4
- declare const SliderDiv: import("styled-components").StyledComponent<"div", any, SliderPropTypes, never>;
5
- declare const SliderRange: import("styled-components").StyledComponent<"div", any, SliderPropTypes & {
6
- width: number;
7
- }, never>;
8
- export { SliderContainer, SliderTrack, SliderRange, SliderDiv };
@@ -1,14 +0,0 @@
1
- import styled from 'styled-components';
2
- import { theme } from '../../theme/index.js';
3
-
4
- const TRACK_HEIGHT = 4;
5
- const BORDER_SIZE = 4;
6
- const SLIDER_SIZE = 12;
7
- const ADDITIONAL_PADDING = 2;
8
- const SliderContainer = styled.div.withConfig({ displayName: "vui--SliderContainer", componentId: "vui--103oce3" }) `min-width:128px;display:inline-block;position:relative;padding:${SLIDER_SIZE / 2 + ADDITIONAL_PADDING}px 0px;`;
9
- const SliderTrack = styled.div.withConfig({ displayName: "vui--SliderTrack", componentId: "vui--1ctzbzj" }) `background:${theme.colors.neutral.grey.base};height:${TRACK_HEIGHT}px;border-radius:20px;`;
10
- const SliderDiv = styled.div.withConfig({ displayName: "vui--SliderDiv", componentId: "vui--1tltjvk" }) `position:absolute;top:-${(SLIDER_SIZE - TRACK_HEIGHT) / 2 - ADDITIONAL_PADDING * 2}px;left:${(props) => `${props.left}%`};width:${SLIDER_SIZE}px;height:${SLIDER_SIZE}px;background:white;border:${BORDER_SIZE}px solid ${theme.colors.secondary.blue.base};border-radius:50%;touch-action:none;cursor:pointer;margin-left:-${SLIDER_SIZE}px;&:active,&:focus,&:focus-visible,&:focus-within{box-shadow:0 0 0 4px ${theme.colors.secondary.blue.light};}`;
11
- const SliderRange = styled(SliderTrack).withConfig({ displayName: "vui--SliderRange", componentId: "vui--t3v3py" }) `position:relative;width:${(props) => `${props.width}%`};left:${(props) => `${props.left}%`};background:${theme.colors.secondary.blue.light};bottom:${TRACK_HEIGHT}px;border-radius:0;`;
12
-
13
- export { SliderContainer, SliderDiv, SliderRange, SliderTrack };
14
- //# sourceMappingURL=styled.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"styled.js","sources":["../../../src/components/Slider/styled.ts"],"sourcesContent":["import styled from 'styled-components';\nimport { theme } from '../../theme';\nimport { SliderPropTypes, SliderRangePropTypes } from './types';\n\nconst TRACK_HEIGHT = 4;\nconst BORDER_SIZE = 4;\nconst SLIDER_SIZE = 12;\nconst ADDITIONAL_PADDING = 2;\n\nconst SliderContainer = styled.div`\n min-width: 128px;\n display: inline-block;\n position: relative;\n padding: ${SLIDER_SIZE / 2 + ADDITIONAL_PADDING}px 0px;\n`;\n\nconst SliderTrack = styled.div`\n background: ${theme.colors.neutral.grey.base};\n height: ${TRACK_HEIGHT}px;\n border-radius: 20px;\n`;\n\nconst SliderDiv = styled.div<SliderPropTypes>`\n position: absolute;\n top: -${(SLIDER_SIZE - TRACK_HEIGHT) / 2 - ADDITIONAL_PADDING * 2}px;\n left: ${(props) => `${props.left}%`};\n width: ${SLIDER_SIZE}px;\n height: ${SLIDER_SIZE}px;\n background: white;\n border: ${BORDER_SIZE}px solid ${theme.colors.secondary.blue.base};\n border-radius: 50%;\n touch-action: none;\n cursor: pointer;\n margin-left: -${SLIDER_SIZE}px;\n\n &:active,\n &:focus,\n &:focus-visible,\n &:focus-within {\n box-shadow: 0 0 0 4px ${theme.colors.secondary.blue.light};\n }\n`;\n\nconst SliderRange = styled(SliderTrack)<SliderRangePropTypes>`\n position: relative;\n width: ${(props) => `${props.width}%`};\n left: ${(props) => `${props.left}%`};\n background: ${theme.colors.secondary.blue.light};\n bottom: ${TRACK_HEIGHT}px;\n border-radius: 0;\n`;\n\nexport { SliderContainer, SliderTrack, SliderRange, SliderDiv };\n"],"names":[],"mappings":";;;AAIA,MAAM,YAAY,GAAG,CAAC;A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