kanto-ds 1.3.0 → 1.5.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.
Files changed (134) hide show
  1. package/README.md +10 -10
  2. package/dist/chunks/defaults-CFrjqae2.js +59 -0
  3. package/dist/chunks/{defaults-DKzFsNbv.js.map → defaults-CFrjqae2.js.map} +1 -1
  4. package/dist/chunks/events-r51msXNf.js +22 -0
  5. package/dist/chunks/{events-Bjl5Zmmq.js.map → events-r51msXNf.js.map} +1 -1
  6. package/dist/chunks/floating-B7_Dahpn.js +54 -0
  7. package/dist/chunks/floating-B7_Dahpn.js.map +1 -0
  8. package/dist/chunks/{form-control-CxjBTt1c.js → form-control-B74_EHtG.js} +7 -7
  9. package/dist/chunks/form-control-B74_EHtG.js.map +1 -0
  10. package/dist/chunks/{index-fzPIgxe2.js → index-STEEvEP7.js} +33 -16
  11. package/dist/chunks/index-STEEvEP7.js.map +1 -0
  12. package/dist/chunks/kt-calendar-B_hFdD9V.js +640 -0
  13. package/dist/chunks/kt-calendar-B_hFdD9V.js.map +1 -0
  14. package/dist/chunks/{kt-element-mdd5cXZX.js → kt-element-Djx2JcGl.js} +2 -2
  15. package/dist/chunks/{kt-element-mdd5cXZX.js.map → kt-element-Djx2JcGl.js.map} +1 -1
  16. package/dist/chunks/{listbox-Sm3nvsC6.js → listbox-llcUu_V-.js} +18 -14
  17. package/dist/chunks/{listbox-Sm3nvsC6.js.map → listbox-llcUu_V-.js.map} +1 -1
  18. package/dist/chunks/locale-C5xLkGx5.js +14 -0
  19. package/dist/chunks/locale-C5xLkGx5.js.map +1 -0
  20. package/dist/chunks/position-Cx_ZH5zh.js +39 -0
  21. package/dist/chunks/position-Cx_ZH5zh.js.map +1 -0
  22. package/dist/components/core/kt-avatar/kt-avatar.js +2 -2
  23. package/dist/components/core/kt-badge/kt-badge.js +3 -3
  24. package/dist/components/core/kt-button/kt-button.js +1 -1
  25. package/dist/components/core/kt-card/kt-card.js +2 -2
  26. package/dist/components/core/kt-code/kt-code.js +3 -3
  27. package/dist/components/core/kt-icon/kt-icon.js +2 -2
  28. package/dist/components/core/kt-kbd/kt-kbd.js +1 -1
  29. package/dist/components/core/kt-split-button/kt-split-button.js +4 -4
  30. package/dist/components/data/kt-chart/kt-chart.js +52 -52
  31. package/dist/components/data/kt-chart/kt-chart.js.map +1 -1
  32. package/dist/components/data/kt-meter/kt-meter.js +1 -1
  33. package/dist/components/data/kt-pagination/kt-pagination.js +3 -3
  34. package/dist/components/data/kt-stat/kt-stat.js +1 -1
  35. package/dist/components/data/kt-table/kt-table.d.ts +53 -3
  36. package/dist/components/data/kt-table/kt-table.js +286 -131
  37. package/dist/components/data/kt-table/kt-table.js.map +1 -1
  38. package/dist/components/data/kt-table/window.d.ts +19 -0
  39. package/dist/components/data/kt-timeline/kt-timeline.js +1 -1
  40. package/dist/components/feedback/kt-alert/kt-alert.js +3 -3
  41. package/dist/components/feedback/kt-empty-state/kt-empty-state.js +1 -1
  42. package/dist/components/feedback/kt-progress-bar/kt-progress-bar.js +10 -10
  43. package/dist/components/feedback/kt-progress-bar/kt-progress-bar.js.map +1 -1
  44. package/dist/components/feedback/kt-skeleton/kt-skeleton.js +1 -1
  45. package/dist/components/feedback/kt-toast/kt-toast.js +58 -42
  46. package/dist/components/feedback/kt-toast/kt-toast.js.map +1 -1
  47. package/dist/components/feedback/kt-toast-container/kt-toast-container.js +1 -1
  48. package/dist/components/feedback/kt-tooltip/kt-tooltip.d.ts +20 -0
  49. package/dist/components/feedback/kt-tooltip/kt-tooltip.js +95 -51
  50. package/dist/components/feedback/kt-tooltip/kt-tooltip.js.map +1 -1
  51. package/dist/components/forms/kt-calendar/kt-calendar.d.ts +96 -0
  52. package/dist/components/forms/kt-calendar/kt-calendar.js +13 -0
  53. package/dist/components/forms/kt-calendar/kt-calendar.js.map +1 -0
  54. package/dist/components/forms/kt-checkbox/kt-checkbox.d.ts +75 -0
  55. package/dist/components/forms/kt-checkbox/kt-checkbox.js +212 -0
  56. package/dist/components/forms/kt-checkbox/kt-checkbox.js.map +1 -0
  57. package/dist/components/forms/kt-date-picker/kt-date-picker.d.ts +105 -0
  58. package/dist/components/forms/kt-date-picker/kt-date-picker.js +382 -0
  59. package/dist/components/forms/kt-date-picker/kt-date-picker.js.map +1 -0
  60. package/dist/components/forms/kt-drag-drop/kt-drag-drop.d.ts +9 -0
  61. package/dist/components/forms/kt-drag-drop/kt-drag-drop.js +36 -22
  62. package/dist/components/forms/kt-drag-drop/kt-drag-drop.js.map +1 -1
  63. package/dist/components/forms/kt-form/kt-form.js +11 -10
  64. package/dist/components/forms/kt-form/kt-form.js.map +1 -1
  65. package/dist/components/forms/kt-input/kt-input.d.ts +37 -1
  66. package/dist/components/forms/kt-input/kt-input.js +380 -194
  67. package/dist/components/forms/kt-input/kt-input.js.map +1 -1
  68. package/dist/components/forms/kt-input-menu/kt-input-menu.d.ts +13 -0
  69. package/dist/components/forms/kt-input-menu/kt-input-menu.js +73 -42
  70. package/dist/components/forms/kt-input-menu/kt-input-menu.js.map +1 -1
  71. package/dist/components/forms/kt-label-input/kt-label-input.js +1 -1
  72. package/dist/components/forms/kt-radio-group/kt-radio-group.d.ts +112 -0
  73. package/dist/components/forms/kt-radio-group/kt-radio-group.js +279 -0
  74. package/dist/components/forms/kt-radio-group/kt-radio-group.js.map +1 -0
  75. package/dist/components/forms/kt-select/kt-select.d.ts +13 -0
  76. package/dist/components/forms/kt-select/kt-select.js +87 -56
  77. package/dist/components/forms/kt-select/kt-select.js.map +1 -1
  78. package/dist/components/forms/kt-textarea/kt-textarea.d.ts +9 -0
  79. package/dist/components/forms/kt-textarea/kt-textarea.js +28 -14
  80. package/dist/components/forms/kt-textarea/kt-textarea.js.map +1 -1
  81. package/dist/components/forms/kt-toggle/kt-toggle.d.ts +9 -0
  82. package/dist/components/forms/kt-toggle/kt-toggle.js +43 -29
  83. package/dist/components/forms/kt-toggle/kt-toggle.js.map +1 -1
  84. package/dist/components/navigation/kt-breadcrumb/kt-breadcrumb.js +3 -3
  85. package/dist/components/navigation/kt-header/kt-header.js +3 -3
  86. package/dist/components/navigation/kt-page-header/kt-page-header.js +1 -1
  87. package/dist/components/navigation/kt-segmented-control/kt-segmented-control.d.ts +9 -0
  88. package/dist/components/navigation/kt-segmented-control/kt-segmented-control.js +40 -22
  89. package/dist/components/navigation/kt-segmented-control/kt-segmented-control.js.map +1 -1
  90. package/dist/components/navigation/kt-sub-menu-navigation/kt-sub-menu-navigation.js +3 -3
  91. package/dist/components/navigation/kt-tabs/kt-tabs.js +2 -2
  92. package/dist/components/navigation/kt-toggle-button/kt-toggle-button.js +2 -2
  93. package/dist/components/navigation/kt-toggle-button-group/kt-toggle-button-group.js +13 -7
  94. package/dist/components/navigation/kt-toggle-button-group/kt-toggle-button-group.js.map +1 -1
  95. package/dist/components/overlays/kt-collapsible/kt-collapsible.js +2 -2
  96. package/dist/components/overlays/kt-confirm-dialog/kt-confirm-dialog.js +3 -3
  97. package/dist/components/overlays/kt-dropdown/kt-dropdown.d.ts +7 -5
  98. package/dist/components/overlays/kt-dropdown/kt-dropdown.js +67 -57
  99. package/dist/components/overlays/kt-dropdown/kt-dropdown.js.map +1 -1
  100. package/dist/components/overlays/kt-modal/kt-modal.js +3 -3
  101. package/dist/components/overlays/kt-side-panel/kt-side-panel.js +3 -3
  102. package/dist/custom-elements.json +3526 -741
  103. package/dist/icons/defaults.d.ts +2 -0
  104. package/dist/icons/index.js +1 -1
  105. package/dist/index.d.ts +8 -0
  106. package/dist/index.js +99 -90
  107. package/dist/index.js.map +1 -1
  108. package/dist/internal/countries.d.ts +24 -9
  109. package/dist/internal/date.d.ts +53 -0
  110. package/dist/internal/events.d.ts +5 -0
  111. package/dist/internal/floating.d.ts +48 -0
  112. package/dist/internal/form-control.d.ts +5 -1
  113. package/dist/internal/locale.d.ts +15 -0
  114. package/dist/internal/position.d.ts +27 -0
  115. package/dist/internal/strings.d.ts +25 -0
  116. package/dist/react/index.d.ts +25 -0
  117. package/dist/react/index.js +189 -156
  118. package/dist/react/index.js.map +1 -1
  119. package/dist/react/jsx.d.ts +22 -1
  120. package/dist/strings/index.js +1 -1
  121. package/dist/tokens/base.css +5 -0
  122. package/dist/tokens/responsive.css +1 -0
  123. package/dist/tokens/spacing.css +1 -0
  124. package/dist/vscode.css-custom-data.json +20 -0
  125. package/dist/vscode.html-custom-data.json +221 -9
  126. package/dist/vue/index.d.ts +10 -0
  127. package/dist/vue/index.js +11 -7
  128. package/dist/vue/index.js.map +1 -1
  129. package/dist/web-types.json +514 -12
  130. package/package.json +18 -1
  131. package/dist/chunks/defaults-DKzFsNbv.js +0 -57
  132. package/dist/chunks/events-Bjl5Zmmq.js +0 -18
  133. package/dist/chunks/form-control-CxjBTt1c.js.map +0 -1
  134. package/dist/chunks/index-fzPIgxe2.js.map +0 -1
