@phcdevworks/spectre-components 0.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/README.md +113 -40
  2. package/dist/base-2rD8EmdC.d.cts +32 -0
  3. package/dist/base-2rD8EmdC.d.ts +32 -0
  4. package/dist/button.cjs +295 -170
  5. package/dist/button.cjs.map +1 -1
  6. package/dist/button.d.cts +30 -61
  7. package/dist/button.d.ts +30 -61
  8. package/dist/button.js +296 -171
  9. package/dist/button.js.map +1 -1
  10. package/dist/checkbox.cjs +286 -71
  11. package/dist/checkbox.cjs.map +1 -1
  12. package/dist/checkbox.d.cts +38 -43
  13. package/dist/checkbox.d.ts +38 -43
  14. package/dist/checkbox.js +287 -72
  15. package/dist/checkbox.js.map +1 -1
  16. package/dist/fieldset.cjs +233 -88
  17. package/dist/fieldset.cjs.map +1 -1
  18. package/dist/fieldset.d.cts +23 -40
  19. package/dist/fieldset.d.ts +23 -40
  20. package/dist/fieldset.js +233 -88
  21. package/dist/fieldset.js.map +1 -1
  22. package/dist/form-iI7vV-3W.d.cts +6 -0
  23. package/dist/form-iI7vV-3W.d.ts +6 -0
  24. package/dist/index.cjs +564 -1029
  25. package/dist/index.cjs.map +1 -1
  26. package/dist/index.d.cts +5 -2
  27. package/dist/index.d.ts +5 -2
  28. package/dist/index.js +566 -1030
  29. package/dist/index.js.map +1 -1
  30. package/dist/input.cjs +232 -119
  31. package/dist/input.cjs.map +1 -1
  32. package/dist/input.d.cts +52 -68
  33. package/dist/input.d.ts +52 -68
  34. package/dist/input.js +232 -119
  35. package/dist/input.js.map +1 -1
  36. package/dist/label.cjs +232 -73
  37. package/dist/label.cjs.map +1 -1
  38. package/dist/label.d.cts +13 -22
  39. package/dist/label.d.ts +13 -22
  40. package/dist/label.js +232 -73
  41. package/dist/label.js.map +1 -1
  42. package/dist/projectable-BzDQ4xp_.d.cts +17 -0
  43. package/dist/projectable-s3SgvjGX.d.ts +17 -0
  44. package/dist/radio.cjs +286 -71
  45. package/dist/radio.cjs.map +1 -1
  46. package/dist/radio.d.cts +38 -43
  47. package/dist/radio.d.ts +38 -43
  48. package/dist/radio.js +287 -72
  49. package/dist/radio.js.map +1 -1
  50. package/dist/select.cjs +292 -163
  51. package/dist/select.cjs.map +1 -1
  52. package/dist/select.d.cts +35 -58
  53. package/dist/select.d.ts +35 -58
  54. package/dist/select.js +293 -163
  55. package/dist/select.js.map +1 -1
  56. package/dist/textarea.cjs +191 -290
  57. package/dist/textarea.cjs.map +1 -1
  58. package/dist/textarea.d.cts +41 -58
  59. package/dist/textarea.d.ts +41 -58
  60. package/dist/textarea.js +191 -290
  61. package/dist/textarea.js.map +1 -1
  62. package/package.json +13 -12
package/dist/input.cjs CHANGED
@@ -6,6 +6,191 @@ var ifDefined_js = require('lit/directives/if-defined.js');
6
6
  var spectreUi = require('@phcdevworks/spectre-ui');
7
7
 
8
8
  // src/components/input/sp-input.ts
