@sebgroup/green-core 1.15.0 → 1.16.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.
- package/README.md +101 -7
- package/chunks/chunk.274BU2AI.js +244 -0
- package/chunks/chunk.2LQSDOD4.js +29 -0
- package/chunks/chunk.2ND5EWHE.js +65 -0
- package/chunks/chunk.2OOTOCUG.js +420 -0
- package/chunks/chunk.2WO4NHJ2.js +34 -0
- package/chunks/chunk.2Y3BHFKO.js +154 -0
- package/chunks/chunk.375BWME4.js +29 -0
- package/chunks/chunk.3SEVAGLE.js +96 -0
- package/chunks/chunk.522C22QY.js +460 -0
- package/chunks/chunk.5VURDMKE.js +75 -0
- package/chunks/chunk.6NM7ENKA.js +31 -0
- package/chunks/chunk.6UA66KQU.js +153 -0
- package/chunks/chunk.7P5N6NZL.js +560 -0
- package/chunks/chunk.7TCXY7BP.js +0 -0
- package/chunks/chunk.D7H7CUS4.js +55 -0
- package/chunks/chunk.DFYMYEGD.js +78 -0
- package/chunks/chunk.HS7ICQNA.js +0 -0
- package/chunks/chunk.IYCENQZG.js +28 -0
- package/chunks/chunk.J2A6J77W.js +81 -0
- package/chunks/chunk.KC32OWZE.js +274 -0
- package/chunks/chunk.KV4SDMFS.js +101 -0
- package/chunks/chunk.LUHCF4BJ.js +64 -0
- package/chunks/chunk.MAD5DQMN.js +161 -0
- package/chunks/chunk.MI4A2C2A.js +0 -0
- package/chunks/chunk.NOYHINYP.js +467 -0
- package/chunks/chunk.Q2T57HE7.js +0 -0
- package/chunks/chunk.QONSFT2N.js +4653 -0
- package/chunks/chunk.TMBQL2RO.js +0 -0
- package/chunks/chunk.TN6ZYAH3.js +74 -0
- package/chunks/chunk.TSDZQZBY.js +0 -0
- package/chunks/chunk.TX64TTBN.js +0 -0
- package/chunks/chunk.UF6IEONX.js +0 -0
- package/chunks/chunk.VOYMQ322.js +61 -0
- package/chunks/chunk.VYK7D6QO.js +64 -0
- package/chunks/chunk.WDZ2JTCP.js +360 -0
- package/chunks/chunk.WJDR7FTS.js +193 -0
- package/chunks/chunk.WM7HBMMV.js +54 -0
- package/chunks/chunk.XHTJVQUJ.js +140 -0
- package/chunks/chunk.XI4H54TV.js +39 -0
- package/chunks/chunk.XU4HZLJL.js +0 -0
- package/chunks/chunk.YIQIH4RW.js +139 -0
- package/chunks/chunk.YJHAKLGR.js +54 -0
- package/chunks/chunk.YO24ZYAD.js +0 -0
- package/chunks/chunk.ZTE73BY2.js +655 -0
- package/components/badge/badge.js +245 -0
- package/components/button/button.d.ts +5 -5
- package/components/button/button.js +18 -0
- package/components/button/button.trans.styles.d.ts +2 -0
- package/components/button/index.d.ts +1 -0
- package/components/button/index.js +18 -0
- package/components/checkbox/checkbox.js +219 -0
- package/components/context-menu/context-menu.d.ts +2 -1
- package/components/context-menu/context-menu.js +22 -0
- package/components/context-menu/index.d.ts +3 -0
- package/components/context-menu/index.js +29 -0
- package/components/datepicker/date-part-spinner.js +10 -0
- package/components/datepicker/datepicker.d.ts +3 -2
- package/components/datepicker/datepicker.js +29 -0
- package/components/datepicker/index.d.ts +1 -0
- package/components/datepicker/index.js +29 -0
- package/components/dropdown/dropdown.d.ts +2 -2
- package/components/dropdown/dropdown.js +22 -0
- package/components/dropdown/index.d.ts +3 -0
- package/components/dropdown/index.js +30 -0
- package/components/form-control.js +12 -0
- package/components/grid/grid.d.ts +2 -2
- package/components/grid/grid.js +11 -0
- package/components/grid/grid.style.css.js +7 -0
- package/components/grid/index.d.ts +1 -0
- package/components/grid/index.js +11 -0
- package/components/grouped-list/grouped-list.js +14 -0
- package/components/grouped-list/index.d.ts +2 -0
- package/components/grouped-list/index.js +17 -0
- package/components/grouped-list/list-item.js +10 -0
- package/components/icon/icon.d.ts +2 -2
- package/components/icon/icon.js +10 -0
- package/components/icon/index.d.ts +1 -0
- package/components/icon/index.js +10 -0
- package/components/index.d.ts +4 -3
- package/components/index.js +81 -0
- package/components/input/input.js +682 -0
- package/components/radio/radio-group.js +9 -0
- package/components/radio/radio.js +240 -0
- package/components/segmented-control/index.d.ts +1 -0
- package/components/segmented-control/index.js +15 -0
- package/components/segmented-control/segment/index.d.ts +1 -0
- package/components/segmented-control/segment/index.js +13 -0
- package/components/segmented-control/segment/segment.js +12 -0
- package/components/segmented-control/segmented-control.d.ts +1 -1
- package/components/segmented-control/segmented-control.js +15 -0
- package/components/switch/switch.js +164 -0
- package/components/theme/index.d.ts +1 -0
- package/components/theme/index.js +11 -0
- package/components/theme/theme.js +11 -0
- package/components/tooltip/tooltip.js +252 -0
- package/index.js +72 -4278
- package/localization.js +40 -44
- package/package.json +7 -16
- package/primitives/calendar/calendar.js +13 -0
- package/primitives/calendar/functions.js +7 -0
- package/primitives/calendar/index.d.ts +1 -0
- package/primitives/calendar/index.js +14 -0
- package/primitives/listbox/index.d.ts +0 -1
- package/primitives/listbox/index.js +17 -0
- package/primitives/listbox/listbox.d.ts +2 -1
- package/primitives/listbox/listbox.js +16 -0
- package/primitives/listbox/option.js +14 -0
- package/primitives/menu/index.d.ts +1 -0
- package/primitives/menu/index.js +15 -0
- package/primitives/menu/menu-heading.js +11 -0
- package/primitives/menu/menu-item.d.ts +1 -2
- package/primitives/menu/menu-item.js +12 -0
- package/primitives/menu/menu.d.ts +2 -1
- package/primitives/menu/menu.js +14 -0
- package/primitives/popover/index.js +14 -0
- package/primitives/popover/popover.js +13 -0
- package/primitives/ripple/index.d.ts +1 -0
- package/primitives/ripple/index.js +11 -0
- package/primitives/ripple/ripple.d.ts +1 -1
- package/primitives/ripple/ripple.js +10 -0
- package/scoping.d.ts +1 -0
- package/scoping.js +18 -0
- package/transitional-styles.js +6 -4275
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import {
|
|
2
|
+
tokens
|
|
3
|
+
} from "./chunk.7P5N6NZL.js";
|
|
4
|
+
import {
|
|
5
|
+
TransitionalStyles
|
|
6
|
+
} from "./chunk.QONSFT2N.js";
|
|
7
|
+
import {
|
|
8
|
+
GdsElement
|
|
9
|
+
} from "./chunk.2LQSDOD4.js";
|
|
10
|
+
import {
|
|
11
|
+
gdsCustomElement,
|
|
12
|
+
html
|
|
13
|
+
} from "./chunk.VOYMQ322.js";
|
|
14
|
+
import {
|
|
15
|
+
__decorateClass
|
|
16
|
+
} from "./chunk.5VURDMKE.js";
|
|
17
|
+
|
|
18
|
+
// libs/core/src/components/segmented-control/segment/segment.ts
|
|
19
|
+
import { property } from "lit/decorators.js";
|
|
20
|
+
import { unsafeCSS } from "lit";
|
|
21
|
+
|
|
22
|
+
// libs/core/src/components/segmented-control/segment/segment.style.css
|
|
23
|
+
var segment_style_default = `:host {
|
|
24
|
+
display: flex;
|
|
25
|
+
transition: 0.2s;
|
|
26
|
+
z-index: 1;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
button {
|
|
30
|
+
-webkit-appearance: none;
|
|
31
|
+
-moz-appearance: none;
|
|
32
|
+
appearance: none;
|
|
33
|
+
background: transparent;
|
|
34
|
+
border-radius: calc(infinity * 1px);
|
|
35
|
+
border-width: 0;
|
|
36
|
+
color: var(--gds-sys-color-content-content);
|
|
37
|
+
cursor: pointer;
|
|
38
|
+
flex-grow: 1;
|
|
39
|
+
flex-shrink: 0;
|
|
40
|
+
font-family: inherit;
|
|
41
|
+
font-size: inherit;
|
|
42
|
+
overflow: hidden;
|
|
43
|
+
padding: 0 1rem;
|
|
44
|
+
text-align: center;
|
|
45
|
+
text-overflow: ellipsis;
|
|
46
|
+
white-space: nowrap;
|
|
47
|
+
width: 100%;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@media (pointer: fine) {
|
|
51
|
+
button:hover {
|
|
52
|
+
background-color: color-mix(
|
|
53
|
+
in srgb,
|
|
54
|
+
var(--gds-sys-color-state-layers-state-black-dim1),
|
|
55
|
+
transparent
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
button:focus-visible {
|
|
61
|
+
outline: 2px solid #000;
|
|
62
|
+
outline-offset: -2px;
|
|
63
|
+
}
|
|
64
|
+
`;
|
|
65
|
+
|
|
66
|
+
// libs/core/src/components/segmented-control/segment/segment.ts
|
|
67
|
+
var GdsSegment = class extends GdsElement {
|
|
68
|
+
constructor() {
|
|
69
|
+
super(...arguments);
|
|
70
|
+
this.selected = false;
|
|
71
|
+
}
|
|
72
|
+
connectedCallback() {
|
|
73
|
+
super.connectedCallback();
|
|
74
|
+
TransitionalStyles.instance.apply(this, "gds-segmented");
|
|
75
|
+
this.setAttribute("role", "listitem");
|
|
76
|
+
}
|
|
77
|
+
render() {
|
|
78
|
+
return html`<button aria-current=${String(this.selected)}>
|
|
79
|
+
<slot></slot>
|
|
80
|
+
</button>`;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
GdsSegment.styles = [...tokens, unsafeCSS(segment_style_default)];
|
|
84
|
+
__decorateClass([
|
|
85
|
+
property({ type: Boolean, reflect: true })
|
|
86
|
+
], GdsSegment.prototype, "selected", 2);
|
|
87
|
+
__decorateClass([
|
|
88
|
+
property()
|
|
89
|
+
], GdsSegment.prototype, "value", 2);
|
|
90
|
+
GdsSegment = __decorateClass([
|
|
91
|
+
gdsCustomElement("gds-segment")
|
|
92
|
+
], GdsSegment);
|
|
93
|
+
|
|
94
|
+
export {
|
|
95
|
+
GdsSegment
|
|
96
|
+
};
|
|
@@ -0,0 +1,460 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GdsSegment
|
|
3
|
+
} from "./chunk.3SEVAGLE.js";
|
|
4
|
+
import {
|
|
5
|
+
tokens
|
|
6
|
+
} from "./chunk.7P5N6NZL.js";
|
|
7
|
+
import {
|
|
8
|
+
TransitionalStyles
|
|
9
|
+
} from "./chunk.QONSFT2N.js";
|
|
10
|
+
import {
|
|
11
|
+
GdsElement
|
|
12
|
+
} from "./chunk.2LQSDOD4.js";
|
|
13
|
+
import {
|
|
14
|
+
watch
|
|
15
|
+
} from "./chunk.2WO4NHJ2.js";
|
|
16
|
+
import {
|
|
17
|
+
gdsCustomElement,
|
|
18
|
+
html
|
|
19
|
+
} from "./chunk.VOYMQ322.js";
|
|
20
|
+
import {
|
|
21
|
+
__decorateClass,
|
|
22
|
+
__privateAdd,
|
|
23
|
+
__privateGet,
|
|
24
|
+
__privateMethod,
|
|
25
|
+
__privateSet,
|
|
26
|
+
__privateWrapper
|
|
27
|
+
} from "./chunk.5VURDMKE.js";
|
|
28
|
+
|
|
29
|
+
// libs/core/src/components/segmented-control/segmented-control.ts
|
|
30
|
+
import { unsafeCSS } from "lit";
|
|
31
|
+
import { query, state, property } from "lit/decorators.js";
|
|
32
|
+
import { when } from "lit/directives/when.js";
|
|
33
|
+
import { msg } from "@lit/localize";
|
|
34
|
+
|
|
35
|
+
// libs/core/src/components/segmented-control/segmented-control.style.css
|
|
36
|
+
var segmented_control_style_default = `:host {
|
|
37
|
+
background-color: var(--gds-sys-color-container-container-dim1);
|
|
38
|
+
border: 0.25rem solid var(--gds-sys-color-container-container-dim1);
|
|
39
|
+
border-radius: calc(infinity * 1px);
|
|
40
|
+
box-sizing: border-box;
|
|
41
|
+
contain: layout;
|
|
42
|
+
display: inline-flex;
|
|
43
|
+
gap: 0.25rem;
|
|
44
|
+
height: 3rem;
|
|
45
|
+
max-width: 100%;
|
|
46
|
+
overflow: hidden;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
:host([size='small']) {
|
|
50
|
+
height: 2.5rem;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
#track {
|
|
54
|
+
box-sizing: border-box;
|
|
55
|
+
display: flex;
|
|
56
|
+
flex-grow: 0;
|
|
57
|
+
flex-shrink: 1;
|
|
58
|
+
overflow: hidden;
|
|
59
|
+
position: relative;
|
|
60
|
+
width: 100%;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
#segments {
|
|
64
|
+
box-sizing: border-box;
|
|
65
|
+
display: inline-flex;
|
|
66
|
+
gap: 0.25rem;
|
|
67
|
+
position: relative;
|
|
68
|
+
transition: 0.2s;
|
|
69
|
+
z-index: 1;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
#btn-prev,
|
|
73
|
+
#btn-next {
|
|
74
|
+
align-items: center;
|
|
75
|
+
-webkit-appearance: none;
|
|
76
|
+
-moz-appearance: none;
|
|
77
|
+
appearance: none;
|
|
78
|
+
aspect-ratio: 1;
|
|
79
|
+
background-color: var(--gds-sys-color-container-container-dim1);
|
|
80
|
+
border-radius: calc(infinity * 1px);
|
|
81
|
+
border-width: 0;
|
|
82
|
+
color: var(--gds-sys-color-content-content);
|
|
83
|
+
cursor: pointer;
|
|
84
|
+
display: flex;
|
|
85
|
+
font-size: 1rem;
|
|
86
|
+
height: 100%;
|
|
87
|
+
justify-content: center;
|
|
88
|
+
width: 2.5rem;
|
|
89
|
+
|
|
90
|
+
@media (pointer: fine) {
|
|
91
|
+
&:hover {
|
|
92
|
+
background-color: color-mix(
|
|
93
|
+
in srgb,
|
|
94
|
+
var(--gds-sys-color-state-layers-state-black-dim1),
|
|
95
|
+
var(--gds-sys-color-container-container-dim1)
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
:host([size='small']) #btn-prev,
|
|
102
|
+
:host([size='small']) #btn-next {
|
|
103
|
+
width: 2rem;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
::slotted(*) {
|
|
107
|
+
flex-grow: 1;
|
|
108
|
+
flex-shrink: 0;
|
|
109
|
+
z-index: 1;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
#indicator {
|
|
113
|
+
background-color: var(--gds-sys-color-container-container-bright);
|
|
114
|
+
border-radius: calc(infinity * 1px);
|
|
115
|
+
height: 100%;
|
|
116
|
+
left: 0;
|
|
117
|
+
position: absolute;
|
|
118
|
+
transition:
|
|
119
|
+
transform 0.2s,
|
|
120
|
+
width 0.2s;
|
|
121
|
+
z-index: 0;
|
|
122
|
+
}
|
|
123
|
+
`;
|
|
124
|
+
|
|
125
|
+
// libs/core/src/components/segmented-control/segmented-control.ts
|
|
126
|
+
var BTN_SIZE = {
|
|
127
|
+
small: 36,
|
|
128
|
+
medium: 44
|
|
129
|
+
};
|
|
130
|
+
var getSegmentGap = (transitionalStyles) => transitionalStyles ? 0 : 4;
|
|
131
|
+
var _value, _tid, _resizeObserver, _firstVisibleIndex, _calculatedSegmentWidth, _segmentWidth, _segmentsContainerLeft, _focusedIndex, _dragStartX, _dragStartLeft, _isDragging, _startDrag, _drag, _endDrag, _calcVisibleAfterDrag, _calcLayout, _applySegmentsTransform, _handleSlotChange, handleSlotChange_fn, _scrollLeft, _scrollRight, _updateScrollBtnState, _updateIndicator, _handleSegmentClick, _updateSelectedFromValue;
|
|
132
|
+
var GdsSegmentedControl = class extends GdsElement {
|
|
133
|
+
constructor() {
|
|
134
|
+
super(...arguments);
|
|
135
|
+
__privateAdd(this, _handleSlotChange);
|
|
136
|
+
this.segMinWidth = 100;
|
|
137
|
+
this.size = "medium";
|
|
138
|
+
__privateAdd(this, _value, void 0);
|
|
139
|
+
this._showPrevButton = false;
|
|
140
|
+
this._showNextButton = false;
|
|
141
|
+
__privateAdd(this, _tid, void 0);
|
|
142
|
+
__privateAdd(this, _resizeObserver, new ResizeObserver(() => {
|
|
143
|
+
__privateGet(this, _tid) && clearTimeout(__privateGet(this, _tid));
|
|
144
|
+
__privateSet(this, _tid, setTimeout(() => {
|
|
145
|
+
__privateGet(this, _calcLayout).call(this);
|
|
146
|
+
}, 20));
|
|
147
|
+
}));
|
|
148
|
+
__privateAdd(this, _firstVisibleIndex, 0);
|
|
149
|
+
__privateAdd(this, _calculatedSegmentWidth, 0);
|
|
150
|
+
__privateAdd(this, _segmentWidth, 0);
|
|
151
|
+
__privateAdd(this, _segmentsContainerLeft, 0);
|
|
152
|
+
__privateAdd(this, _focusedIndex, 0);
|
|
153
|
+
__privateAdd(this, _dragStartX, 0);
|
|
154
|
+
__privateAdd(this, _dragStartLeft, 0);
|
|
155
|
+
__privateAdd(this, _isDragging, false);
|
|
156
|
+
__privateAdd(this, _startDrag, (event) => {
|
|
157
|
+
__privateSet(this, _dragStartX, event.clientX);
|
|
158
|
+
__privateSet(this, _dragStartLeft, __privateGet(this, _segmentsContainerLeft));
|
|
159
|
+
__privateSet(this, _isDragging, true);
|
|
160
|
+
});
|
|
161
|
+
__privateAdd(this, _drag, (event) => {
|
|
162
|
+
if (!__privateGet(this, _isDragging))
|
|
163
|
+
return;
|
|
164
|
+
event.preventDefault();
|
|
165
|
+
const delta = event.clientX - __privateGet(this, _dragStartX);
|
|
166
|
+
if (Math.abs(delta) < 5)
|
|
167
|
+
return;
|
|
168
|
+
try {
|
|
169
|
+
if (!this._elSegments.hasPointerCapture(event.pointerId))
|
|
170
|
+
this._elSegments.setPointerCapture(event.pointerId);
|
|
171
|
+
__privateSet(this, _segmentsContainerLeft, __privateGet(this, _dragStartLeft) + delta);
|
|
172
|
+
__privateGet(this, _applySegmentsTransform).call(this);
|
|
173
|
+
} catch (e) {
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
__privateAdd(this, _endDrag, (event) => {
|
|
177
|
+
if (!__privateGet(this, _isDragging))
|
|
178
|
+
return;
|
|
179
|
+
__privateSet(this, _isDragging, false);
|
|
180
|
+
try {
|
|
181
|
+
this._elSegments.releasePointerCapture(event.pointerId);
|
|
182
|
+
__privateGet(this, _calcVisibleAfterDrag).call(this);
|
|
183
|
+
} catch (e) {
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
__privateAdd(this, _calcVisibleAfterDrag, () => {
|
|
187
|
+
__privateSet(this, _firstVisibleIndex, Math.round(
|
|
188
|
+
-__privateGet(this, _segmentsContainerLeft) / __privateGet(this, _calculatedSegmentWidth)
|
|
189
|
+
));
|
|
190
|
+
__privateGet(this, _calcLayout).call(this);
|
|
191
|
+
});
|
|
192
|
+
// Calculates the layout based on the configured min width
|
|
193
|
+
// and the available space in the track
|
|
194
|
+
__privateAdd(this, _calcLayout, (followFocus = false) => {
|
|
195
|
+
const calcNumVisibleSegments = () => {
|
|
196
|
+
const numSegments = this.segments.length;
|
|
197
|
+
const availableWidth = this._elTrack.offsetWidth;
|
|
198
|
+
if (availableWidth / numSegments > this.segMinWidth) {
|
|
199
|
+
return {
|
|
200
|
+
count: numSegments,
|
|
201
|
+
segmentWidth: (availableWidth - getSegmentGap(this._isUsingTransitionalStyles) * (numSegments - 1)) / numSegments
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
const availableWidthIncBtns = this.offsetWidth - BTN_SIZE[this.size] * 2;
|
|
205
|
+
const maxVisibleSegments = Math.floor(
|
|
206
|
+
availableWidthIncBtns / this.segMinWidth
|
|
207
|
+
);
|
|
208
|
+
const segmentWidth = (availableWidth - getSegmentGap(this._isUsingTransitionalStyles) * (maxVisibleSegments - 1)) / maxVisibleSegments;
|
|
209
|
+
return {
|
|
210
|
+
count: maxVisibleSegments,
|
|
211
|
+
segmentWidth
|
|
212
|
+
};
|
|
213
|
+
};
|
|
214
|
+
const { count } = calcNumVisibleSegments();
|
|
215
|
+
if (followFocus) {
|
|
216
|
+
if (__privateGet(this, _focusedIndex) >= __privateGet(this, _firstVisibleIndex) + count) {
|
|
217
|
+
__privateSet(this, _firstVisibleIndex, __privateGet(this, _focusedIndex) - count + 1);
|
|
218
|
+
}
|
|
219
|
+
if (__privateGet(this, _focusedIndex) < __privateGet(this, _firstVisibleIndex)) {
|
|
220
|
+
__privateSet(this, _firstVisibleIndex, __privateGet(this, _focusedIndex));
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
const endFirstIndex = this.segments.length - count;
|
|
224
|
+
const hasReachedEnd = __privateGet(this, _firstVisibleIndex) >= endFirstIndex;
|
|
225
|
+
const isAtStart = __privateGet(this, _firstVisibleIndex) <= 0;
|
|
226
|
+
if (hasReachedEnd) {
|
|
227
|
+
__privateSet(this, _firstVisibleIndex, endFirstIndex);
|
|
228
|
+
}
|
|
229
|
+
if (isAtStart) {
|
|
230
|
+
__privateSet(this, _firstVisibleIndex, 0);
|
|
231
|
+
}
|
|
232
|
+
__privateGet(this, _updateScrollBtnState).call(this, count);
|
|
233
|
+
this.updateComplete.then(() => {
|
|
234
|
+
const { segmentWidth, count: count2 } = calcNumVisibleSegments();
|
|
235
|
+
this.segments.forEach((segment) => {
|
|
236
|
+
segment.style.width = segmentWidth + "px";
|
|
237
|
+
});
|
|
238
|
+
__privateSet(this, _segmentsContainerLeft, -__privateGet(this, _firstVisibleIndex) * segmentWidth - getSegmentGap(this._isUsingTransitionalStyles) * __privateGet(this, _firstVisibleIndex));
|
|
239
|
+
__privateGet(this, _applySegmentsTransform).call(this);
|
|
240
|
+
__privateSet(this, _calculatedSegmentWidth, segmentWidth);
|
|
241
|
+
__privateSet(this, _segmentWidth, segmentWidth);
|
|
242
|
+
__privateGet(this, _updateIndicator).call(this);
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
__privateAdd(this, _applySegmentsTransform, () => {
|
|
246
|
+
window.requestAnimationFrame(() => {
|
|
247
|
+
this._elSegments.style.transform = `translateX(${__privateGet(this, _segmentsContainerLeft)}px)`;
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
__privateAdd(this, _scrollLeft, () => {
|
|
251
|
+
__privateWrapper(this, _firstVisibleIndex)._--;
|
|
252
|
+
__privateGet(this, _calcLayout).call(this);
|
|
253
|
+
});
|
|
254
|
+
__privateAdd(this, _scrollRight, () => {
|
|
255
|
+
__privateWrapper(this, _firstVisibleIndex)._++;
|
|
256
|
+
__privateGet(this, _calcLayout).call(this);
|
|
257
|
+
});
|
|
258
|
+
// Updates the visibility of the scroll buttons
|
|
259
|
+
__privateAdd(this, _updateScrollBtnState, (numVisibleSegments) => {
|
|
260
|
+
this._showPrevButton = __privateGet(this, _firstVisibleIndex) > 0;
|
|
261
|
+
this._showNextButton = __privateGet(this, _firstVisibleIndex) < this.segments.length - numVisibleSegments;
|
|
262
|
+
});
|
|
263
|
+
// Updates the selection indicator position
|
|
264
|
+
__privateAdd(this, _updateIndicator, () => {
|
|
265
|
+
const segment = this.segments.find((s) => s.selected);
|
|
266
|
+
if (segment) {
|
|
267
|
+
const selectedSegmentIndex = this.segments.indexOf(segment);
|
|
268
|
+
const offset = selectedSegmentIndex * __privateGet(this, _segmentWidth) + getSegmentGap(this._isUsingTransitionalStyles) * selectedSegmentIndex;
|
|
269
|
+
this._elIndicator.style.transform = `translateX(${offset}px)`;
|
|
270
|
+
this._elIndicator.style.width = `${__privateGet(this, _segmentWidth)}px`;
|
|
271
|
+
} else {
|
|
272
|
+
this._elIndicator.style.transform = `translateX(-100%)`;
|
|
273
|
+
this._elIndicator.style.width = `0px`;
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
__privateAdd(this, _handleSegmentClick, (event) => {
|
|
277
|
+
const selectedSegment = this.segments.find(
|
|
278
|
+
(s) => s === event.target || s.contains(event.target)
|
|
279
|
+
);
|
|
280
|
+
if (selectedSegment) {
|
|
281
|
+
this.segments.forEach((s) => s.selected = false);
|
|
282
|
+
selectedSegment.selected = true;
|
|
283
|
+
__privateSet(this, _value, selectedSegment.value);
|
|
284
|
+
__privateGet(this, _updateIndicator).call(this);
|
|
285
|
+
this.dispatchEvent(
|
|
286
|
+
new CustomEvent("change", {
|
|
287
|
+
detail: { segment: selectedSegment },
|
|
288
|
+
bubbles: true,
|
|
289
|
+
composed: true
|
|
290
|
+
})
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
__privateAdd(this, _updateSelectedFromValue, () => {
|
|
295
|
+
if (!__privateGet(this, _value))
|
|
296
|
+
return;
|
|
297
|
+
this.updateComplete.then(() => {
|
|
298
|
+
const selectedSegment = this.segments.find((s) => s.value === __privateGet(this, _value));
|
|
299
|
+
if (selectedSegment) {
|
|
300
|
+
this.segments.forEach((s) => s.selected = false);
|
|
301
|
+
selectedSegment.selected = true;
|
|
302
|
+
__privateSet(this, _focusedIndex, this.segments.indexOf(selectedSegment));
|
|
303
|
+
__privateGet(this, _calcLayout).call(this, true);
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
get value() {
|
|
309
|
+
return __privateGet(this, _value);
|
|
310
|
+
}
|
|
311
|
+
set value(val) {
|
|
312
|
+
__privateSet(this, _value, val);
|
|
313
|
+
__privateGet(this, _updateSelectedFromValue).call(this);
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Returns the segments in the control
|
|
317
|
+
* @readonly
|
|
318
|
+
*/
|
|
319
|
+
get segments() {
|
|
320
|
+
return this._elSlot ? this._elSlot.assignedElements() : [];
|
|
321
|
+
}
|
|
322
|
+
connectedCallback() {
|
|
323
|
+
super.connectedCallback();
|
|
324
|
+
TransitionalStyles.instance.apply(this, "gds-segmented-control");
|
|
325
|
+
__privateGet(this, _resizeObserver).observe(this);
|
|
326
|
+
this.addEventListener("focusin", (e) => {
|
|
327
|
+
if (e.target instanceof GdsSegment) {
|
|
328
|
+
__privateSet(this, _focusedIndex, this.segments.indexOf(e.target));
|
|
329
|
+
__privateGet(this, _calcLayout).call(this, true);
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
disconnectedCallback() {
|
|
334
|
+
super.disconnectedCallback();
|
|
335
|
+
__privateGet(this, _resizeObserver).unobserve(this);
|
|
336
|
+
}
|
|
337
|
+
render() {
|
|
338
|
+
return html`${this._tStyles}
|
|
339
|
+
${when(
|
|
340
|
+
this._showPrevButton,
|
|
341
|
+
() => html`<button
|
|
342
|
+
id="btn-prev"
|
|
343
|
+
@click=${__privateGet(this, _scrollLeft)}
|
|
344
|
+
aria-label=${msg("Scroll right")}
|
|
345
|
+
>
|
|
346
|
+
<gds-icon name="chevron-left"></gds-icon>
|
|
347
|
+
</button>`
|
|
348
|
+
)}
|
|
349
|
+
<div
|
|
350
|
+
id="track"
|
|
351
|
+
@scroll=${() => {
|
|
352
|
+
this._elTrack.scrollLeft = 0;
|
|
353
|
+
}}
|
|
354
|
+
>
|
|
355
|
+
<div
|
|
356
|
+
id="segments"
|
|
357
|
+
@pointerdown=${__privateGet(this, _startDrag)}
|
|
358
|
+
@pointermove=${__privateGet(this, _drag)}
|
|
359
|
+
@touchmove=${__privateGet(this, _drag)}
|
|
360
|
+
@pointerup=${__privateGet(this, _endDrag)}
|
|
361
|
+
@pointercancel=${__privateGet(this, _endDrag)}
|
|
362
|
+
role="list"
|
|
363
|
+
>
|
|
364
|
+
<slot
|
|
365
|
+
gds-allow="gds-segment"
|
|
366
|
+
@click=${__privateGet(this, _handleSegmentClick)}
|
|
367
|
+
@slotchange=${__privateMethod(this, _handleSlotChange, handleSlotChange_fn)}
|
|
368
|
+
role="none"
|
|
369
|
+
></slot>
|
|
370
|
+
<div id="indicator" role="none"></div>
|
|
371
|
+
</div>
|
|
372
|
+
</div>
|
|
373
|
+
${when(
|
|
374
|
+
this._showNextButton,
|
|
375
|
+
() => html`<button
|
|
376
|
+
id="btn-next"
|
|
377
|
+
@click=${__privateGet(this, _scrollRight)}
|
|
378
|
+
aria-label=${msg("Scroll right")}
|
|
379
|
+
>
|
|
380
|
+
<gds-icon name="chevron-right"></gds-icon>
|
|
381
|
+
</button>`
|
|
382
|
+
)}`;
|
|
383
|
+
}
|
|
384
|
+
_recalculateMinWidth() {
|
|
385
|
+
this.updateComplete.then(() => __privateGet(this, _calcLayout).call(this));
|
|
386
|
+
}
|
|
387
|
+
};
|
|
388
|
+
_value = new WeakMap();
|
|
389
|
+
_tid = new WeakMap();
|
|
390
|
+
_resizeObserver = new WeakMap();
|
|
391
|
+
_firstVisibleIndex = new WeakMap();
|
|
392
|
+
_calculatedSegmentWidth = new WeakMap();
|
|
393
|
+
_segmentWidth = new WeakMap();
|
|
394
|
+
_segmentsContainerLeft = new WeakMap();
|
|
395
|
+
_focusedIndex = new WeakMap();
|
|
396
|
+
_dragStartX = new WeakMap();
|
|
397
|
+
_dragStartLeft = new WeakMap();
|
|
398
|
+
_isDragging = new WeakMap();
|
|
399
|
+
_startDrag = new WeakMap();
|
|
400
|
+
_drag = new WeakMap();
|
|
401
|
+
_endDrag = new WeakMap();
|
|
402
|
+
_calcVisibleAfterDrag = new WeakMap();
|
|
403
|
+
_calcLayout = new WeakMap();
|
|
404
|
+
_applySegmentsTransform = new WeakMap();
|
|
405
|
+
_handleSlotChange = new WeakSet();
|
|
406
|
+
handleSlotChange_fn = function() {
|
|
407
|
+
var _a;
|
|
408
|
+
const selSegmentValue = (_a = this.segments.find((s) => s.selected)) == null ? void 0 : _a.value;
|
|
409
|
+
if (selSegmentValue) {
|
|
410
|
+
__privateSet(this, _value, selSegmentValue);
|
|
411
|
+
}
|
|
412
|
+
__privateGet(this, _calcLayout).call(this);
|
|
413
|
+
};
|
|
414
|
+
_scrollLeft = new WeakMap();
|
|
415
|
+
_scrollRight = new WeakMap();
|
|
416
|
+
_updateScrollBtnState = new WeakMap();
|
|
417
|
+
_updateIndicator = new WeakMap();
|
|
418
|
+
_handleSegmentClick = new WeakMap();
|
|
419
|
+
_updateSelectedFromValue = new WeakMap();
|
|
420
|
+
GdsSegmentedControl.styles = [tokens, unsafeCSS(segmented_control_style_default)];
|
|
421
|
+
__decorateClass([
|
|
422
|
+
property({ type: Number, attribute: "seg-min-width" })
|
|
423
|
+
], GdsSegmentedControl.prototype, "segMinWidth", 2);
|
|
424
|
+
__decorateClass([
|
|
425
|
+
property()
|
|
426
|
+
], GdsSegmentedControl.prototype, "size", 2);
|
|
427
|
+
__decorateClass([
|
|
428
|
+
property()
|
|
429
|
+
], GdsSegmentedControl.prototype, "value", 1);
|
|
430
|
+
__decorateClass([
|
|
431
|
+
state()
|
|
432
|
+
], GdsSegmentedControl.prototype, "_tStyles", 2);
|
|
433
|
+
__decorateClass([
|
|
434
|
+
query("slot")
|
|
435
|
+
], GdsSegmentedControl.prototype, "_elSlot", 2);
|
|
436
|
+
__decorateClass([
|
|
437
|
+
query("#indicator")
|
|
438
|
+
], GdsSegmentedControl.prototype, "_elIndicator", 2);
|
|
439
|
+
__decorateClass([
|
|
440
|
+
query("#track")
|
|
441
|
+
], GdsSegmentedControl.prototype, "_elTrack", 2);
|
|
442
|
+
__decorateClass([
|
|
443
|
+
query("#segments")
|
|
444
|
+
], GdsSegmentedControl.prototype, "_elSegments", 2);
|
|
445
|
+
__decorateClass([
|
|
446
|
+
state()
|
|
447
|
+
], GdsSegmentedControl.prototype, "_showPrevButton", 2);
|
|
448
|
+
__decorateClass([
|
|
449
|
+
state()
|
|
450
|
+
], GdsSegmentedControl.prototype, "_showNextButton", 2);
|
|
451
|
+
__decorateClass([
|
|
452
|
+
watch("segMinWidth")
|
|
453
|
+
], GdsSegmentedControl.prototype, "_recalculateMinWidth", 1);
|
|
454
|
+
GdsSegmentedControl = __decorateClass([
|
|
455
|
+
gdsCustomElement("gds-segmented-control")
|
|
456
|
+
], GdsSegmentedControl);
|
|
457
|
+
|
|
458
|
+
export {
|
|
459
|
+
GdsSegmentedControl
|
|
460
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __spreadValues = (a, b) => {
|
|
10
|
+
for (var prop in b || (b = {}))
|
|
11
|
+
if (__hasOwnProp.call(b, prop))
|
|
12
|
+
__defNormalProp(a, prop, b[prop]);
|
|
13
|
+
if (__getOwnPropSymbols)
|
|
14
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
15
|
+
if (__propIsEnum.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
}
|
|
18
|
+
return a;
|
|
19
|
+
};
|
|
20
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
21
|
+
var __export = (target, all) => {
|
|
22
|
+
for (var name in all)
|
|
23
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
24
|
+
};
|
|
25
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
26
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
27
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
28
|
+
if (decorator = decorators[i])
|
|
29
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
30
|
+
if (kind && result)
|
|
31
|
+
__defProp(target, key, result);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
var __accessCheck = (obj, member, msg) => {
|
|
35
|
+
if (!member.has(obj))
|
|
36
|
+
throw TypeError("Cannot " + msg);
|
|
37
|
+
};
|
|
38
|
+
var __privateGet = (obj, member, getter) => {
|
|
39
|
+
__accessCheck(obj, member, "read from private field");
|
|
40
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
41
|
+
};
|
|
42
|
+
var __privateAdd = (obj, member, value) => {
|
|
43
|
+
if (member.has(obj))
|
|
44
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
45
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
46
|
+
};
|
|
47
|
+
var __privateSet = (obj, member, value, setter) => {
|
|
48
|
+
__accessCheck(obj, member, "write to private field");
|
|
49
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
50
|
+
return value;
|
|
51
|
+
};
|
|
52
|
+
var __privateWrapper = (obj, member, setter, getter) => ({
|
|
53
|
+
set _(value) {
|
|
54
|
+
__privateSet(obj, member, value, setter);
|
|
55
|
+
},
|
|
56
|
+
get _() {
|
|
57
|
+
return __privateGet(obj, member, getter);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
var __privateMethod = (obj, member, method) => {
|
|
61
|
+
__accessCheck(obj, member, "access private method");
|
|
62
|
+
return method;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export {
|
|
66
|
+
__spreadValues,
|
|
67
|
+
__spreadProps,
|
|
68
|
+
__export,
|
|
69
|
+
__decorateClass,
|
|
70
|
+
__privateGet,
|
|
71
|
+
__privateAdd,
|
|
72
|
+
__privateSet,
|
|
73
|
+
__privateWrapper,
|
|
74
|
+
__privateMethod
|
|
75
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// libs/core/src/utils/helpers/constrain-slots.ts
|
|
2
|
+
function constrainSlots(self) {
|
|
3
|
+
self.updateComplete.then(() => {
|
|
4
|
+
var _a, _b, _c;
|
|
5
|
+
const slots = (_a = self.shadowRoot) == null ? void 0 : _a.querySelectorAll("slot[gds-allow]");
|
|
6
|
+
if (!slots)
|
|
7
|
+
return;
|
|
8
|
+
for (const node of Array.from(self.childNodes)) {
|
|
9
|
+
if (node.nodeType === Node.TEXT_NODE && ((_b = node.textContent) == null ? void 0 : _b.trim()) === "") {
|
|
10
|
+
(_c = node.parentNode) == null ? void 0 : _c.removeChild(node);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
const constrain = (slot) => {
|
|
14
|
+
var _a2, _b2;
|
|
15
|
+
const allowed = ((_a2 = slot.getAttribute("gds-allow")) == null ? void 0 : _a2.split(" ")) || [];
|
|
16
|
+
for (const node of Array.from(slot.assignedNodes())) {
|
|
17
|
+
if (!allowed.includes(node.nodeName.toLowerCase())) {
|
|
18
|
+
(_b2 = node.parentNode) == null ? void 0 : _b2.removeChild(node);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
slots.forEach((slot) => {
|
|
23
|
+
constrain(slot);
|
|
24
|
+
slot.addEventListener("slotchange", () => constrain(slot));
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export {
|
|
30
|
+
constrainSlots
|
|
31
|
+
};
|