@@ -1,27 +1,28 @@
1
- import { css as h, html as l } from "lit";
2
- import { state as c, property as n } from "lit/decorators.js";
1
+ import { css as h, html as c } from "lit";
2
+ import { state as b, query as u, 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";
5
- import { u as f } from "../../../chunks/events-Bjl5Zmmq.js";
6
- var u = Object.defineProperty, s = (r, t, a, y) => {
7
- for (var e = void 0, o = r.length - 1, p; o >= 0; o--)
8
- (p = r[o]) && (e = p(t, a, e) || e);
9
- return e && u(t, a, e), e;
4
+ import { K as l, d as f } from "../../../chunks/kt-element-Djx2JcGl.js";
5
+ import { u as m } from "../../../chunks/events-r51msXNf.js";
6
+ import { p as w } from "../../../chunks/position-Cx_ZH5zh.js";
7
+ var y = Object.defineProperty, o = (r, e, s, d) => {
8
+ for (var t = void 0, a = r.length - 1, p; a >= 0; a--)
9
+ (p = r[a]) && (t = p(e, s, t) || t);
10
+ return t && y(e, s, t), t;
10
11
  };
11
- const m = "kt-tooltip-description";
12
- class i extends d {
12
+ const g = "kt-tooltip-description";
13
+ class i extends l {
13
14
  constructor() {
14
- super(...arguments), this.descriptionId = f("kt-tooltip"), this.visible = !1, this.text = "", this.placement = "top", this.disabled = !1, this.show = () => {
15
+ super(...arguments), this.descriptionId = m("kt-tooltip"), this.visible = !1, this.text = "", this.placement = "top", this.open = !1, this.disabled = !1, this.show = () => {
15
16
  !this.disabled && this.text && (this.visible = !0);
16
17
  }, this.hide = () => {
17
18
  this.visible = !1;
18
- }, this.onKeyDown = (t) => {
19
- t.key === "Escape" && this.visible && (t.stopPropagation(), this.visible = !1);
19
+ }, this.onKeyDown = (e) => {
20
+ e.key === "Escape" && this.visible && (e.stopPropagation(), this.visible = !1);
20
21
  };
21
22
  }
22
23
  static {
23
24
  this.styles = [
24
- d.styles,
25
+ l.styles,
25
26
  h`
26
27
  :host {
27
28
  position: relative;
@@ -30,47 +31,54 @@ class i extends d {
30
31
  justify-content: center;
31
32
  }
32
33
 
34
+ /* A popover in the top layer, placed in viewport coordinates from
35
+ the trigger: no ancestor's overflow can clip it, and it takes no
36
+ room in the page — a bubble by the right edge used to widen the
37
+ document. */
33
38
  .bubble {
34
- position: absolute;
39
+ position: fixed;
40
+ inset: auto;
35
41
  z-index: var(--z-tooltip);
36
42
  max-width: 260px;
43
+ margin: 0;
37
44
  padding: var(--padding-chip);
45
+ overflow: visible;
38
46
  /* Inverted against the page, so the bubble reads as floating in
39
47
  both themes — the raw ramp step this used to name is pure white
40
48
  under data-theme="light". */
41
49
  color: var(--text-inverted);
42
50
  font: var(--font-code-regular);
43
- white-space: nowrap;
51
+ /* As wide as a short label, and wrapped at max-width for a sentence:
52
+ a positioned box beside a small trigger would otherwise shrink to
53
+ one word per line. */
54
+ width: max-content;
55
+ overflow-wrap: anywhere;
44
56
  background: var(--surface-inverted);
57
+ border: none;
45
58
  border-radius: var(--radius-input);
59
+ display: none;
46
60
  opacity: 0;
47
61
  pointer-events: none;
48
- transition: opacity 150ms var(--easing-standard);
62
+ /* The discrete display and overlay transitions keep the fade-out
63
+ once the popover closes. */
64
+ transition:
65
+ opacity var(--duration-fast) var(--easing-standard),
66
+ display var(--duration-fast) allow-discrete,
67
+ overlay var(--duration-fast) allow-discrete;
68
+ }
69
+
70
+ .bubble:popover-open {
71
+ display: block;
49
72
  }
50
73
 
51
74
  .bubble.visible {
52
75
  opacity: 1;
53
76
  }
54
77
 
55
- .top {
56
- bottom: calc(100% + 6px);
57
- left: 50%;
58
- transform: translateX(-50%);
59
- }
60
- .bottom {
61
- top: calc(100% + 6px);
62
- left: 50%;
63
- transform: translateX(-50%);
64
- }
65
- .left {
66
- top: 50%;
67
- right: calc(100% + 6px);
68
- transform: translateY(-50%);
69
- }
70
- .right {
71
- top: 50%;
72
- left: calc(100% + 6px);
73
- transform: translateY(-50%);
78
+ @starting-style {
79
+ .bubble.visible {
80
+ opacity: 0;
81
+ }
74
82
  }
75
83
 
76
84
  @media (prefers-reduced-motion: reduce) {
@@ -85,10 +93,39 @@ class i extends d {
85
93
  super.connectedCallback(), this.addEventListener("pointerenter", this.show), this.addEventListener("pointerleave", this.hide), this.addEventListener("focusin", this.show), this.addEventListener("focusout", this.hide), this.addEventListener("keydown", this.onKeyDown);
86
94
  }
87
95
  disconnectedCallback() {
88
- super.disconnectedCallback(), this.removeEventListener("pointerenter", this.show), this.removeEventListener("pointerleave", this.hide), this.removeEventListener("focusin", this.show), this.removeEventListener("focusout", this.hide), this.removeEventListener("keydown", this.onKeyDown), this.description?.remove();
96
+ super.disconnectedCallback(), this.removeEventListener("pointerenter", this.show), this.removeEventListener("pointerleave", this.hide), this.removeEventListener("focusin", this.show), this.removeEventListener("focusout", this.hide), this.removeEventListener("keydown", this.onKeyDown), this.description?.remove(), this.visible = !1, this.closeBubble();
97
+ }
98
+ willUpdate(e) {
99
+ e.has("text") && this.syncDescription();
89
100
  }
90
- willUpdate(t) {
91
- t.has("text") && this.syncDescription();
101
+ /** Hovered, focused or held open — and something to say. */
102
+ get shown() {
103
+ return (this.visible || this.open) && !this.disabled && !!this.text;
104
+ }
105
+ // Untyped: `visible` is private, so not among the keys PropertyValues<this> knows.
106
+ updated(e) {
107
+ ["visible", "open", "text", "disabled"].some((s) => e.has(s)) && (this.shown ? this.openBubble() : this.closeBubble());
108
+ }
109
+ /**
110
+ * Opens the bubble in the top layer, then places it: it has to be open to be
111
+ * measured. Where popovers are missing — a test DOM — it stays in place.
112
+ */
113
+ openBubble() {
114
+ const e = this.bubble;
115
+ if (typeof e.showPopover != "function") return;
116
+ e.matches(":popover-open") || e.showPopover();
117
+ const s = this.getBoundingClientRect(), { x: d, y: t } = w(
118
+ s,
119
+ e.getBoundingClientRect(),
120
+ { width: window.innerWidth, height: window.innerHeight },
121
+ this.placement
122
+ );
123
+ e.style.left = `${d}px`, e.style.top = `${t}px`, window.addEventListener("scroll", this.hide, { capture: !0, passive: !0 }), window.addEventListener("resize", this.hide);
124
+ }
125
+ closeBubble() {
126
+ window.removeEventListener("scroll", this.hide, { capture: !0 }), window.removeEventListener("resize", this.hide);
127
+ const e = this.bubble;
128
+ typeof e?.hidePopover == "function" && e.matches(":popover-open") && e.hidePopover();
92
129
  }
93
130
  /**
94
131
  * `aria-describedby` cannot reach across a shadow boundary: an id inside this
@@ -104,34 +141,41 @@ class i extends d {
104
141
  this.description?.remove(), this.description = void 0;
105
142
  return;
106
143
  }
107
- this.description || (this.description = document.createElement("span"), this.description.id = this.descriptionId, this.description.slot = m, this.append(this.description)), this.description.textContent = this.text;
108
- for (const t of this.children)
109
- t !== this.description && t.setAttribute("aria-describedby", this.descriptionId);
144
+ this.description || (this.description = document.createElement("span"), this.description.id = this.descriptionId, this.description.slot = g, this.append(this.description)), this.description.textContent = this.text;
145
+ for (const e of this.children)
146
+ e !== this.description && e.setAttribute("aria-describedby", this.descriptionId);
110
147
  }
111
148
  render() {
112
- return l`<slot @slotchange=${this.syncDescription}></slot>
149
+ return c`<slot @slotchange=${this.syncDescription}></slot>
113
150
  <span
114
151
  part="bubble"
115
- class=${v({ bubble: !0, [this.placement]: !0, visible: this.visible })}
152
+ popover="manual"
153
+ class=${v({ bubble: !0, visible: this.shown })}
116
154
  role="tooltip"
117
- aria-hidden=${this.visible ? "false" : "true"}
155
+ aria-hidden=${this.shown ? "false" : "true"}
118
156
  >${this.text}</span
119
157
  >`;
120
158
  }
121
159
  }
122
- s([
123
- c()
160
+ o([
161
+ b()
124
162
  ], i.prototype, "visible");
125
- s([
163
+ o([
164
+ u(".bubble")
165
+ ], i.prototype, "bubble");
166
+ o([
126
167
  n({ type: String })
127
168
  ], i.prototype, "text");
128
- s([
169
+ o([
129
170
  n({ type: String, reflect: !0 })
130
171
  ], i.prototype, "placement");
131
- s([
172
+ o([
173
+ n({ type: Boolean, reflect: !0 })
174
+ ], i.prototype, "open");
175
+ o([
132
176
  n({ type: Boolean, reflect: !0 })
133
177
  ], i.prototype, "disabled");
134
- b("kt-tooltip", i);
178
+ f("kt-tooltip", i);
135
179
  export {
136
180
  i as KtTooltip
137
181
  };
@@ -1 +1 @@
1
- {"version":3,"file":"kt-tooltip.js","sources":["../../../../src/components/feedback/kt-tooltip/kt-tooltip.ts"],"sourcesContent":["import { css, html, type PropertyValues, type TemplateResult } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { KtElement, defineElement } from '#internal/kt-element';\nimport { uniqueId } from '#internal/events';\n\nexport type KtTooltipPlacement = 'top' | 'bottom' | 'left' | 'right';\n\n/** Marks the description node so it is never assigned to the default slot. */\nconst DESCRIPTION_SLOT = 'kt-tooltip-description';\n\n/**\n * A short label that appears on hover or focus.\n *\n * Wrap the thing it describes:\n *\n * ```html\n * <kt-tooltip text=\"Refresh the data\">\n * <kt-button icon=\"refresh-cw\" label=\"Refresh\"></kt-button>\n * </kt-tooltip>\n * ```\n *\n * A tooltip is a *description*, never the only name of a control. If the\n * trigger has no visible text, give it its own `label` too — a tooltip that has\n * to be hovered to be read leaves touch and screen-reader users with nothing.\n *\n * @element kt-tooltip\n *\n * @slot - The trigger.\n *\n * @csspart bubble - The tooltip bubble.\n */\nexport class KtTooltip extends KtElement {\n static override styles = [\n KtElement.styles,\n css`\n :host {\n position: relative;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n }\n\n .bubble {\n position: absolute;\n z-index: var(--z-tooltip);\n max-width: 260px;\n padding: var(--padding-chip);\n /* Inverted against the page, so the bubble reads as floating in\n both themes — the raw ramp step this used to name is pure white\n under data-theme=\"light\". */\n color: var(--text-inverted);\n font: var(--font-code-regular);\n white-space: nowrap;\n background: var(--surface-inverted);\n border-radius: var(--radius-input);\n opacity: 0;\n pointer-events: none;\n transition: opacity 150ms var(--easing-standard);\n }\n\n .bubble.visible {\n opacity: 1;\n }\n\n .top {\n bottom: calc(100% + 6px);\n left: 50%;\n transform: translateX(-50%);\n }\n .bottom {\n top: calc(100% + 6px);\n left: 50%;\n transform: translateX(-50%);\n }\n .left {\n top: 50%;\n right: calc(100% + 6px);\n transform: translateY(-50%);\n }\n .right {\n top: 50%;\n left: calc(100% + 6px);\n transform: translateY(-50%);\n }\n\n @media (prefers-reduced-motion: reduce) {\n .bubble {\n transition: none;\n }\n }\n `,\n ];\n\n private readonly descriptionId = uniqueId('kt-tooltip');\n private description: HTMLElement | undefined;\n\n @state()\n private visible = false;\n\n @property({ type: String })\n text = '';\n\n @property({ type: String, reflect: true })\n placement: KtTooltipPlacement = 'top';\n\n /** Suppresses the tooltip without removing it from the markup. */\n @property({ type: Boolean, reflect: true })\n disabled = false;\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.addEventListener('pointerenter', this.show);\n this.addEventListener('pointerleave', this.hide);\n this.addEventListener('focusin', this.show);\n this.addEventListener('focusout', this.hide);\n this.addEventListener('keydown', this.onKeyDown);\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.removeEventListener('pointerenter', this.show);\n this.removeEventListener('pointerleave', this.hide);\n this.removeEventListener('focusin', this.show);\n this.removeEventListener('focusout', this.hide);\n this.removeEventListener('keydown', this.onKeyDown);\n this.description?.remove();\n }\n\n override willUpdate(changed: PropertyValues<this>): void {\n if (changed.has('text')) this.syncDescription();\n }\n\n /**\n * `aria-describedby` cannot reach across a shadow boundary: an id inside this\n * element's shadow root is invisible to a trigger sitting in the light DOM.\n *\n * So the description also exists as a light-DOM node, addressed to a slot\n * that does not exist — which keeps it out of the rendered output while\n * leaving it referenceable, since an explicit aria-describedby target is read\n * even when it is not displayed.\n */\n private syncDescription(): void {\n if (!this.text) {\n this.description?.remove();\n this.description = undefined;\n return;\n }\n\n if (!this.description) {\n this.description = document.createElement('span');\n this.description.id = this.descriptionId;\n this.description.slot = DESCRIPTION_SLOT;\n this.append(this.description);\n }\n this.description.textContent = this.text;\n\n for (const trigger of this.children) {\n if (trigger !== this.description)\n trigger.setAttribute('aria-describedby', this.descriptionId);\n }\n }\n\n private show = (): void => {\n if (!this.disabled && this.text) this.visible = true;\n };\n\n private hide = (): void => {\n this.visible = false;\n };\n\n /** WCAG 1.4.13: a pointer-triggered overlay must be dismissible from the keyboard. */\n private onKeyDown = (event: KeyboardEvent): void => {\n if (event.key === 'Escape' && this.visible) {\n event.stopPropagation();\n this.visible = false;\n }\n };\n\n override render(): TemplateResult {\n return html`<slot @slotchange=${this.syncDescription}></slot>\n <span\n part=\"bubble\"\n class=${classMap({ bubble: true, [this.placement]: true, visible: this.visible })}\n role=\"tooltip\"\n aria-hidden=${this.visible ? 'false' : 'true'}\n >${this.text}</span\n >`;\n }\n}\n\ndefineElement('kt-tooltip', KtTooltip);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'kt-tooltip': KtTooltip;\n }\n}\n"],"names":["DESCRIPTION_SLOT","KtTooltip","KtElement","uniqueId","event","css","changed","trigger","html","classMap","__decorateClass","state","property","defineElement"],"mappings":";;;;;;;;;;AASA,MAAMA,IAAmB;AAuBlB,MAAMC,UAAkBC,EAAU;AAAA,EAAlC,cAAA;AAAA,UAAA,GAAA,SAAA,GA8DL,KAAiB,gBAAgBC,EAAS,YAAY,GAItD,KAAQ,UAAU,IAGlB,KAAA,OAA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ooltip.js","sources":["../../../../src/components/feedback/kt-tooltip/kt-tooltip.ts"],"sourcesContent":["import { css, html, type PropertyValues, type TemplateResult } from 'lit';\nimport { property, query, state } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { KtElement, defineElement } from '#internal/kt-element';\nimport { uniqueId } from '#internal/events';\nimport { placeFloating } from '#internal/position';\n\nexport type KtTooltipPlacement = 'top' | 'bottom' | 'left' | 'right';\n\n/** Marks the description node so it is never assigned to the default slot. */\nconst DESCRIPTION_SLOT = 'kt-tooltip-description';\n\n/**\n * A short label that appears on hover or focus.\n *\n * Wrap the thing it describes:\n *\n * ```html\n * <kt-tooltip text=\"Refresh the data\">\n * <kt-button icon=\"refresh-cw\" label=\"Refresh\"></kt-button>\n * </kt-tooltip>\n * ```\n *\n * A tooltip is a *description*, never the only name of a control. If the\n * trigger has no visible text, give it its own `label` too — a tooltip that has\n * to be hovered to be read leaves touch and screen-reader users with nothing.\n *\n * @element kt-tooltip\n *\n * @slot - The trigger.\n *\n * @csspart bubble - The tooltip bubble.\n */\nexport class KtTooltip extends KtElement {\n static override styles = [\n KtElement.styles,\n css`\n :host {\n position: relative;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n }\n\n /* A popover in the top layer, placed in viewport coordinates from\n the trigger: no ancestor's overflow can clip it, and it takes no\n room in the page — a bubble by the right edge used to widen the\n document. */\n .bubble {\n position: fixed;\n inset: auto;\n z-index: var(--z-tooltip);\n max-width: 260px;\n margin: 0;\n padding: var(--padding-chip);\n overflow: visible;\n /* Inverted against the page, so the bubble reads as floating in\n both themes — the raw ramp step this used to name is pure white\n under data-theme=\"light\". */\n color: var(--text-inverted);\n font: var(--font-code-regular);\n /* As wide as a short label, and wrapped at max-width for a sentence:\n a positioned box beside a small trigger would otherwise shrink to\n one word per line. */\n width: max-content;\n overflow-wrap: anywhere;\n background: var(--surface-inverted);\n border: none;\n border-radius: var(--radius-input);\n display: none;\n opacity: 0;\n pointer-events: none;\n /* The discrete display and overlay transitions keep the fade-out\n once the popover closes. */\n transition:\n opacity var(--duration-fast) var(--easing-standard),\n display var(--duration-fast) allow-discrete,\n overlay var(--duration-fast) allow-discrete;\n }\n\n .bubble:popover-open {\n display: block;\n }\n\n .bubble.visible {\n opacity: 1;\n }\n\n @starting-style {\n .bubble.visible {\n opacity: 0;\n }\n }\n\n @media (prefers-reduced-motion: reduce) {\n .bubble {\n transition: none;\n }\n }\n `,\n ];\n\n private readonly descriptionId = uniqueId('kt-tooltip');\n private description: HTMLElement | undefined;\n\n @state()\n private visible = false;\n\n @query('.bubble')\n private bubble!: HTMLElement;\n\n @property({ type: String })\n text = '';\n\n /**\n * The side the bubble prefers. It takes the opposite one when this one has\n * no room — \"top\" on a trigger at the top of the page shows below it.\n */\n @property({ type: String, reflect: true })\n placement: KtTooltipPlacement = 'top';\n\n /**\n * Shows the bubble whatever the pointer and focus do — for a trigger that\n * cannot take focus itself, like an icon beside a field, whose owner shows\n * it while the field is focused.\n */\n @property({ type: Boolean, reflect: true })\n open = false;\n\n /** Suppresses the tooltip without removing it from the markup. */\n @property({ type: Boolean, reflect: true })\n disabled = false;\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.addEventListener('pointerenter', this.show);\n this.addEventListener('pointerleave', this.hide);\n this.addEventListener('focusin', this.show);\n this.addEventListener('focusout', this.hide);\n this.addEventListener('keydown', this.onKeyDown);\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.removeEventListener('pointerenter', this.show);\n this.removeEventListener('pointerleave', this.hide);\n this.removeEventListener('focusin', this.show);\n this.removeEventListener('focusout', this.hide);\n this.removeEventListener('keydown', this.onKeyDown);\n this.description?.remove();\n this.visible = false;\n this.closeBubble();\n }\n\n override willUpdate(changed: PropertyValues<this>): void {\n if (changed.has('text')) this.syncDescription();\n }\n\n /** Hovered, focused or held open — and something to say. */\n private get shown(): boolean {\n return (this.visible || this.open) && !this.disabled && Boolean(this.text);\n }\n\n // Untyped: `visible` is private, so not among the keys PropertyValues<this> knows.\n override updated(changed: PropertyValues): void {\n if (!['visible', 'open', 'text', 'disabled'].some((key) => changed.has(key))) return;\n if (this.shown) this.openBubble();\n else this.closeBubble();\n }\n\n /**\n * Opens the bubble in the top layer, then places it: it has to be open to be\n * measured. Where popovers are missing — a test DOM — it stays in place.\n */\n private openBubble(): void {\n const bubble = this.bubble;\n if (typeof bubble.showPopover !== 'function') return;\n if (!bubble.matches(':popover-open')) bubble.showPopover();\n\n const anchor = this.getBoundingClientRect();\n const { x, y } = placeFloating(\n anchor,\n bubble.getBoundingClientRect(),\n { width: window.innerWidth, height: window.innerHeight },\n this.placement,\n );\n bubble.style.left = `${x}px`;\n bubble.style.top = `${y}px`;\n // Fixed to the viewport, the bubble would drift from its trigger.\n window.addEventListener('scroll', this.hide, { capture: true, passive: true });\n window.addEventListener('resize', this.hide);\n }\n\n private closeBubble(): void {\n window.removeEventListener('scroll', this.hide, { capture: true });\n window.removeEventListener('resize', this.hide);\n const bubble = this.bubble;\n if (typeof bubble?.hidePopover === 'function' && bubble.matches(':popover-open')) {\n bubble.hidePopover();\n }\n }\n\n /**\n * `aria-describedby` cannot reach across a shadow boundary: an id inside this\n * element's shadow root is invisible to a trigger sitting in the light DOM.\n *\n * So the description also exists as a light-DOM node, addressed to a slot\n * that does not exist — which keeps it out of the rendered output while\n * leaving it referenceable, since an explicit aria-describedby target is read\n * even when it is not displayed.\n */\n private syncDescription(): void {\n if (!this.text) {\n this.description?.remove();\n this.description = undefined;\n return;\n }\n\n if (!this.description) {\n this.description = document.createElement('span');\n this.description.id = this.descriptionId;\n this.description.slot = DESCRIPTION_SLOT;\n this.append(this.description);\n }\n this.description.textContent = this.text;\n\n for (const trigger of this.children) {\n if (trigger !== this.description)\n trigger.setAttribute('aria-describedby', this.descriptionId);\n }\n }\n\n private show = (): void => {\n if (!this.disabled && this.text) this.visible = true;\n };\n\n private hide = (): void => {\n this.visible = false;\n };\n\n /** WCAG 1.4.13: a pointer-triggered overlay must be dismissible from the keyboard. */\n private onKeyDown = (event: KeyboardEvent): void => {\n if (event.key === 'Escape' && this.visible) {\n event.stopPropagation();\n this.visible = false;\n }\n };\n\n override render(): TemplateResult {\n return html`<slot @slotchange=${this.syncDescription}></slot>\n <span\n part=\"bubble\"\n popover=\"manual\"\n class=${classMap({ bubble: true, visible: this.shown })}\n role=\"tooltip\"\n aria-hidden=${this.shown ? 'false' : 'true'}\n >${this.text}</span\n >`;\n }\n}\n\ndefineElement('kt-tooltip', KtTooltip);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'kt-tooltip': KtTooltip;\n }\n}\n"],"names":["DESCRIPTION_SLOT","KtTooltip","KtElement","uniqueId","event","css","changed","key","bubble","anchor","x","y","placeFloating","trigger","html","classMap","__decorateClass","state","query","property","defineElement"],"mappings":";;;;;;;;;;;AAUA,MAAMA,IAAmB;AAuBlB,MAAMC,UAAkBC,EAAU;AAAA,EAAlC,cAAA;AAAA,UAAA,GAAA,SAAA,GAqEL,KAAiB,gBAAgBC,EAAS,YAAY,GAItD,KAAQ,UAAU,IAMlB,KAAA,OAAO,IAOP,KAAA,YAAgC,OAQhC,KAAA,OAAO,IAIP,KAAA,WAAW,IAqGX,KAAQ,OAAO,MAAY;AACzB,MAAI,CAAC,KAAK,YAAY,KAAK,cAAW,UAAU;AAAA,IAClD,GAEA,KAAQ,OAAO,MAAY;AACzB,WAAK,UAAU;AAAA,IACjB,GAGA,KAAQ,YAAY,CAACC,MAA+B;AAClD,MAAIA,EAAM,QAAQ,YAAY,KAAK,YACjCA,EAAM,gBAAA,GACN,KAAK,UAAU;AAAA,IAEnB;AAAA,EAAA;AAAA,EApNA,OAAA;AAAA,SAAgB,SAAS;AAAA,MACvBF,EAAU;AAAA,MACVG;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;A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AAK,eAAe;AAAA;AAAA;AAAA;AAAA,gBAIxCC,EAAS,EAAE,QAAQ,IAAM,SAAS,KAAK,OAAO,CAAC;AAAA;AAAA,sBAEzC,KAAK,QAAQ,UAAU,MAAM;AAAA,WACxC,KAAK,IAAI;AAAA;AAAA,EAElB;AACF;AAzJUC,EAAA;AAAA,EADPC,EAAA;AAAM,GAxEIhB,EAyEH,WAAA,SAAA;AAGAe,EAAA;AAAA,EADPE,EAAM,SAAS;AAAA,GA3ELjB,EA4EH,WAAA,QAAA;AAGRe,EAAA;AAAA,EADCG,EAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GA9EflB,EA+EX,WAAA,MAAA;AAOAe,EAAA;AAAA,EADCG,EAAS,EAAE,MAAM,QAAQ,SAAS,IAAM;AAAA,GArF9BlB,EAsFX,WAAA,WAAA;AAQAe,EAAA;AAAA,EADCG,EAAS,EAAE,MAAM,SAAS,SAAS,IAAM;AAAA,GA7F/BlB,EA8FX,WAAA,MAAA;AAIAe,EAAA;AAAA,EADCG,EAAS,EAAE,MAAM,SAAS,SAAS,IAAM;AAAA,GAjG/BlB,EAkGX,WAAA,UAAA;AAkIFmB,EAAc,cAAcnB,CAAS;"}
@@ -0,0 +1,96 @@
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 KtCalendarView = 'day' | 'month' | 'year';
5
+ /**
6
+ * A month calendar to pick a day or a period from, shown in the page.
7
+ *
8
+ * The same calendar `<kt-date-picker>` opens in its popup, for when the
9
+ * calendar is the interface rather than a way to fill a field: a booking
10
+ * page, a dashboard's date filter, a planning view.
11
+ *
12
+ * The header's month and year are buttons. The month opens a grid of the
13
+ * twelve months, the year a grid of twelve years, so reaching a date years
14
+ * away takes three clicks rather than paging month by month.
15
+ *
16
+ * Keyboard, in the day grid (the WAI-ARIA date grid pattern): arrows by day
17
+ * and week, Home/End to the week's ends, Page Up/Down by month and with Shift
18
+ * by year, Enter to choose. In the month and year grids: arrows, Page Up/Down
19
+ * by year or by twelve years, Enter to choose, Escape back to the days.
20
+ *
21
+ * @element kt-calendar
22
+ *
23
+ * @csspart base - The calendar.
24
+ * @csspart day - A day cell.
25
+ *
26
+ * @fires kt-change - A day, or a whole period, was chosen. `detail: { value }`.
27
+ *
28
+ * @example
29
+ * ```html
30
+ * <kt-calendar value="2026-09-25"></kt-calendar>
31
+ * <kt-calendar range value="2026-09-01/2026-09-25" min="2026-01-01"></kt-calendar>
32
+ * ```
33
+ */
34
+ export declare class KtCalendar extends KtElement {
35
+ static styles: import("lit").CSSResultGroup[];
36
+ private readonly liveId;
37
+ private focusCell;
38
+ /** Set while the calendar writes its own value, which should not move it. */
39
+ private committing;
40
+ private view;
41
+ /** First day of the month the day view shows. */
42
+ private month;
43
+ /** The day, month or year holding the grid's one tab stop. */
44
+ private focused;
45
+ /** In a period: the first end chosen, while the second is pending. */
46
+ private anchor;
47
+ /** ISO date, or `start/end` interval with `range`. `null` when empty. */
48
+ value: string | null;
49
+ /** Choose a period — two dates — instead of one day. */
50
+ range: boolean;
51
+ /** Earliest date that can be chosen, ISO. */
52
+ min: string;
53
+ /** Latest date that can be chosen, ISO. */
54
+ max: string;
55
+ /**
56
+ * BCP 47 language tag for names and the first day of the week. Empty: the
57
+ * page's `lang`, then the browser's language.
58
+ */
59
+ locale: string;
60
+ /** Accessible name of the calendar. Defaults to the strings registry. */
61
+ label: string;
62
+ connectedCallback(): void;
63
+ willUpdate(changed: PropertyValues<this>): void;
64
+ updated(): void;
65
+ /** Focuses the grid's current cell — the chosen day, or today. */
66
+ focus(): void;
67
+ private get resolvedLocale();
68
+ private get selection();
69
+ private get bounds();
70
+ private clamp;
71
+ private isOutOfBounds;
72
+ /** A month or a year is unavailable only when every day of it is. */
73
+ private isSpanOutOfBounds;
74
+ private format;
75
+ /** Moves the tab stop, and the day view with it when it leaves the month. */
76
+ private jumpTo;
77
+ private setView;
78
+ private chooseDay;
79
+ private commit;
80
+ private chooseMonth;
81
+ private chooseYear;
82
+ private onDayKeyDown;
83
+ /** Months and years share one model: a list of cells, three to a row. */
84
+ private onPickerKeyDown;
85
+ private renderHeader;
86
+ private renderDay;
87
+ private renderDays;
88
+ /** The month or year grid: twelve cells, three to a row. */
89
+ private renderPicker;
90
+ render(): TemplateResult;
91
+ }
92
+ declare global {
93
+ interface HTMLElementTagNameMap {
94
+ 'kt-calendar': KtCalendar;
95
+ }
96
+ }
@@ -0,0 +1,13 @@
1
+ import "lit";
2
+ import "lit/decorators.js";
3
+ import "lit/directives/class-map.js";
4
+ import "../../../chunks/kt-element-Djx2JcGl.js";
5
+ import "../../../chunks/events-r51msXNf.js";
6
+ import "../../../chunks/locale-C5xLkGx5.js";
7
+ import "../../../chunks/index-STEEvEP7.js";
8
+ import { K as f } from "../../../chunks/kt-calendar-B_hFdD9V.js";
9
+ import "../../core/kt-icon/kt-icon.js";
10
+ export {
11
+ f as KtCalendar
12
+ };
13
+ //# sourceMappingURL=kt-calendar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kt-calendar.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;"}
@@ -0,0 +1,75 @@
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
+ /** Disabled by an enclosing `<fieldset>`, which leaves `disabled` alone. */
46
+ private formDisabled;
47
+ /** Whether the control is off, by its own `disabled` or by its form. */
48
+ private get inactive();
49
+ required: boolean;
50
+ size: KtCheckboxSize;
51
+ name: string;
52
+ /** Submitted when checked, as for a native checkbox. */
53
+ value: string;
54
+ /** Accessible name, when nothing is slotted. */
55
+ label: string;
56
+ /** Error message. A non-empty value puts the box in its error state. */
57
+ error: string;
58
+ connectedCallback(): void;
59
+ willUpdate(changed: PropertyValues<this>): void;
60
+ formResetCallback(): void;
61
+ /**
62
+ * Called by the platform when the control's disabled state changes — its
63
+ * own `disabled`, or an ancestor `<fieldset disabled>` it cannot see.
64
+ */
65
+ formDisabledCallback(disabled: boolean): void;
66
+ formStateRestoreCallback(state: string | null): void;
67
+ focus(options?: FocusOptions): void;
68
+ private onChange;
69
+ render(): TemplateResult;
70
+ }
71
+ declare global {
72
+ interface HTMLElementTagNameMap {
73
+ 'kt-checkbox': KtCheckbox;
74
+ }
75
+ }
@@ -0,0 +1,212 @@
1
+ import { css as p, nothing as a, html as c } from "lit";
2
+ import { query as b, property as i, state as u } from "lit/decorators.js";
3
+ import { live as m } from "lit/directives/live.js";
4
+ import { K as d, d as f } from "../../../chunks/kt-element-Djx2JcGl.js";
5
+ import { e as k } from "../../../chunks/events-r51msXNf.js";
6
+ import { a as v, s as g, b as y } from "../../../chunks/form-control-B74_EHtG.js";
7
+ import { s as x } from "../../../chunks/index-STEEvEP7.js";
8
+ import "../../core/kt-icon/kt-icon.js";
9
+ var C = Object.defineProperty, r = (l, e, o, $) => {
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 && C(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.formDisabled = !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
+ /** Whether the control is off, by its own `disabled` or by its form. */
114
+ get inactive() {
115
+ return this.disabled || this.formDisabled;
116
+ }
117
+ connectedCallback() {
118
+ super.connectedCallback(), this.internals ??= v(this), this.defaultChecked = this.checked;
119
+ }
120
+ willUpdate(e) {
121
+ if (e.has("checked") || e.has("value") || e.has("required") || e.has("error") || this.stringsChanged(e)) {
122
+ g(this.internals, this.checked ? this.value : null);
123
+ const o = this.required && !this.checked;
124
+ y(
125
+ this.internals,
126
+ { valueMissing: o, customError: !!this.error },
127
+ this.error || (o ? x().checkRequired : "")
128
+ );
129
+ }
130
+ }
131
+ formResetCallback() {
132
+ this.checked = this.defaultChecked, this.indeterminate = !1;
133
+ }
134
+ /**
135
+ * Called by the platform when the control's disabled state changes — its
136
+ * own `disabled`, or an ancestor `<fieldset disabled>` it cannot see.
137
+ */
138
+ formDisabledCallback(e) {
139
+ this.formDisabled = e;
140
+ }
141
+ formStateRestoreCallback(e) {
142
+ this.checked = e === this.value;
143
+ }
144
+ focus(e) {
145
+ this.input?.focus(e);
146
+ }
147
+ onChange(e) {
148
+ const o = e.target;
149
+ this.checked = o.checked, this.indeterminate = !1, k(this, "kt-change", { checked: this.checked });
150
+ }
151
+ render() {
152
+ const e = this.indeterminate ? "minus" : this.checked ? "check" : "";
153
+ return c`${this.error ? c`<span id="error-message" class="visually-hidden">${this.error}</span>` : a}<label part="base" class=${this.error ? "error" : ""}>
154
+ <span class="control">
155
+ <input
156
+ part="input"
157
+ type="checkbox"
158
+ .checked=${m(this.checked)}
159
+ .indeterminate=${this.indeterminate}
160
+ ?disabled=${this.inactive}
161
+ ?required=${this.required}
162
+ aria-label=${this.label || a}
163
+ aria-invalid=${this.error ? "true" : a}
164
+ aria-describedby=${this.error ? "error-message" : a}
165
+ @change=${this.onChange}
166
+ />
167
+ <span part="box" class="box">
168
+ ${e ? c`<kt-icon name=${e} size="14"></kt-icon>` : a}
169
+ </span>
170
+ </span>
171
+ <span class="text"><slot></slot></span>
172
+ </label>`;
173
+ }
174
+ }
175
+ r([
176
+ b("input")
177
+ ], t.prototype, "input");
178
+ r([
179
+ i({ type: Boolean, reflect: !0 })
180
+ ], t.prototype, "checked");
181
+ r([
182
+ i({ type: Boolean, reflect: !0 })
183
+ ], t.prototype, "indeterminate");
184
+ r([
185
+ i({ type: Boolean, reflect: !0 })
186
+ ], t.prototype, "disabled");
187
+ r([
188
+ u()
189
+ ], t.prototype, "formDisabled");
190
+ r([
191
+ i({ type: Boolean, reflect: !0 })
192
+ ], t.prototype, "required");
193
+ r([
194
+ i({ type: String, reflect: !0 })
195
+ ], t.prototype, "size");
196
+ r([
197
+ i({ type: String })
198
+ ], t.prototype, "name");
199
+ r([
200
+ i({ type: String })
201
+ ], t.prototype, "value");
202
+ r([
203
+ i({ type: String })
204
+ ], t.prototype, "label");
205
+ r([
206
+ i({ type: String, reflect: !0 })
207
+ ], t.prototype, "error");
208
+ f("kt-checkbox", t);
209
+ export {
210
+ t as KtCheckbox
211
+ };
212
+ //# sourceMappingURL=kt-checkbox.js.map