@golemui/gui-lit 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -0
- package/{accordion.element-BIgxl5e9.js → accordion.element-C9GzfKrY.js} +29 -30
- package/alert.element-CHn49Yaf.js +55 -0
- package/button.element-C9fHivSw.js +59 -0
- package/{calendar.element-Cv3RBphf.js → calendar.element-XkojKTJk.js} +30 -31
- package/checkbox.element-DU_tVMXu.js +66 -0
- package/currency.element-BmAH5KS_.js +73 -0
- package/date-picker.element-Bg3rF95F.js +94 -0
- package/{date-time-calendar.element-DlbWZjoe.js → date-time-calendar.element-sywQCeQQ.js} +24 -24
- package/date-time-picker.element-HHpwjWTQ.js +107 -0
- package/{date-time.element-CLLxM2nV.js → date-time.element-ucETvSTC.js} +26 -26
- package/{date.element-B8ZHK9KJ.js → date.element-BEHGxRFF.js} +27 -27
- package/default-list-item-renderer-CuPJ9jUD.js +24 -0
- package/{dropdown.element-DMZ7oL5n.js → dropdown.element-DUqG_p1x.js} +85 -84
- package/{flex.element-DG4Uaj_X.js → flex.element-pwba7621.js} +27 -28
- package/{grid.element-DCZsh-3J.js → grid.element-C8K7_Qi3.js} +29 -30
- package/index.js +1316 -3883
- package/index.umd.cjs +117 -2132
- package/{list.element-ADtUK2na.js → list.element-ZtEMKE2x.js} +41 -40
- package/markdown-text.element-DDm36qD0.js +54 -0
- package/markdown.element-DWz3U9rG.js +84 -0
- package/number.element-VkG5wScD.js +71 -0
- package/package.json +6 -6
- package/password.element-C5vQHq5P.js +72 -0
- package/radiogroup.element-CKdO9HwO.js +69 -0
- package/{range-calendar.element-D5eb2f7p.js → range-calendar.element-BznGrej5.js} +23 -24
- package/{range-date-input.element-C35grlYo.js → range-date-input.element-BloTHRDl.js} +24 -24
- package/range-date-picker.element-DKhwFasW.js +98 -0
- package/{range-date-time-calendar.element-BV0J96Gu.js → range-date-time-calendar.element-CZCET-sb.js} +26 -26
- package/{range-date-time-input.element-CzgRbR9F.js → range-date-time-input.element-Dr2VrYhG.js} +24 -24
- package/range-date-time-picker.element-CYeIMWLp.js +109 -0
- package/{range-time-input.element-BOHLUO8z.js → range-time-input.element-7OZhPQqx.js} +23 -23
- package/range-time-picker.element-D0mRFZkK.js +96 -0
- package/renderer.element-DbsFoBba.js +48 -0
- package/{repeater.element-Da8YN1Vy.js → repeater.element-DGEbwvhY.js} +54 -65
- package/select.element-Bb_9jAVB.js +76 -0
- package/{tabs.element-CvcIA8P3.js → tabs.element-BYDNF_pm.js} +49 -50
- package/tags.element-BSN3i9Gx.js +73 -0
- package/textarea.element-Dl1ZEOqO.js +71 -0
- package/textinput.element-C5Vbbkxq.js +68 -0
- package/{time-picker.element-C3oR0EkQ.js → time-picker.element-Crmj9YDy.js} +26 -26
- package/{time.element-X286nthD.js → time.element-DfSeAZp4.js} +29 -29
- package/toggle.element-ORsprZ2M.js +66 -0
- package/alert.element-DPWq9-0F.js +0 -56
- package/button.element-CJay43iR.js +0 -132
- package/calendar-DleRbmvP.js +0 -267
- package/checkbox.element-CpmrzdH0.js +0 -200
- package/currency.element-Cezgzbbs.js +0 -276
- package/date-DBuYpvcO.js +0 -849
- package/date-input-B3yHsn-g.js +0 -204
- package/date-picker.element-ByZefznr.js +0 -357
- package/date-time-calendar-CB5cNoOX.js +0 -374
- package/date-time-input-DrY68YDX.js +0 -246
- package/date-time-picker.element-CYwmumfq.js +0 -440
- package/day-status-ljexnwEO.js +0 -554
- package/errors-Bs_vYN-_.js +0 -110
- package/focus-leave.controller-2gV0pQd5.js +0 -73
- package/list-D730tmGN.js +0 -297
- package/markdown-text-X-BRJT6K.js +0 -30
- package/markdown-text.element-B8TfVLIO.js +0 -55
- package/markdown.element-D5zcxAUS.js +0 -693
- package/number.element-DEY5tR_y.js +0 -291
- package/numeric-jmOOKz30.js +0 -12
- package/one-of-anKkm7mD.js +0 -50
- package/part-templates-VORbpgs2.js +0 -691
- package/password.element-C1aQh_iz.js +0 -240
- package/pill-ranges-DpvWwP-3.js +0 -48
- package/pills-BDMO2NiR.js +0 -348
- package/popup.controller-B33OvX_y.js +0 -86
- package/radiogroup.element-B2G-XyGx.js +0 -235
- package/range-calendar-D7sG24Kx.js +0 -466
- package/range-commit-8-MmYUyo.js +0 -14
- package/range-date-input-BChaoBC1.js +0 -311
- package/range-date-picker.element-Do5YsL5V.js +0 -434
- package/range-date-time-calendar-DulGK2EQ.js +0 -734
- package/range-date-time-input-8ggqckP7.js +0 -353
- package/range-date-time-picker.element-hi5KdopZ.js +0 -472
- package/range-selection-CU3hxLJE.js +0 -25
- package/range-time-input-D7GFdDeA.js +0 -348
- package/range-time-picker.element-DDNQMA_u.js +0 -470
- package/renderer.element-CNyMn2Lu.js +0 -49
- package/select.element-SDxBhGjz.js +0 -266
- package/tabs-DzSCq_98.js +0 -13
- package/tags.element-Bnhfevp3.js +0 -369
- package/templates-Df7abEkB.js +0 -92
- package/textarea.element-Dx7eYEnl.js +0 -239
- package/textinput.element-BnIoDRmY.js +0 -205
- package/time-input-Kk4EX6at.js +0 -201
- package/time-list-DLcq8BAp.js +0 -217
- package/time-picker-DLj1rhOf.js +0 -299
- package/toggle.element-Dokdat_o.js +0 -203
|
@@ -1,291 +0,0 @@
|
|
|
1
|
-
import { InputWidgetAdapter as v, formContext as y, inputContext as g } from "@golemui/lit";
|
|
2
|
-
import { LitElement as m, nothing as d, html as c } from "lit";
|
|
3
|
-
import { property as r, customElement as b } from "lit/decorators.js";
|
|
4
|
-
import { G as f, b as $, c as w } from "./templates-Df7abEkB.js";
|
|
5
|
-
import { b as x, a as N } from "./numeric-jmOOKz30.js";
|
|
6
|
-
import { styleMap as D } from "lit-html/directives/style-map.js";
|
|
7
|
-
import { consume as C, provide as A } from "@lit/context";
|
|
8
|
-
import "rxjs";
|
|
9
|
-
var E = Object.defineProperty, O = Object.getOwnPropertyDescriptor, s = (t, i, e, o) => {
|
|
10
|
-
for (var u = o > 1 ? void 0 : o ? O(i, e) : i, l = t.length - 1, p; l >= 0; l--)
|
|
11
|
-
(p = t[l]) && (u = (o ? p(i, e, u) : p(u)) || u);
|
|
12
|
-
return o && u && E(i, e, u), u;
|
|
13
|
-
};
|
|
14
|
-
let a = class extends m {
|
|
15
|
-
constructor() {
|
|
16
|
-
super(...arguments), this.uid = void 0, this.label = void 0, this.hint = void 0, this.localeId = "en", this.errors = [], this.touched = !1, this.required = !1, this.disabled = !1, this.readOnly = !1, this.value = void 0, this.step = void 0, this.placeholder = void 0, this.autocomplete = void 0, this.minimum = void 0, this.maximum = void 0, this.autoGrow = !1, this.ariaController = new f(this, {
|
|
17
|
-
getTargets: () => this.querySelectorAll(`input[id="${this.uid}"]`),
|
|
18
|
-
getState: () => ({
|
|
19
|
-
uid: this.uid,
|
|
20
|
-
templateData: {
|
|
21
|
-
hint: this.hint,
|
|
22
|
-
errors: this.errors,
|
|
23
|
-
readonly: this.readOnly,
|
|
24
|
-
disabled: this.disabled,
|
|
25
|
-
touched: this.touched,
|
|
26
|
-
required: this.required
|
|
27
|
-
}
|
|
28
|
-
})
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
createRenderRoot() {
|
|
32
|
-
return this;
|
|
33
|
-
}
|
|
34
|
-
connectedCallback() {
|
|
35
|
-
super.connectedCallback(), this.classList.add("gui-field");
|
|
36
|
-
}
|
|
37
|
-
render() {
|
|
38
|
-
super.render();
|
|
39
|
-
const t = this.querySelector(`input[id="${this.uid}"]`), i = {
|
|
40
|
-
"min-width": "23px"
|
|
41
|
-
};
|
|
42
|
-
if (this.autoGrow)
|
|
43
|
-
if (t) {
|
|
44
|
-
t.style.width = "0px";
|
|
45
|
-
const o = Math.max(23, t.scrollWidth);
|
|
46
|
-
i.width = `${o}px`, i.maxWidth = `${o}px`, t.style.width = "";
|
|
47
|
-
} else
|
|
48
|
-
i.width = "47px";
|
|
49
|
-
const e = {
|
|
50
|
-
uid: this.uid,
|
|
51
|
-
label: this.label,
|
|
52
|
-
hint: this.hint,
|
|
53
|
-
errors: this.errors,
|
|
54
|
-
touched: this.touched,
|
|
55
|
-
required: this.required,
|
|
56
|
-
disabled: this.disabled,
|
|
57
|
-
readonly: this.readOnly,
|
|
58
|
-
value: this.value,
|
|
59
|
-
step: this.step,
|
|
60
|
-
placeholder: this.placeholder,
|
|
61
|
-
autocomplete: this.autocomplete
|
|
62
|
-
};
|
|
63
|
-
return c`
|
|
64
|
-
${$(this.uid, e)}
|
|
65
|
-
|
|
66
|
-
<div class="gui-widget">
|
|
67
|
-
<input
|
|
68
|
-
type="number"
|
|
69
|
-
inputmode="decimal"
|
|
70
|
-
id=${this.uid}
|
|
71
|
-
data-cy=${`${this.uid}_number`}
|
|
72
|
-
class="gui-widget-input"
|
|
73
|
-
style=${D(i)}
|
|
74
|
-
value=${this.value}
|
|
75
|
-
?required=${this.required}
|
|
76
|
-
?disabled=${this.disabled}
|
|
77
|
-
?readonly=${this.readOnly}
|
|
78
|
-
step=${typeof this.step == "number" ? this.step : d}
|
|
79
|
-
min=${Number(this.minimum) ? this.minimum : d}
|
|
80
|
-
max=${Number(this.maximum) ? this.maximum : d}
|
|
81
|
-
placeholder=${this.placeholder || d}
|
|
82
|
-
autocomplete=${this.autocomplete || d}
|
|
83
|
-
@input=${this.valueChanged}
|
|
84
|
-
@beforeinput=${x}
|
|
85
|
-
@keydown=${this.keyDown}
|
|
86
|
-
@blur=${this.onBlur}
|
|
87
|
-
/>
|
|
88
|
-
<span class="gui-number__decoration">
|
|
89
|
-
<svg
|
|
90
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
91
|
-
width="12"
|
|
92
|
-
height="12"
|
|
93
|
-
viewBox="0 0 256 256"
|
|
94
|
-
aria-hidden="true"
|
|
95
|
-
>
|
|
96
|
-
<path
|
|
97
|
-
d="M213.66,165.66a8,8,0,0,1-11.32,0L128,91.31,53.66,165.66a8,8,0,0,1-11.32-11.32l80-80a8,8,0,0,1,11.32,0l80,80A8,8,0,0,1,213.66,165.66Z"
|
|
98
|
-
></path>
|
|
99
|
-
</svg>
|
|
100
|
-
<svg
|
|
101
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
102
|
-
width="12"
|
|
103
|
-
height="12"
|
|
104
|
-
viewBox="0 0 256 256"
|
|
105
|
-
aria-hidden="true"
|
|
106
|
-
>
|
|
107
|
-
<path
|
|
108
|
-
d="M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,90.34L128,164.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z"
|
|
109
|
-
></path>
|
|
110
|
-
</svg>
|
|
111
|
-
</span>
|
|
112
|
-
</div>
|
|
113
|
-
|
|
114
|
-
${w(this.uid, e)}
|
|
115
|
-
`;
|
|
116
|
-
}
|
|
117
|
-
keyDown(t) {
|
|
118
|
-
switch (t.stopPropagation(), N(t), t.key) {
|
|
119
|
-
case "ArrowUp":
|
|
120
|
-
t.preventDefault(), this.plus();
|
|
121
|
-
break;
|
|
122
|
-
case "ArrowDown":
|
|
123
|
-
t.preventDefault(), this.minus();
|
|
124
|
-
break;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
minus() {
|
|
128
|
-
if (!this.readOnly) {
|
|
129
|
-
const t = this.querySelector(`input[id="${this.uid}"]`), i = typeof this.step == "number" ? this.step : 1;
|
|
130
|
-
let e = Number(t.valueAsNumber) || Number(t.valueAsNumber) === 0 ? t.valueAsNumber - i : 1;
|
|
131
|
-
e = Number(this.maximum) ? Math.min(e, this.maximum) : e, e = Number(this.minimum) ? Math.max(e, this.minimum) : e, t.valueAsNumber = e, this.value = e, this.dispatchEvent(
|
|
132
|
-
new CustomEvent("input", {
|
|
133
|
-
detail: { value: this.value },
|
|
134
|
-
bubbles: !0,
|
|
135
|
-
composed: !0
|
|
136
|
-
})
|
|
137
|
-
);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
plus() {
|
|
141
|
-
if (!this.readOnly) {
|
|
142
|
-
const t = this.querySelector(`input[id="${this.uid}"]`), i = typeof this.step == "number" ? this.step : 1;
|
|
143
|
-
let e = Number(t.valueAsNumber) || Number(t.valueAsNumber) === 0 ? t.valueAsNumber + i : 1;
|
|
144
|
-
e = Number(this.maximum) ? Math.min(e, this.maximum) : e, e = Number(this.minimum) ? Math.max(e, this.minimum) : e, t.valueAsNumber = e, this.value = e, this.dispatchEvent(
|
|
145
|
-
new CustomEvent("input", {
|
|
146
|
-
detail: { value: this.value },
|
|
147
|
-
bubbles: !0,
|
|
148
|
-
composed: !0
|
|
149
|
-
})
|
|
150
|
-
);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
valueChanged(t) {
|
|
154
|
-
if (t.stopPropagation(), !this.readOnly) {
|
|
155
|
-
const e = t.target.valueAsNumber;
|
|
156
|
-
this.dispatchEvent(
|
|
157
|
-
new CustomEvent("input", {
|
|
158
|
-
detail: { value: Number.isNaN(e) ? void 0 : e },
|
|
159
|
-
bubbles: !0,
|
|
160
|
-
composed: !0
|
|
161
|
-
})
|
|
162
|
-
);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
onBlur() {
|
|
166
|
-
this.dispatchEvent(
|
|
167
|
-
new CustomEvent("blur", {
|
|
168
|
-
bubbles: !0,
|
|
169
|
-
composed: !0
|
|
170
|
-
})
|
|
171
|
-
);
|
|
172
|
-
}
|
|
173
|
-
};
|
|
174
|
-
s([
|
|
175
|
-
r({ type: String })
|
|
176
|
-
], a.prototype, "uid", 2);
|
|
177
|
-
s([
|
|
178
|
-
r({ type: String })
|
|
179
|
-
], a.prototype, "label", 2);
|
|
180
|
-
s([
|
|
181
|
-
r({ type: String })
|
|
182
|
-
], a.prototype, "hint", 2);
|
|
183
|
-
s([
|
|
184
|
-
r({ type: String, attribute: "locale-id" })
|
|
185
|
-
], a.prototype, "localeId", 2);
|
|
186
|
-
s([
|
|
187
|
-
r({ type: Array })
|
|
188
|
-
], a.prototype, "errors", 2);
|
|
189
|
-
s([
|
|
190
|
-
r({ type: Boolean })
|
|
191
|
-
], a.prototype, "touched", 2);
|
|
192
|
-
s([
|
|
193
|
-
r({ type: Boolean })
|
|
194
|
-
], a.prototype, "required", 2);
|
|
195
|
-
s([
|
|
196
|
-
r({ type: Boolean })
|
|
197
|
-
], a.prototype, "disabled", 2);
|
|
198
|
-
s([
|
|
199
|
-
r({ type: Boolean, attribute: "readonly" })
|
|
200
|
-
], a.prototype, "readOnly", 2);
|
|
201
|
-
s([
|
|
202
|
-
r({ type: Number })
|
|
203
|
-
], a.prototype, "value", 2);
|
|
204
|
-
s([
|
|
205
|
-
r({ type: Number })
|
|
206
|
-
], a.prototype, "step", 2);
|
|
207
|
-
s([
|
|
208
|
-
r({ type: String })
|
|
209
|
-
], a.prototype, "placeholder", 2);
|
|
210
|
-
s([
|
|
211
|
-
r({ type: String })
|
|
212
|
-
], a.prototype, "autocomplete", 2);
|
|
213
|
-
s([
|
|
214
|
-
r({ type: Number })
|
|
215
|
-
], a.prototype, "minimum", 2);
|
|
216
|
-
s([
|
|
217
|
-
r({ type: Number })
|
|
218
|
-
], a.prototype, "maximum", 2);
|
|
219
|
-
s([
|
|
220
|
-
r({ type: Number })
|
|
221
|
-
], a.prototype, "autoGrow", 2);
|
|
222
|
-
a = s([
|
|
223
|
-
b("gui-number")
|
|
224
|
-
], a);
|
|
225
|
-
typeof customElements < "u" && !customElements.get("gui-number") && customElements.define("gui-number", a);
|
|
226
|
-
var q = Object.defineProperty, _ = Object.getOwnPropertyDescriptor, n = (t, i, e, o) => {
|
|
227
|
-
for (var u = o > 1 ? void 0 : o ? _(i, e) : i, l = t.length - 1, p; l >= 0; l--)
|
|
228
|
-
(p = t[l]) && (u = (o ? p(i, e, u) : p(u)) || u);
|
|
229
|
-
return o && u && q(i, e, u), u;
|
|
230
|
-
};
|
|
231
|
-
let h = class extends m {
|
|
232
|
-
constructor() {
|
|
233
|
-
super(...arguments), this.adapter = new v(), this.subscriptions = [];
|
|
234
|
-
}
|
|
235
|
-
createRenderRoot() {
|
|
236
|
-
return this;
|
|
237
|
-
}
|
|
238
|
-
updated(t) {
|
|
239
|
-
super.updated(t);
|
|
240
|
-
const i = this.adapter.templateData.size;
|
|
241
|
-
i ? this.style.flex = String(i) : this.style.removeProperty("flex");
|
|
242
|
-
}
|
|
243
|
-
connectedCallback() {
|
|
244
|
-
super.connectedCallback(), this.classList.add("gui-number", "gui-field"), this.adapter.context = this.formContext, this.adapter.init(this.widget), this.subscriptions.push(
|
|
245
|
-
this.adapter.templateDataChanged$.subscribe(() => this.requestUpdate())
|
|
246
|
-
);
|
|
247
|
-
}
|
|
248
|
-
render() {
|
|
249
|
-
return super.render(), c`
|
|
250
|
-
<gui-number
|
|
251
|
-
.uid=${this.widget.uid}
|
|
252
|
-
.label=${this.adapter.templateData.label}
|
|
253
|
-
.hint=${this.adapter.templateData.hint}
|
|
254
|
-
.errors=${this.adapter.templateData.errors}
|
|
255
|
-
?touched=${this.adapter.templateData.touched}
|
|
256
|
-
?required=${this.adapter.templateData.validator?.required}
|
|
257
|
-
?disabled=${this.adapter.templateData.disabled}
|
|
258
|
-
?readonly=${this.adapter.templateData.readonly}
|
|
259
|
-
.value=${this.adapter.templateData.value}
|
|
260
|
-
.step=${this.adapter.templateData.step}
|
|
261
|
-
.minimum=${this.adapter.templateData.minimum}
|
|
262
|
-
.maximum=${this.adapter.templateData.maximum}
|
|
263
|
-
.autoGrow=${this.adapter.templateData.autoGrow}
|
|
264
|
-
.placeholder=${this.adapter.templateData.placeholder}
|
|
265
|
-
.autocomplete=${this.adapter.templateData.autocomplete}
|
|
266
|
-
@input=${this.valueChanged}
|
|
267
|
-
@blur=${() => this.adapter.onBlur()}
|
|
268
|
-
></gui-number>
|
|
269
|
-
`;
|
|
270
|
-
}
|
|
271
|
-
valueChanged(t) {
|
|
272
|
-
const i = t.detail.value;
|
|
273
|
-
this.adapter.valueChanged(i);
|
|
274
|
-
}
|
|
275
|
-
disconnectedCallback() {
|
|
276
|
-
super.disconnectedCallback(), this.adapter.destroy(), this.subscriptions.forEach((t) => t.unsubscribe());
|
|
277
|
-
}
|
|
278
|
-
};
|
|
279
|
-
n([
|
|
280
|
-
C({ context: y }),
|
|
281
|
-
r({ attribute: !1 })
|
|
282
|
-
], h.prototype, "formContext", 2);
|
|
283
|
-
n([
|
|
284
|
-
A({ context: g })
|
|
285
|
-
], h.prototype, "adapter", 2);
|
|
286
|
-
h = n([
|
|
287
|
-
b("gui-number-input")
|
|
288
|
-
], h);
|
|
289
|
-
export {
|
|
290
|
-
h as NumberElement
|
|
291
|
-
};
|
package/numeric-jmOOKz30.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
const r = /^[0-9.,eE+-]+$/;
|
|
2
|
-
function i(t) {
|
|
3
|
-
const a = t.data ?? t.dataTransfer?.getData("text");
|
|
4
|
-
a && (r.test(a) || t.preventDefault());
|
|
5
|
-
}
|
|
6
|
-
function o(t) {
|
|
7
|
-
t.ctrlKey || t.metaKey || t.altKey || t.isComposing || t.key.length === 1 && (r.test(t.key) || t.preventDefault());
|
|
8
|
-
}
|
|
9
|
-
export {
|
|
10
|
-
o as a,
|
|
11
|
-
i as b
|
|
12
|
-
};
|
package/one-of-anKkm7mD.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import "./index.js";
|
|
2
|
-
import "@golemui/core";
|
|
3
|
-
const i = (e) => e !== null && typeof e == "object" && Object.prototype.hasOwnProperty.call(e, "label") && Object.prototype.hasOwnProperty.call(e, "value");
|
|
4
|
-
function s(e) {
|
|
5
|
-
const r = typeof e;
|
|
6
|
-
return r === "string" || r === "number";
|
|
7
|
-
}
|
|
8
|
-
function b(e, r) {
|
|
9
|
-
return r.find((t) => t.value.toString() === e)?.value;
|
|
10
|
-
}
|
|
11
|
-
const O = (e, r) => {
|
|
12
|
-
if (Array.isArray(e) && e.length > 0 && !i(e[0])) {
|
|
13
|
-
if (s(e[0]))
|
|
14
|
-
return e.map((t) => ({
|
|
15
|
-
label: t.toString(),
|
|
16
|
-
value: t
|
|
17
|
-
}));
|
|
18
|
-
if (u(e[0], r)) {
|
|
19
|
-
const t = f(e[0], r);
|
|
20
|
-
return e.map(t);
|
|
21
|
-
} else
|
|
22
|
-
throw new Error("Invalid option shape");
|
|
23
|
-
}
|
|
24
|
-
return e;
|
|
25
|
-
}, u = (e, { labelField: r, valueField: t }) => {
|
|
26
|
-
if (e === null || typeof e != "object")
|
|
27
|
-
return !1;
|
|
28
|
-
const n = e, o = r ? Object.prototype.hasOwnProperty.call(n, r) : !1, a = t ? Object.prototype.hasOwnProperty.call(n, t) : !1;
|
|
29
|
-
return r && !o ? !1 : !(t && !a);
|
|
30
|
-
};
|
|
31
|
-
function f(e, { labelField: r, valueField: t }) {
|
|
32
|
-
if (e === null || typeof e != "object")
|
|
33
|
-
throw new Error("Provided value is not an object");
|
|
34
|
-
const n = e, o = r && Object.prototype.hasOwnProperty.call(n, r) ? r : void 0, a = t && Object.prototype.hasOwnProperty.call(n, t) ? t : void 0;
|
|
35
|
-
if (!o && !a)
|
|
36
|
-
throw new Error("Neither labelField nor valueField exists on the object");
|
|
37
|
-
return (l) => {
|
|
38
|
-
if (l === null || typeof l != "object")
|
|
39
|
-
throw new Error("Item is not an object");
|
|
40
|
-
const c = l;
|
|
41
|
-
return {
|
|
42
|
-
label: o ? c[o] : "",
|
|
43
|
-
value: a ? c[a] : ""
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
export {
|
|
48
|
-
b as i,
|
|
49
|
-
O as u
|
|
50
|
-
};
|