mtrl 0.2.5 → 0.2.7
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/index.ts +18 -0
- package/package.json +1 -1
- package/src/components/badge/_styles.scss +123 -115
- package/src/components/badge/api.ts +57 -59
- package/src/components/badge/badge.ts +16 -2
- package/src/components/badge/config.ts +65 -11
- package/src/components/badge/constants.ts +22 -12
- package/src/components/badge/features.ts +44 -40
- package/src/components/badge/types.ts +42 -30
- package/src/components/bottom-app-bar/_styles.scss +103 -0
- package/src/components/bottom-app-bar/bottom-app-bar.ts +196 -0
- package/src/components/bottom-app-bar/config.ts +73 -0
- package/src/components/bottom-app-bar/index.ts +11 -0
- package/src/components/bottom-app-bar/types.ts +108 -0
- package/src/components/button/_styles.scss +0 -66
- package/src/components/button/api.ts +5 -0
- package/src/components/button/button.ts +0 -2
- package/src/components/button/config.ts +5 -0
- package/src/components/button/constants.ts +0 -6
- package/src/components/button/index.ts +2 -2
- package/src/components/button/types.ts +7 -7
- package/src/components/card/_styles.scss +67 -25
- package/src/components/card/api.ts +54 -3
- package/src/components/card/card.ts +25 -6
- package/src/components/card/config.ts +189 -22
- package/src/components/card/constants.ts +20 -19
- package/src/components/card/content.ts +299 -2
- package/src/components/card/features.ts +158 -4
- package/src/components/card/index.ts +31 -9
- package/src/components/card/types.ts +166 -15
- package/src/components/checkbox/_styles.scss +0 -2
- package/src/components/chip/chip.ts +1 -9
- package/src/components/chip/constants.ts +0 -10
- package/src/components/chip/index.ts +1 -1
- package/src/components/chip/types.ts +1 -4
- package/src/components/datepicker/_styles.scss +358 -0
- package/src/components/datepicker/api.ts +272 -0
- package/src/components/datepicker/config.ts +144 -0
- package/src/components/datepicker/constants.ts +98 -0
- package/src/components/datepicker/datepicker.ts +346 -0
- package/src/components/datepicker/index.ts +9 -0
- package/src/components/datepicker/render.ts +452 -0
- package/src/components/datepicker/types.ts +268 -0
- package/src/components/datepicker/utils.ts +290 -0
- package/src/components/dialog/_styles.scss +174 -128
- package/src/components/dialog/api.ts +48 -13
- package/src/components/dialog/config.ts +9 -5
- package/src/components/dialog/dialog.ts +6 -3
- package/src/components/dialog/features.ts +290 -130
- package/src/components/dialog/types.ts +7 -4
- package/src/components/divider/_styles.scss +57 -0
- package/src/components/divider/config.ts +81 -0
- package/src/components/divider/divider.ts +37 -0
- package/src/components/divider/features.ts +207 -0
- package/src/components/divider/index.ts +5 -0
- package/src/components/divider/types.ts +55 -0
- package/src/components/extended-fab/_styles.scss +267 -0
- package/src/components/extended-fab/api.ts +141 -0
- package/src/components/extended-fab/config.ts +108 -0
- package/src/components/extended-fab/constants.ts +36 -0
- package/src/components/extended-fab/extended-fab.ts +125 -0
- package/src/components/extended-fab/index.ts +4 -0
- package/src/components/extended-fab/types.ts +287 -0
- package/src/components/fab/_styles.scss +225 -0
- package/src/components/fab/api.ts +97 -0
- package/src/components/fab/config.ts +94 -0
- package/src/components/fab/constants.ts +41 -0
- package/src/components/fab/fab.ts +67 -0
- package/src/components/fab/index.ts +4 -0
- package/src/components/fab/types.ts +234 -0
- package/src/components/navigation/_styles.scss +1 -0
- package/src/components/navigation/api.ts +78 -50
- package/src/components/navigation/features/items.ts +280 -0
- package/src/components/navigation/nav-item.ts +72 -23
- package/src/components/navigation/navigation.ts +54 -2
- package/src/components/navigation/types.ts +210 -188
- package/src/components/progress/_styles.scss +0 -65
- package/src/components/progress/config.ts +1 -2
- package/src/components/progress/constants.ts +0 -14
- package/src/components/progress/index.ts +1 -1
- package/src/components/progress/progress.ts +1 -4
- package/src/components/progress/types.ts +1 -4
- package/src/components/radios/_styles.scss +0 -45
- package/src/components/radios/api.ts +85 -60
- package/src/components/radios/config.ts +1 -2
- package/src/components/radios/constants.ts +0 -9
- package/src/components/radios/index.ts +1 -1
- package/src/components/radios/radio.ts +34 -11
- package/src/components/radios/radios.ts +2 -1
- package/src/components/radios/types.ts +1 -7
- package/src/components/search/_styles.scss +306 -0
- package/src/components/search/api.ts +203 -0
- package/src/components/search/config.ts +87 -0
- package/src/components/search/constants.ts +21 -0
- package/src/components/search/features/index.ts +4 -0
- package/src/components/search/features/search.ts +718 -0
- package/src/components/search/features/states.ts +165 -0
- package/src/components/search/features/structure.ts +198 -0
- package/src/components/search/index.ts +10 -0
- package/src/components/search/search.ts +52 -0
- package/src/components/search/types.ts +163 -0
- package/src/components/segmented-button/_styles.scss +117 -0
- package/src/components/segmented-button/config.ts +67 -0
- package/src/components/segmented-button/constants.ts +42 -0
- package/src/components/segmented-button/index.ts +4 -0
- package/src/components/segmented-button/segment.ts +155 -0
- package/src/components/segmented-button/segmented-button.ts +250 -0
- package/src/components/segmented-button/types.ts +219 -0
- package/src/components/slider/_styles.scss +221 -168
- package/src/components/slider/accessibility.md +59 -0
- package/src/components/slider/api.ts +41 -120
- package/src/components/slider/config.ts +51 -49
- package/src/components/slider/features/handlers.ts +495 -0
- package/src/components/slider/features/index.ts +1 -2
- package/src/components/slider/features/slider.ts +66 -84
- package/src/components/slider/features/states.ts +195 -0
- package/src/components/slider/features/structure.ts +141 -184
- package/src/components/slider/features/ui.ts +150 -201
- package/src/components/slider/index.ts +2 -11
- package/src/components/slider/slider.ts +9 -12
- package/src/components/slider/types.ts +39 -24
- package/src/components/switch/_styles.scss +0 -2
- package/src/components/tabs/_styles.scss +346 -154
- package/src/components/tabs/api.ts +178 -400
- package/src/components/tabs/config.ts +46 -52
- package/src/components/tabs/constants.ts +85 -8
- package/src/components/tabs/features.ts +403 -0
- package/src/components/tabs/index.ts +60 -3
- package/src/components/tabs/indicator.ts +285 -0
- package/src/components/tabs/responsive.ts +144 -0
- package/src/components/tabs/scroll-indicators.ts +149 -0
- package/src/components/tabs/state.ts +186 -0
- package/src/components/tabs/tab-api.ts +258 -0
- package/src/components/tabs/tab.ts +255 -0
- package/src/components/tabs/tabs.ts +50 -31
- package/src/components/tabs/types.ts +332 -128
- package/src/components/tabs/utils.ts +107 -0
- package/src/components/textfield/_styles.scss +0 -98
- package/src/components/textfield/config.ts +2 -3
- package/src/components/textfield/constants.ts +0 -14
- package/src/components/textfield/index.ts +2 -2
- package/src/components/textfield/textfield.ts +0 -2
- package/src/components/textfield/types.ts +1 -4
- package/src/components/timepicker/README.md +277 -0
- package/src/components/timepicker/_styles.scss +451 -0
- package/src/components/timepicker/api.ts +632 -0
- package/src/components/timepicker/clockdial.ts +482 -0
- package/src/components/timepicker/config.ts +130 -0
- package/src/components/timepicker/constants.ts +138 -0
- package/src/components/timepicker/index.ts +8 -0
- package/src/components/timepicker/render.ts +613 -0
- package/src/components/timepicker/timepicker.ts +117 -0
- package/src/components/timepicker/types.ts +336 -0
- package/src/components/timepicker/utils.ts +241 -0
- package/src/components/top-app-bar/_styles.scss +225 -0
- package/src/components/top-app-bar/config.ts +83 -0
- package/src/components/top-app-bar/index.ts +11 -0
- package/src/components/top-app-bar/top-app-bar.ts +316 -0
- package/src/components/top-app-bar/types.ts +140 -0
- package/src/core/build/_ripple.scss +6 -6
- package/src/core/build/ripple.ts +72 -95
- package/src/core/compose/component.ts +1 -1
- package/src/core/compose/features/badge.ts +79 -0
- package/src/core/compose/features/icon.ts +3 -1
- package/src/core/compose/features/index.ts +3 -1
- package/src/core/compose/features/ripple.ts +4 -1
- package/src/core/compose/features/textlabel.ts +26 -2
- package/src/core/dom/create.ts +5 -0
- package/src/index.ts +9 -0
- package/src/styles/abstract/_theme.scss +115 -3
- package/src/styles/themes/_autumn.scss +21 -0
- package/src/styles/themes/_base-theme.scss +61 -0
- package/src/styles/themes/_baseline.scss +58 -0
- package/src/styles/themes/_bluekhaki.scss +125 -0
- package/src/styles/themes/_brownbeige.scss +125 -0
- package/src/styles/themes/_browngreen.scss +125 -0
- package/src/styles/themes/_forest.scss +6 -0
- package/src/styles/themes/_greenbeige.scss +125 -0
- package/src/styles/themes/_material.scss +125 -0
- package/src/styles/themes/_ocean.scss +6 -0
- package/src/styles/themes/_sageivory.scss +125 -0
- package/src/styles/themes/_spring.scss +6 -0
- package/src/styles/themes/_summer.scss +5 -0
- package/src/styles/themes/_sunset.scss +5 -0
- package/src/styles/themes/_tealcaramel.scss +125 -0
- package/src/styles/themes/_winter.scss +6 -0
- package/src/components/card/actions.ts +0 -48
- package/src/components/card/header.ts +0 -88
- package/src/components/card/media.ts +0 -52
- package/src/components/navigation/features/items.js +0 -192
- package/src/components/slider/features/appearance.ts +0 -94
- package/src/components/slider/features/disabled.ts +0 -43
- package/src/components/slider/features/events.ts +0 -164
- package/src/components/slider/features/interactions.ts +0 -261
- package/src/components/slider/features/keyboard.ts +0 -112
- package/src/core/collection/adapters/mongodb.js +0 -232
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
// src/components/slider/features/structure.ts
|
|
2
2
|
import { SLIDER_COLORS, SLIDER_SIZES } from '../constants';
|
|
3
3
|
import { SliderConfig } from '../types';
|
|
4
|
+
import createLayout from '../../../core/layout';
|
|
5
|
+
import { createElement } from '../../../core/dom/create';
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
|
-
* Creates the slider DOM structure
|
|
8
|
+
* Creates the slider DOM structure using layout system
|
|
7
9
|
* @param config Slider configuration
|
|
8
10
|
* @returns Component enhancer with DOM structure
|
|
9
11
|
*/
|
|
@@ -11,214 +13,169 @@ export const withStructure = (config: SliderConfig) => component => {
|
|
|
11
13
|
// Set default values
|
|
12
14
|
const min = config.min || 0;
|
|
13
15
|
const max = config.max || 100;
|
|
14
|
-
const range = max - min;
|
|
15
16
|
const value = config.value !== undefined ? config.value : min;
|
|
16
17
|
const secondValue = config.secondValue !== undefined ? config.secondValue : null;
|
|
17
18
|
const isRangeSlider = config.range && secondValue !== null;
|
|
19
|
+
const isDisabled = config.disabled === true;
|
|
18
20
|
|
|
19
|
-
//
|
|
20
|
-
const getPercentage = (val) => ((val - min) / range) * 100;
|
|
21
|
-
const valuePercent = getPercentage(value);
|
|
22
|
-
|
|
23
|
-
// Create track element and segments
|
|
24
|
-
const track = createElement('slider-track');
|
|
25
|
-
const remainingTrack = createElement('slider-remaining-track');
|
|
26
|
-
const startTrack = createElement('slider-start-track');
|
|
27
|
-
const activeTrack = createElement('slider-active-track');
|
|
28
|
-
|
|
29
|
-
// Create ticks container
|
|
30
|
-
const ticksContainer = createElement('slider-ticks-container');
|
|
31
|
-
|
|
32
|
-
// Create dots for track ends
|
|
33
|
-
const startDot = createElement('slider-dot');
|
|
34
|
-
startDot.classList.add(component.getClass('slider-dot--start'));
|
|
35
|
-
|
|
36
|
-
const endDot = createElement('slider-dot');
|
|
37
|
-
endDot.classList.add(component.getClass('slider-dot--end'));
|
|
38
|
-
|
|
39
|
-
// Create value bubble and format the value
|
|
21
|
+
// Format the values
|
|
40
22
|
const formatter = config.valueFormatter || (val => val.toString());
|
|
41
|
-
const valueBubble = createElement('slider-value');
|
|
42
|
-
valueBubble.textContent = formatter(value);
|
|
43
|
-
|
|
44
|
-
// Create thumb element
|
|
45
|
-
const thumb = createElement('slider-thumb');
|
|
46
|
-
thumb.setAttribute('tabindex', '0');
|
|
47
|
-
thumb.setAttribute('role', 'slider');
|
|
48
|
-
|
|
49
|
-
// Set initial thumb position
|
|
50
|
-
thumb.style.left = `${valuePercent}%`;
|
|
51
|
-
|
|
52
|
-
// Calculate padding adjustment (8px equivalent as percentage)
|
|
53
|
-
const paddingAdjustment = 8; // 8px padding
|
|
54
|
-
const estimatedTrackSize = 300; // A reasonable guess at track width
|
|
55
|
-
const paddingPercent = (paddingAdjustment / estimatedTrackSize) * 100;
|
|
56
|
-
|
|
57
|
-
// Create second thumb and value bubble for range slider
|
|
58
|
-
let secondThumb = null;
|
|
59
|
-
let secondValueBubble = null;
|
|
60
23
|
|
|
24
|
+
// Get prefixed class names
|
|
25
|
+
const getClass = (className) => component.getClass(className);
|
|
26
|
+
|
|
27
|
+
// Define slider structure
|
|
28
|
+
const structure = [
|
|
29
|
+
[createElement, 'container', {
|
|
30
|
+
className: getClass('slider-container')
|
|
31
|
+
}, [
|
|
32
|
+
// Track with segments
|
|
33
|
+
[createElement, 'track', {
|
|
34
|
+
className: getClass('slider-track')
|
|
35
|
+
}, [
|
|
36
|
+
[createElement, 'startTrack', {
|
|
37
|
+
className: getClass('slider-start-track')
|
|
38
|
+
}],
|
|
39
|
+
[createElement, 'activeTrack', {
|
|
40
|
+
className: getClass('slider-active-track')
|
|
41
|
+
}],
|
|
42
|
+
[createElement, 'remainingTrack', {
|
|
43
|
+
className: getClass('slider-remaining-track')
|
|
44
|
+
}]
|
|
45
|
+
]],
|
|
46
|
+
|
|
47
|
+
// Ticks container
|
|
48
|
+
[createElement, 'ticksContainer', {
|
|
49
|
+
className: getClass('slider-ticks-container')
|
|
50
|
+
}],
|
|
51
|
+
|
|
52
|
+
// Dots for ends
|
|
53
|
+
[createElement, 'startDot', {
|
|
54
|
+
className: [
|
|
55
|
+
getClass('slider-dot'),
|
|
56
|
+
getClass('slider-dot--start')
|
|
57
|
+
]
|
|
58
|
+
}],
|
|
59
|
+
[createElement, 'endDot', {
|
|
60
|
+
className: [
|
|
61
|
+
getClass('slider-dot'),
|
|
62
|
+
getClass('slider-dot--end')
|
|
63
|
+
]
|
|
64
|
+
}],
|
|
65
|
+
|
|
66
|
+
// Main handle
|
|
67
|
+
[createElement, 'handle', {
|
|
68
|
+
className: getClass('slider-handle'),
|
|
69
|
+
attrs: {
|
|
70
|
+
'role': 'slider',
|
|
71
|
+
'aria-valuemin': String(min),
|
|
72
|
+
'aria-valuemax': String(max),
|
|
73
|
+
'aria-valuenow': String(value),
|
|
74
|
+
'aria-orientation': 'horizontal',
|
|
75
|
+
'tabindex': isDisabled ? '-1' : '0',
|
|
76
|
+
'aria-disabled': isDisabled ? 'true' : 'false'
|
|
77
|
+
},
|
|
78
|
+
style: {
|
|
79
|
+
left: `${((value - min) / (max - min)) * 100}%`
|
|
80
|
+
}
|
|
81
|
+
}],
|
|
82
|
+
|
|
83
|
+
// Main value bubble
|
|
84
|
+
[createElement, 'valueBubble', {
|
|
85
|
+
className: getClass('slider-value'),
|
|
86
|
+
text: formatter(value)
|
|
87
|
+
}]
|
|
88
|
+
]]
|
|
89
|
+
];
|
|
90
|
+
|
|
91
|
+
// Add second handle and bubble for range slider
|
|
61
92
|
if (isRangeSlider) {
|
|
62
|
-
|
|
63
|
-
secondThumb.setAttribute('tabindex', '0');
|
|
64
|
-
secondThumb.setAttribute('role', 'slider');
|
|
93
|
+
const secondHandlePos = ((secondValue - min) / (max - min)) * 100;
|
|
65
94
|
|
|
66
|
-
|
|
67
|
-
|
|
95
|
+
// Add second handle to structure
|
|
96
|
+
structure[0][3].push(
|
|
97
|
+
[createElement, 'secondHandle', {
|
|
98
|
+
className: getClass('slider-handle'),
|
|
99
|
+
attrs: {
|
|
100
|
+
'role': 'slider',
|
|
101
|
+
'aria-valuemin': String(min),
|
|
102
|
+
'aria-valuemax': String(max),
|
|
103
|
+
'aria-valuenow': String(secondValue),
|
|
104
|
+
'aria-orientation': 'horizontal',
|
|
105
|
+
'tabindex': isDisabled ? '-1' : '0',
|
|
106
|
+
'aria-disabled': isDisabled ? 'true' : 'false'
|
|
107
|
+
},
|
|
108
|
+
style: {
|
|
109
|
+
left: `${secondHandlePos}%`
|
|
110
|
+
}
|
|
111
|
+
}]
|
|
112
|
+
);
|
|
68
113
|
|
|
69
|
-
|
|
70
|
-
|
|
114
|
+
// Add second bubble to structure
|
|
115
|
+
structure[0][3].push(
|
|
116
|
+
[createElement, 'secondValueBubble', {
|
|
117
|
+
className: getClass('slider-value'),
|
|
118
|
+
text: formatter(secondValue)
|
|
119
|
+
}]
|
|
120
|
+
);
|
|
71
121
|
}
|
|
72
122
|
|
|
73
|
-
//
|
|
74
|
-
|
|
123
|
+
// Create layout and get structure elements
|
|
124
|
+
const components = createLayout(structure, component.element).component;
|
|
75
125
|
|
|
76
|
-
// Add
|
|
77
|
-
track.appendChild(remainingTrack);
|
|
78
|
-
track.appendChild(startTrack);
|
|
79
|
-
track.appendChild(activeTrack);
|
|
80
|
-
|
|
81
|
-
// Add elements to the slider
|
|
126
|
+
// Add component base class and accessibility attributes
|
|
82
127
|
component.element.classList.add(component.getClass('slider'));
|
|
83
|
-
component.element.
|
|
84
|
-
component.element.
|
|
85
|
-
component.element.
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
component.element.
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
component.element.classList.add(
|
|
92
|
-
component.element.appendChild(secondThumb);
|
|
93
|
-
component.element.appendChild(secondValueBubble);
|
|
128
|
+
component.element.setAttribute('tabindex', '-1');
|
|
129
|
+
component.element.setAttribute('role', 'none');
|
|
130
|
+
component.element.setAttribute('aria-disabled', isDisabled ? 'true' : 'false');
|
|
131
|
+
|
|
132
|
+
// Position any icon properly
|
|
133
|
+
const iconElement = component.element.querySelector(`.${component.getClass('icon')}`);
|
|
134
|
+
if (iconElement && config.label) {
|
|
135
|
+
iconElement.classList.add(component.getClass('slider-icon'));
|
|
136
|
+
component.element.classList.add(component.getClass('slider--icon'));
|
|
94
137
|
}
|
|
95
138
|
|
|
96
|
-
// Apply
|
|
97
|
-
applyStyleClasses();
|
|
98
|
-
|
|
99
|
-
// Schedule UI update after DOM is attached
|
|
100
|
-
setTimeout(() => {
|
|
101
|
-
component.slider?.updateUi?.();
|
|
102
|
-
}, 0);
|
|
139
|
+
// Apply style classes
|
|
140
|
+
applyStyleClasses(component, config, isRangeSlider, isDisabled);
|
|
103
141
|
|
|
104
142
|
// Return enhanced component with structure
|
|
105
143
|
return {
|
|
106
144
|
...component,
|
|
107
|
-
structure:
|
|
108
|
-
track,
|
|
109
|
-
activeTrack,
|
|
110
|
-
startTrack,
|
|
111
|
-
remainingTrack,
|
|
112
|
-
ticksContainer,
|
|
113
|
-
thumb,
|
|
114
|
-
valueBubble,
|
|
115
|
-
secondThumb,
|
|
116
|
-
secondValueBubble,
|
|
117
|
-
startDot,
|
|
118
|
-
endDot
|
|
119
|
-
}
|
|
145
|
+
structure: components
|
|
120
146
|
};
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Applies style classes based on configuration
|
|
151
|
+
*/
|
|
152
|
+
function applyStyleClasses(component, config, isRangeSlider, isDisabled) {
|
|
153
|
+
const baseClass = component.getClass('slider');
|
|
121
154
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
*/
|
|
127
|
-
function createElement(className) {
|
|
128
|
-
const element = document.createElement('div');
|
|
129
|
-
element.classList.add(component.getClass(className));
|
|
130
|
-
return element;
|
|
155
|
+
// Apply size class
|
|
156
|
+
const size = config.size || SLIDER_SIZES.MEDIUM;
|
|
157
|
+
if (size !== SLIDER_SIZES.MEDIUM) {
|
|
158
|
+
component.element.classList.add(`${baseClass}--${size}`);
|
|
131
159
|
}
|
|
132
160
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
if (isRangeSlider) {
|
|
138
|
-
// Range slider with two thumbs
|
|
139
|
-
const lowerValue = Math.min(value, secondValue);
|
|
140
|
-
const higherValue = Math.max(value, secondValue);
|
|
141
|
-
const lowerPercent = getPercentage(lowerValue);
|
|
142
|
-
const higherPercent = getPercentage(higherValue);
|
|
143
|
-
|
|
144
|
-
// Adjust positions to account for spacing
|
|
145
|
-
let adjustedLowerPercent = lowerPercent + paddingPercent;
|
|
146
|
-
let adjustedHigherPercent = higherPercent - paddingPercent;
|
|
147
|
-
|
|
148
|
-
// Handle case when thumbs are very close
|
|
149
|
-
if (adjustedHigherPercent <= adjustedLowerPercent) {
|
|
150
|
-
adjustedLowerPercent = (lowerPercent + higherPercent) / 2 - 1;
|
|
151
|
-
adjustedHigherPercent = (lowerPercent + higherPercent) / 2 + 1;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// Calculate segment sizes
|
|
155
|
-
const startWidth = Math.max(0, lowerPercent - paddingPercent);
|
|
156
|
-
const activeWidth = Math.max(0, adjustedHigherPercent - adjustedLowerPercent);
|
|
157
|
-
const remainingWidth = Math.max(0, 100 - higherPercent - paddingPercent);
|
|
158
|
-
|
|
159
|
-
// Set styles
|
|
160
|
-
startTrack.style.display = 'block';
|
|
161
|
-
activeTrack.style.display = 'block';
|
|
162
|
-
remainingTrack.style.display = 'block';
|
|
163
|
-
|
|
164
|
-
// Horizontal orientation
|
|
165
|
-
setTrackStyles(startTrack, startWidth, 0);
|
|
166
|
-
setTrackStyles(activeTrack, activeWidth, adjustedLowerPercent);
|
|
167
|
-
setTrackStyles(remainingTrack, remainingWidth, higherPercent + paddingPercent);
|
|
168
|
-
} else {
|
|
169
|
-
// Single thumb slider
|
|
170
|
-
const adjustedWidth = Math.max(0, valuePercent - paddingPercent);
|
|
171
|
-
const remainingWidth = Math.max(0, 100 - valuePercent - paddingPercent);
|
|
172
|
-
|
|
173
|
-
// Hide start track for single thumb
|
|
174
|
-
startTrack.style.display = 'none';
|
|
175
|
-
activeTrack.style.display = 'block';
|
|
176
|
-
remainingTrack.style.display = 'block';
|
|
177
|
-
|
|
178
|
-
// Horizontal orientation
|
|
179
|
-
setTrackStyles(activeTrack, adjustedWidth, 0);
|
|
180
|
-
setTrackStyles(remainingTrack, remainingWidth, valuePercent + paddingPercent);
|
|
181
|
-
}
|
|
161
|
+
// Apply color class
|
|
162
|
+
const color = config.color || SLIDER_COLORS.PRIMARY;
|
|
163
|
+
if (color !== SLIDER_COLORS.PRIMARY) {
|
|
164
|
+
component.element.classList.add(`${baseClass}--${color}`);
|
|
182
165
|
}
|
|
183
166
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
* @param width Width as percentage
|
|
188
|
-
* @param left Left position as percentage
|
|
189
|
-
*/
|
|
190
|
-
function setTrackStyles(element, width, left) {
|
|
191
|
-
element.style.width = `${width}%`;
|
|
192
|
-
element.style.left = `${left}%`;
|
|
193
|
-
element.style.height = '100%';
|
|
167
|
+
// Apply discrete class if step is specified
|
|
168
|
+
if (config.step !== undefined && config.step > 0) {
|
|
169
|
+
component.element.classList.add(`${baseClass}--discrete`);
|
|
194
170
|
}
|
|
195
171
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
if (size !== SLIDER_SIZES.MEDIUM) {
|
|
205
|
-
component.element.classList.add(`${baseClass}--${size}`);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
// Apply color class
|
|
209
|
-
const color = config.color || SLIDER_COLORS.PRIMARY;
|
|
210
|
-
if (color !== SLIDER_COLORS.PRIMARY) {
|
|
211
|
-
component.element.classList.add(`${baseClass}--${color}`);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
// Apply discrete class if step is specified
|
|
215
|
-
if (config.step !== undefined && config.step > 0) {
|
|
216
|
-
component.element.classList.add(`${baseClass}--discrete`);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
// Apply disabled class if needed
|
|
220
|
-
if (config.disabled) {
|
|
221
|
-
component.element.classList.add(`${baseClass}--disabled`);
|
|
222
|
-
}
|
|
172
|
+
// Apply disabled class if needed
|
|
173
|
+
if (isDisabled) {
|
|
174
|
+
component.element.classList.add(`${baseClass}--disabled`);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// Apply range class if needed
|
|
178
|
+
if (isRangeSlider) {
|
|
179
|
+
component.element.classList.add(`${baseClass}--range`);
|
|
223
180
|
}
|
|
224
|
-
}
|
|
181
|
+
}
|