kanto-ds 1.3.0 → 1.4.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 (79) hide show
  1. package/README.md +3 -3
  2. package/dist/chunks/{defaults-DKzFsNbv.js → defaults-BwgjMcww.js} +27 -26
  3. package/dist/chunks/{defaults-DKzFsNbv.js.map → defaults-BwgjMcww.js.map} +1 -1
  4. package/dist/chunks/{index-fzPIgxe2.js → index-DSSLJirw.js} +17 -12
  5. package/dist/chunks/index-DSSLJirw.js.map +1 -0
  6. package/dist/chunks/{kt-element-mdd5cXZX.js → kt-element-E-tfJpGQ.js} +2 -2
  7. package/dist/chunks/{kt-element-mdd5cXZX.js.map → kt-element-E-tfJpGQ.js.map} +1 -1
  8. package/dist/components/core/kt-avatar/kt-avatar.js +2 -2
  9. package/dist/components/core/kt-badge/kt-badge.js +2 -2
  10. package/dist/components/core/kt-button/kt-button.js +1 -1
  11. package/dist/components/core/kt-card/kt-card.js +1 -1
  12. package/dist/components/core/kt-code/kt-code.js +2 -2
  13. package/dist/components/core/kt-icon/kt-icon.js +2 -2
  14. package/dist/components/core/kt-kbd/kt-kbd.js +1 -1
  15. package/dist/components/core/kt-split-button/kt-split-button.js +2 -2
  16. package/dist/components/data/kt-chart/kt-chart.js +51 -51
  17. package/dist/components/data/kt-chart/kt-chart.js.map +1 -1
  18. package/dist/components/data/kt-meter/kt-meter.js +1 -1
  19. package/dist/components/data/kt-pagination/kt-pagination.js +2 -2
  20. package/dist/components/data/kt-stat/kt-stat.js +1 -1
  21. package/dist/components/data/kt-table/kt-table.js +2 -2
  22. package/dist/components/data/kt-timeline/kt-timeline.js +1 -1
  23. package/dist/components/feedback/kt-alert/kt-alert.js +2 -2
  24. package/dist/components/feedback/kt-empty-state/kt-empty-state.js +1 -1
  25. package/dist/components/feedback/kt-progress-bar/kt-progress-bar.js +1 -1
  26. package/dist/components/feedback/kt-skeleton/kt-skeleton.js +1 -1
  27. package/dist/components/feedback/kt-toast/kt-toast.js +2 -2
  28. package/dist/components/feedback/kt-toast-container/kt-toast-container.js +1 -1
  29. package/dist/components/feedback/kt-tooltip/kt-tooltip.js +1 -1
  30. package/dist/components/forms/kt-checkbox/kt-checkbox.d.ts +66 -0
  31. package/dist/components/forms/kt-checkbox/kt-checkbox.js +198 -0
  32. package/dist/components/forms/kt-checkbox/kt-checkbox.js.map +1 -0
  33. package/dist/components/forms/kt-drag-drop/kt-drag-drop.js +2 -2
  34. package/dist/components/forms/kt-form/kt-form.js +11 -10
  35. package/dist/components/forms/kt-form/kt-form.js.map +1 -1
  36. package/dist/components/forms/kt-input/kt-input.js +2 -2
  37. package/dist/components/forms/kt-input-menu/kt-input-menu.js +2 -2
  38. package/dist/components/forms/kt-label-input/kt-label-input.js +1 -1
  39. package/dist/components/forms/kt-radio-group/kt-radio-group.d.ts +103 -0
  40. package/dist/components/forms/kt-radio-group/kt-radio-group.js +265 -0
  41. package/dist/components/forms/kt-radio-group/kt-radio-group.js.map +1 -0
  42. package/dist/components/forms/kt-select/kt-select.js +2 -2
  43. package/dist/components/forms/kt-textarea/kt-textarea.js +2 -2
  44. package/dist/components/forms/kt-toggle/kt-toggle.js +1 -1
  45. package/dist/components/navigation/kt-breadcrumb/kt-breadcrumb.js +2 -2
  46. package/dist/components/navigation/kt-header/kt-header.js +2 -2
  47. package/dist/components/navigation/kt-page-header/kt-page-header.js +1 -1
  48. package/dist/components/navigation/kt-segmented-control/kt-segmented-control.js +2 -2
  49. package/dist/components/navigation/kt-sub-menu-navigation/kt-sub-menu-navigation.js +2 -2
  50. package/dist/components/navigation/kt-tabs/kt-tabs.js +1 -1
  51. package/dist/components/navigation/kt-toggle-button/kt-toggle-button.js +1 -1
  52. package/dist/components/navigation/kt-toggle-button-group/kt-toggle-button-group.js +12 -6
  53. package/dist/components/navigation/kt-toggle-button-group/kt-toggle-button-group.js.map +1 -1
  54. package/dist/components/overlays/kt-collapsible/kt-collapsible.js +1 -1
  55. package/dist/components/overlays/kt-confirm-dialog/kt-confirm-dialog.js +2 -2
  56. package/dist/components/overlays/kt-dropdown/kt-dropdown.js +2 -2
  57. package/dist/components/overlays/kt-modal/kt-modal.js +2 -2
  58. package/dist/components/overlays/kt-side-panel/kt-side-panel.js +2 -2
  59. package/dist/custom-elements.json +1740 -941
  60. package/dist/icons/defaults.d.ts +1 -0
  61. package/dist/icons/index.js +1 -1
  62. package/dist/index.d.ts +4 -0
  63. package/dist/index.js +95 -90
  64. package/dist/index.js.map +1 -1
  65. package/dist/internal/strings.d.ts +10 -0
  66. package/dist/react/index.d.ts +13 -0
  67. package/dist/react/index.js +176 -157
  68. package/dist/react/index.js.map +1 -1
  69. package/dist/react/jsx.d.ts +12 -1
  70. package/dist/strings/index.js +1 -1
  71. package/dist/tokens/base.css +3 -0
  72. package/dist/vscode.css-custom-data.json +12 -0
  73. package/dist/vscode.html-custom-data.json +85 -0
  74. package/dist/vue/index.d.ts +6 -0
  75. package/dist/vue/index.js +9 -7
  76. package/dist/vue/index.js.map +1 -1
  77. package/dist/web-types.json +225 -1
  78. package/package.json +9 -1
  79. package/dist/chunks/index-fzPIgxe2.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import { css as m, html as r, nothing as o } from "lit";
2
2
  import { property as i } from "lit/decorators.js";
