@bodynarf/react.components 1.13.7 → 1.14.0

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 (101) hide show
  1. package/changelog.md +55 -0
  2. package/components/index.d.ts +14 -0
  3. package/components/index.d.ts.map +1 -1
  4. package/components/index.js +14 -0
  5. package/components/modal/component/index.d.ts +7 -0
  6. package/components/modal/component/index.d.ts.map +1 -0
  7. package/components/modal/component/index.js +42 -0
  8. package/components/modal/component/style.scss +42 -0
  9. package/components/modal/index.d.ts +3 -0
  10. package/components/modal/index.d.ts.map +1 -0
  11. package/components/modal/index.js +2 -0
  12. package/components/modal/types.d.ts +44 -0
  13. package/components/modal/types.d.ts.map +1 -0
  14. package/components/modal/types.js +1 -0
  15. package/components/multiselect/components/withoutLabel/index.js +2 -2
  16. package/components/primitives/index.d.ts +4 -0
  17. package/components/primitives/index.d.ts.map +1 -1
  18. package/components/primitives/index.js +4 -0
  19. package/components/primitives/number/components/withLabel/index.d.ts.map +1 -1
  20. package/components/primitives/number/components/withLabel/index.js +10 -2
  21. package/components/primitives/number/components/withoutLabel/index.d.ts.map +1 -1
  22. package/components/primitives/number/components/withoutLabel/index.js +12 -4
  23. package/components/primitives/number/types.d.ts +6 -0
  24. package/components/primitives/number/types.d.ts.map +1 -1
  25. package/components/primitives/radioGroup/component/index.d.ts +7 -0
  26. package/components/primitives/radioGroup/component/index.d.ts.map +1 -0
  27. package/components/primitives/radioGroup/component/index.js +42 -0
  28. package/components/primitives/radioGroup/component/style.scss +269 -0
  29. package/components/primitives/radioGroup/index.d.ts +3 -0
  30. package/components/primitives/radioGroup/index.d.ts.map +1 -0
  31. package/components/primitives/radioGroup/index.js +2 -0
  32. package/components/primitives/radioGroup/types.d.ts +61 -0
  33. package/components/primitives/radioGroup/types.d.ts.map +1 -0
  34. package/components/primitives/radioGroup/types.js +1 -0
  35. package/components/primitives/slider/component/index.d.ts +7 -0
  36. package/components/primitives/slider/component/index.d.ts.map +1 -0
  37. package/components/primitives/slider/component/index.js +47 -0
  38. package/components/primitives/slider/component/style.scss +319 -0
  39. package/components/primitives/slider/index.d.ts +3 -0
  40. package/components/primitives/slider/index.d.ts.map +1 -0
  41. package/components/primitives/slider/index.js +2 -0
  42. package/components/primitives/slider/types.d.ts +51 -0
  43. package/components/primitives/slider/types.d.ts.map +1 -0
  44. package/components/primitives/slider/types.js +1 -0
  45. package/components/primitives/switch/component/index.d.ts +7 -0
  46. package/components/primitives/switch/component/index.d.ts.map +1 -0
  47. package/components/primitives/switch/component/index.js +39 -0
  48. package/components/primitives/switch/component/style.scss +214 -0
  49. package/components/primitives/switch/index.d.ts +3 -0
  50. package/components/primitives/switch/index.d.ts.map +1 -0
  51. package/components/primitives/switch/index.js +2 -0
  52. package/components/primitives/switch/types.d.ts +23 -0
  53. package/components/primitives/switch/types.d.ts.map +1 -0
  54. package/components/primitives/switch/types.js +1 -0
  55. package/components/primitives/timePicker/component/index.d.ts +8 -0
  56. package/components/primitives/timePicker/component/index.d.ts.map +1 -0
  57. package/components/primitives/timePicker/component/index.js +65 -0
  58. package/components/primitives/timePicker/component/style.scss +26 -0
  59. package/components/primitives/timePicker/index.d.ts +3 -0
  60. package/components/primitives/timePicker/index.d.ts.map +1 -0
  61. package/components/primitives/timePicker/index.js +2 -0
  62. package/components/primitives/timePicker/types.d.ts +33 -0
  63. package/components/primitives/timePicker/types.d.ts.map +1 -0
  64. package/components/primitives/timePicker/types.js +1 -0
  65. package/components/search/component/index.d.ts.map +1 -1
  66. package/components/search/component/index.js +9 -3
  67. package/components/search/types.d.ts +5 -0
  68. package/components/search/types.d.ts.map +1 -1
  69. package/components/stepper/component/index.d.ts +7 -0
  70. package/components/stepper/component/index.d.ts.map +1 -0
  71. package/components/stepper/component/index.js +56 -0
  72. package/components/stepper/component/style.scss +430 -0
  73. package/components/stepper/index.d.ts +3 -0
  74. package/components/stepper/index.d.ts.map +1 -0
  75. package/components/stepper/index.js +2 -0
  76. package/components/stepper/types.d.ts +65 -0
  77. package/components/stepper/types.d.ts.map +1 -0
  78. package/components/stepper/types.js +1 -0
  79. package/components/tabs/component/index.js +1 -1
  80. package/components/timeline/component/index.d.ts +7 -0
  81. package/components/timeline/component/index.d.ts.map +1 -0
  82. package/components/timeline/component/index.js +36 -0
  83. package/components/timeline/component/style.scss +395 -0
  84. package/components/timeline/index.d.ts +3 -0
  85. package/components/timeline/index.d.ts.map +1 -0
  86. package/components/timeline/index.js +2 -0
  87. package/components/timeline/types.d.ts +55 -0
  88. package/components/timeline/types.d.ts.map +1 -0
  89. package/components/timeline/types.js +1 -0
  90. package/components/tooltip/component/index.d.ts +6 -0
  91. package/components/tooltip/component/index.d.ts.map +1 -0
  92. package/components/tooltip/component/index.js +80 -0
  93. package/components/tooltip/index.d.ts +3 -0
  94. package/components/tooltip/index.d.ts.map +1 -0
  95. package/components/tooltip/index.js +2 -0
  96. package/components/tooltip/types.d.ts +31 -0
  97. package/components/tooltip/types.d.ts.map +1 -0
  98. package/components/tooltip/types.js +1 -0
  99. package/package.json +1 -1
  100. package/readme.md +18 -3
  101. package/tsconfig.tsbuildinfo +1 -1
