@cupra/ui-kit 2.0.0-canary.62 → 2.0.0-canary.63
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/dist/cjs/components/ds-select/ds-select.cjs +4 -3
- package/dist/cjs/components/ds-slider/ds-slider.cjs +18 -18
- package/dist/cjs/components/ds-text-input/ds-text-input.cjs +3 -2
- package/dist/cjs/components/ds-textarea/ds-textarea.cjs +4 -3
- package/dist/cjs/components/ds-theme-provider/ds-theme-provider.cjs +1 -1
- package/dist/cjs/mixins/inputStatesMixin.cjs +1 -1
- package/dist/cjs/node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/directive-helpers.cjs +2 -2
- package/dist/cjs/node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/directive.cjs +1 -1
- package/dist/cjs/node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/directives/live.cjs +5 -0
- package/dist/cjs/utils/IconsManager.cjs +1 -1
- package/dist/cjs/utils/PubSub.cjs +1 -1
- package/dist/cjs/utils/StylesRegistry/StylesRegistry.cjs +1 -1
- package/dist/cjs/utils/concurrencyLimit.cjs +1 -0
- package/dist/cjs/utils/cssWithTokens.cjs +1 -1
- package/dist/cjs/utils/htmlWithTokens.cjs +1 -1
- package/dist/esm/components/ds-select/ds-select.js +38 -32
- package/dist/esm/components/ds-slider/ds-slider.js +84 -67
- package/dist/esm/components/ds-text-input/ds-text-input.js +38 -30
- package/dist/esm/components/ds-textarea/ds-textarea.js +45 -37
- package/dist/esm/components/ds-theme-provider/ds-theme-provider.js +1 -1
- package/dist/esm/mixins/inputStatesMixin.js +4 -3
- package/dist/esm/node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/directive-helpers.js +17 -16
- package/dist/esm/node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/directive.js +4 -4
- package/dist/esm/node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/directives/live.js +30 -0
- package/dist/esm/utils/IconsManager.js +1 -1
- package/dist/esm/utils/PubSub.js +1 -1
- package/dist/esm/utils/StylesRegistry/StylesRegistry.js +8 -6
- package/dist/esm/utils/concurrencyLimit.js +32 -0
- package/dist/esm/utils/cssWithTokens.js +1 -1
- package/dist/esm/utils/htmlWithTokens.js +1 -1
- package/dist/types/components/ds-select/ds-select.d.ts +2 -0
- package/dist/types/components/ds-select/ds-select.types.d.ts +1 -0
- package/dist/types/components/ds-slider/ds-slider.d.ts +7 -2
- package/dist/types/components/ds-slider/ds-slider.types.d.ts +18 -3
- package/dist/types/components/ds-text-input/ds-text-input.d.ts +2 -0
- package/dist/types/components/ds-text-input/ds-text-input.types.d.ts +1 -0
- package/dist/types/components/ds-textarea/ds-textarea.d.ts +2 -0
- package/dist/types/components/ds-textarea/ds-textarea.types.d.ts +1 -0
- package/dist/types/mixins/inputStatesMixin.d.ts +1 -0
- package/dist/types/utils/concurrencyLimit.d.ts +4 -0
- package/dist/types/utils/concurrencyLimit.test.d.ts +1 -0
- package/dist-react/cjs/components/ds-select/ds-select.cjs +4 -3
- package/dist-react/cjs/components/ds-slider/ds-slider.cjs +18 -18
- package/dist-react/cjs/components/ds-text-input/ds-text-input.cjs +3 -2
- package/dist-react/cjs/components/ds-textarea/ds-textarea.cjs +4 -3
- package/dist-react/cjs/components/ds-theme-provider/ds-theme-provider.cjs +1 -1
- package/dist-react/cjs/mixins/inputStatesMixin.cjs +1 -1
- package/dist-react/cjs/node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/directive-helpers.cjs +2 -2
- package/dist-react/cjs/node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/directive.cjs +1 -1
- package/dist-react/cjs/node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/directives/live.cjs +5 -0
- package/dist-react/cjs/utils/IconsManager.cjs +1 -1
- package/dist-react/cjs/utils/PubSub.cjs +1 -1
- package/dist-react/cjs/utils/StylesRegistry/StylesRegistry.cjs +1 -1
- package/dist-react/cjs/utils/concurrencyLimit.cjs +1 -0
- package/dist-react/cjs/utils/cssWithTokens.cjs +1 -1
- package/dist-react/cjs/utils/htmlWithTokens.cjs +1 -1
- package/dist-react/esm/components/ds-select/ds-select.js +38 -32
- package/dist-react/esm/components/ds-slider/ds-slider.js +84 -67
- package/dist-react/esm/components/ds-text-input/ds-text-input.js +38 -30
- package/dist-react/esm/components/ds-textarea/ds-textarea.js +45 -37
- package/dist-react/esm/components/ds-theme-provider/ds-theme-provider.js +1 -1
- package/dist-react/esm/mixins/inputStatesMixin.js +4 -3
- package/dist-react/esm/node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/directive-helpers.js +17 -16
- package/dist-react/esm/node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/directive.js +4 -4
- package/dist-react/esm/node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/directives/live.js +30 -0
- package/dist-react/esm/utils/IconsManager.js +1 -1
- package/dist-react/esm/utils/PubSub.js +1 -1
- package/dist-react/esm/utils/StylesRegistry/StylesRegistry.js +8 -6
- package/dist-react/esm/utils/concurrencyLimit.js +32 -0
- package/dist-react/esm/utils/cssWithTokens.js +1 -1
- package/dist-react/esm/utils/htmlWithTokens.js +1 -1
- package/dist-react/types/components/ds-select/ds-select.d.ts +2 -0
- package/dist-react/types/components/ds-select/ds-select.types.d.ts +1 -0
- package/dist-react/types/components/ds-slider/ds-slider.d.ts +7 -2
- package/dist-react/types/components/ds-slider/ds-slider.types.d.ts +18 -3
- package/dist-react/types/components/ds-text-input/ds-text-input.d.ts +2 -0
- package/dist-react/types/components/ds-text-input/ds-text-input.types.d.ts +1 -0
- package/dist-react/types/components/ds-textarea/ds-textarea.d.ts +2 -0
- package/dist-react/types/components/ds-textarea/ds-textarea.types.d.ts +1 -0
- package/dist-react/types/mixins/inputStatesMixin.d.ts +1 -0
- package/dist-react/types/utils/concurrencyLimit.d.ts +4 -0
- package/package.json +1 -1
|
@@ -2,46 +2,47 @@ import { UiKitElement as $ } from "../base/UiKitElement.js";
|
|
|
2
2
|
import { getStepValue as d } from "./utils/getStepValue/getStepValue.js";
|
|
3
3
|
import { roundToDecimals as S } from "./utils/roundToDecimals/roundToDecimals.js";
|
|
4
4
|
import { customUiKitElement as V } from "../../decorators/customUiKitElement.js";
|
|
5
|
-
import { ViewportMixin as
|
|
6
|
-
import { booleanConverter as
|
|
7
|
-
import { formatNumber as
|
|
8
|
-
import { htmlWithTokens as
|
|
9
|
-
import { objectConverter as
|
|
5
|
+
import { ViewportMixin as _ } from "../../mixins/ViewportMixin.js";
|
|
6
|
+
import { booleanConverter as T } from "../../utils/booleanConverter.js";
|
|
7
|
+
import { formatNumber as L } from "../../utils/formatNumber/formatNumber.js";
|
|
8
|
+
import { htmlWithTokens as P } from "../../utils/htmlWithTokens.js";
|
|
9
|
+
import { objectConverter as D } from "../../utils/objectConverter.js";
|
|
10
10
|
import "../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/reactive-element.js";
|
|
11
11
|
import { nothing as h, html as l } from "../../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/lit-html.js";
|
|
12
12
|
import "../../node_modules/.pnpm/lit-element@4.2.1/node_modules/lit-element/lit-element.js";
|
|
13
13
|
import { property as r } from "../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/property.js";
|
|
14
14
|
import { state as p } from "../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/state.js";
|
|
15
|
-
import { query as
|
|
16
|
-
import { classMap as
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
import { query as k } from "../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/query.js";
|
|
16
|
+
import { classMap as E } from "../../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/directives/class-map.js";
|
|
17
|
+
import { live as F } from "../../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/directives/live.js";
|
|
18
|
+
import { commonStyles as N, trackStyles as C, thumbStyles as I, currentValueStyles as R, rangeValueStyles as A } from "./styles/common.styles.js";
|
|
19
|
+
var O = Object.defineProperty, U = Object.getOwnPropertyDescriptor, a = (t, e, i, n) => {
|
|
20
|
+
for (var o = n > 1 ? void 0 : n ? U(e, i) : e, u = t.length - 1, m; u >= 0; u--)
|
|
21
|
+
(m = t[u]) && (o = (n ? m(e, i, o) : m(o)) || o);
|
|
22
|
+
return n && o && O(e, i, o), o;
|
|
22
23
|
};
|
|
23
|
-
let s = class extends
|
|
24
|
+
let s = class extends _($) {
|
|
24
25
|
constructor() {
|
|
25
26
|
super(...arguments), this.min = 0, this.max = 100, this.minLabel = "", this.maxLabel = "", this.step = 1, this.initialValueMin = 0, this.mode = "light", this.locale = void 0, this.localeMatcher = "lookup", this.useGrouping = !0, this.minimumIntegerDigits = 1, this.minimumFractionDigits = 0, this.maximumFractionDigits = 3, this.size = "medium", this.disabled = !1, this.keyboardMode = !1, this.getNewValue = (t) => {
|
|
26
|
-
const { width: e, left: i } = this.track.getBoundingClientRect(),
|
|
27
|
+
const { width: e, left: i } = this.track.getBoundingClientRect(), n = t.type.indexOf("mouse") !== -1 ? t.clientX : t.touches[0].clientX, u = Math.min(Math.max(0, n - i), e) * 100 / e;
|
|
27
28
|
return this.min + u * (this.max - this.min) / 100;
|
|
28
29
|
}, this.setActiveThumb = (t) => {
|
|
29
30
|
const e = this.getNewValue(t);
|
|
30
|
-
typeof this.
|
|
31
|
+
typeof this._valueMax != "number" || e <= this._valueMin ? this.activeThumb = "min" : e >= this._valueMax ? this.activeThumb = "max" : e - this._valueMin < this._valueMax - e ? this.activeThumb = "min" : this.activeThumb = "max";
|
|
31
32
|
}, this.handleMouseMove = (t) => {
|
|
32
33
|
this.animationFrameRequest && cancelAnimationFrame(this.animationFrameRequest), this.animationFrameRequest = requestAnimationFrame(() => {
|
|
33
|
-
const e = this.getNewValue(t), i = this.activeThumb ?? "min", { stepValue:
|
|
34
|
+
const e = this.getNewValue(t), i = this.activeThumb ?? "min", { stepValue: n } = d({
|
|
34
35
|
step: this.step,
|
|
35
36
|
min: this.min,
|
|
36
37
|
max: this.max,
|
|
37
38
|
proposedValue: e,
|
|
38
39
|
role: i,
|
|
39
40
|
currentValues: {
|
|
40
|
-
1: this.
|
|
41
|
-
...typeof this.
|
|
41
|
+
1: this._valueMin,
|
|
42
|
+
...typeof this._valueMax == "number" ? { 2: this._valueMax } : {}
|
|
42
43
|
}
|
|
43
44
|
});
|
|
44
|
-
this.handleChange({ value:
|
|
45
|
+
this.handleChange({ value: n, role: i });
|
|
45
46
|
});
|
|
46
47
|
}, this.handleMouseDown = (t) => {
|
|
47
48
|
var e;
|
|
@@ -53,23 +54,23 @@ let s = class extends T($) {
|
|
|
53
54
|
}, this.handlePointerOrMouseDown = () => {
|
|
54
55
|
this.keyboardMode = !1;
|
|
55
56
|
}, this.onInputFocus = (t, e) => {
|
|
56
|
-
const i = t.currentTarget,
|
|
57
|
-
this.editingField =
|
|
58
|
-
const
|
|
59
|
-
i.value = String(
|
|
57
|
+
const i = t.currentTarget, n = e === 1 ? "min" : "max";
|
|
58
|
+
this.editingField = n, i.type = "number", i.step = String(this.step ?? 1);
|
|
59
|
+
const o = n === "min" ? this._valueMin : this._valueMax;
|
|
60
|
+
i.value = String(o ?? ""), this.keyboardMode && i.classList.add("focus-visible");
|
|
60
61
|
}, this.commitInputValue = (t, e) => {
|
|
61
|
-
const i = t.currentTarget,
|
|
62
|
+
const i = t.currentTarget, n = e === 1 ? "min" : "max", { stepValue: o } = d({
|
|
62
63
|
step: this.step,
|
|
63
64
|
min: this.min,
|
|
64
65
|
max: this.max,
|
|
65
66
|
proposedValue: Number(i.value),
|
|
66
|
-
role:
|
|
67
|
+
role: n,
|
|
67
68
|
currentValues: {
|
|
68
|
-
1: this.
|
|
69
|
-
...typeof this.
|
|
69
|
+
1: this._valueMin,
|
|
70
|
+
...typeof this._valueMax == "number" ? { 2: this._valueMax } : {}
|
|
70
71
|
}
|
|
71
72
|
});
|
|
72
|
-
this.handleChange({ value:
|
|
73
|
+
this.handleChange({ value: o, role: n }), this.isControlled(n) || (i.value = String(o));
|
|
73
74
|
}, this.onInputBlur = (t) => {
|
|
74
75
|
var i;
|
|
75
76
|
this.editingField = void 0;
|
|
@@ -80,40 +81,50 @@ let s = class extends T($) {
|
|
|
80
81
|
}, this.onThumbKeyDown = (t, e) => {
|
|
81
82
|
if (!this.disabled && (t.key === "ArrowLeft" || t.key === "ArrowRight")) {
|
|
82
83
|
t.preventDefault();
|
|
83
|
-
const i = this.step ?? 1,
|
|
84
|
+
const i = this.step ?? 1, n = t.key === "ArrowLeft" ? -i : i, o = e === 1 ? "min" : "max", m = (o === "min" ? this._valueMin : this._valueMax) + n, { stepValue: b } = d({
|
|
84
85
|
step: this.step,
|
|
85
86
|
min: this.min,
|
|
86
87
|
max: this.max,
|
|
87
88
|
proposedValue: m,
|
|
88
|
-
role:
|
|
89
|
+
role: o,
|
|
89
90
|
currentValues: {
|
|
90
|
-
1: this.
|
|
91
|
-
...typeof this.
|
|
91
|
+
1: this._valueMin,
|
|
92
|
+
...typeof this._valueMax == "number" ? { 2: this._valueMax } : {}
|
|
92
93
|
}
|
|
93
94
|
});
|
|
94
|
-
this.handleChange({ value: b, role:
|
|
95
|
+
this.handleChange({ value: b, role: o });
|
|
95
96
|
}
|
|
96
97
|
};
|
|
97
98
|
}
|
|
99
|
+
get isRange() {
|
|
100
|
+
return typeof this.initialValueMax == "number" || typeof this.valueMax == "number";
|
|
101
|
+
}
|
|
102
|
+
isControlled(t) {
|
|
103
|
+
return typeof (t === "min" ? this.valueMin : this.valueMax) == "number";
|
|
104
|
+
}
|
|
105
|
+
willUpdate(t) {
|
|
106
|
+
super.willUpdate(t), typeof this.valueMin == "number" && (this._valueMin = this.valueMin), typeof this.valueMax == "number" && (this._valueMax = this.valueMax);
|
|
107
|
+
}
|
|
98
108
|
disconnectedCallback() {
|
|
99
109
|
super.disconnectedCallback(), window == null || window.removeEventListener("mousemove", this.handleMouseMove), window == null || window.removeEventListener("touchmove", this.handleMouseMove), window == null || window.removeEventListener("pointerup", this.handlePointerUp), window == null || window.removeEventListener("keydown", this.handleKeydown), window == null || window.removeEventListener("mousedown", this.handlePointerOrMouseDown), window == null || window.removeEventListener("pointerdown", this.handlePointerOrMouseDown);
|
|
100
110
|
}
|
|
101
111
|
firstUpdated(t) {
|
|
102
112
|
super.firstUpdated(t), window == null || window.addEventListener("keydown", this.handleKeydown), window == null || window.addEventListener("mousedown", this.handlePointerOrMouseDown), window == null || window.addEventListener("pointerdown", this.handlePointerOrMouseDown), ["min", "max"].forEach((i) => {
|
|
103
|
-
|
|
104
|
-
|
|
113
|
+
if (this.isControlled(i)) return;
|
|
114
|
+
const o = this[i === "min" ? "initialValueMin" : "initialValueMax"];
|
|
115
|
+
if (typeof o != "number") return;
|
|
105
116
|
const { stepValue: u } = d({
|
|
106
117
|
step: this.step,
|
|
107
118
|
min: this.min,
|
|
108
119
|
max: this.max,
|
|
109
|
-
proposedValue:
|
|
120
|
+
proposedValue: o,
|
|
110
121
|
role: i,
|
|
111
122
|
currentValues: {
|
|
112
|
-
1: this.
|
|
113
|
-
...typeof this.
|
|
123
|
+
1: this._valueMin,
|
|
124
|
+
...typeof this._valueMax == "number" ? { 2: this._valueMax } : {}
|
|
114
125
|
}
|
|
115
126
|
});
|
|
116
|
-
this[i === "min" ? "
|
|
127
|
+
this[i === "min" ? "_valueMin" : "_valueMax"] !== u && this.handleChange({ value: u, role: i });
|
|
117
128
|
});
|
|
118
129
|
}
|
|
119
130
|
getTrackPct(t) {
|
|
@@ -121,8 +132,8 @@ let s = class extends T($) {
|
|
|
121
132
|
return e === 0 ? 0 : (t - this.min) / e * 100;
|
|
122
133
|
}
|
|
123
134
|
handleChange({ value: t, role: e }) {
|
|
124
|
-
const i = S({ value: t, fractionDigits: this.maximumFractionDigits }),
|
|
125
|
-
this[
|
|
135
|
+
const i = S({ value: t, fractionDigits: this.maximumFractionDigits }), n = e === "min" ? "_valueMin" : "_valueMax";
|
|
136
|
+
this[n] !== i && (this.isControlled(e) || (this[n] = i), this.dispatchEvent(
|
|
126
137
|
new CustomEvent("change", {
|
|
127
138
|
bubbles: !0,
|
|
128
139
|
composed: !0,
|
|
@@ -148,39 +159,39 @@ let s = class extends T($) {
|
|
|
148
159
|
fractionSeparator: this.fractionSeparator,
|
|
149
160
|
useGrouping: this.useGrouping
|
|
150
161
|
};
|
|
151
|
-
return
|
|
162
|
+
return L(e);
|
|
152
163
|
}
|
|
153
164
|
get rangeValuesTemplates() {
|
|
154
165
|
const {
|
|
155
166
|
formattedValue: t,
|
|
156
167
|
unitSymbol: e,
|
|
157
168
|
unitSymbolPosition: i
|
|
158
|
-
} = this.formatNumber(this.min),
|
|
169
|
+
} = this.formatNumber(this.min), n = this.unitSymbol ?? e, o = this.unitSymbolPosition ?? i, { formattedValue: u } = this.formatNumber(this.max);
|
|
159
170
|
return l`
|
|
160
171
|
<div class="range-value-text">
|
|
161
172
|
${this.minLabel ? l`<span class="range-value-label">${this.minLabel}</span>` : h}
|
|
162
|
-
${
|
|
173
|
+
${o === "left" ? l`<span>${n}</span>` : h}
|
|
163
174
|
<span>${t}</span>
|
|
164
|
-
${
|
|
175
|
+
${o === "right" ? l`<span>${n}</span>` : h}
|
|
165
176
|
</div>
|
|
166
177
|
<div class="range-value-text">
|
|
167
178
|
${this.maxLabel ? l` <span class="range-value-label">${this.maxLabel}</span>` : h}
|
|
168
|
-
${
|
|
179
|
+
${o === "left" ? l`<span>${n}</span>` : h}
|
|
169
180
|
<span>${u}</span>
|
|
170
|
-
${
|
|
181
|
+
${o === "right" ? l`<span>${n}</span>` : h}
|
|
171
182
|
</div>
|
|
172
183
|
`;
|
|
173
184
|
}
|
|
174
185
|
getThumbTemplate(t) {
|
|
175
|
-
const e = t === 1 ? "min" : "max", i = e === "min" ? this.
|
|
186
|
+
const e = t === 1 ? "min" : "max", i = e === "min" ? this._valueMin : this._valueMax, { minLimit: n, maxLimit: o } = d({
|
|
176
187
|
step: this.step,
|
|
177
188
|
min: this.min,
|
|
178
189
|
max: this.max,
|
|
179
190
|
proposedValue: i,
|
|
180
191
|
role: e,
|
|
181
192
|
currentValues: {
|
|
182
|
-
1: this.
|
|
183
|
-
...typeof this.
|
|
193
|
+
1: this._valueMin,
|
|
194
|
+
...typeof this._valueMax == "number" ? { 2: this._valueMax } : {}
|
|
184
195
|
}
|
|
185
196
|
}), u = this.getTrackPct(i);
|
|
186
197
|
return l`
|
|
@@ -199,8 +210,8 @@ let s = class extends T($) {
|
|
|
199
210
|
tabindex=${this.disabled ? -1 : 0}
|
|
200
211
|
aria-disabled=${String(!!this.disabled)}
|
|
201
212
|
aria-label=${t === 1 ? "Minumum value" : "Maximum Value"}
|
|
202
|
-
aria-valuemin=${
|
|
203
|
-
aria-valuemax=${
|
|
213
|
+
aria-valuemin=${n}
|
|
214
|
+
aria-valuemax=${o}
|
|
204
215
|
aria-valuenow=${i}
|
|
205
216
|
>
|
|
206
217
|
<svg
|
|
@@ -217,12 +228,12 @@ let s = class extends T($) {
|
|
|
217
228
|
get thumbTemplates() {
|
|
218
229
|
return l`
|
|
219
230
|
${this.getThumbTemplate(1)}
|
|
220
|
-
${
|
|
231
|
+
${this.isRange ? this.getThumbTemplate(2) : h}
|
|
221
232
|
`;
|
|
222
233
|
}
|
|
223
234
|
get trackRangeTemplate() {
|
|
224
235
|
let t, e;
|
|
225
|
-
return
|
|
236
|
+
return this.isRange ? (t = this.getTrackPct(this._valueMin), e = this.getTrackPct(this._valueMax) - t) : (t = 0, e = this.getTrackPct(this._valueMin)), l`
|
|
226
237
|
<style>
|
|
227
238
|
.track-range {
|
|
228
239
|
left: ${t}%;
|
|
@@ -233,17 +244,17 @@ let s = class extends T($) {
|
|
|
233
244
|
`;
|
|
234
245
|
}
|
|
235
246
|
getInputTemplate(t) {
|
|
236
|
-
const e = t === 1 ? "min" : "max", i = this.editingField === e,
|
|
237
|
-
formattedValue:
|
|
247
|
+
const e = t === 1 ? "min" : "max", i = this.editingField === e, n = e === "min" ? this._valueMin : this._valueMax, {
|
|
248
|
+
formattedValue: o,
|
|
238
249
|
unitSymbol: u,
|
|
239
250
|
unitSymbolPosition: m
|
|
240
|
-
} = this.formatNumber(
|
|
251
|
+
} = this.formatNumber(n), b = this.unitSymbolPosition ?? m, y = this.unitSymbol ?? u, g = y ? b === "left" ? `${y} ${o}` : `${o} ${y}` : `${o}`, f = i ? "number" : "text", v = i ? String(n ?? "") : g, M = t === 1 ? this.inputMinAriaLabel : this.inputMaxAriaLabel, x = this.isRange ? t === 1 ? "Start value" : "End value" : "Value", w = M ?? x;
|
|
241
252
|
return l`
|
|
242
253
|
<div class="input-wrapper">
|
|
243
254
|
<input
|
|
244
255
|
class="input-value input-value-${t}"
|
|
245
256
|
type=${f}
|
|
246
|
-
.value=${v}
|
|
257
|
+
.value=${F(v)}
|
|
247
258
|
step=${String(this.step ?? 1)}
|
|
248
259
|
?disabled=${this.disabled}
|
|
249
260
|
tabindex=${this.disabled ? -1 : 0}
|
|
@@ -263,7 +274,7 @@ let s = class extends T($) {
|
|
|
263
274
|
return l`
|
|
264
275
|
<div class="inputs-container">
|
|
265
276
|
${this.getInputTemplate(1)}
|
|
266
|
-
${
|
|
277
|
+
${this.isRange ? this.getInputTemplate(2) : h}
|
|
267
278
|
</div>
|
|
268
279
|
`;
|
|
269
280
|
}
|
|
@@ -278,7 +289,7 @@ let s = class extends T($) {
|
|
|
278
289
|
};
|
|
279
290
|
}
|
|
280
291
|
get styleTokens() {
|
|
281
|
-
return
|
|
292
|
+
return P`
|
|
282
293
|
<style>
|
|
283
294
|
:host{
|
|
284
295
|
color-scheme: ${this.mode};
|
|
@@ -289,7 +300,7 @@ let s = class extends T($) {
|
|
|
289
300
|
render() {
|
|
290
301
|
return l`
|
|
291
302
|
${this.styleTokens}
|
|
292
|
-
<div class=${
|
|
303
|
+
<div class=${E(this.containerClasses)}>
|
|
293
304
|
<div @touchstart=${this.handleMouseDown} @mousedown=${this.handleMouseDown} class="track" role="presentation">
|
|
294
305
|
${this.thumbTemplates}
|
|
295
306
|
${this.trackRangeTemplate}
|
|
@@ -300,7 +311,7 @@ let s = class extends T($) {
|
|
|
300
311
|
`;
|
|
301
312
|
}
|
|
302
313
|
};
|
|
303
|
-
s.styles = [N, I,
|
|
314
|
+
s.styles = [N, C, I, R, A];
|
|
304
315
|
a([
|
|
305
316
|
r({ type: Number })
|
|
306
317
|
], s.prototype, "min", 2);
|
|
@@ -322,6 +333,12 @@ a([
|
|
|
322
333
|
a([
|
|
323
334
|
r({ type: Number, attribute: "initial-value-max" })
|
|
324
335
|
], s.prototype, "initialValueMax", 2);
|
|
336
|
+
a([
|
|
337
|
+
r({ type: Number, attribute: "value-min" })
|
|
338
|
+
], s.prototype, "valueMin", 2);
|
|
339
|
+
a([
|
|
340
|
+
r({ type: Number, attribute: "value-max" })
|
|
341
|
+
], s.prototype, "valueMax", 2);
|
|
325
342
|
a([
|
|
326
343
|
r({ type: String, reflect: !0 })
|
|
327
344
|
], s.prototype, "mode", 2);
|
|
@@ -369,10 +386,10 @@ a([
|
|
|
369
386
|
r({ type: String, attribute: "fraction-separator" })
|
|
370
387
|
], s.prototype, "fractionSeparator", 2);
|
|
371
388
|
a([
|
|
372
|
-
r({ type: String, converter:
|
|
389
|
+
r({ type: String, converter: D })
|
|
373
390
|
], s.prototype, "size", 2);
|
|
374
391
|
a([
|
|
375
|
-
r({ type: Boolean, converter:
|
|
392
|
+
r({ type: Boolean, converter: T })
|
|
376
393
|
], s.prototype, "disabled", 2);
|
|
377
394
|
a([
|
|
378
395
|
r({ type: String, attribute: "input-min-aria-label" })
|
|
@@ -381,14 +398,14 @@ a([
|
|
|
381
398
|
r({ type: String, attribute: "input-max-aria-label" })
|
|
382
399
|
], s.prototype, "inputMaxAriaLabel", 2);
|
|
383
400
|
a([
|
|
384
|
-
|
|
401
|
+
k(".track")
|
|
385
402
|
], s.prototype, "track", 2);
|
|
386
403
|
a([
|
|
387
404
|
p()
|
|
388
|
-
], s.prototype, "
|
|
405
|
+
], s.prototype, "_valueMin", 2);
|
|
389
406
|
a([
|
|
390
407
|
p()
|
|
391
|
-
], s.prototype, "
|
|
408
|
+
], s.prototype, "_valueMax", 2);
|
|
392
409
|
a([
|
|
393
410
|
p()
|
|
394
411
|
], s.prototype, "activeThumb", 2);
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { UiKitElement as
|
|
2
|
-
import { customUiKitElement as
|
|
1
|
+
import { UiKitElement as d } from "../base/UiKitElement.js";
|
|
2
|
+
import { customUiKitElement as c } from "../../decorators/customUiKitElement.js";
|
|
3
3
|
import { inputStatesMixin as m } from "../../mixins/inputStatesMixin.js";
|
|
4
4
|
import { validateMaxLength as v } from "../../utils/validateMaxLength.js";
|
|
5
5
|
import "../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/reactive-element.js";
|
|
6
|
-
import { html as
|
|
6
|
+
import { html as o, nothing as l } from "../../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/lit-html.js";
|
|
7
7
|
import "../../node_modules/.pnpm/lit-element@4.2.1/node_modules/lit-element/lit-element.js";
|
|
8
|
-
import { property as
|
|
8
|
+
import { property as p } from "../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/property.js";
|
|
9
9
|
import { classMap as f } from "../../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/directives/class-map.js";
|
|
10
|
-
import { commonStyles as
|
|
11
|
-
var
|
|
12
|
-
for (var a = s > 1 ? void 0 : s ?
|
|
10
|
+
import { commonStyles as y } from "./styles/common.styles.js";
|
|
11
|
+
var x = Object.defineProperty, b = Object.getOwnPropertyDescriptor, n = (t, e, r, s) => {
|
|
12
|
+
for (var a = s > 1 ? void 0 : s ? b(e, r) : e, u = t.length - 1, h; u >= 0; u--)
|
|
13
13
|
(h = t[u]) && (a = (s ? h(e, r, a) : h(a)) || a);
|
|
14
|
-
return s && a &&
|
|
14
|
+
return s && a && x(e, r, a), a;
|
|
15
15
|
};
|
|
16
|
-
let i = class extends m(
|
|
16
|
+
let i = class extends m(d) {
|
|
17
17
|
constructor() {
|
|
18
|
-
super(...arguments), this.keyboardMode = !1, this.size = "medium", this.helperText = "", this.forcedError = "", this.invalidError = "", this.dataAriaLabelRemoveButton = "", this.handleClickIcon = () => {
|
|
18
|
+
super(...arguments), this.keyboardMode = !1, this.size = "medium", this.helperText = "", this.forcedError = "", this.invalidError = "", this.readonlyText = "", this.dataAriaLabelRemoveButton = "", this.handleClickIcon = () => {
|
|
19
19
|
this.nativeInput.value = "", this.nativeInput.focus(), ["input", "change"].forEach(
|
|
20
20
|
(t) => this.nativeInput.dispatchEvent(new Event(t, { bubbles: !0, composed: !0 }))
|
|
21
21
|
);
|
|
@@ -27,6 +27,7 @@ let i = class extends m(c) {
|
|
|
27
27
|
error: !!this.forcedError,
|
|
28
28
|
[this.size]: !!this.size,
|
|
29
29
|
disabled: this.inputStates.disabled,
|
|
30
|
+
readonly: this.inputStates.readonly,
|
|
30
31
|
filled: this.inputStates.filled,
|
|
31
32
|
invalid: this.inputStates.invalid,
|
|
32
33
|
focus: this.inputStates.focus,
|
|
@@ -34,13 +35,14 @@ let i = class extends m(c) {
|
|
|
34
35
|
};
|
|
35
36
|
}
|
|
36
37
|
render() {
|
|
37
|
-
return
|
|
38
|
+
return o`
|
|
38
39
|
<div class=${f(this.classes)}>
|
|
39
40
|
<div class="input-container">
|
|
40
41
|
<div><slot></slot></div>
|
|
41
42
|
${this.iconTemplate}
|
|
42
43
|
</div>
|
|
43
44
|
<div class="footer">
|
|
45
|
+
${this.readonlyTextTemplate}
|
|
44
46
|
${this.helperTextTemplate}
|
|
45
47
|
${this.forcedErrorTemplate}
|
|
46
48
|
${this.invalidErrorTemplate}
|
|
@@ -51,7 +53,7 @@ let i = class extends m(c) {
|
|
|
51
53
|
}
|
|
52
54
|
get iconTemplate() {
|
|
53
55
|
var t, e, r;
|
|
54
|
-
return (e = (t = this.nativeInput) == null ? void 0 : t.value) != null && e.length ? this.componentFactory.createIconButton({
|
|
56
|
+
return !((e = (t = this.nativeInput) == null ? void 0 : t.value) != null && e.length) || this.inputStates.readonly ? l : this.componentFactory.createIconButton({
|
|
55
57
|
class: "icon-button",
|
|
56
58
|
"icon-name": "cross",
|
|
57
59
|
size: this.size,
|
|
@@ -59,41 +61,47 @@ let i = class extends m(c) {
|
|
|
59
61
|
variant: "naked",
|
|
60
62
|
"@click": this.handleClickIcon,
|
|
61
63
|
"data-aria-label": this.dataAriaLabelRemoveButton || "remove button"
|
|
62
|
-
})
|
|
64
|
+
});
|
|
63
65
|
}
|
|
64
66
|
get lengthTemplate() {
|
|
65
67
|
var e, r, s;
|
|
66
68
|
const t = (r = (e = this.nativeInput) == null ? void 0 : e.maxLength) == null ? void 0 : r.toString();
|
|
67
|
-
return v(t) ?
|
|
69
|
+
return v(t) ? o`<span class="char-counter">${((s = this.inputStates.currentValue) == null ? void 0 : s.length) || 0}/${t}</span>` : l;
|
|
68
70
|
}
|
|
69
71
|
get helperTextTemplate() {
|
|
70
|
-
return this.forcedError || this.inputStates.invalid && this.invalidError ?
|
|
72
|
+
return this.inputStates.readonly || this.forcedError || this.inputStates.invalid && this.invalidError ? l : o`<span class="support-text helper-text">${this.helperText}</span>`;
|
|
71
73
|
}
|
|
72
74
|
get forcedErrorTemplate() {
|
|
73
|
-
return this.forcedError ?
|
|
75
|
+
return this.inputStates.readonly || !this.forcedError ? l : o`<span class="support-text error-text forced-error">${this.forcedError}</span>`;
|
|
76
|
+
}
|
|
77
|
+
get readonlyTextTemplate() {
|
|
78
|
+
return !this.inputStates.readonly || !this.readonlyText ? l : o`<span class="support-text readonly-text">${this.readonlyText}</span>`;
|
|
74
79
|
}
|
|
75
80
|
get invalidErrorTemplate() {
|
|
76
|
-
return this.forcedError || !this.inputStates.invalid || !this.invalidError ?
|
|
81
|
+
return this.inputStates.readonly || this.forcedError || !this.inputStates.invalid || !this.invalidError ? l : o`<span class="support-text error-text invalid-error">${this.invalidError}</span>`;
|
|
77
82
|
}
|
|
78
83
|
};
|
|
79
|
-
i.styles = [
|
|
80
|
-
|
|
81
|
-
|
|
84
|
+
i.styles = [y];
|
|
85
|
+
n([
|
|
86
|
+
p({ type: String })
|
|
82
87
|
], i.prototype, "size", 2);
|
|
83
|
-
|
|
84
|
-
|
|
88
|
+
n([
|
|
89
|
+
p({ type: String, attribute: "helper-text" })
|
|
85
90
|
], i.prototype, "helperText", 2);
|
|
86
|
-
|
|
87
|
-
|
|
91
|
+
n([
|
|
92
|
+
p({ type: String, attribute: "forced-error" })
|
|
88
93
|
], i.prototype, "forcedError", 2);
|
|
89
|
-
|
|
90
|
-
|
|
94
|
+
n([
|
|
95
|
+
p({ type: String, attribute: "invalid-error" })
|
|
91
96
|
], i.prototype, "invalidError", 2);
|
|
92
|
-
|
|
93
|
-
|
|
97
|
+
n([
|
|
98
|
+
p({ type: String, attribute: "readonly-text" })
|
|
99
|
+
], i.prototype, "readonlyText", 2);
|
|
100
|
+
n([
|
|
101
|
+
p({ type: String, attribute: "data-aria-label-remove-button" })
|
|
94
102
|
], i.prototype, "dataAriaLabelRemoveButton", 2);
|
|
95
|
-
i =
|
|
96
|
-
|
|
103
|
+
i = n([
|
|
104
|
+
c("ds-text-input")
|
|
97
105
|
], i);
|
|
98
106
|
export {
|
|
99
107
|
i as DsTextInput
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { UiKitElement as
|
|
2
|
-
import { customUiKitElement as
|
|
1
|
+
import { UiKitElement as u } from "../base/UiKitElement.js";
|
|
2
|
+
import { customUiKitElement as m } from "../../decorators/customUiKitElement.js";
|
|
3
3
|
import { ViewportMixin as c } from "../../mixins/ViewportMixin.js";
|
|
4
4
|
import { inputStatesMixin as f } from "../../mixins/inputStatesMixin.js";
|
|
5
|
-
import { objectConverter as
|
|
6
|
-
import { validateMaxLength as
|
|
5
|
+
import { objectConverter as y } from "../../utils/objectConverter.js";
|
|
6
|
+
import { validateMaxLength as v } from "../../utils/validateMaxLength.js";
|
|
7
7
|
import "../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/reactive-element.js";
|
|
8
|
-
import { html as
|
|
8
|
+
import { html as n, nothing as l } from "../../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/lit-html.js";
|
|
9
9
|
import "../../node_modules/.pnpm/lit-element@4.2.1/node_modules/lit-element/lit-element.js";
|
|
10
10
|
import { property as p } from "../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/decorators/property.js";
|
|
11
|
-
import { classMap as
|
|
12
|
-
import { commonStyles as
|
|
13
|
-
var
|
|
14
|
-
for (var s = i > 1 ? void 0 : i ?
|
|
15
|
-
(
|
|
16
|
-
return i && s &&
|
|
11
|
+
import { classMap as x } from "../../node_modules/.pnpm/lit-html@3.3.1/node_modules/lit-html/directives/class-map.js";
|
|
12
|
+
import { commonStyles as g } from "./styles/common.styles.js";
|
|
13
|
+
var S = Object.defineProperty, T = Object.getOwnPropertyDescriptor, o = (t, r, a, i) => {
|
|
14
|
+
for (var s = i > 1 ? void 0 : i ? T(r, a) : r, d = t.length - 1, h; d >= 0; d--)
|
|
15
|
+
(h = t[d]) && (s = (i ? h(r, a, s) : h(s)) || s);
|
|
16
|
+
return i && s && S(r, a, s), s;
|
|
17
17
|
};
|
|
18
|
-
let
|
|
18
|
+
let e = class extends f(c(u)) {
|
|
19
19
|
constructor() {
|
|
20
|
-
super(...arguments), this.keyboardMode = !1, this.size = "medium", this.helperText = "", this.forcedError = "", this.invalidError = "", this.mode = "light";
|
|
20
|
+
super(...arguments), this.keyboardMode = !1, this.size = "medium", this.helperText = "", this.forcedError = "", this.invalidError = "", this.readonlyText = "", this.mode = "light";
|
|
21
21
|
}
|
|
22
22
|
onInputReady(t) {
|
|
23
23
|
t.classList.add("ds-scroll");
|
|
@@ -30,6 +30,7 @@ let r = class extends f(c(m)) {
|
|
|
30
30
|
[t]: !!t,
|
|
31
31
|
[this.mode]: !!this.mode,
|
|
32
32
|
disabled: this.inputStates.disabled,
|
|
33
|
+
readonly: this.inputStates.readonly,
|
|
33
34
|
filled: this.inputStates.filled,
|
|
34
35
|
invalid: this.inputStates.invalid,
|
|
35
36
|
focus: this.inputStates.focus,
|
|
@@ -37,12 +38,13 @@ let r = class extends f(c(m)) {
|
|
|
37
38
|
};
|
|
38
39
|
}
|
|
39
40
|
render() {
|
|
40
|
-
return
|
|
41
|
-
<div class=${
|
|
41
|
+
return n`
|
|
42
|
+
<div class=${x(this.classes)}>
|
|
42
43
|
<div class="input-container">
|
|
43
44
|
<slot></slot>
|
|
44
45
|
</div>
|
|
45
46
|
<div class="footer">
|
|
47
|
+
${this.readonlyTextTemplate}
|
|
46
48
|
${this.helperTextTemplate}
|
|
47
49
|
${this.forcedErrorTemplate}
|
|
48
50
|
${this.invalidErrorTemplate}
|
|
@@ -52,39 +54,45 @@ let r = class extends f(c(m)) {
|
|
|
52
54
|
`;
|
|
53
55
|
}
|
|
54
56
|
get lengthTemplate() {
|
|
55
|
-
var
|
|
56
|
-
const t = (
|
|
57
|
-
return
|
|
57
|
+
var r, a, i;
|
|
58
|
+
const t = (a = (r = this.nativeInput) == null ? void 0 : r.maxLength) == null ? void 0 : a.toString();
|
|
59
|
+
return v(t) ? n`<span class="char-counter">${((i = this.inputStates.currentValue) == null ? void 0 : i.length) || 0}/${t}</span>` : l;
|
|
58
60
|
}
|
|
59
61
|
get helperTextTemplate() {
|
|
60
|
-
return this.forcedError || this.inputStates.invalid && this.invalidError ? l :
|
|
62
|
+
return this.inputStates.readonly || this.forcedError || this.inputStates.invalid && this.invalidError ? l : n`<span class="support-text helper-text">${this.helperText}</span>`;
|
|
61
63
|
}
|
|
62
64
|
get forcedErrorTemplate() {
|
|
63
|
-
return this.forcedError ?
|
|
65
|
+
return this.inputStates.readonly || !this.forcedError ? l : n`<span class="support-text error-text forced-error">${this.forcedError}</span>`;
|
|
66
|
+
}
|
|
67
|
+
get readonlyTextTemplate() {
|
|
68
|
+
return !this.inputStates.readonly || !this.readonlyText ? l : n`<span class="support-text readonly-text">${this.readonlyText}</span>`;
|
|
64
69
|
}
|
|
65
70
|
get invalidErrorTemplate() {
|
|
66
|
-
return this.forcedError || !this.inputStates.invalid || !this.invalidError ? l :
|
|
71
|
+
return this.inputStates.readonly || this.forcedError || !this.inputStates.invalid || !this.invalidError ? l : n`<span class="support-text error-text invalid-error">${this.invalidError}</span>`;
|
|
67
72
|
}
|
|
68
73
|
};
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
p({ type: String, converter:
|
|
72
|
-
],
|
|
73
|
-
|
|
74
|
+
e.styles = [g];
|
|
75
|
+
o([
|
|
76
|
+
p({ type: String, converter: y })
|
|
77
|
+
], e.prototype, "size", 2);
|
|
78
|
+
o([
|
|
74
79
|
p({ type: String, attribute: "helper-text" })
|
|
75
|
-
],
|
|
76
|
-
|
|
80
|
+
], e.prototype, "helperText", 2);
|
|
81
|
+
o([
|
|
77
82
|
p({ type: String, attribute: "forced-error" })
|
|
78
|
-
],
|
|
79
|
-
|
|
83
|
+
], e.prototype, "forcedError", 2);
|
|
84
|
+
o([
|
|
80
85
|
p({ type: String, attribute: "invalid-error" })
|
|
81
|
-
],
|
|
82
|
-
|
|
86
|
+
], e.prototype, "invalidError", 2);
|
|
87
|
+
o([
|
|
88
|
+
p({ type: String, attribute: "readonly-text" })
|
|
89
|
+
], e.prototype, "readonlyText", 2);
|
|
90
|
+
o([
|
|
83
91
|
p({ type: String })
|
|
84
|
-
],
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
],
|
|
92
|
+
], e.prototype, "mode", 2);
|
|
93
|
+
e = o([
|
|
94
|
+
m("ds-textarea")
|
|
95
|
+
], e);
|
|
88
96
|
export {
|
|
89
|
-
|
|
97
|
+
e as DsTextarea
|
|
90
98
|
};
|
|
@@ -54,7 +54,7 @@ let m = class extends v {
|
|
|
54
54
|
}
|
|
55
55
|
loadThemeStyles() {
|
|
56
56
|
return this.loadStyles ? new Promise((t, o) => {
|
|
57
|
-
const s = "/2.0.0-canary.
|
|
57
|
+
const s = "/2.0.0-canary.63", r = `https://ds-assets.cupra.com${s}/styles/${this.theme}/theme.css`;
|
|
58
58
|
if (document.head.querySelector(`link[href="${r}"]`)) t();
|
|
59
59
|
else {
|
|
60
60
|
const e = `ui-kit-theme-${s}`, a = document.getElementById(e), n = document.createElement("link");
|
|
@@ -6,10 +6,11 @@ const o = (u) => class extends u {
|
|
|
6
6
|
focusVisible: !1,
|
|
7
7
|
invalid: !1,
|
|
8
8
|
filled: !1,
|
|
9
|
-
disabled: !1
|
|
9
|
+
disabled: !1,
|
|
10
|
+
readonly: !1
|
|
10
11
|
}, this.keyboardMode = !1, this._updateStates = () => {
|
|
11
|
-
var t, e, s, i, n;
|
|
12
|
-
this.inputStates.currentValue = (t = this.nativeInput) == null ? void 0 : t.value, this.inputStates.invalid = !((e = this.nativeInput) != null && e.validity.valid), this.inputStates.focus = document.activeElement === this.nativeInput, this.inputStates.disabled = (s = this.nativeInput) == null ? void 0 : s.disabled, this.inputStates.filled = ((
|
|
12
|
+
var t, e, s, i, n, a;
|
|
13
|
+
this.inputStates.currentValue = (t = this.nativeInput) == null ? void 0 : t.value, this.inputStates.invalid = !((e = this.nativeInput) != null && e.validity.valid), this.inputStates.focus = document.activeElement === this.nativeInput, this.inputStates.disabled = (s = this.nativeInput) == null ? void 0 : s.disabled, this.inputStates.readonly = ((i = this.nativeInput) == null ? void 0 : i.readOnly) ?? !1, this.inputStates.filled = ((a = (n = this.nativeInput) == null ? void 0 : n.value) == null ? void 0 : a.length) > 0, this.requestUpdate();
|
|
13
14
|
}, this._handleKeydown = () => {
|
|
14
15
|
this.keyboardMode = !0;
|
|
15
16
|
}, this._handleMousedown = () => {
|