3
- import { K as u, d as c } from "../../../chunks/kt-element-mdd5cXZX.js";
3
+ import { K as u, d as c } from "../../../chunks/kt-element-E-tfJpGQ.js";
4
4
  var g = Object.defineProperty, n = (d, t, e, s) => {
5
5
  for (var a = void 0, p = d.length - 1, h; p >= 0; p--)
6
6
  (h = d[p]) && (a = h(t, e, a) || a);
@@ -1,8 +1,8 @@
1
1
  import { css as h, html as m } from "lit";
2
2
  import { property as n } from "lit/decorators.js";
3
- import { K as g, d as c } from "../../../chunks/kt-element-mdd5cXZX.js";
3
+ import { K as g, d as c } from "../../../chunks/kt-element-E-tfJpGQ.js";
4
4
  import { e as u } from "../../../chunks/events-Bjl5Zmmq.js";
5
- import { s as i } from "../../../chunks/index-fzPIgxe2.js";
5
+ import { s as i } from "../../../chunks/index-DSSLJirw.js";
6
6
  import "../../core/kt-button/kt-button.js";
7
7
  var d = Object.defineProperty, p = (r, a, t, f) => {
8
8
  for (var e = void 0, o = r.length - 1, l; o >= 0; o--)
@@ -1,6 +1,6 @@
1
1
  import { css as h, nothing as l, html as r } from "lit";
2
2
  import { property as e } from "lit/decorators.js";
3
- import { K as c, d as f } from "../../../chunks/kt-element-mdd5cXZX.js";
3
+ import { K as c, d as f } from "../../../chunks/kt-element-E-tfJpGQ.js";
4
4
  import "../../core/kt-icon/kt-icon.js";
5
5
  import "../../core/kt-badge/kt-badge.js";
6
6
  import "../../feedback/kt-skeleton/kt-skeleton.js";
@@ -2,9 +2,9 @@ import { css as k, html as d, nothing as h } from "lit";
2
2
  import { state as $, property as n } from "lit/decorators.js";
3
3
  import { classMap as v } from "lit/directives/class-map.js";
4
4
  import { styleMap as f } from "lit/directives/style-map.js";
5
- import { K as m, d as S } from "../../../chunks/kt-element-mdd5cXZX.js";
5
+ import { K as m, d as S } from "../../../chunks/kt-element-E-tfJpGQ.js";
6
6
  import { e as g } from "../../../chunks/events-Bjl5Zmmq.js";
7
- import { s as u } from "../../../chunks/index-fzPIgxe2.js";
7
+ import { s as u } from "../../../chunks/index-DSSLJirw.js";
8
8
  import "../kt-pagination/kt-pagination.js";
9
9
  var w = Object.defineProperty, a = (o, t, e, s) => {
10
10
  for (var i = void 0, c = o.length - 1, l; c >= 0; c--)
@@ -1,7 +1,7 @@
1
1
  import { css as h, html as s, nothing as m } from "lit";
2
2
  import { property as a } from "lit/decorators.js";
3
3
  import { classMap as k } from "lit/directives/class-map.js";
4
- import { K as c, d as f } from "../../../chunks/kt-element-mdd5cXZX.js";
4
+ import { K as c, d as f } from "../../../chunks/kt-element-E-tfJpGQ.js";
5
5
  import "../../core/kt-icon/kt-icon.js";
6
6
  var v = Object.defineProperty, i = (l, r, o, n) => {
7
7
  for (var e = void 0, p = l.length - 1, d; p >= 0; p--)
@@ -1,8 +1,8 @@
1
1
  import { css as v, nothing as s, html as e } from "lit";
2
2
  import { property as t } from "lit/decorators.js";
3
- import { K as p, d as g } from "../../../chunks/kt-element-mdd5cXZX.js";
3
+ import { K as p, d as g } from "../../../chunks/kt-element-E-tfJpGQ.js";
4
4
  import { e as h } from "../../../chunks/events-Bjl5Zmmq.js";
5
- import { s as f } from "../../../chunks/index-fzPIgxe2.js";
5
+ import { s as f } from "../../../chunks/index-DSSLJirw.js";
6
6
  import "../../core/kt-icon/kt-icon.js";
7
7
  var u = Object.defineProperty, a = (n, i, c, b) => {
8
8
  for (var r = void 0, l = n.length - 1, d; l >= 0; l--)
@@ -1,6 +1,6 @@
1
1
  import { css as h, nothing as r, html as i } from "lit";
2
2
  import { property as n } from "lit/decorators.js";
3
- import { K as d, d as m } from "../../../chunks/kt-element-mdd5cXZX.js";
3
+ import { K as d, d as m } from "../../../chunks/kt-element-E-tfJpGQ.js";
4
4
  import "../../core/kt-icon/kt-icon.js";
5
5
  var g = Object.defineProperty, o = (s, p, c, f) => {
6
6
  for (var t = void 0, a = s.length - 1, l; a >= 0; a--)
@@ -2,7 +2,7 @@ import { css as v, nothing as p, html as o } from "lit";
2
2
  import { property as t } from "lit/decorators.js";
3
3
  import { classMap as h } from "lit/directives/class-map.js";
4
4
  import { styleMap as m } from "lit/directives/style-map.js";
5
- import { K as u, d as b } from "../../../chunks/kt-element-mdd5cXZX.js";
5
+ import { K as u, d as b } from "../../../chunks/kt-element-E-tfJpGQ.js";
6
6
  var f = Object.defineProperty, r = (n, e, i, c) => {
7
7
  for (var s = void 0, l = n.length - 1, d; l >= 0; l--)
8
8
  (d = n[l]) && (s = d(e, i, s) || s);
@@ -2,7 +2,7 @@ import { css as c, html as d } from "lit";
2
2
  import { property as s } from "lit/decorators.js";
3
3
  import { classMap as h } from "lit/directives/class-map.js";
4
4
  import { styleMap as m } from "lit/directives/style-map.js";
5
- import { K as u, d as f } from "../../../chunks/kt-element-mdd5cXZX.js";
5
+ import { K as u, d as f } from "../../../chunks/kt-element-E-tfJpGQ.js";
6
6
  var y = Object.defineProperty, a = (n, i, t, p) => {
7
7
  for (var e = void 0, o = n.length - 1, l; o >= 0; o--)
8
8
  (l = n[o]) && (e = l(i, t, e) || e);
@@ -1,8 +1,8 @@
1
1
  import { css as u, nothing as n, html as a } from "lit";
2
2
  import { state as v, property as e } from "lit/decorators.js";
3
- import { K as p, d as m } from "../../../chunks/kt-element-mdd5cXZX.js";
3
+ import { K as p, d as m } from "../../../chunks/kt-element-E-tfJpGQ.js";
4
4
  import { e as f } from "../../../chunks/events-Bjl5Zmmq.js";
5
- import { s as h } from "../../../chunks/index-fzPIgxe2.js";
5
+ import { s as h } from "../../../chunks/index-DSSLJirw.js";
6
6
  import "../../core/kt-icon/kt-icon.js";
7
7
  import "../kt-progress-bar/kt-progress-bar.js";
8
8
  var b = Object.defineProperty, i = (c, o, s, x) => {
@@ -1,6 +1,6 @@
1
1
  import { css as c, html as m } from "lit";
2
2
  import { property as p } from "lit/decorators.js";
3
- import { K as l, d } from "../../../chunks/kt-element-mdd5cXZX.js";
3
+ import { K as l, d } from "../../../chunks/kt-element-E-tfJpGQ.js";
4
4
  import "../kt-toast/kt-toast.js";
5
5
  var f = Object.defineProperty, h = (i, t, e, n) => {
6
6
  for (var s = void 0, o = i.length - 1, a; o >= 0; o--)
@@ -1,7 +1,7 @@
1
1
  import { css as h, html as l } from "lit";
2
2
  import { state as c, property as n } from "lit/decorators.js";
3
3
  import { classMap as v } from "lit/directives/class-map.js";
4
- import { K as d, d as b } from "../../../chunks/kt-element-mdd5cXZX.js";
4
+ import { K as d, d as b } from "../../../chunks/kt-element-E-tfJpGQ.js";
5
5
  import { u as f } from "../../../chunks/events-Bjl5Zmmq.js";
6
6
  var u = Object.defineProperty, s = (r, t, a, y) => {
7
7
  for (var e = void 0, o = r.length - 1, p; o >= 0; o--)
@@ -0,0 +1,66 @@
1
+ import { type PropertyValues, type TemplateResult } from 'lit';
2
+ import { KtElement } from '#internal/kt-element';
3
+ import '../../core/kt-icon/kt-icon.js';
4
+ export type KtCheckboxSize = 'small' | 'medium' | 'large';
5
+ /**
6
+ * A checkbox: a choice that applies when the form is submitted.
7
+ *
8
+ * Built on a real `<input type="checkbox">`, laid invisibly over the drawn
9
+ * box, so the keyboard, the label click, the indeterminate state and what a
10
+ * screen reader announces all come from the platform rather than a
11
+ * reimplementation of it.
12
+ *
13
+ * For a setting that takes effect the moment it is flipped, use
14
+ * `<kt-toggle>`; for one choice among several, `<kt-radio-group>`.
15
+ *
16
+ * @element kt-checkbox
17
+ *
18
+ * @slot - The label, clickable.
19
+ *
20
+ * @csspart base - The `<label>` around box and text.
21
+ * @csspart input - The native checkbox.
22
+ * @csspart box - The drawn box.
23
+ *
24
+ * @fires kt-change - The box was checked or unchecked. `detail: { checked }`.
25
+ *
26
+ * @example
27
+ * ```html
28
+ * <kt-checkbox name="terms" required>I accept the terms</kt-checkbox>
29
+ * <kt-checkbox indeterminate>Select all</kt-checkbox>
30
+ * ```
31
+ */
32
+ export declare class KtCheckbox extends KtElement {
33
+ static readonly formAssociated = true;
34
+ static styles: import("lit").CSSResultGroup[];
35
+ private input?;
36
+ private internals;
37
+ private defaultChecked;
38
+ checked: boolean;
39
+ /**
40
+ * Neither checked nor unchecked — for a "select all" over a partial
41
+ * selection. Cleared as soon as the user clicks, as on a native checkbox.
42
+ */
43
+ indeterminate: boolean;
44
+ disabled: boolean;
45
+ required: boolean;
46
+ size: KtCheckboxSize;
47
+ name: string;
48
+ /** Submitted when checked, as for a native checkbox. */
49
+ value: string;
50
+ /** Accessible name, when nothing is slotted. */
51
+ label: string;
52
+ /** Error message. A non-empty value puts the box in its error state. */
53
+ error: string;
54
+ connectedCallback(): void;
55
+ willUpdate(changed: PropertyValues<this>): void;
56
+ formResetCallback(): void;
57
+ formStateRestoreCallback(state: string | null): void;
58
+ focus(options?: FocusOptions): void;
59
+ private onChange;
60
+ render(): TemplateResult;
61
+ }
62
+ declare global {
63
+ interface HTMLElementTagNameMap {
64
+ 'kt-checkbox': KtCheckbox;
65
+ }
66
+ }
@@ -0,0 +1,198 @@
1
+ import { css as p, nothing as a, html as c } from "lit";
2
+ import { query as u, property as i } from "lit/decorators.js";
3
+ import { live as b } from "lit/directives/live.js";
4
+ import { K as d, d as m } from "../../../chunks/kt-element-E-tfJpGQ.js";
5
+ import { e as f } from "../../../chunks/events-Bjl5Zmmq.js";
6
+ import { a as k, s as v, b as g } from "../../../chunks/form-control-CxjBTt1c.js";
7
+ import { s as y } from "../../../chunks/index-DSSLJirw.js";
8
+ import "../../core/kt-icon/kt-icon.js";
9
+ var x = Object.defineProperty, r = (l, e, o, C) => {
10
+ for (var s = void 0, n = l.length - 1, h; n >= 0; n--)
11
+ (h = l[n]) && (s = h(e, o, s) || s);
12
+ return s && x(e, o, s), s;
13
+ };
14
+ class t extends d {
15
+ constructor() {
16
+ super(...arguments), this.internals = null, this.defaultChecked = !1, this.checked = !1, this.indeterminate = !1, this.disabled = !1, this.required = !1, this.size = "medium", this.name = "", this.value = "on", this.label = "", this.error = "";
17
+ }
18
+ static {
19
+ this.formAssociated = !0;
20
+ }
21
+ static {
22
+ this.styles = [
23
+ d.styles,
24
+ p`
25
+ :host {
26
+ display: inline-flex;
27
+ vertical-align: middle;
28
+ /* Sized off the button heights, like the toggle, so a checkbox lines
29
+ up with the fields and buttons beside it. */
30
+ --checkbox-size: calc(var(--button-height) * 0.45);
31
+ }
32
+ :host([size='small']) {
33
+ --checkbox-size: calc(var(--button-height-small) * 0.45);
34
+ }
35
+ :host([size='large']) {
36
+ --checkbox-size: calc(var(--button-height-large) * 0.45);
37
+ }
38
+
39
+ label {
40
+ display: inline-flex;
41
+ align-items: flex-start;
42
+ gap: var(--gap-button);
43
+ color: var(--text-body);
44
+ font: var(--font-normal-regular);
45
+ cursor: pointer;
46
+ }
47
+
48
+ .control {
49
+ position: relative;
50
+ flex: none;
51
+ width: var(--checkbox-size);
52
+ height: var(--checkbox-size);
53
+ /* Centre the box on the first line of text, not the whole block. */
54
+ margin-top: calc((1lh - var(--checkbox-size)) / 2);
55
+ }
56
+
57
+ input {
58
+ position: absolute;
59
+ inset: 0;
60
+ width: 100%;
61
+ height: 100%;
62
+ margin: 0;
63
+ opacity: 0;
64
+ cursor: inherit;
65
+ }
66
+
67
+ .box {
68
+ display: grid;
69
+ place-items: center;
70
+ width: 100%;
71
+ height: 100%;
72
+ color: var(--color-white);
73
+ background-color: var(--surface-field);
74
+ border: var(--border-width) solid var(--border-field);
75
+ border-radius: var(--radius-sub-menu);
76
+ transition:
77
+ background-color var(--duration-instant),
78
+ border-color var(--duration-instant);
79
+ pointer-events: none;
80
+ }
81
+
82
+ label:hover .box {
83
+ border-color: var(--text-muted);
84
+ }
85
+
86
+ input:focus-visible + .box {
87
+ outline: var(--outline-width) solid var(--color-primary-base);
88
+ outline-offset: 2px;
89
+ }
90
+
91
+ input:checked + .box,
92
+ input:indeterminate + .box {
93
+ background-color: var(--color-primary-base);
94
+ border-color: var(--color-primary-base);
95
+ }
96
+
97
+ .error .box {
98
+ border-color: var(--color-danger-base);
99
+ }
100
+
101
+ :host([disabled]) label {
102
+ color: var(--text-disabled);
103
+ cursor: not-allowed;
104
+ }
105
+ :host([disabled]) .box {
106
+ background-color: var(--color-dark-22);
107
+ border-color: var(--color-dark-24);
108
+ color: var(--text-disabled);
109
+ }
110
+ `
111
+ ];
112
+ }
113
+ connectedCallback() {
114
+ super.connectedCallback(), this.internals ??= k(this), this.defaultChecked = this.checked;
115
+ }
116
+ willUpdate(e) {
117
+ if (e.has("checked") || e.has("value") || e.has("required") || e.has("error") || this.stringsChanged(e)) {
118
+ v(this.internals, this.checked ? this.value : null);
119
+ const o = this.required && !this.checked;
120
+ g(
121
+ this.internals,
122
+ { valueMissing: o, customError: !!this.error },
123
+ this.error || (o ? y().checkRequired : "")
124
+ );
125
+ }
126
+ }
127
+ formResetCallback() {
128
+ this.checked = this.defaultChecked, this.indeterminate = !1;
129
+ }
130
+ formStateRestoreCallback(e) {
131
+ this.checked = e === this.value;
132
+ }
133
+ focus(e) {
134
+ this.input?.focus(e);
135
+ }
136
+ onChange(e) {
137
+ const o = e.target;
138
+ this.checked = o.checked, this.indeterminate = !1, f(this, "kt-change", { checked: this.checked });
139
+ }
140
+ render() {
141
+ const e = this.indeterminate ? "minus" : this.checked ? "check" : "";
142
+ return c`${this.error ? c`<span id="error-message" class="visually-hidden">${this.error}</span>` : a}<label part="base" class=${this.error ? "error" : ""}>
143
+ <span class="control">
144
+ <input
145
+ part="input"
146
+ type="checkbox"
147
+ .checked=${b(this.checked)}
148
+ .indeterminate=${this.indeterminate}
149
+ ?disabled=${this.disabled}
150
+ ?required=${this.required}
151
+ aria-label=${this.label || a}
152
+ aria-invalid=${this.error ? "true" : a}
153
+ aria-describedby=${this.error ? "error-message" : a}
154
+ @change=${this.onChange}
155
+ />
156
+ <span part="box" class="box">
157
+ ${e ? c`<kt-icon name=${e} size="14"></kt-icon>` : a}
158
+ </span>
159
+ </span>
160
+ <span class="text"><slot></slot></span>
161
+ </label>`;
162
+ }
163
+ }
164
+ r([
165
+ u("input")
166
+ ], t.prototype, "input");
167
+ r([
168
+ i({ type: Boolean, reflect: !0 })
169
+ ], t.prototype, "checked");
170
+ r([
171
+ i({ type: Boolean, reflect: !0 })
172
+ ], t.prototype, "indeterminate");
173
+ r([
174
+ i({ type: Boolean, reflect: !0 })
175
+ ], t.prototype, "disabled");
176
+ r([
177
+ i({ type: Boolean, reflect: !0 })
178
+ ], t.prototype, "required");
179
+ r([
180
+ i({ type: String, reflect: !0 })
181
+ ], t.prototype, "size");
182
+ r([
183
+ i({ type: String })
184
+ ], t.prototype, "name");
185
+ r([
186
+ i({ type: String })
187
+ ], t.prototype, "value");
188
+ r([
189
+ i({ type: String })
190
+ ], t.prototype, "label");
191
+ r([
192
+ i({ type: String, reflect: !0 })
193
+ ], t.prototype, "error");
194
+ m("kt-checkbox", t);
195
+ export {
196
+ t as KtCheckbox
197
+ };
198
+ //# sourceMappingURL=kt-checkbox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kt-checkbox.js","sources":["../../../../src/components/forms/kt-checkbox/kt-checkbox.ts"],"sourcesContent":["import { css, html, nothing, type PropertyValues, type TemplateResult } from 'lit';\nimport { property, query } from 'lit/decorators.js';\nimport { live } from 'lit/directives/live.js';\nimport { KtElement, defineElement } from '#internal/kt-element';\nimport { emit } from '#internal/events';\nimport {\n attachFormInternals,\n setFormValue,\n setValidity,\n type UsableInternals,\n} from '#internal/form-control';\nimport { strings } from '#internal/strings';\nimport '../../core/kt-icon/kt-icon.js';\n\nexport type KtCheckboxSize = 'small' | 'medium' | 'large';\n\n/**\n * A checkbox: a choice that applies when the form is submitted.\n *\n * Built on a real `<input type=\"checkbox\">`, laid invisibly over the drawn\n * box, so the keyboard, the label click, the indeterminate state and what a\n * screen reader announces all come from the platform rather than a\n * reimplementation of it.\n *\n * For a setting that takes effect the moment it is flipped, use\n * `<kt-toggle>`; for one choice among several, `<kt-radio-group>`.\n *\n * @element kt-checkbox\n *\n * @slot - The label, clickable.\n *\n * @csspart base - The `<label>` around box and text.\n * @csspart input - The native checkbox.\n * @csspart box - The drawn box.\n *\n * @fires kt-change - The box was checked or unchecked. `detail: { checked }`.\n *\n * @example\n * ```html\n * <kt-checkbox name=\"terms\" required>I accept the terms</kt-checkbox>\n * <kt-checkbox indeterminate>Select all</kt-checkbox>\n * ```\n */\nexport class KtCheckbox extends KtElement {\n static readonly formAssociated = true;\n\n static override styles = [\n KtElement.styles,\n css`\n :host {\n display: inline-flex;\n vertical-align: middle;\n /* Sized off the button heights, like the toggle, so a checkbox lines\n up with the fields and buttons beside it. */\n --checkbox-size: calc(var(--button-height) * 0.45);\n }\n :host([size='small']) {\n --checkbox-size: calc(var(--button-height-small) * 0.45);\n }\n :host([size='large']) {\n --checkbox-size: calc(var(--button-height-large) * 0.45);\n }\n\n label {\n display: inline-flex;\n align-items: flex-start;\n gap: var(--gap-button);\n color: var(--text-body);\n font: var(--font-normal-regular);\n cursor: pointer;\n }\n\n .control {\n position: relative;\n flex: none;\n width: var(--checkbox-size);\n height: var(--checkbox-size);\n /* Centre the box on the first line of text, not the whole block. */\n margin-top: calc((1lh - var(--checkbox-size)) / 2);\n }\n\n input {\n position: absolute;\n inset: 0;\n width: 100%;\n height: 100%;\n margin: 0;\n opacity: 0;\n cursor: inherit;\n }\n\n .box {\n display: grid;\n place-items: center;\n width: 100%;\n height: 100%;\n color: var(--color-white);\n background-color: var(--surface-field);\n border: var(--border-width) solid var(--border-field);\n border-radius: var(--radius-sub-menu);\n transition:\n background-color var(--duration-instant),\n border-color var(--duration-instant);\n pointer-events: none;\n }\n\n label:hover .box {\n border-color: var(--text-muted);\n }\n\n input:focus-visible + .box {\n outline: var(--outline-width) solid var(--color-primary-base);\n outline-offset: 2px;\n }\n\n input:checked + .box,\n input:indeterminate + .box {\n background-color: var(--color-primary-base);\n border-color: var(--color-primary-base);\n }\n\n .error .box {\n border-color: var(--color-danger-base);\n }\n\n :host([disabled]) label {\n color: var(--text-disabled);\n cursor: not-allowed;\n }\n :host([disabled]) .box {\n background-color: var(--color-dark-22);\n border-color: var(--color-dark-24);\n color: var(--text-disabled);\n }\n `,\n ];\n\n @query('input')\n private input?: HTMLInputElement;\n\n private internals: UsableInternals | null = null;\n private defaultChecked = false;\n\n @property({ type: Boolean, reflect: true })\n checked = false;\n\n /**\n * Neither checked nor unchecked — for a \"select all\" over a partial\n * selection. Cleared as soon as the user clicks, as on a native checkbox.\n */\n @property({ type: Boolean, reflect: true })\n indeterminate = false;\n\n @property({ type: Boolean, reflect: true })\n disabled = false;\n\n @property({ type: Boolean, reflect: true })\n required = false;\n\n @property({ type: String, reflect: true })\n size: KtCheckboxSize = 'medium';\n\n @property({ type: String })\n name = '';\n\n /** Submitted when checked, as for a native checkbox. */\n @property({ type: String })\n value = 'on';\n\n /** Accessible name, when nothing is slotted. */\n @property({ type: String })\n label = '';\n\n /** Error message. A non-empty value puts the box in its error state. */\n @property({ type: String, reflect: true })\n error = '';\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.internals ??= attachFormInternals(this);\n this.defaultChecked = this.checked;\n }\n\n override willUpdate(changed: PropertyValues<this>): void {\n if (\n changed.has('checked') ||\n changed.has('value') ||\n changed.has('required') ||\n changed.has('error') ||\n this.stringsChanged(changed)\n ) {\n // Unchecked contributes nothing to the submission, not an empty string.\n setFormValue(this.internals, this.checked ? this.value : null);\n\n const missing = this.required && !this.checked;\n setValidity(\n this.internals,\n { valueMissing: missing, customError: Boolean(this.error) },\n this.error || (missing ? strings().checkRequired : ''),\n );\n }\n }\n\n formResetCallback(): void {\n this.checked = this.defaultChecked;\n this.indeterminate = false;\n }\n\n formStateRestoreCallback(state: string | null): void {\n this.checked = state === this.value;\n }\n\n override focus(options?: FocusOptions): void {\n this.input?.focus(options);\n }\n\n private onChange(event: Event): void {\n const input = event.target as HTMLInputElement;\n this.checked = input.checked;\n this.indeterminate = false;\n emit(this, 'kt-change', { checked: this.checked });\n }\n\n override render(): TemplateResult {\n const icon = this.indeterminate ? 'minus' : this.checked ? 'check' : '';\n\n // The message sits outside the <label>: inside it, it would become part of\n // the checkbox's name instead of its description.\n return html`${\n this.error\n ? html`<span id=\"error-message\" class=\"visually-hidden\">${this.error}</span>`\n : nothing\n }<label part=\"base\" class=${this.error ? 'error' : ''}>\n <span class=\"control\">\n <input\n part=\"input\"\n type=\"checkbox\"\n .checked=${live(this.checked)}\n .indeterminate=${this.indeterminate}\n ?disabled=${this.disabled}\n ?required=${this.required}\n aria-label=${this.label || nothing}\n aria-invalid=${this.error ? 'true' : nothing}\n aria-describedby=${this.error ? 'error-message' : nothing}\n @change=${this.onChange}\n />\n <span part=\"box\" class=\"box\">\n ${icon ? html`<kt-icon name=${icon} size=\"14\"></kt-icon>` : nothing}\n </span>\n </span>\n <span class=\"text\"><slot></slot></span>\n </label>`;\n }\n}\n\ndefineElement('kt-checkbox', KtCheckbox);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'kt-checkbox': KtCheckbox;\n }\n}\n"],"names":["KtCheckbox","KtElement","css","attachFormInternals","changed","setFormValue","missing","setValidity","strings","state","options","event","input","emit","icon","html","nothing","live","__decorateClass","query","property","defineElement"],"mappings":";;;;;;;;;;;;;AA2CO,MAAMA,UAAmBC,EAAU;AAAA,EAAnC,cAAA;AAAA,UAAA,GAAA,SAAA,GAiGL,KAAQ,YAAoC,MAC5C,KAAQ,iBAAiB,IAGzB,KAAA,UAAU,IAOV,KAAA,gBAAgB,IAGhB,KAAA,WAAW,IAGX,KAAA,WAAW,IAGX,KAAA,OAAuB,UAGvB,KAAA,OAAO,IAIP,KAAA,QAAQ,MAIR,KAAA,QAAQ,IAIR,KAAA,QAAQ;AAAA,EAAA;AAAA,EAnIR,OAAA;AAAA,SAAgB,iBAAiB;AAAA,EAAA;AAAA,EAEjC,OAAA;AAAA,SAAgB,SAAS;AAAA,MACvBA,EAAU;AAAA,MACVC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAA;AAAA,EAuFF;AAAA,EA0CS,oBAA0B;AACjC,UAAM,kBAAA,GACN,KAAK,cAAcC,EAAoB,IAAI,GAC3C,KAAK,iBAAiB,KAAK;AAAA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
3
3
  import { classMap as b } from "lit/directives/class-map.js";
4
- import { K as m, d as x } from "../../../chunks/kt-element-mdd5cXZX.js";
4
+ import { K as m, d as x } from "../../../chunks/kt-element-E-tfJpGQ.js";
5
5
  import { e as h } from "../../../chunks/events-Bjl5Zmmq.js";
6
6
  import { a as k, s as $, b as w } from "../../../chunks/form-control-CxjBTt1c.js";
7
- import { s as l } from "../../../chunks/index-fzPIgxe2.js";
7
+ import { s as l } from "../../../chunks/index-DSSLJirw.js";
8
8
  import "../../core/kt-icon/kt-icon.js";
9
9
  import "../../core/kt-button/kt-button.js";
10
10
  const u = ["B", "KB", "MB", "GB", "TB"];
@@ -1,12 +1,13 @@
1
- import { css as f, nothing as h, html as r } from "lit";
1
+ import { css as f, nothing as h, html as d } from "lit";
2
2
  import { queryAssignedElements as c, state as g, property as a } from "lit/decorators.js";
3
- import { K as p, d as m } from "../../../chunks/kt-element-mdd5cXZX.js";
3
+ import { K as p, d as m } from "../../../chunks/kt-element-E-tfJpGQ.js";
4
4
  import { h as y } from "../../../chunks/slots-BPbIdxAJ.js";
5
+ import { s as b } from "../../../chunks/index-DSSLJirw.js";
5
6
  import "../../feedback/kt-skeleton/kt-skeleton.js";
6
- var b = Object.defineProperty, s = (l, e, o, u) => {
7
- for (var i = void 0, d = l.length - 1, n; d >= 0; d--)
8
- (n = l[d]) && (i = n(e, o, i) || i);
9
- return i && b(e, o, i), i;
7
+ var u = Object.defineProperty, s = (r, e, o, v) => {
8
+ for (var i = void 0, l = r.length - 1, n; l >= 0; l--)
9
+ (n = r[l]) && (i = n(e, o, i) || i);
10
+ return i && u(e, o, i), i;
10
11
  };
11
12
  class t extends p {
12
13
  constructor() {
@@ -133,19 +134,19 @@ class t extends p {
133
134
  }
134
135
  render() {
135
136
  const e = !!this.heading || !!this.description;
136
- return r`<fieldset part="base" ?disabled=${this.disabled}>
137
+ return d`<fieldset part="base" ?disabled=${this.disabled}>
137
138
  <legend class=${this.heading ? "" : "visually-hidden"}>
138
- <slot name="heading">${this.heading || "Form section"}</slot>
139
+ <slot name="heading">${this.heading || b().formSection}</slot>
139
140
  </legend>
140
141
 
141
- ${e && this.description ? r`<div part="header" class="header">
142
+ ${e && this.description ? d`<div part="header" class="header">
142
143
  <p class="description">${this.description}</p>
143
144
  </div>` : h}
144
145
 
145
146
  <div part="fields" class="fields">
146
147
  ${this.loading ? Array.from(
147
148
  { length: this.loadingFields },
148
- () => r`<div class="placeholder" aria-hidden="true">
149
+ () => d`<div class="placeholder" aria-hidden="true">
149
150
  <kt-skeleton width="30%" height="14px"></kt-skeleton>
150
151
  <kt-skeleton variant="rect" height="40px"></kt-skeleton>
151
152
  </div>`
@@ -1 +1 @@
1
- {"version":3,"file":"kt-form.js","sources":["../../../../src/components/forms/kt-form/kt-form.ts"],"sourcesContent":["import { css, html, nothing, type PropertyValues, type TemplateResult } from 'lit';\nimport { property, queryAssignedElements, state } from 'lit/decorators.js';\nimport { KtElement, defineElement } from '#internal/kt-element';\nimport { hasAssignedContent } from '#internal/slots';\nimport '../../feedback/kt-skeleton/kt-skeleton.js';\n\n/** Anything the panel can switch off along with itself. */\ninterface Disableable extends HTMLElement {\n disabled?: boolean;\n}\n\n/**\n * A panel grouping related fields.\n *\n * It sits one step above the page on `--surface-form`, so the fields inside —\n * filled at `--surface-field` — read as wells recessed into it rather than as\n * boxes floating on it.\n *\n * **Put it inside your own `<form>`.** It renders a `<fieldset>`, not a form:\n * Kanto fields are form-associated custom elements, and a control finds its\n * form by walking its *own* tree. A `<form>` inside this element's shadow root\n * would not own anything slotted into it, and `new FormData(form)` would come\n * back empty. The `<form>` above stays in charge of submission, validation and\n * reset; this owns the grouping and the look.\n *\n * @element kt-form\n *\n * @slot - The fields.\n * @slot heading - Replaces the `heading` attribute, for markup.\n * @slot footer - Actions, right-aligned. Hidden when empty.\n *\n * @csspart base - The `<fieldset>`.\n * @csspart header - The heading and description.\n * @csspart fields - The field column.\n * @csspart footer - The action row.\n *\n * @example\n * ```html\n * <form>\n * <kt-form heading=\"Identity\" description=\"How we address you.\">\n * <kt-label-input label=\"Company\" required>\n * <kt-input name=\"company\" required></kt-input>\n * </kt-label-input>\n * <kt-button slot=\"footer\" type=\"submit\">Save</kt-button>\n * </kt-form>\n * </form>\n * ```\n */\nexport class KtForm extends KtElement {\n static override styles = [\n KtElement.styles,\n css`\n :host {\n display: block;\n }\n\n fieldset {\n display: flex;\n flex-direction: column;\n gap: var(--gap-form);\n min-width: 0;\n margin: 0;\n padding: var(--padding-card);\n background-color: var(--surface-form);\n border: var(--border-width) solid var(--border-subtle);\n border-radius: var(--border-radius-card);\n }\n\n .header {\n display: flex;\n flex-direction: column;\n gap: var(--gap-element);\n }\n\n /* A legend is the accessible name for the group, so it stays in the\n accessibility tree even when there is nothing to show. */\n legend {\n padding: 0;\n color: var(--text-body);\n font: var(--font-title-h6);\n }\n\n legend.visually-hidden {\n position: absolute;\n width: 1px;\n height: 1px;\n overflow: hidden;\n clip-path: inset(50%);\n white-space: nowrap;\n }\n\n .description {\n margin: 0;\n color: var(--text-muted);\n font: var(--font-normal-regular);\n }\n\n .fields {\n display: flex;\n flex-direction: column;\n gap: var(--gap-form);\n min-width: 0;\n }\n\n .placeholder {\n display: flex;\n flex-direction: column;\n gap: 8px;\n }\n\n .footer {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n justify-content: flex-end;\n gap: var(--gap-button);\n }\n\n /* Collapsed from JS: a wrapper around a <slot> always has the slot as a\n child, so :has(*) cannot tell an empty slot from a filled one. */\n .footer.empty {\n display: none;\n }\n\n /* While loading, the real fields stay in the DOM — and keep their state\n — but step aside for the placeholders. */\n :host([loading]) ::slotted(*) {\n display: none;\n }\n\n :host([disabled]) fieldset {\n opacity: 0.6;\n }\n `,\n ];\n\n @queryAssignedElements()\n private fields!: HTMLElement[];\n\n @state()\n private hasFooter = false;\n\n /** Group heading. Also the fieldset's accessible name. */\n @property({ type: String })\n heading = '';\n\n @property({ type: String })\n description = '';\n\n /** Replaces the fields with placeholders. */\n @property({ type: Boolean, reflect: true })\n loading = false;\n\n /** Switches off every field in the panel. */\n @property({ type: Boolean, reflect: true })\n disabled = false;\n\n /** How many placeholder fields `loading` draws. */\n @property({ type: Number, attribute: 'loading-fields' })\n loadingFields = 3;\n\n override updated(changed: PropertyValues<this>): void {\n if (changed.has('disabled')) this.syncDisabled();\n }\n\n /**\n * A native `<fieldset disabled>` switches off its descendants, but slotted\n * fields are not descendants of the fieldset in their own tree — the shadow\n * boundary sits between them — so the platform never reaches them. Walk the\n * slotted controls and set it directly.\n */\n /**\n * The initial `slotchange` is queued as a microtask and can land after the\n * first render has settled, so read the slots once directly as well.\n */\n override firstUpdated(): void {\n this.readSlots();\n this.syncDisabled();\n }\n\n private readSlots(): void {\n this.hasFooter = hasAssignedContent(\n this.shadowRoot?.querySelector<HTMLSlotElement>('slot[name=\"footer\"]'),\n );\n }\n\n private onFooterSlotChange(): void {\n this.readSlots();\n }\n\n private syncDisabled(): void {\n for (const field of this.fields ?? []) {\n if ('disabled' in field) (field as Disableable).disabled = this.disabled;\n for (const nested of field.querySelectorAll<Disableable>('*')) {\n if ('disabled' in nested) nested.disabled = this.disabled;\n }\n }\n }\n\n override render(): TemplateResult {\n const hasHeader = Boolean(this.heading) || Boolean(this.description);\n\n return html`<fieldset part=\"base\" ?disabled=${this.disabled}>\n <legend class=${this.heading ? '' : 'visually-hidden'}>\n <slot name=\"heading\">${this.heading || 'Form section'}</slot>\n </legend>\n\n ${\n hasHeader && this.description\n ? html`<div part=\"header\" class=\"header\">\n <p class=\"description\">${this.description}</p>\n </div>`\n : nothing\n }\n\n <div part=\"fields\" class=\"fields\">\n ${\n this.loading\n ? Array.from(\n { length: this.loadingFields },\n () =>\n html`<div class=\"placeholder\" aria-hidden=\"true\">\n <kt-skeleton width=\"30%\" height=\"14px\"></kt-skeleton>\n <kt-skeleton variant=\"rect\" height=\"40px\"></kt-skeleton>\n </div>`,\n )\n : nothing\n }\n <slot @slotchange=${this.syncDisabled}></slot>\n </div>\n\n <div part=\"footer\" class=${this.hasFooter ? 'footer' : 'footer empty'}>\n <slot name=\"footer\" @slotchange=${this.onFooterSlotChange}></slot>\n </div>\n </fieldset>`;\n }\n}\n\ndefineElement('kt-form', KtForm);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'kt-form': KtForm;\n }\n}\n"],"names":["KtForm","KtElement","css","changed","hasAssignedContent","field","nested","hasHeader","html","nothing","__decorateClass","queryAssignedElements","state","property","defineElement"],"mappings":";;;;;;;;;;AAgDO,MAAMA,UAAeC,EAAU;AAAA,EAA/B,cAAA;AAAA,UAAA,GAAA,SAAA,GA4FL,KAAQ,YAAY,IAIpB,KAAA,UAAU,IAGV,KAAA,cAAc,IAId,KAAA,UAAU,IAIV,KAAA,WAAW,IAIX,KAAA,gBAAgB;AAAA,EAAA;AAAA,EA9GhB,OAAA;AAAA,SAAgB,SAAS;AAAA,MACvBA,EAAU;AAAA,MACVC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAA;AAAA,EAmFF;AAAA,EA2BS,QAAQC,GAAqC;AACpD,IAAIA,EAAQ,IAAI,UAAU,UAAQ,aAAA;AAAA,EACpC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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EAAE,MAAM,OAAA,CAAQ;AAAA,GAlGfb,EAmGX,WAAA,aAAA;AAIAU,EAAA;AAAA,EADCG,EAAS,EAAE,MAAM,SAAS,SAAS,IAAM;AAAA,GAtG/Bb,EAuGX,WAAA,SAAA;AAIAU,EAAA;AAAA,EADCG,EAAS,EAAE,MAAM,SAAS,SAAS,IAAM;AAAA,GA1G/Bb,EA2GX,WAAA,UAAA;AAIAU,EAAA;AAAA,EADCG,EAAS,EAAE,MAAM,QAAQ,WAAW,kBAAkB;AAAA,GA9G5Cb,EA+GX,WAAA,eAAA;AA+EFc,EAAc,WAAWd,CAAM;"}
1
+ {"version":3,"file":"kt-form.js","sources":["../../../../src/components/forms/kt-form/kt-form.ts"],"sourcesContent":["import { css, html, nothing, type PropertyValues, type TemplateResult } from 'lit';\nimport { property, queryAssignedElements, state } from 'lit/decorators.js';\nimport { KtElement, defineElement } from '#internal/kt-element';\nimport { hasAssignedContent } from '#internal/slots';\nimport { strings } from '#internal/strings';\nimport '../../feedback/kt-skeleton/kt-skeleton.js';\n\n/** Anything the panel can switch off along with itself. */\ninterface Disableable extends HTMLElement {\n disabled?: boolean;\n}\n\n/**\n * A panel grouping related fields.\n *\n * It sits one step above the page on `--surface-form`, so the fields inside —\n * filled at `--surface-field` — read as wells recessed into it rather than as\n * boxes floating on it.\n *\n * **Put it inside your own `<form>`.** It renders a `<fieldset>`, not a form:\n * Kanto fields are form-associated custom elements, and a control finds its\n * form by walking its *own* tree. A `<form>` inside this element's shadow root\n * would not own anything slotted into it, and `new FormData(form)` would come\n * back empty. The `<form>` above stays in charge of submission, validation and\n * reset; this owns the grouping and the look.\n *\n * @element kt-form\n *\n * @slot - The fields.\n * @slot heading - Replaces the `heading` attribute, for markup.\n * @slot footer - Actions, right-aligned. Hidden when empty.\n *\n * @csspart base - The `<fieldset>`.\n * @csspart header - The heading and description.\n * @csspart fields - The field column.\n * @csspart footer - The action row.\n *\n * @example\n * ```html\n * <form>\n * <kt-form heading=\"Identity\" description=\"How we address you.\">\n * <kt-label-input label=\"Company\" required>\n * <kt-input name=\"company\" required></kt-input>\n * </kt-label-input>\n * <kt-button slot=\"footer\" type=\"submit\">Save</kt-button>\n * </kt-form>\n * </form>\n * ```\n */\nexport class KtForm extends KtElement {\n static override styles = [\n KtElement.styles,\n css`\n :host {\n display: block;\n }\n\n fieldset {\n display: flex;\n flex-direction: column;\n gap: var(--gap-form);\n min-width: 0;\n margin: 0;\n padding: var(--padding-card);\n background-color: var(--surface-form);\n border: var(--border-width) solid var(--border-subtle);\n border-radius: var(--border-radius-card);\n }\n\n .header {\n display: flex;\n flex-direction: column;\n gap: var(--gap-element);\n }\n\n /* A legend is the accessible name for the group, so it stays in the\n accessibility tree even when there is nothing to show. */\n legend {\n padding: 0;\n color: var(--text-body);\n font: var(--font-title-h6);\n }\n\n legend.visually-hidden {\n position: absolute;\n width: 1px;\n height: 1px;\n overflow: hidden;\n clip-path: inset(50%);\n white-space: nowrap;\n }\n\n .description {\n margin: 0;\n color: var(--text-muted);\n font: var(--font-normal-regular);\n }\n\n .fields {\n display: flex;\n flex-direction: column;\n gap: var(--gap-form);\n min-width: 0;\n }\n\n .placeholder {\n display: flex;\n flex-direction: column;\n gap: 8px;\n }\n\n .footer {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n justify-content: flex-end;\n gap: var(--gap-button);\n }\n\n /* Collapsed from JS: a wrapper around a <slot> always has the slot as a\n child, so :has(*) cannot tell an empty slot from a filled one. */\n .footer.empty {\n display: none;\n }\n\n /* While loading, the real fields stay in the DOM — and keep their state\n — but step aside for the placeholders. */\n :host([loading]) ::slotted(*) {\n display: none;\n }\n\n :host([disabled]) fieldset {\n opacity: 0.6;\n }\n `,\n ];\n\n @queryAssignedElements()\n private fields!: HTMLElement[];\n\n @state()\n private hasFooter = false;\n\n /** Group heading. Also the fieldset's accessible name. */\n @property({ type: String })\n heading = '';\n\n @property({ type: String })\n description = '';\n\n /** Replaces the fields with placeholders. */\n @property({ type: Boolean, reflect: true })\n loading = false;\n\n /** Switches off every field in the panel. */\n @property({ type: Boolean, reflect: true })\n disabled = false;\n\n /** How many placeholder fields `loading` draws. */\n @property({ type: Number, attribute: 'loading-fields' })\n loadingFields = 3;\n\n override updated(changed: PropertyValues<this>): void {\n if (changed.has('disabled')) this.syncDisabled();\n }\n\n /**\n * A native `<fieldset disabled>` switches off its descendants, but slotted\n * fields are not descendants of the fieldset in their own tree — the shadow\n * boundary sits between them — so the platform never reaches them. Walk the\n * slotted controls and set it directly.\n */\n /**\n * The initial `slotchange` is queued as a microtask and can land after the\n * first render has settled, so read the slots once directly as well.\n */\n override firstUpdated(): void {\n this.readSlots();\n this.syncDisabled();\n }\n\n private readSlots(): void {\n this.hasFooter = hasAssignedContent(\n this.shadowRoot?.querySelector<HTMLSlotElement>('slot[name=\"footer\"]'),\n );\n }\n\n private onFooterSlotChange(): void {\n this.readSlots();\n }\n\n private syncDisabled(): void {\n for (const field of this.fields ?? []) {\n if ('disabled' in field) (field as Disableable).disabled = this.disabled;\n for (const nested of field.querySelectorAll<Disableable>('*')) {\n if ('disabled' in nested) nested.disabled = this.disabled;\n }\n }\n }\n\n override render(): TemplateResult {\n const hasHeader = Boolean(this.heading) || Boolean(this.description);\n\n return html`<fieldset part=\"base\" ?disabled=${this.disabled}>\n <legend class=${this.heading ? '' : 'visually-hidden'}>\n <slot name=\"heading\">${this.heading || strings().formSection}</slot>\n </legend>\n\n ${\n hasHeader && this.description\n ? html`<div part=\"header\" class=\"header\">\n <p class=\"description\">${this.description}</p>\n </div>`\n : nothing\n }\n\n <div part=\"fields\" class=\"fields\">\n ${\n this.loading\n ? Array.from(\n { length: this.loadingFields },\n () =>\n html`<div class=\"placeholder\" aria-hidden=\"true\">\n <kt-skeleton width=\"30%\" height=\"14px\"></kt-skeleton>\n <kt-skeleton variant=\"rect\" height=\"40px\"></kt-skeleton>\n </div>`,\n )\n : nothing\n }\n <slot @slotchange=${this.syncDisabled}></slot>\n </div>\n\n <div part=\"footer\" class=${this.hasFooter ? 'footer' : 'footer empty'}>\n <slot name=\"footer\" @slotchange=${this.onFooterSlotChange}></slot>\n </div>\n </fieldset>`;\n }\n}\n\ndefineElement('kt-form', KtForm);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'kt-form': KtForm;\n }\n}\n"],"names":["KtForm","KtElement","css","changed","hasAssignedContent","field","nested","hasHeader","html","strings","nothing","__decorateClass","queryAssignedElements","state","property","defineElement"],"mappings":";;;;;;;;;;;AAiDO,MAAMA,UAAeC,EAAU;AAAA,EAA/B,cAAA;AAAA,UAAA,GAAA,SAAA,GA4FL,KAAQ,YAAY,IAIpB,KAAA,UAAU,IAGV,KAAA,cAAc,IAId,KAAA,UAAU,IAIV,KAAA,WAAW,IAIX,KAAA,gBAAgB;AAAA,EAAA;AAAA,EA9GhB,OAAA;AAAA,SAAgB,SAAS;AAAA,MACvBA,EAAU;AAAA,MACVC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAA;AAAA,EAmFF;AAAA,EA2BS,QAAQC,GAAqC;AACpD,IAAIA,EAAQ,IAAI,UAAU,UAAQ,aAAA;AAAA,EACpC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYS,e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AS,EAAE,MAAM,OAAA,CAAQ;AAAA,GAlGfd,EAmGX,WAAA,aAAA;AAIAW,EAAA;AAAA,EADCG,EAAS,EAAE,MAAM,SAAS,SAAS,IAAM;AAAA,GAtG/Bd,EAuGX,WAAA,SAAA;AAIAW,EAAA;AAAA,EADCG,EAAS,EAAE,MAAM,SAAS,SAAS,IAAM;AAAA,GA1G/Bd,EA2GX,WAAA,UAAA;AAIAW,EAAA;AAAA,EADCG,EAAS,EAAE,MAAM,QAAQ,WAAW,kBAAkB;AAAA,GA9G5Cd,EA+GX,WAAA,eAAA;AA+EFe,EAAc,WAAWf,CAAM;"}
@@ -2,10 +2,10 @@ import { css as w, nothing as n, html as l } from "lit";
2
2
  import { query as x, state as y, property as a } from "lit/decorators.js";
3
3
  import { classMap as m } from "lit/directives/class-map.js";
4
4
  import { live as $ } from "lit/directives/live.js";
5
- import { K as b, d as C } from "../../../chunks/kt-element-mdd5cXZX.js";
5
+ import { K as b, d as C } from "../../../chunks/kt-element-E-tfJpGQ.js";
6
6
  import { e as c } from "../../../chunks/events-Bjl5Zmmq.js";
7
7
  import { a as k, s as g, b as P } from "../../../chunks/form-control-CxjBTt1c.js";
8
- import { s as d } from "../../../chunks/index-fzPIgxe2.js";
8
+ import { s as d } from "../../../chunks/index-DSSLJirw.js";
9
9
  import "../../core/kt-icon/kt-icon.js";
10
10
  const O = [
11
11
  { id: "us", name: "United States", dialCode: "1", format: "123-456-7890" },
@@ -2,11 +2,11 @@ import { css as g, nothing as a, html as h } from "lit";
2
2
  import { query as x, state as f, property as n } from "lit/decorators.js";
3
3
  import { classMap as p } from "lit/directives/class-map.js";
4
4
  import { live as w } from "lit/directives/live.js";
5
- import { K as m, d as k } from "../../../chunks/kt-element-mdd5cXZX.js";
5
+ import { K as m, d as k } from "../../../chunks/kt-element-E-tfJpGQ.js";
6
6
  import { u as $, e as c } from "../../../chunks/events-Bjl5Zmmq.js";
7
7
  import { a as I, s as q, b as D } from "../../../chunks/form-control-CxjBTt1c.js";
8
8
  import { a as O, b as E, o as y, f as v, l as L, n as C } from "../../../chunks/listbox-Sm3nvsC6.js";
9
- import { s as l } from "../../../chunks/index-fzPIgxe2.js";
9
+ import { s as l } from "../../../chunks/index-DSSLJirw.js";
10
10
  import "../../core/kt-icon/kt-icon.js";
11
11
  var P = Object.defineProperty, i = (d, t, o, r) => {
12
12
  for (var s = void 0, u = d.length - 1, b; u >= 0; u--)
@@ -1,6 +1,6 @@
1
1
  import { css as p, html as i } from "lit";
2
2
  import { query as d, property as f } from "lit/decorators.js";
3
- import { K as u, d as c } from "../../../chunks/kt-element-mdd5cXZX.js";
3
+ import { K as u, d as c } from "../../../chunks/kt-element-E-tfJpGQ.js";
4
4
  var b = Object.defineProperty, a = (r, t, s, h) => {
5
5
  for (var e = void 0, o = r.length - 1, n; o >= 0; o--)
6
6
  (n = r[o]) && (e = n(t, s, e) || e);