9
+ var SpectreBaseElement = class extends lit.LitElement {
10
+ constructor() {
11
+ super(...arguments);
12
+ this._ariaLabel = null;
13
+ this._ariaLabelledBy = null;
14
+ this._ariaDescribedBy = null;
15
+ this._title = "";
16
+ this._id = "";
17
+ }
18
+ get ariaLabel() {
19
+ return this._ariaLabel;
20
+ }
21
+ set ariaLabel(value) {
22
+ if (this._ariaLabel === value) {
23
+ return;
24
+ }
25
+ this._ariaLabel = value;
26
+ this._removeHostAttribute("aria-label");
27
+ this.requestUpdate();
28
+ }
29
+ get ariaLabelledBy() {
30
+ return this._ariaLabelledBy;
31
+ }
32
+ set ariaLabelledBy(value) {
33
+ if (this._ariaLabelledBy === value) {
34
+ return;
35
+ }
36
+ this._ariaLabelledBy = value;
37
+ this._removeHostAttribute("aria-labelledby");
38
+ this.requestUpdate();
39
+ }
40
+ get ariaDescribedBy() {
41
+ return this._ariaDescribedBy;
42
+ }
43
+ set ariaDescribedBy(value) {
44
+ if (this._ariaDescribedBy === value) {
45
+ return;
46
+ }
47
+ this._ariaDescribedBy = value;
48
+ this._removeHostAttribute("aria-describedby");
49
+ this.requestUpdate();
50
+ }
51
+ get title() {
52
+ return this._title;
53
+ }
54
+ set title(value) {
55
+ const normalizedValue = value ?? "";
56
+ if (this._title === normalizedValue) {
57
+ return;
58
+ }
59
+ this._title = normalizedValue;
60
+ this._removeHostAttribute("title");
61
+ this.requestUpdate();
62
+ }
63
+ get id() {
64
+ return this._id;
65
+ }
66
+ set id(value) {
67
+ const normalizedValue = value ?? "";
68
+ if (this._id === normalizedValue) {
69
+ return;
70
+ }
71
+ this._id = normalizedValue;
72
+ this._removeHostAttribute("id");
73
+ this.requestUpdate();
74
+ }
75
+ // Spectre components intentionally render in light DOM so the global
76
+ // `@phcdevworks/spectre-ui` styling contract can apply directly.
77
+ createRenderRoot() {
78
+ return this;
79
+ }
80
+ connectedCallback() {
81
+ super.connectedCallback();
82
+ const proxiedAttributes = [
83
+ "id",
84
+ "title",
85
+ "aria-label",
86
+ "aria-labelledby",
87
+ "aria-describedby"
88
+ ];
89
+ proxiedAttributes.forEach((attr) => {
90
+ const value = super.getAttribute(attr);
91
+ if (value !== null) {
92
+ this.setAttribute(attr, value);
93
+ }
94
+ });
95
+ }
96
+ getAttribute(qualifiedName) {
97
+ switch (qualifiedName) {
98
+ case "id":
99
+ return this.id || null;
100
+ case "title":
101
+ return this.title || null;
102
+ case "aria-label":
103
+ return this.ariaLabel;
104
+ case "aria-labelledby":
105
+ return this.ariaLabelledBy;
106
+ case "aria-describedby":
107
+ return this.ariaDescribedBy;
108
+ default:
109
+ return super.getAttribute(qualifiedName);
110
+ }
111
+ }
112
+ hasAttribute(qualifiedName) {
113
+ switch (qualifiedName) {
114
+ case "id":
115
+ return this.id !== "";
116
+ case "title":
117
+ return this.title !== "";
118
+ case "aria-label":
119
+ return this.ariaLabel !== null;
120
+ case "aria-labelledby":
121
+ return this.ariaLabelledBy !== null;
122
+ case "aria-describedby":
123
+ return this.ariaDescribedBy !== null;
124
+ default:
125
+ return super.hasAttribute(qualifiedName);
126
+ }
127
+ }
128
+ setAttribute(qualifiedName, value) {
129
+ switch (qualifiedName) {
130
+ case "id":
131
+ this.id = value;
132
+ break;
133
+ case "title":
134
+ this.title = value;
135
+ break;
136
+ case "aria-label":
137
+ this.ariaLabel = value;
138
+ break;
139
+ case "aria-labelledby":
140
+ this.ariaLabelledBy = value;
141
+ break;
142
+ case "aria-describedby":
143
+ this.ariaDescribedBy = value;
144
+ break;
145
+ default:
146
+ super.setAttribute(qualifiedName, value);
147
+ }
148
+ }
149
+ removeAttribute(qualifiedName) {
150
+ switch (qualifiedName) {
151
+ case "id":
152
+ this.id = "";
153
+ break;
154
+ case "title":
155
+ this.title = "";
156
+ break;
157
+ case "aria-label":
158
+ this.ariaLabel = null;
159
+ break;
160
+ case "aria-labelledby":
161
+ this.ariaLabelledBy = null;
162
+ break;
163
+ case "aria-describedby":
164
+ this.ariaDescribedBy = null;
165
+ break;
166
+ default:
167
+ super.removeAttribute(qualifiedName);
168
+ }
169
+ }
170
+ _removeHostAttribute(name) {
171
+ const host = this;
172
+ if (HTMLElement.prototype.hasAttribute.call(host, name)) {
173
+ HTMLElement.prototype.removeAttribute.call(host, name);
174
+ }
175
+ }
176
+ get forwardedAriaLabel() {
177
+ const value = this.ariaLabel?.trim();
178
+ return value ? value : void 0;
179
+ }
180
+ get forwardedAriaLabelledBy() {
181
+ const value = this.ariaLabelledBy?.trim();
182
+ return value ? value : void 0;
183
+ }
184
+ get forwardedAriaDescribedBy() {
185
+ const value = this.ariaDescribedBy?.trim();
186
+ return value ? value : void 0;
187
+ }
188
+ };
189
+ SpectreBaseElement.properties = {};
190
+ var spectreInputSizes = ["sm", "md", "lg"];
191
+ function isInputSize(value) {
192
+ return spectreInputSizes.includes(value);
193
+ }
9
194
  var spectreInputTypes = [
10
195
  "text",
11
196
  "email",
@@ -20,19 +205,18 @@ var spectreInputTypes = [
20
205
  "time",
21
206
  "week"
22
207
  ];
23
- var spectreInputSizes = ["sm", "md", "lg"];
24
208
  function isInputType(value) {
25
209
  return spectreInputTypes.includes(value);
26
210
  }
27
- function isInputSize(value) {
28
- return spectreInputSizes.includes(value);
211
+ function normalizeInt(value, fallback, min = 0) {
212
+ if (value == null || typeof value !== "number" || !Number.isInteger(value) || value < min) {
213
+ return fallback;
214
+ }
215
+ return value;
29
216
  }
30
- var SpectreInputElement = class extends lit.LitElement {
217
+ var SpectreInputElement = class extends SpectreBaseElement {
31
218
  constructor() {
32
219
  super(...arguments);
33
- this.ariaLabel = null;
34
- this.ariaLabelledBy = null;
35
- this.ariaDescribedBy = null;
36
220
  this.autofocus = false;
37
221
  this.disabled = false;
38
222
  this.fullWidth = false;
@@ -43,60 +227,9 @@ var SpectreInputElement = class extends lit.LitElement {
43
227
  this.required = false;
44
228
  this.size = "md";
45
229
  this.success = false;
46
- this.title = "";
47
230
  this.type = "text";
48
231
  this.value = "";
49
232
  }
50
- get id() {
51
- return this._id ?? "";
52
- }
53
- set id(value) {
54
- if ((this._id ?? "") === value) {
55
- return;
56
- }
57
- this._id = value;
58
- const host = this;
59
- if (HTMLElement.prototype.hasAttribute.call(host, "id")) {
60
- HTMLElement.prototype.removeAttribute.call(host, "id");
61
- }
62
- this.requestUpdate();
63
- }
64
- createRenderRoot() {
65
- return this;
66
- }
67
- connectedCallback() {
68
- super.connectedCallback();
69
- const hostId = super.getAttribute("id");
70
- if (hostId !== null) {
71
- this.id = hostId;
72
- }
73
- }
74
- getAttribute(qualifiedName) {
75
- if (qualifiedName === "id") {
76
- return this.id || null;
77
- }
78
- return super.getAttribute(qualifiedName);
79
- }
80
- hasAttribute(qualifiedName) {
81
- if (qualifiedName === "id") {
82
- return this.id !== "";
83
- }
84
- return super.hasAttribute(qualifiedName);
85
- }
86
- setAttribute(qualifiedName, value) {
87
- if (qualifiedName === "id") {
88
- this.id = value;
89
- return;
90
- }
91
- super.setAttribute(qualifiedName, value);
92
- }
93
- removeAttribute(qualifiedName) {
94
- if (qualifiedName === "id") {
95
- this.id = "";
96
- return;
97
- }
98
- super.removeAttribute(qualifiedName);
99
- }
100
233
  willUpdate(changedProperties) {
101
234
  if (changedProperties.has("size") && !isInputSize(this.size)) {
102
235
  this.size = "md";
@@ -108,14 +241,10 @@ var SpectreInputElement = class extends lit.LitElement {
108
241
  this.value = "";
109
242
  }
110
243
  if (changedProperties.has("maxlength")) {
111
- if (this.maxlength == null || !Number.isInteger(this.maxlength) || this.maxlength < 0) {
112
- this.maxlength = void 0;
113
- }
244
+ this.maxlength = normalizeInt(this.maxlength, void 0);
114
245
  }
115
246
  if (changedProperties.has("minlength")) {
116
- if (this.minlength == null || !Number.isInteger(this.minlength) || this.minlength < 0) {
117
- this.minlength = void 0;
118
- }
247
+ this.minlength = normalizeInt(this.minlength, void 0);
119
248
  }
120
249
  }
121
250
  get inputClasses() {
@@ -132,18 +261,6 @@ var SpectreInputElement = class extends lit.LitElement {
132
261
  get nativeInput() {
133
262
  return this.querySelector("[data-sp-input-native]");
134
263
  }
135
- get forwardedAriaLabel() {
136
- const ariaLabel = this.ariaLabel?.trim();
137
- return ariaLabel ? ariaLabel : void 0;
138
- }
139
- get forwardedAriaLabelledBy() {
140
- const ariaLabelledBy = this.ariaLabelledBy?.trim();
141
- return ariaLabelledBy ? ariaLabelledBy : void 0;
142
- }
143
- get forwardedAriaDescribedBy() {
144
- const ariaDescribedBy = this.ariaDescribedBy?.trim();
145
- return ariaDescribedBy ? ariaDescribedBy : void 0;
146
- }
147
264
  handleInput(event) {
148
265
  const input = event.currentTarget;
149
266
  this.value = input.value;
@@ -159,62 +276,58 @@ var SpectreInputElement = class extends lit.LitElement {
159
276
  this.nativeInput?.blur();
160
277
  }
161
278
  render() {
162
- return lit.html`
163
- <input
164
- aria-busy=${this.loading ? "true" : "false"}
165
- aria-describedby=${ifDefined_js.ifDefined(this.forwardedAriaDescribedBy)}
166
- aria-invalid=${ifDefined_js.ifDefined(this.invalid ? "true" : void 0)}
167
- aria-label=${ifDefined_js.ifDefined(this.forwardedAriaLabel)}
168
- aria-labelledby=${ifDefined_js.ifDefined(this.forwardedAriaLabelledBy)}
169
- autocomplete=${ifDefined_js.ifDefined(this.autocomplete)}
170
- ?autofocus=${this.autofocus}
171
- class=${this.inputClasses}
172
- data-sp-input-native
173
- ?disabled=${this.isDisabled}
174
- ?readonly=${this.readonly}
175
- ?required=${this.required}
176
- id=${ifDefined_js.ifDefined(this.id || void 0)}
177
- inputmode=${ifDefined_js.ifDefined(this.inputmode)}
178
- max=${ifDefined_js.ifDefined(this.max)}
179
- maxlength=${ifDefined_js.ifDefined(this.maxlength)}
180
- min=${ifDefined_js.ifDefined(this.min)}
181
- minlength=${ifDefined_js.ifDefined(this.minlength)}
182
- name=${ifDefined_js.ifDefined(this.name)}
183
- placeholder=${ifDefined_js.ifDefined(this.placeholder)}
184
- step=${ifDefined_js.ifDefined(this.step)}
185
- title=${ifDefined_js.ifDefined(this.title || void 0)}
186
- type=${this.type}
187
- .value=${live_js.live(this.value)}
188
- @change=${this.handleChange}
189
- @input=${this.handleInput}
190
- />
191
- `;
279
+ return lit.html`<input
280
+ aria-busy="${this.loading ? "true" : "false"}"
281
+ aria-describedby="${ifDefined_js.ifDefined(this.forwardedAriaDescribedBy)}"
282
+ aria-invalid="${ifDefined_js.ifDefined(this.invalid ? "true" : void 0)}"
283
+ aria-label="${ifDefined_js.ifDefined(this.forwardedAriaLabel)}"
284
+ aria-labelledby="${ifDefined_js.ifDefined(this.forwardedAriaLabelledBy)}"
285
+ autocomplete="${ifDefined_js.ifDefined(this.autocomplete || void 0)}"
286
+ ?autofocus="${this.autofocus}"
287
+ class="${this.inputClasses}"
288
+ data-sp-input-native
289
+ ?disabled="${this.isDisabled}"
290
+ form="${ifDefined_js.ifDefined(this.form || void 0)}"
291
+ ?readonly="${this.readonly}"
292
+ ?required="${this.required}"
293
+ id="${ifDefined_js.ifDefined(this.id || void 0)}"
294
+ inputmode="${ifDefined_js.ifDefined(this.inputmode || void 0)}"
295
+ max="${ifDefined_js.ifDefined(this.max || void 0)}"
296
+ maxlength="${ifDefined_js.ifDefined(this.maxlength)}"
297
+ min="${ifDefined_js.ifDefined(this.min || void 0)}"
298
+ minlength="${ifDefined_js.ifDefined(this.minlength)}"
299
+ name="${ifDefined_js.ifDefined(this.name || void 0)}"
300
+ placeholder="${ifDefined_js.ifDefined(this.placeholder || void 0)}"
301
+ step="${ifDefined_js.ifDefined(this.step || void 0)}"
302
+ title="${ifDefined_js.ifDefined(this.title || void 0)}"
303
+ type="${this.type}"
304
+ .value="${live_js.live(this.value)}"
305
+ @change="${this.handleChange}"
306
+ @input="${this.handleInput}"
307
+ />`;
192
308
  }
193
309
  };
194
310
  SpectreInputElement.properties = {
195
- ariaLabel: { attribute: "aria-label", type: String },
196
- ariaLabelledBy: { attribute: "aria-labelledby", type: String },
197
- ariaDescribedBy: { attribute: "aria-describedby", type: String },
198
- autocomplete: { type: String },
311
+ autocomplete: { type: String, reflect: true },
199
312
  autofocus: { type: Boolean, reflect: true },
200
313
  disabled: { type: Boolean, reflect: true },
314
+ form: { type: String },
201
315
  fullWidth: { attribute: "full-width", type: Boolean, reflect: true },
202
- inputmode: { type: String },
316
+ inputmode: { type: String, reflect: true },
203
317
  invalid: { type: Boolean, reflect: true },
204
318
  loading: { type: Boolean, reflect: true },
205
- max: { type: String },
206
- maxlength: { type: Number },
207
- min: { type: String },
208
- minlength: { type: Number },
209
- name: { type: String },
319
+ max: { type: String, reflect: true },
320
+ maxlength: { type: Number, reflect: true },
321
+ min: { type: String, reflect: true },
322
+ minlength: { type: Number, reflect: true },
323
+ name: { type: String, reflect: true },
210
324
  pill: { type: Boolean, reflect: true },
211
- placeholder: { type: String },
325
+ placeholder: { type: String, reflect: true },
212
326
  readonly: { type: Boolean, reflect: true },
213
327
  required: { type: Boolean, reflect: true },
214
328
  size: { type: String, reflect: true },
215
- step: { type: String },
329
+ step: { type: String, reflect: true },
216
330
  success: { type: Boolean, reflect: true },
217
- title: { type: String, reflect: true },
218
331
  type: { type: String, reflect: true },
219
332
  value: { type: String }
220
333
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/input/sp-input.ts"],"names":["LitElement","getInputClasses","html","ifDefined","live"],"mappings":";;;;;;;;AASO,IAAM,iBAAA,GAAoB;AAAA,EAC/B,MAAA;AAAA,EACA,OAAA;AAAA,EACA,UAAA;AAAA,EACA,QAAA;AAAA,EACA,KAAA;AAAA,EACA,KAAA;AAAA,EACA,QAAA;AAAA,EACA,MAAA;AAAA,EACA,gBAAA;AAAA,EACA,OAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF;AAEO,IAAM,iBAAA,GAAoB,CAAC,IAAA,EAAM,IAAA,EAAM,IAAI;AA8BlD,SAAS,YAAY,KAAA,EAA0C;AAC7D,EAAA,OAAQ,iBAAA,CAAwC,SAAS,KAAK,CAAA;AAChE;AAEO,SAAS,YAAY,KAAA,EAAmC;AAC7D,EAAA,OAAQ,iBAAA,CAAwC,SAAS,KAAK,CAAA;AAChE;AAEO,IAAM,mBAAA,GAAN,cAAkCA,cAAA,CAAwC;AAAA,EAA1E,WAAA,GAAA;AAAA,IAAA,KAAA,CAAA,GAAA,SAAA,CAAA;AA6BL,IAAA,IAAA,CAAA,SAAA,GAA2B,IAAA;AAC3B,IAAA,IAAA,CAAA,cAAA,GAAgC,IAAA;AAChC,IAAA,IAAA,CAAA,eAAA,GAAiC,IAAA;AAEjC,IAAA,IAAA,CAAA,SAAA,GAAY,KAAA;AACZ,IAAA,IAAA,CAAA,QAAA,GAAW,KAAA;AACX,IAAA,IAAA,CAAA,SAAA,GAAY,KAAA;AAEZ,IAAA,IAAA,CAAA,OAAA,GAAU,KAAA;AACV,IAAA,IAAA,CAAA,OAAA,GAAU,KAAA;AAMV,IAAA,IAAA,CAAA,IAAA,GAAO,KAAA;AAEP,IAAA,IAAA,CAAA,QAAA,GAAW,KAAA;AACX,IAAA,IAAA,CAAA,QAAA,GAAW,KAAA;AACX,IAAA,IAAA,CAAA,IAAA,GAAyB,IAAA;AAEzB,I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,kBAAA,CAAmB,UAAU,UAAA,EAAwC;AACnF,EAAA,MAAM,eAAA,GAAkB,cAAA,CAAe,GAAA,CAAI,OAAO,CAAA;AAElD,EAAA,IAAI,eAAA,EAAiB;AACnB,IAAA,OAAO,eAAA;AAAA,EACT;AAEA,EAAA,cAAA,CAAe,MAAA,CAAO,SAAS,mBAAmB,CAAA;AAClD,EAAA,OAAO,mBAAA;AACT","file":"input.cjs","sourcesContent":["import { LitElement, html } from 'lit';\nimport { live } from 'lit/directives/live.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\n\nimport {\n getInputClasses,\n type InputSize,\n} from '@phcdevworks/spectre-ui';\n\nexport const spectreInputTypes = [\n 'text',\n 'email',\n 'password',\n 'search',\n 'tel',\n 'url',\n 'number',\n 'date',\n 'datetime-local',\n 'month',\n 'time',\n 'week',\n] as const;\n\nexport const spectreInputSizes = ['sm', 'md', 'lg'] as const;\n\nexport type SpectreInputType = (typeof spectreInputTypes)[number];\nexport type SpectreInputSize = (typeof spectreInputSizes)[number];\n\nexport interface SpectreInputProps {\n autocomplete?: string;\n autofocus?: boolean;\n disabled?: boolean;\n fullWidth?: boolean;\n inputmode?: string;\n invalid?: boolean;\n loading?: boolean;\n max?: string;\n maxlength?: number | undefined;\n min?: string;\n minlength?: number | undefined;\n name?: string;\n pill?: boolean;\n placeholder?: string;\n readonly?: boolean;\n required?: boolean;\n size?: SpectreInputSize;\n step?: string;\n success?: boolean;\n title?: string;\n type?: SpectreInputType;\n value?: string;\n}\n\nfunction isInputType(value: string): value is SpectreInputType {\n return (spectreInputTypes as readonly string[]).includes(value);\n}\n\nexport function isInputSize(value: string): value is InputSize {\n return (spectreInputSizes as readonly string[]).includes(value);\n}\n\nexport class SpectreInputElement extends LitElement implements SpectreInputProps {\n static properties = {\n ariaLabel: { attribute: 'aria-label', type: String },\n ariaLabelledBy: { attribute: 'aria-labelledby', type: String },\n ariaDescribedBy: { attribute: 'aria-describedby', type: String },\n autocomplete: { type: String },\n autofocus: { type: Boolean, reflect: true },\n disabled: { type: Boolean, reflect: true },\n fullWidth: { attribute: 'full-width', type: Boolean, reflect: true },\n inputmode: { type: String },\n invalid: { type: Boolean, reflect: true },\n loading: { type: Boolean, reflect: true },\n max: { type: String },\n maxlength: { type: Number },\n min: { type: String },\n minlength: { type: Number },\n name: { type: String },\n pill: { type: Boolean, reflect: true },\n placeholder: { type: String },\n readonly: { type: Boolean, reflect: true },\n required: { type: Boolean, reflect: true },\n size: { type: String, reflect: true },\n step: { type: String },\n success: { type: Boolean, reflect: true },\n title: { type: String, reflect: true },\n type: { type: String, reflect: true },\n value: { type: String },\n };\n\n ariaLabel: string | null = null;\n ariaLabelledBy: string | null = null;\n ariaDescribedBy: string | null = null;\n autocomplete?: string;\n autofocus = false;\n disabled = false;\n fullWidth = false;\n inputmode?: string;\n invalid = false;\n loading = false;\n max?: string;\n maxlength?: number | undefined;\n min?: string;\n minlength?: number | undefined;\n name?: string;\n pill = false;\n placeholder?: string;\n readonly = false;\n required = false;\n size: SpectreInputSize = 'md';\n step?: string;\n success = false;\n override title = '';\n type: SpectreInputType = 'text';\n value = '';\n private _id?: string;\n\n override get id(): string {\n return this._id ?? '';\n }\n\n override set id(value: string) {\n if ((this._id ?? '') === value) {\n return;\n }\n\n this._id = value;\n\n const host = this as unknown as HTMLElement;\n if (HTMLElement.prototype.hasAttribute.call(host, 'id')) {\n HTMLElement.prototype.removeAttribute.call(host, 'id');\n }\n\n this.requestUpdate();\n }\n\n createRenderRoot(): this {\n // Spectre components intentionally render in light DOM so the global\n // `@phcdevworks/spectre-ui` styling contract can apply directly.\n return this;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n\n const hostId = super.getAttribute('id');\n\n if (hostId !== null) {\n this.id = hostId;\n }\n }\n\n override getAttribute(qualifiedName: string): string | null {\n if (qualifiedName === 'id') {\n return this.id || null;\n }\n\n return super.getAttribute(qualifiedName);\n }\n\n override hasAttribute(qualifiedName: string): boolean {\n if (qualifiedName === 'id') {\n return this.id !== '';\n }\n\n return super.hasAttribute(qualifiedName);\n }\n\n override setAttribute(qualifiedName: string, value: string): void {\n if (qualifiedName === 'id') {\n this.id = value;\n return;\n }\n\n super.setAttribute(qualifiedName, value);\n }\n\n override removeAttribute(qualifiedName: string): void {\n if (qualifiedName === 'id') {\n this.id = '';\n return;\n }\n\n super.removeAttribute(qualifiedName);\n }\n\n protected override willUpdate(changedProperties: Map<PropertyKey, unknown>): void {\n if (changedProperties.has('size') && !isInputSize(this.size)) {\n this.size = 'md';\n }\n\n if (changedProperties.has('type') && !isInputType(this.type)) {\n this.type = 'text';\n }\n\n if (changedProperties.has('value') && this.value == null) {\n this.value = '';\n }\n\n if (changedProperties.has('maxlength')) {\n if (\n this.maxlength == null ||\n !Number.isInteger(this.maxlength) ||\n this.maxlength < 0\n ) {\n this.maxlength = undefined;\n }\n }\n\n if (changedProperties.has('minlength')) {\n if (\n this.minlength == null ||\n !Number.isInteger(this.minlength) ||\n this.minlength < 0\n ) {\n this.minlength = undefined;\n }\n }\n }\n\n private get inputClasses(): string {\n return getInputClasses({\n fullWidth: this.fullWidth,\n pill: this.pill,\n size: this.size,\n state: this.isDisabled\n ? this.disabled\n ? 'disabled'\n : 'loading'\n : this.invalid\n ? 'error'\n : this.success\n ? 'success'\n : 'default',\n });\n }\n\n private get isDisabled(): boolean {\n return this.disabled || this.loading;\n }\n\n private get nativeInput(): HTMLInputElement | null {\n return this.querySelector('[data-sp-input-native]');\n }\n\n private get forwardedAriaLabel(): string | undefined {\n const ariaLabel = this.ariaLabel?.trim();\n return ariaLabel ? ariaLabel : undefined;\n }\n\n private get forwardedAriaLabelledBy(): string | undefined {\n const ariaLabelledBy = this.ariaLabelledBy?.trim();\n return ariaLabelledBy ? ariaLabelledBy : undefined;\n }\n\n private get forwardedAriaDescribedBy(): string | undefined {\n const ariaDescribedBy = this.ariaDescribedBy?.trim();\n return ariaDescribedBy ? ariaDescribedBy : undefined;\n }\n\n private handleInput(event: Event): void {\n const input = event.currentTarget as HTMLInputElement;\n this.value = input.value;\n }\n\n private handleChange(event: Event): void {\n const input = event.currentTarget as HTMLInputElement;\n this.value = input.value;\n }\n\n override focus(options?: FocusOptions): void {\n this.nativeInput?.focus(options);\n }\n\n override blur(): void {\n this.nativeInput?.blur();\n }\n\n override render() {\n return html`\n <input\n aria-busy=${this.loading ? 'true' : 'false'}\n aria-describedby=${ifDefined(this.forwardedAriaDescribedBy)}\n aria-invalid=${ifDefined(this.invalid ? 'true' : undefined)}\n aria-label=${ifDefined(this.forwardedAriaLabel)}\n aria-labelledby=${ifDefined(this.forwardedAriaLabelledBy)}\n autocomplete=${ifDefined(this.autocomplete)}\n ?autofocus=${this.autofocus}\n class=${this.inputClasses}\n data-sp-input-native\n ?disabled=${this.isDisabled}\n ?readonly=${this.readonly}\n ?required=${this.required}\n id=${ifDefined(this.id || undefined)}\n inputmode=${ifDefined(this.inputmode)}\n max=${ifDefined(this.max)}\n maxlength=${ifDefined(this.maxlength)}\n min=${ifDefined(this.min)}\n minlength=${ifDefined(this.minlength)}\n name=${ifDefined(this.name)}\n placeholder=${ifDefined(this.placeholder)}\n step=${ifDefined(this.step)}\n title=${ifDefined(this.title || undefined)}\n type=${this.type}\n .value=${live(this.value)}\n @change=${this.handleChange}\n @input=${this.handleInput}\n />\n `;\n }\n}\n\nexport function defineSpectreInput(tagName = 'sp-input'): typeof SpectreInputElement {\n const existingElement = customElements.get(tagName);\n\n if (existingElement) {\n return existingElement as unknown as typeof SpectreInputElement;\n }\n\n customElements.define(tagName, SpectreInputElement);\n return SpectreInputElement;\n}\n"]}
1
+ {"version":3,"sources":["../src/utils/base.ts","../src/utils/form.ts","../src/components/input/sp-input.ts"],"names":["LitElement","getInputClasses","html","ifDefined","live"],"mappings":";;;;;;;;AAEO,IAAM,kBAAA,GAAN,cAAiCA,cAAA,CAAW;AAAA,EAA5C,WAAA,GAAA;AAAA,IAAA,KAAA,CAAA,GAAA,SAAA,CAAA;AAGL,IAAA,IAAA,CAAQ,UAAA,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A,EAAM,OAAA,EAAS,SAAS,IAAA,EAAK;AAAA,EACrC,WAAA,EAAa,EAAE,IAAA,EAAM,MAAA,EAAQ,SAAS,IAAA,EAAK;AAAA,EAC3C,QAAA,EAAU,EAAE,IAAA,EAAM,OAAA,EAAS,SAAS,IAAA,EAAK;AAAA,EACzC,QAAA,EAAU,EAAE,IAAA,EAAM,OAAA,EAAS,SAAS,IAAA,EAAK;AAAA,EACzC,IAAA,EAAM,EAAE,IAAA,EAAM,MAAA,EAAQ,SAAS,IAAA,EAAK;AAAA,EACpC,IAAA,EAAM,EAAE,IAAA,EAAM,MAAA,EAAQ,SAAS,IAAA,EAAK;AAAA,EACpC,OAAA,EAAS,EAAE,IAAA,EAAM,OAAA,EAAS,SAAS,IAAA,EAAK;AAAA,EACxC,IAAA,EAAM,EAAE,IAAA,EAAM,MAAA,EAAQ,SAAS,IAAA,EAAK;AAAA,EACpC,KAAA,EAAO,EAAE,IAAA,EAAM,MAAA;AACjB,CAAA;AA2HK,SAAS,kBAAA,CAAmB,UAAU,UAAA,EAAwC;AACnF,EAAA,MAAM,eAAA,GAAkB,cAAA,CAAe,GAAA,CAAI,OAAO,CAAA;AAElD,EAAA,IAAI,eAAA,EAAiB;AACnB,IAAA,OAAO,eAAA;AAAA,EACT;AAEA,EAAA,cAAA,CAAe,MAAA,CAAO,SAAS,mBAAmB,CAAA;AAClD,EAAA,OAAO,mBAAA;AACT","file":"input.cjs","sourcesContent":["import { LitElement, type PropertyDeclarations } from 'lit';\n\nexport class SpectreBaseElement extends LitElement {\n static properties: PropertyDeclarations = {};\n\n private _ariaLabel: string | null = null;\n private _ariaLabelledBy: string | null = null;\n private _ariaDescribedBy: string | null = null;\n private _title = '';\n private _id = '';\n\n get ariaLabel(): string | null {\n return this._ariaLabel;\n }\n\n set ariaLabel(value: string | null) {\n if (this._ariaLabel === value) {\n return;\n }\n this._ariaLabel = value;\n this._removeHostAttribute('aria-label');\n this.requestUpdate();\n }\n\n get ariaLabelledBy(): string | null {\n return this._ariaLabelledBy;\n }\n\n set ariaLabelledBy(value: string | null) {\n if (this._ariaLabelledBy === value) {\n return;\n }\n this._ariaLabelledBy = value;\n this._removeHostAttribute('aria-labelledby');\n this.requestUpdate();\n }\n\n get ariaDescribedBy(): string | null {\n return this._ariaDescribedBy;\n }\n\n set ariaDescribedBy(value: string | null) {\n if (this._ariaDescribedBy === value) {\n return;\n }\n this._ariaDescribedBy = value;\n this._removeHostAttribute('aria-describedby');\n this.requestUpdate();\n }\n\n override get title(): string {\n return this._title;\n }\n\n override set title(value: string | undefined | null) {\n const normalizedValue = value ?? '';\n if (this._title === normalizedValue) {\n return;\n }\n this._title = normalizedValue;\n this._removeHostAttribute('title');\n this.requestUpdate();\n }\n\n override get id(): string {\n return this._id;\n }\n\n override set id(value: string | undefined | null) {\n const normalizedValue = value ?? '';\n if (this._id === normalizedValue) {\n return;\n }\n this._id = normalizedValue;\n this._removeHostAttribute('id');\n this.requestUpdate();\n }\n\n // Spectre components intentionally render in light DOM so the global\n // `@phcdevworks/spectre-ui` styling contract can apply directly.\n createRenderRoot(): this {\n return this;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n\n const proxiedAttributes = [\n 'id',\n 'title',\n 'aria-label',\n 'aria-labelledby',\n 'aria-describedby',\n ];\n\n proxiedAttributes.forEach((attr) => {\n const value = super.getAttribute(attr);\n if (value !== null) {\n this.setAttribute(attr, value);\n }\n });\n }\n\n override getAttribute(qualifiedName: string): string | null {\n switch (qualifiedName) {\n case 'id':\n return this.id || null;\n case 'title':\n return this.title || null;\n case 'aria-label':\n return this.ariaLabel;\n case 'aria-labelledby':\n return this.ariaLabelledBy;\n case 'aria-describedby':\n return this.ariaDescribedBy;\n default:\n return super.getAttribute(qualifiedName);\n }\n }\n\n override hasAttribute(qualifiedName: string): boolean {\n switch (qualifiedName) {\n case 'id':\n return this.id !== '';\n case 'title':\n return this.title !== '';\n case 'aria-label':\n return this.ariaLabel !== null;\n case 'aria-labelledby':\n return this.ariaLabelledBy !== null;\n case 'aria-describedby':\n return this.ariaDescribedBy !== null;\n default:\n return super.hasAttribute(qualifiedName);\n }\n }\n\n override setAttribute(qualifiedName: string, value: string): void {\n switch (qualifiedName) {\n case 'id':\n this.id = value;\n break;\n case 'title':\n this.title = value;\n break;\n case 'aria-label':\n this.ariaLabel = value;\n break;\n case 'aria-labelledby':\n this.ariaLabelledBy = value;\n break;\n case 'aria-describedby':\n this.ariaDescribedBy = value;\n break;\n default:\n super.setAttribute(qualifiedName, value);\n }\n }\n\n override removeAttribute(qualifiedName: string): void {\n switch (qualifiedName) {\n case 'id':\n this.id = '';\n break;\n case 'title':\n this.title = '';\n break;\n case 'aria-label':\n this.ariaLabel = null;\n break;\n case 'aria-labelledby':\n this.ariaLabelledBy = null;\n break;\n case 'aria-describedby':\n this.ariaDescribedBy = null;\n break;\n default:\n super.removeAttribute(qualifiedName);\n }\n }\n\n private _removeHostAttribute(name: string): void {\n const host = this as unknown as HTMLElement;\n if (HTMLElement.prototype.hasAttribute.call(host, name)) {\n HTMLElement.prototype.removeAttribute.call(host, name);\n }\n }\n\n protected get forwardedAriaLabel(): string | undefined {\n const value = this.ariaLabel?.trim();\n return value ? value : undefined;\n }\n\n protected get forwardedAriaLabelledBy(): string | undefined {\n const value = this.ariaLabelledBy?.trim();\n return value ? value : undefined;\n }\n\n protected get forwardedAriaDescribedBy(): string | undefined {\n const value = this.ariaDescribedBy?.trim();\n return value ? value : undefined;\n }\n}\n","import { type InputSize } from '@phcdevworks/spectre-ui';\n\nexport const spectreInputSizes = ['sm', 'md', 'lg'] as const;\nexport type SpectreInputSize = (typeof spectreInputSizes)[number];\n\nexport function isInputSize(value: unknown): value is InputSize {\n return (spectreInputSizes as readonly string[]).includes(value as string);\n}\n\nexport const spectreInputTypes = [\n 'text',\n 'email',\n 'password',\n 'search',\n 'tel',\n 'url',\n 'number',\n 'date',\n 'datetime-local',\n 'month',\n 'time',\n 'week',\n] as const;\n\nexport type SpectreInputType = (typeof spectreInputTypes)[number];\n\nexport function isInputType(value: unknown): value is SpectreInputType {\n return (spectreInputTypes as readonly string[]).includes(value as string);\n}\n\nexport function normalizeInt(\n value: unknown,\n fallback: number | undefined,\n min = 0,\n): number | undefined {\n if (\n value == null ||\n typeof value !== 'number' ||\n !Number.isInteger(value) ||\n value < min\n ) {\n return fallback;\n }\n return value;\n}\n","import { html } from 'lit';\nimport { live } from 'lit/directives/live.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\n\nimport { SpectreBaseElement } from '../../utils/base';\nimport {\n spectreInputSizes,\n isInputSize,\n type SpectreInputSize,\n spectreInputTypes,\n isInputType,\n type SpectreInputType,\n normalizeInt,\n} from '../../utils/form';\n\nimport { getInputClasses } from '@phcdevworks/spectre-ui';\n\nexport {\n spectreInputSizes,\n type SpectreInputSize,\n spectreInputTypes,\n type SpectreInputType,\n};\n\nexport interface SpectreInputProps {\n ariaLabel: string | null;\n ariaLabelledBy: string | null;\n ariaDescribedBy: string | null;\n autocomplete?: string | undefined;\n autofocus?: boolean | undefined;\n disabled?: boolean | undefined;\n form?: string | undefined;\n fullWidth?: boolean | undefined;\n inputmode?: string | undefined;\n invalid?: boolean | undefined;\n loading?: boolean | undefined;\n max?: string | undefined;\n maxlength?: number | undefined;\n min?: string | undefined;\n minlength?: number | undefined;\n name?: string | undefined;\n pill?: boolean | undefined;\n placeholder?: string | undefined;\n readonly?: boolean | undefined;\n required?: boolean | undefined;\n size?: SpectreInputSize | undefined;\n step?: string | undefined;\n success?: boolean | undefined;\n title?: string | undefined;\n type?: SpectreInputType | undefined;\n value?: string | undefined;\n}\n\nexport class SpectreInputElement extends SpectreBaseElement implements SpectreInputProps {\n static properties = {\n autocomplete: { type: String, reflect: true },\n autofocus: { type: Boolean, reflect: true },\n disabled: { type: Boolean, reflect: true },\n form: { type: String },\n fullWidth: { attribute: 'full-width', type: Boolean, reflect: true },\n inputmode: { type: String, reflect: true },\n invalid: { type: Boolean, reflect: true },\n loading: { type: Boolean, reflect: true },\n max: { type: String, reflect: true },\n maxlength: { type: Number, reflect: true },\n min: { type: String, reflect: true },\n minlength: { type: Number, reflect: true },\n name: { type: String, reflect: true },\n pill: { type: Boolean, reflect: true },\n placeholder: { type: String, reflect: true },\n readonly: { type: Boolean, reflect: true },\n required: { type: Boolean, reflect: true },\n size: { type: String, reflect: true },\n step: { type: String, reflect: true },\n success: { type: Boolean, reflect: true },\n type: { type: String, reflect: true },\n value: { type: String },\n };\n\n autocomplete: string | undefined;\n autofocus = false;\n disabled = false;\n form: string | undefined;\n fullWidth = false;\n inputmode: string | undefined;\n invalid = false;\n loading = false;\n max: string | undefined;\n maxlength: number | undefined;\n min: string | undefined;\n minlength: number | undefined;\n name: string | undefined;\n pill = false;\n placeholder: string | undefined;\n readonly = false;\n required = false;\n size: SpectreInputSize = 'md';\n step: string | undefined;\n success = false;\n type: SpectreInputType = 'text';\n value = '';\n\n protected override willUpdate(changedProperties: Map<PropertyKey, unknown>): void {\n if (changedProperties.has('size') && !isInputSize(this.size)) {\n this.size = 'md';\n }\n\n if (changedProperties.has('type') && !isInputType(this.type)) {\n this.type = 'text';\n }\n\n if (changedProperties.has('value') && this.value == null) {\n this.value = '';\n }\n\n if (changedProperties.has('maxlength')) {\n this.maxlength = normalizeInt(this.maxlength, undefined);\n }\n\n if (changedProperties.has('minlength')) {\n this.minlength = normalizeInt(this.minlength, undefined);\n }\n }\n\n private get inputClasses(): string {\n return getInputClasses({\n fullWidth: this.fullWidth,\n pill: this.pill,\n size: this.size,\n state: this.isDisabled\n ? this.disabled\n ? 'disabled'\n : 'loading'\n : this.invalid\n ? 'error'\n : this.success\n ? 'success'\n : 'default',\n });\n }\n\n private get isDisabled(): boolean {\n return this.disabled || this.loading;\n }\n\n private get nativeInput(): HTMLInputElement | null {\n return this.querySelector('[data-sp-input-native]');\n }\n\n private handleInput(event: Event): void {\n const input = event.currentTarget as HTMLInputElement;\n this.value = input.value;\n }\n\n private handleChange(event: Event): void {\n const input = event.currentTarget as HTMLInputElement;\n this.value = input.value;\n }\n\n override focus(options?: FocusOptions): void {\n this.nativeInput?.focus(options);\n }\n\n override blur(): void {\n this.nativeInput?.blur();\n }\n\n override render() {\n return html`<input\n aria-busy=\"${this.loading ? 'true' : 'false'}\"\n aria-describedby=\"${ifDefined(this.forwardedAriaDescribedBy)}\"\n aria-invalid=\"${ifDefined(this.invalid ? 'true' : undefined)}\"\n aria-label=\"${ifDefined(this.forwardedAriaLabel)}\"\n aria-labelledby=\"${ifDefined(this.forwardedAriaLabelledBy)}\"\n autocomplete=\"${ifDefined(this.autocomplete || undefined)}\"\n ?autofocus=\"${this.autofocus}\"\n class=\"${this.inputClasses}\"\n data-sp-input-native\n ?disabled=\"${this.isDisabled}\"\n form=\"${ifDefined(this.form || undefined)}\"\n ?readonly=\"${this.readonly}\"\n ?required=\"${this.required}\"\n id=\"${ifDefined(this.id || undefined)}\"\n inputmode=\"${ifDefined(this.inputmode || undefined)}\"\n max=\"${ifDefined(this.max || undefined)}\"\n maxlength=\"${ifDefined(this.maxlength)}\"\n min=\"${ifDefined(this.min || undefined)}\"\n minlength=\"${ifDefined(this.minlength)}\"\n name=\"${ifDefined(this.name || undefined)}\"\n placeholder=\"${ifDefined(this.placeholder || undefined)}\"\n step=\"${ifDefined(this.step || undefined)}\"\n title=\"${ifDefined(this.title || undefined)}\"\n type=\"${this.type}\"\n .value=\"${live(this.value)}\"\n @change=\"${this.handleChange}\"\n @input=\"${this.handleInput}\"\n />`;\n }\n}\n\nexport function defineSpectreInput(tagName = 'sp-input'): typeof SpectreInputElement {\n const existingElement = customElements.get(tagName);\n\n if (existingElement) {\n return existingElement as unknown as typeof SpectreInputElement;\n }\n\n customElements.define(tagName, SpectreInputElement);\n return SpectreInputElement;\n}\n"]}