@@ -0,0 +1,319 @@
1
+ $slider-radius: $radius !default;
2
+ $slider-track-background: $grey-lighter !default;
3
+ $slider-track-radius: $radius !default;
4
+ $slider-track-border: 0px solid $grey !default;
5
+ $slider-track-shadow: 0px 0px 0px $grey !default;
6
+ $slider-thumb-background: $white !default;
7
+ $slider-thumb-radius: $radius !default;
8
+ $slider-thumb-border: 1px solid $grey-light !default;
9
+ $slider-thumb-shadow: none !default;
10
+ $slider-thumb-to-track-ratio: 2 !default;
11
+ $slider-output-width: 3rem !default;
12
+ $slider-output-background: $primary !default;
13
+ $slider-output-radius: $radius !default;
14
+
15
+ @mixin slider-size($size) {
16
+ $track-height: calc($size / $slider-thumb-to-track-ratio);
17
+ $thumb-size: $size;
18
+
19
+ &::-webkit-slider-runnable-track {
20
+ height: $track-height;
21
+ }
22
+
23
+ &::-moz-range-track {
24
+ height: $track-height;
25
+ }
26
+
27
+ &::-ms-track {
28
+ height: $track-height;
29
+ }
30
+
31
+ &::-webkit-slider-thumb {
32
+ height: $thumb-size;
33
+ width: $thumb-size;
34
+ margin-top: calc(($track-height - $thumb-size) / 2);
35
+ }
36
+
37
+ &::-moz-range-thumb {
38
+ height: $thumb-size;
39
+ width: $thumb-size;
40
+ }
41
+
42
+ &::-ms-thumb {
43
+ height: $thumb-size;
44
+ width: $thumb-size;
45
+ margin-top: 0;
46
+ }
47
+ }
48
+
49
+ .bbr-slider-container {
50
+ position: relative;
51
+ display: flex;
52
+ flex-direction: column;
53
+ width: 100%;
54
+ padding-top: 0.5rem;
55
+
56
+ &.is-vertical {
57
+ flex-direction: row;
58
+ width: auto;
59
+ height: 200px;
60
+ padding-top: 0;
61
+ padding-left: 0.5rem;
62
+ }
63
+ }
64
+
65
+ .bbr-slider-output {
66
+ position: absolute;
67
+ top: -1.5rem;
68
+ display: inline-block;
69
+ width: $slider-output-width;
70
+ padding: 0.25rem 0.5rem;
71
+ font-size: 0.75rem;
72
+ text-align: center;
73
+ color: $white;
74
+ background-color: $slider-output-background;
75
+ border-radius: $slider-output-radius;
76
+ pointer-events: none;
77
+
78
+ &::after {
79
+ content: "";
80
+ position: absolute;
81
+ top: 100%;
82
+ left: 50%;
83
+ margin-left: -5px;
84
+ border-width: 5px;
85
+ border-style: solid;
86
+ border-color: $slider-output-background transparent transparent transparent;
87
+ }
88
+ }
89
+
90
+ .bbr-slider-labels {
91
+ display: flex;
92
+ justify-content: space-between;
93
+ margin-top: 0.25rem;
94
+ font-size: 0.75rem;
95
+ color: $grey;
96
+ }
97
+
98
+ input[type="range"].slider.bbr-slider {
99
+ --progress-percent: 0%;
100
+
101
+ appearance: none;
102
+ width: 100%;
103
+ margin: 0;
104
+ padding: 0;
105
+ background: transparent;
106
+ cursor: pointer;
107
+
108
+ // Track styles
109
+ &::-webkit-slider-runnable-track {
110
+ box-sizing: border-box;
111
+ width: 100%;
112
+ height: 0.5rem;
113
+ background: linear-gradient(
114
+ to right,
115
+ $primary var(--progress-percent),
116
+ $slider-track-background var(--progress-percent)
117
+ );
118
+ border: $slider-track-border;
119
+ border-radius: $slider-track-radius;
120
+ box-shadow: $slider-track-shadow;
121
+ }
122
+
123
+ &::-moz-range-track {
124
+ box-sizing: border-box;
125
+ width: 100%;
126
+ height: 0.5rem;
127
+ background: $slider-track-background;
128
+ border: $slider-track-border;
129
+ border-radius: $slider-track-radius;
130
+ box-shadow: $slider-track-shadow;
131
+ }
132
+
133
+ &::-moz-range-progress {
134
+ height: 0.5rem;
135
+ background: $primary;
136
+ border-radius: $slider-track-radius;
137
+ }
138
+
139
+ &::-ms-track {
140
+ box-sizing: border-box;
141
+ width: 100%;
142
+ height: 0.5rem;
143
+ background: transparent;
144
+ border-color: transparent;
145
+ color: transparent;
146
+ }
147
+
148
+ &::-ms-fill-lower {
149
+ background: $primary;
150
+ border-radius: $slider-track-radius;
151
+ }
152
+
153
+ &::-ms-fill-upper {
154
+ background: $slider-track-background;
155
+ border-radius: $slider-track-radius;
156
+ }
157
+
158
+ // Thumb styles
159
+ &::-webkit-slider-thumb {
160
+ appearance: none;
161
+ width: 1rem;
162
+ height: 1rem;
163
+ margin-top: -0.25rem;
164
+ background: $slider-thumb-background;
165
+ border: $slider-thumb-border;
166
+ border-radius: $slider-thumb-radius;
167
+ box-shadow: $slider-thumb-shadow;
168
+ transition: transform 0.2s ease;
169
+
170
+ &:hover {
171
+ transform: scale(1.1);
172
+ }
173
+ }
174
+
175
+ &::-moz-range-thumb {
176
+ width: 1rem;
177
+ height: 1rem;
178
+ background: $slider-thumb-background;
179
+ border: $slider-thumb-border;
180
+ border-radius: $slider-thumb-radius;
181
+ box-shadow: $slider-thumb-shadow;
182
+ transition: transform 0.2s ease;
183
+
184
+ &:hover {
185
+ transform: scale(1.1);
186
+ }
187
+ }
188
+
189
+ &::-ms-thumb {
190
+ width: 1rem;
191
+ height: 1rem;
192
+ background: $slider-thumb-background;
193
+ border: $slider-thumb-border;
194
+ border-radius: $slider-thumb-radius;
195
+ box-shadow: $slider-thumb-shadow;
196
+ }
197
+
198
+ // Focus state
199
+ &:focus {
200
+ outline: none;
201
+
202
+ &::-webkit-slider-thumb {
203
+ border-color: $primary;
204
+ box-shadow: 0 0 0 0.125em rgba($primary, 0.25);
205
+ }
206
+
207
+ &::-moz-range-thumb {
208
+ border-color: $primary;
209
+ box-shadow: 0 0 0 0.125em rgba($primary, 0.25);
210
+ }
211
+ }
212
+
213
+ // Disabled state
214
+ &:disabled {
215
+ cursor: not-allowed;
216
+ opacity: 0.5;
217
+ }
218
+
219
+ // Circle style
220
+ &.is-circle {
221
+ &::-webkit-slider-thumb {
222
+ border-radius: 50%;
223
+ }
224
+
225
+ &::-moz-range-thumb {
226
+ border-radius: 50%;
227
+ }
228
+
229
+ &::-ms-thumb {
230
+ border-radius: 50%;
231
+ }
232
+ }
233
+
234
+ // Size variations
235
+ &.is-small {
236
+ @include slider-size($size-small);
237
+ }
238
+
239
+ &.is-medium {
240
+ @include slider-size($size-medium);
241
+ }
242
+
243
+ &.is-large {
244
+ @include slider-size($size-large);
245
+ }
246
+
247
+ // Color variations
248
+ @each $name, $pair in $colors {
249
+ $color: nth($pair, 1);
250
+
251
+ &.is-#{$name} {
252
+ &::-webkit-slider-runnable-track {
253
+ background: linear-gradient(
254
+ to right,
255
+ $color var(--progress-percent),
256
+ $slider-track-background var(--progress-percent)
257
+ );
258
+ }
259
+
260
+ &::-moz-range-progress {
261
+ background: $color;
262
+ }
263
+
264
+ &::-ms-fill-lower {
265
+ background: $color;
266
+ }
267
+
268
+ &:focus {
269
+ &::-webkit-slider-thumb {
270
+ border-color: $color;
271
+ box-shadow: 0 0 0 0.125em rgba($color, 0.25);
272
+ }
273
+
274
+ &::-moz-range-thumb {
275
+ border-color: $color;
276
+ box-shadow: 0 0 0 0.125em rgba($color, 0.25);
277
+ }
278
+ }
279
+ }
280
+ }
281
+
282
+ // Vertical mode
283
+ &.is-vertical {
284
+ writing-mode: vertical-lr;
285
+ direction: rtl;
286
+ width: 0.5rem;
287
+ height: 100%;
288
+ min-height: 100px;
289
+
290
+ &::-webkit-slider-runnable-track {
291
+ width: 0.5rem;
292
+ height: 100%;
293
+ background: linear-gradient(
294
+ to top,
295
+ $primary var(--progress-percent),
296
+ $slider-track-background var(--progress-percent)
297
+ );
298
+ }
299
+
300
+ &::-webkit-slider-thumb {
301
+ margin-top: 0;
302
+ margin-left: -0.25rem;
303
+ }
304
+
305
+ @each $name, $pair in $colors {
306
+ $color: nth($pair, 1);
307
+
308
+ &.is-#{$name} {
309
+ &::-webkit-slider-runnable-track {
310
+ background: linear-gradient(
311
+ to top,
312
+ $color var(--progress-percent),
313
+ $slider-track-background var(--progress-percent)
314
+ );
315
+ }
316
+ }
317
+ }
318
+ }
319
+ }
@@ -0,0 +1,3 @@
1
+ export { default } from "./component";
2
+ export * from "./types";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/primitives/slider/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,cAAc,SAAS,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { default } from "./component";
2
+ export * from "./types";
@@ -0,0 +1,51 @@
1
+ import { BaseNotNullableInputElementProps, BlurableElement } from "../../../types";
2
+ /** Slider/Range component props type */
3
+ export type SliderProps = Omit<BaseNotNullableInputElementProps<number>, "readonly" | "validationState" | "loading" | "placeholder" | "hint" | "autofocus" | "label" | "rounded"> & BlurableElement & {
4
+ /** Minimum value */
5
+ min?: number;
6
+ /** Maximum value */
7
+ max?: number;
8
+ /**
9
+ * Step increment.
10
+ * @default 1
11
+ */
12
+ step?: number;
13
+ /**
14
+ * Display current value as tooltip/bubble above the slider.
15
+ * @default false
16
+ */
17
+ showValue?: boolean;
18
+ /**
19
+ * Display min and max labels below the slider.
20
+ * @default false
21
+ */
22
+ showMinMax?: boolean;
23
+ /**
24
+ * Fill the track from start to current value with color.
25
+ * @default true
26
+ */
27
+ showProgress?: boolean;
28
+ /**
29
+ * Make the slider vertical instead of horizontal.
30
+ * @default false
31
+ */
32
+ vertical?: boolean;
33
+ /**
34
+ * Height of the slider in vertical mode (in px or any CSS unit).
35
+ * @default "200px"
36
+ */
37
+ verticalHeight?: string;
38
+ /**
39
+ * Display as circle/rounded style.
40
+ * @default false
41
+ */
42
+ circle?: boolean;
43
+ /**
44
+ * Format the displayed value.
45
+ * Used when `showValue` is true.
46
+ * @example (value) => `${value}%`
47
+ * @example (value) => `${value}°C`
48
+ */
49
+ valueFormatter?: (value: number) => string;
50
+ };
51
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/primitives/slider/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gCAAgC,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE/E,wCAAwC;AACxC,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,gCAAgC,CAAC,MAAM,CAAC,EACjE,UAAU,GAAG,iBAAiB,GAC9B,SAAS,GAAG,aAAa,GACzB,MAAM,GAAG,WAAW,GACpB,OAAO,GAAG,SAAS,CACxB,GAAG,eAAe,GAAG;IAClB,oBAAoB;IACpB,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb,oBAAoB;IACpB,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB;;;;;OAKG;IACH,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;CAC9C,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ import { FC } from "react";
2
+ import "./style.scss";
3
+ import { SwitchProps } from "..";
4
+ /** Switch/Toggle input component */
5
+ declare const Switch: FC<SwitchProps>;
6
+ export default Switch;
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/primitives/switch/component/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAe,EAAE,EAAe,MAAM,OAAO,CAAC;AAQrD,OAAO,cAAc,CAAC;AAEtB,OAAO,EAAE,WAAW,EAAE,MAAM,IAAI,CAAC;AAEjC,oCAAoC;AACpC,QAAA,MAAM,MAAM,EAAE,EAAE,CAAC,WAAW,CA8F3B,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -0,0 +1,39 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useCallback } from "react";
3
+ import { emptyFn, generateGuid, getClassName, isNotNullish, isNullish } from "@bodynarf/utils";
4
+ import { ElementSize } from "../../../../types";
5
+ import { getElementColorClassName, getSizeClassName, mapDataAttributes } from "../../../../utils";
6
+ import ComponentWithLabel from "../../internal/componentWithLabel";
7
+ import "./style.scss";
8
+ /** Switch/Toggle input component */
9
+ const Switch = ({ onValueChange = emptyFn, defaultValue, label, name = generateGuid(), size = ElementSize.Normal, style, disabled = false, rounded = false, outlined = false, thin = false, rtl = false, isFormLabel = false, className, data, title }) => {
10
+ const onChecked = useCallback((event) => onValueChange(event.target.checked), [onValueChange]);
11
+ const elClassName = getClassName([
12
+ "switch",
13
+ "bbr-switch",
14
+ className,
15
+ getSizeClassName(size, ElementSize.Normal),
16
+ getElementColorClassName(style),
17
+ rounded ? "is-rounded" : "",
18
+ outlined ? "is-outlined" : "",
19
+ thin ? "is-thin" : "",
20
+ rtl ? "is-rtl" : "",
21
+ ]);
22
+ const dataAttributes = mapDataAttributes(data);
23
+ if (isNotNullish(label) && isFormLabel) {
24
+ return (_jsxs(ComponentWithLabel, { id: name, size: size, label: {
25
+ ...label,
26
+ horizontal: label.horizontal ?? false,
27
+ horizontalContainerClassName: getClassName([label.horizontalContainerClassName, "p-0"]),
28
+ }, children: [_jsx("input", { id: name, name: name, type: "checkbox", disabled: disabled, ...dataAttributes, onChange: onChecked, className: elClassName, defaultChecked: defaultValue }), _jsx("label", { title: title, htmlFor: name, className: "is-empty" })] }));
29
+ }
30
+ const isEmptyLabel = isNullish(label);
31
+ const labelClassName = isEmptyLabel
32
+ ? "is-empty"
33
+ : undefined;
34
+ const labelDataAttributes = isNullish(label?.data)
35
+ ? undefined
36
+ : mapDataAttributes(label.data);
37
+ return (_jsxs("div", { className: "bbr-field bbr-input field mr-2", children: [_jsx("input", { id: name, name: name, type: "checkbox", disabled: disabled, ...dataAttributes, onChange: onChecked, className: elClassName, defaultChecked: defaultValue }), _jsx("label", { htmlFor: name, ...labelDataAttributes, className: labelClassName, title: isEmptyLabel ? title : label?.title, children: label?.caption })] }));
38
+ };
39
+ export default Switch;
@@ -0,0 +1,214 @@
1
+ $switch-background: $grey-light !default;
2
+ $switch-border: 0.1rem solid transparent !default;
3
+ $switch-background-active: $primary !default;
4
+ $switch-radius: $radius !default;
5
+ $switch-paddle-background: $white !default;
6
+ $switch-paddle-background-active: $primary !default;
7
+ $switch-paddle-offset: 0.25rem !default;
8
+ $switch-paddle-transition: all 0.25s ease-out !default;
9
+ $switch-focus: 1px dotted $grey-light !default;
10
+
11
+ @mixin switch-size($size) {
12
+ $switch-height: $size * 1.5;
13
+ $switch-width: $switch-height * 2;
14
+ $paddle-height: $switch-height - ($switch-paddle-offset * 2);
15
+ $paddle-width: $switch-height - ($switch-paddle-offset * 2);
16
+ $paddle-active-offest: $switch-width - $paddle-width - ($switch-paddle-offset * 1.5);
17
+
18
+ + label {
19
+ position: relative;
20
+ display: initial;
21
+ font-size: $size;
22
+ line-height: initial;
23
+ padding-left: $switch-width + 0.5;
24
+ padding-top: 0.2rem;
25
+ cursor: pointer;
26
+
27
+ &::before {
28
+ position: absolute;
29
+ display: block;
30
+ top: 0;
31
+ left: 0;
32
+ width: $switch-width;
33
+ height: $switch-height;
34
+ border: $switch-border;
35
+ border-radius: $switch-radius;
36
+ background: $switch-background;
37
+ content: "";
38
+ }
39
+
40
+ &::after {
41
+ display: block;
42
+ position: absolute;
43
+ top: ($switch-height * 0.5) - ($paddle-height * 0.5);
44
+ left: $switch-paddle-offset;
45
+ width: $paddle-width;
46
+ height: $paddle-height;
47
+ transform: translate3d(0, 0, 0);
48
+ border-radius: $switch-radius;
49
+ background: $switch-paddle-background;
50
+ transition: $switch-paddle-transition;
51
+ content: "";
52
+ }
53
+
54
+ &.is-empty {
55
+ padding-left: $switch-width;
56
+ margin: 0 !important;
57
+ }
58
+ }
59
+
60
+ &.is-rtl + label {
61
+ padding-left: 0;
62
+ padding-right: $switch-width + 0.5;
63
+
64
+ &::before {
65
+ left: auto;
66
+ right: 0;
67
+ }
68
+
69
+ &::after {
70
+ left: auto;
71
+ right: $paddle-active-offest;
72
+ }
73
+ }
74
+
75
+ &:checked + label::after {
76
+ left: $paddle-active-offest;
77
+ }
78
+
79
+ &.is-rtl:checked + label::after {
80
+ left: auto;
81
+ right: $switch-paddle-offset;
82
+ }
83
+
84
+ &.is-outlined {
85
+ + label {
86
+ &::before {
87
+ background-color: transparent;
88
+ border-color: $switch-background;
89
+ }
90
+
91
+ &::after {
92
+ background: $switch-background;
93
+ }
94
+ }
95
+
96
+ &:checked + label {
97
+ &::before {
98
+ background-color: transparent;
99
+ border-color: $switch-background-active;
100
+ }
101
+
102
+ &::after {
103
+ background: $switch-paddle-background-active;
104
+ }
105
+ }
106
+ }
107
+
108
+ &.is-thin {
109
+ + label {
110
+ &::before {
111
+ top: $switch-height * 0.25;
112
+ height: $switch-height * 0.5;
113
+ }
114
+ }
115
+ }
116
+
117
+ &.is-rounded {
118
+ + label {
119
+ &::before {
120
+ border-radius: $switch-height * 0.5;
121
+ }
122
+
123
+ &::after {
124
+ border-radius: 50%;
125
+ }
126
+ }
127
+ }
128
+ }
129
+
130
+ .switch[type="checkbox"].bbr-switch {
131
+ outline: 0;
132
+ user-select: none;
133
+ display: inline-block;
134
+ position: absolute;
135
+ opacity: 0;
136
+
137
+ &:focus + label::before {
138
+ outline: $switch-focus;
139
+ }
140
+
141
+ &[disabled] {
142
+ cursor: not-allowed;
143
+
144
+ + label {
145
+ opacity: 0.5;
146
+
147
+ &::before {
148
+ opacity: 0.5;
149
+ }
150
+
151
+ &::after {
152
+ opacity: 0.5;
153
+ }
154
+
155
+ &:hover {
156
+ cursor: not-allowed;
157
+ }
158
+ }
159
+ }
160
+
161
+ &:checked + label::before {
162
+ background: $switch-background-active;
163
+ }
164
+
165
+ // Size variations
166
+ @include switch-size($size-normal);
167
+
168
+ &.is-small {
169
+ @include switch-size($size-small);
170
+ }
171
+
172
+ &.is-medium {
173
+ @include switch-size($size-medium);
174
+ }
175
+
176
+ &.is-large {
177
+ @include switch-size($size-large);
178
+ }
179
+
180
+ // Color variations
181
+ @each $name, $pair in $colors {
182
+ $color: nth($pair, 1);
183
+ $color-invert: nth($pair, 2);
184
+
185
+ &.is-#{$name} {
186
+ &:checked + label::before {
187
+ background: $color;
188
+ }
189
+
190
+ &.is-outlined {
191
+ &:checked + label {
192
+ &::before {
193
+ background-color: transparent;
194
+ border-color: $color !important;
195
+ }
196
+
197
+ &::after {
198
+ background: $color;
199
+ }
200
+ }
201
+ }
202
+
203
+ &.is-thin {
204
+ &.is-outlined {
205
+ &:checked + label {
206
+ &::after {
207
+ box-shadow: none;
208
+ }
209
+ }
210
+ }
211
+ }
212
+ }
213
+ }
214
+ }
@@ -0,0 +1,3 @@
1
+ export { default } from "./component";
2
+ export * from "./types";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/primitives/switch/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,cAAc,SAAS,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { default } from "./component";
2
+ export * from "./types";
@@ -0,0 +1,23 @@
1
+ import { BaseNotNullableInputElementProps, LabelConfiguration } from "../../../types";
2
+ /** Switch/Toggle component props type */
3
+ export type SwitchProps = Omit<BaseNotNullableInputElementProps<boolean>, "readonly" | "validationState" | "loading" | "placeholder" | "hint" | "autofocus" | "label"> & {
4
+ /** Label configuration */
5
+ label?: Omit<LabelConfiguration, "horizontal"> & Partial<Pick<LabelConfiguration, "horizontal">>;
6
+ /** Display switch with rounded edges (pill-shaped) */
7
+ rounded?: boolean;
8
+ /** Display switch with outlined style */
9
+ outlined?: boolean;
10
+ /** Display switch as thin variant */
11
+ thin?: boolean;
12
+ /**
13
+ * Right-to-left mode.
14
+ * Switch will be displayed on the right side of the label
15
+ */
16
+ rtl?: boolean;
17
+ /**
18
+ * Display component with label as form element.
19
+ * Label will be placed at left
20
+ */
21
+ isFormLabel?: boolean;
22
+ };
23
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/primitives/switch/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gCAAgC,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAElF,yCAAyC;AACzC,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,gCAAgC,CAAC,OAAO,CAAC,EAClE,UAAU,GAAG,iBAAiB,GAC9B,SAAS,GAAG,aAAa,GACzB,MAAM,GAAG,WAAW,GACpB,OAAO,CACZ,GAAG;IACA,0BAA0B;IAC1B,KAAK,CAAC,EAAE,IAAI,CAAC,kBAAkB,EAAE,YAAY,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,kBAAkB,EAAE,YAAY,CAAC,CAAC,CAAC;IAEjG,sDAAsD;IACtD,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,yCAAyC;IACzC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,qCAAqC;IACrC,IAAI,CAAC,EAAE,OAAO,CAAC;IAEf;;;OAGG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC;IAEd;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC"}
@@ -0,0 +1 @@
1
+ export {};