@golemui/gui-react 0.12.2 → 0.13.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 (96) hide show
  1. package/Accordion-BU3skkjb.js +58 -0
  2. package/Alert-DpUiDxQT.js +17 -0
  3. package/Button-BYVR5EKG.js +86 -0
  4. package/CHANGELOG.md +16 -0
  5. package/{Calendar-Dxavv2c7.js → Calendar-BmMkpTcV.js} +13 -11
  6. package/Checkbox-B1Tsf-vi.js +164 -0
  7. package/Currency-D0pOQwU4.js +233 -0
  8. package/{DateInput-CdkyyAhc.js → DateInput-CqFHtc9F.js} +12 -10
  9. package/{DatePicker-TkMCndrw.js → DatePicker-BmW3TO0X.js} +18 -15
  10. package/{Dropdown-jKk4TyOa.js → Dropdown-C-_zDFCe.js} +5 -3
  11. package/Flex-Rs-RvIcq.js +20 -0
  12. package/{Grid-DREMTVQI.js → Grid-BcPUrfRL.js} +3 -2
  13. package/{List-BjMIo577.js → List-YkH8gdMh.js} +5 -3
  14. package/Markdown-DeAW4y3P.js +571 -0
  15. package/MarkdownText-BdISjAsE.js +11 -0
  16. package/Number-GsGZMR5a.js +247 -0
  17. package/Password-B8QjtpUe.js +204 -0
  18. package/RadioGroup-Cd1_Zkkz.js +197 -0
  19. package/{RangeCalendar-u2vxIhna.js → RangeCalendar-9IJoFEXw.js} +10 -8
  20. package/{RangeDateInput-CopLdb6J.js → RangeDateInput-DrVR4T_z.js} +21 -19
  21. package/{RangeDatePicker-DXpV-B_G.js → RangeDatePicker-Cq_Tt6NE.js} +38 -35
  22. package/{Renderer-B6WmwKDv.js → Renderer-CWqudTUu.js} +4 -2
  23. package/Repeater-DE-DAylQ.js +124 -0
  24. package/Select-CCCPYQW6.js +238 -0
  25. package/{Tabs-C2qqi8xO.js → Tabs-BVgVVvnu.js} +4 -3
  26. package/TextArea-BlRaVCon.js +202 -0
  27. package/TextInput-KuHLSN2X.js +169 -0
  28. package/Toggle-D-bglMPv.js +166 -0
  29. package/abstract-calendar-JfbbRwFb.js +528 -0
  30. package/calendar-BgptByan.js +95 -0
  31. package/class-map-DrTVAYz_.js +26 -0
  32. package/date-BS1lA1xg.js +786 -0
  33. package/date-input-Dux0mFJw.js +266 -0
  34. package/directive-1yd1wdny.js +555 -0
  35. package/errors-6UKoJh8Y.js +108 -0
  36. package/index.js +2705 -1171
  37. package/index.umd.cjs +878 -2
  38. package/lib/components/Accordion.d.ts +2 -2
  39. package/lib/components/Alert.d.ts +2 -2
  40. package/lib/components/Button.d.ts +2 -2
  41. package/lib/components/Calendar.d.ts +2 -2
  42. package/lib/components/Checkbox.d.ts +2 -2
  43. package/lib/components/Currency.d.ts +2 -2
  44. package/lib/components/DateInput.d.ts +2 -2
  45. package/lib/components/DatePicker.d.ts +2 -2
  46. package/lib/components/Dropdown.d.ts +2 -2
  47. package/lib/components/Flex.d.ts +2 -2
  48. package/lib/components/Form.d.ts +5 -5
  49. package/lib/components/Grid.d.ts +2 -2
  50. package/lib/components/List.d.ts +2 -2
  51. package/lib/components/Markdown.d.ts +2 -2
  52. package/lib/components/MarkdownText.d.ts +2 -2
  53. package/lib/components/Number.d.ts +2 -2
  54. package/lib/components/Password.d.ts +2 -2
  55. package/lib/components/RadioGroup.d.ts +2 -2
  56. package/lib/components/RangeCalendar.d.ts +2 -2
  57. package/lib/components/RangeDateInput.d.ts +2 -2
  58. package/lib/components/RangeDatePicker.d.ts +2 -2
  59. package/lib/components/Renderer.d.ts +2 -2
  60. package/lib/components/Repeater.d.ts +2 -2
  61. package/lib/components/Select.d.ts +2 -2
  62. package/lib/components/Tabs.d.ts +2 -2
  63. package/lib/components/TextArea.d.ts +2 -2
  64. package/lib/components/TextInput.d.ts +2 -2
  65. package/lib/components/Toggle.d.ts +2 -2
  66. package/lib/widget.loaders.d.ts +2 -2
  67. package/list-DHX7bG4r.js +282 -0
  68. package/live-BfTBpQrp.js +24 -0
  69. package/markdown-text-BUv0K0WF.js +44 -0
  70. package/one-of-DifUsEYY.js +48 -0
  71. package/package.json +6 -6
  72. package/query-h1h36oxg.js +12 -0
  73. package/range-calendar-SAyiW3EF.js +326 -0
  74. package/range-date-input-8WtB1urD.js +507 -0
  75. package/repeat-BucBfSPF.js +79 -0
  76. package/state-DI9ZsB5W.js +7 -0
  77. package/style-map-C_0XzJlx.js +29 -0
  78. package/tabs-DzSCq_98.js +13 -0
  79. package/templates-DBGyvZtc.js +75 -0
  80. package/Accordion-Btp_b0xA.js +0 -59
  81. package/Alert-CBgIsMKO.js +0 -16
  82. package/Button-DN0G-MUb.js +0 -21
  83. package/Checkbox-ViM9MktI.js +0 -30
  84. package/Currency-C4QFWO7Y.js +0 -37
  85. package/DefaultListItemRenderer-lNc9Kk7x.js +0 -18
  86. package/Flex-gD893rrB.js +0 -19
  87. package/Markdown-Ck_88HOR.js +0 -47
  88. package/MarkdownText-kJVkmihW.js +0 -9
  89. package/Number-CnQ95aLO.js +0 -35
  90. package/Password-Bg97DYW3.js +0 -36
  91. package/RadioGroup-Dldom5ja.js +0 -33
  92. package/Repeater-BYgXVfbl.js +0 -111
  93. package/Select-BLUX_W91.js +0 -55
  94. package/TextArea-cw3Q2v97.js +0 -35
  95. package/TextInput-geLoAA0c.js +0 -32
  96. package/Toggle-a7L71GwR.js +0 -30
@@ -1,2 +1,2 @@
1
- import * as Core from '@golemui/core';
2
- export declare function Accordion(widgetInstance: Core.WithWidget): import("react/jsx-runtime").JSX.Element;
1
+ import { WithWidget } from '@golemui/core';
2
+ export declare function Accordion(widgetInstance: WithWidget): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
- import * as Core from '@golemui/core';
2
- export declare function Alert(widgetInstance: Core.WithWidget): import("react/jsx-runtime").JSX.Element;
1
+ import { WithWidget } from '@golemui/core';
2
+ export declare function Alert(widgetInstance: WithWidget): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
- import * as Core from '@golemui/core';
2
- export declare function Button(widgetInstance: Core.WithWidget): import("react/jsx-runtime").JSX.Element;
1
+ import { WithWidget } from '@golemui/core';
2
+ export declare function Button(widgetInstance: WithWidget): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
- import * as Core from '@golemui/core';
2
- export declare function Calendar(widgetInstance: Core.WithWidget): import("react/jsx-runtime").JSX.Element;
1
+ import { WithWidget } from '@golemui/core';
2
+ export declare function Calendar(widgetInstance: WithWidget): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
- import * as Core from '@golemui/core';
2
- export declare function Checkbox(widgetInstance: Core.WithWidget): import("react/jsx-runtime").JSX.Element;
1
+ import { WithWidget } from '@golemui/core';
2
+ export declare function Checkbox(widgetInstance: WithWidget): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
- import * as Core from '@golemui/core';
2
- export declare function Currency(widgetInstance: Core.WithWidget): import("react/jsx-runtime").JSX.Element;
1
+ import { WithWidget } from '@golemui/core';
2
+ export declare function Currency(widgetInstance: WithWidget): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
- import * as Core from '@golemui/core';
2
- export declare function DateInput(widgetInstance: Core.WithWidget): import("react/jsx-runtime").JSX.Element;
1
+ import { WithWidget } from '@golemui/core';
2
+ export declare function DateInput(widgetInstance: WithWidget): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
- import * as Core from '@golemui/core';
2
- export declare function DatePicker(widgetInstance: Core.WithWidget): import("react/jsx-runtime").JSX.Element;
1
+ import { WithWidget } from '@golemui/core';
2
+ export declare function DatePicker(widgetInstance: WithWidget): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
- import * as Core from '@golemui/core';
2
- export declare function Dropdown(widgetInstance: Core.WithWidget): import("react/jsx-runtime").JSX.Element;
1
+ import { WithWidget } from '@golemui/core';
2
+ export declare function Dropdown(widgetInstance: WithWidget): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
- import * as Core from '@golemui/core';
2
- export declare function Flex(widgetInstance: Core.WithWidget): import("react/jsx-runtime").JSX.Element;
1
+ import { WithWidget } from '@golemui/core';
2
+ export declare function Flex(widgetInstance: WithWidget): import("react/jsx-runtime").JSX.Element;
@@ -1,12 +1,12 @@
1
+ import { FormEvent, FormHealth } from '@golemui/core';
1
2
  import { GuiFormInitConfig } from '@golemui/gui-shared';
3
+ import { FormComponentHandle } from '@golemui/react';
2
4
  import { Ref } from 'react';
3
- import * as Core from '@golemui/core';
4
- import * as React from '@golemui/react';
5
5
  export interface ReactFormComponentProps {
6
6
  config: GuiFormInitConfig;
7
7
  autocomplete?: string;
8
- formEvent?: (event: Core.FormEvent) => void;
9
- formHealth?: (formHealth: Core.FormHealth) => void;
10
- ref?: Ref<React.FormComponentHandle>;
8
+ formEvent?: (event: FormEvent) => void;
9
+ formHealth?: (formHealth: FormHealth) => void;
10
+ ref?: Ref<FormComponentHandle>;
11
11
  }
12
12
  export declare function GuiForm({ config, formHealth, formEvent, autocomplete, ref, }: ReactFormComponentProps): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
- import * as Core from '@golemui/core';
2
- export declare function Grid(widgetInstance: Core.WithWidget): import("react/jsx-runtime").JSX.Element;
1
+ import { WithWidget } from '@golemui/core';
2
+ export declare function Grid(widgetInstance: WithWidget): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
- import * as Core from '@golemui/core';
2
- export declare function List(widgetInstance: Core.WithWidget): import("react/jsx-runtime").JSX.Element;
1
+ import { WithWidget } from '@golemui/core';
2
+ export declare function List(widgetInstance: WithWidget): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
- import * as Core from '@golemui/core';
2
- export declare function Markdown(widgetInstance: Core.WithWidget): import("react/jsx-runtime").JSX.Element;
1
+ import { WithWidget } from '@golemui/core';
2
+ export declare function Markdown(widgetInstance: WithWidget): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
- import * as Core from '@golemui/core';
2
- export declare function MarkdownText(widgetInstance: Core.WithWidget): import("react/jsx-runtime").JSX.Element;
1
+ import { WithWidget } from '@golemui/core';
2
+ export declare function MarkdownText(widgetInstance: WithWidget): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
- import * as Core from '@golemui/core';
2
- export declare function NumberInput(widgetInstance: Core.WithWidget): import("react/jsx-runtime").JSX.Element;
1
+ import { WithWidget } from '@golemui/core';
2
+ export declare function NumberInput(widgetInstance: WithWidget): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
- import * as Core from '@golemui/core';
2
- export declare function Password(widgetInstance: Core.WithWidget): import("react/jsx-runtime").JSX.Element;
1
+ import { WithWidget } from '@golemui/core';
2
+ export declare function Password(widgetInstance: WithWidget): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
- import * as Core from '@golemui/core';
2
- export declare function RadioGroup(widgetInstance: Core.WithWidget): import("react/jsx-runtime").JSX.Element;
1
+ import { WithWidget } from '@golemui/core';
2
+ export declare function RadioGroup(widgetInstance: WithWidget): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
- import * as Core from '@golemui/core';
2
- export declare function RangeCalendar(widgetInstance: Core.WithWidget): import("react/jsx-runtime").JSX.Element;
1
+ import { WithWidget } from '@golemui/core';
2
+ export declare function RangeCalendar(widgetInstance: WithWidget): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
- import * as Core from '@golemui/core';
2
- export declare function RangeDateInput(widgetInstance: Core.WithWidget): import("react/jsx-runtime").JSX.Element;
1
+ import { WithWidget } from '@golemui/core';
2
+ export declare function RangeDateInput(widgetInstance: WithWidget): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
- import * as Core from '@golemui/core';
2
- export declare function RangeDatePicker(widgetInstance: Core.WithWidget): import("react/jsx-runtime").JSX.Element;
1
+ import { WithWidget } from '@golemui/core';
2
+ export declare function RangeDatePicker(widgetInstance: WithWidget): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
- import * as Core from '@golemui/core';
2
- export declare function Renderer(widgetInstance: Core.WithWidget): import("react/jsx-runtime").JSX.Element;
1
+ import { WithWidget } from '@golemui/core';
2
+ export declare function Renderer(widgetInstance: WithWidget): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
- import * as Core from '@golemui/core';
2
- export declare function Repeater(widgetInstance: Core.WithWidget): import("react/jsx-runtime").JSX.Element;
1
+ import { WithWidget } from '@golemui/core';
2
+ export declare function Repeater(widgetInstance: WithWidget): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
- import * as Core from '@golemui/core';
2
- export declare function Select(widgetInstance: Core.WithWidget): import("react/jsx-runtime").JSX.Element;
1
+ import { WithWidget } from '@golemui/core';
2
+ export declare function Select(widgetInstance: WithWidget): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
- import * as Core from '@golemui/core';
2
- export declare function Tabs(widgetInstance: Core.WithWidget): import("react/jsx-runtime").JSX.Element;
1
+ import { WithWidget } from '@golemui/core';
2
+ export declare function Tabs(widgetInstance: WithWidget): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
- import * as Core from '@golemui/core';
2
- export declare function TextArea(widgetInstance: Core.WithWidget): import("react/jsx-runtime").JSX.Element;
1
+ import { WithWidget } from '@golemui/core';
2
+ export declare function TextArea(widgetInstance: WithWidget): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
- import * as Core from '@golemui/core';
2
- export declare function TextInput(widgetInstance: Core.WithWidget): import("react/jsx-runtime").JSX.Element;
1
+ import { WithWidget } from '@golemui/core';
2
+ export declare function TextInput(widgetInstance: WithWidget): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
- import * as Core from '@golemui/core';
2
- export declare function Toggle(widgetInstance: Core.WithWidget): import("react/jsx-runtime").JSX.Element;
1
+ import { WithWidget } from '@golemui/core';
2
+ export declare function Toggle(widgetInstance: WithWidget): import("react/jsx-runtime").JSX.Element;
@@ -1,3 +1,3 @@
1
+ import { WidgetLoaders, WithWidget } from '@golemui/core';
1
2
  import { GolemWidget } from '@golemui/gui-shared';
2
- import * as Core from '@golemui/core';
3
- export declare const widgetLoaders: Core.WidgetLoaders<React.ComponentType<Core.WithWidget>, GolemWidget>;
3
+ export declare const widgetLoaders: WidgetLoaders<React.ComponentType<WithWidget>, GolemWidget>;
@@ -0,0 +1,282 @@
1
+ import { jsx as d } from "react/jsx-runtime";
2
+ import "react";
3
+ import "@golemui/gui-shared";
4
+ import { i as p, A as u, b as m, n as a, t as f } from "./directive-1yd1wdny.js";
5
+ import { r as c } from "./state-DI9ZsB5W.js";
6
+ import { e as v } from "./query-h1h36oxg.js";
7
+ function $({
8
+ template: e,
9
+ selected: t,
10
+ disabled: i,
11
+ focused: o
12
+ }) {
13
+ const s = [
14
+ "gui-list__item",
15
+ i ? "gui-list__item-disabled" : "",
16
+ t ? "gui-list__item-selected" : "",
17
+ o ? "gui-list__item-focused" : ""
18
+ ].filter(Boolean).join(" ");
19
+ return /* @__PURE__ */ d("div", { role: "option", className: s, "aria-selected": t, children: e });
20
+ }
21
+ const g = (e) => e !== null && typeof e == "object" && Object.prototype.hasOwnProperty.call(e, "template") && Object.prototype.hasOwnProperty.call(e, "value");
22
+ function b(e) {
23
+ const t = typeof e;
24
+ return t === "string" || t === "number";
25
+ }
26
+ const y = (e, { valueField: t }) => {
27
+ if (e === null || typeof e != "object")
28
+ return !1;
29
+ const i = e, o = t ?? "value";
30
+ return !!Object.prototype.hasOwnProperty.call(i, o);
31
+ };
32
+ function w(e, { valueField: t }) {
33
+ if (e === null || typeof e != "object")
34
+ throw new Error("Provided value is not an object");
35
+ const i = e, o = t ?? "value", s = Object.prototype.hasOwnProperty.call(i, o) ? o : void 0;
36
+ if (!s)
37
+ throw new Error("No valueField exists on the object");
38
+ return (n) => {
39
+ if (n === null || typeof n != "object")
40
+ throw new Error("Item is not an object");
41
+ return {
42
+ template: n,
43
+ value: s ? n[s] : ""
44
+ };
45
+ };
46
+ }
47
+ const I = (e, t) => {
48
+ if (Array.isArray(e) && e.length > 0 && !g(e[0])) {
49
+ if (b(e[0]))
50
+ return e.map((i) => ({
51
+ template: i,
52
+ value: i
53
+ }));
54
+ if (y(e[0], t)) {
55
+ const i = w(e[0], t);
56
+ return e.map(i);
57
+ } else
58
+ throw new Error("Invalid list item shape");
59
+ }
60
+ return e;
61
+ };
62
+ var _ = Object.defineProperty, x = Object.getOwnPropertyDescriptor, l = (e, t, i, o) => {
63
+ for (var s = o > 1 ? void 0 : o ? x(t, i) : t, n = e.length - 1, h; n >= 0; n--)
64
+ (h = e[n]) && (s = (o ? h(t, i, s) : h(s)) || s);
65
+ return o && s && _(t, i, s), s;
66
+ };
67
+ let r = class extends p {
68
+ constructor() {
69
+ super(...arguments), this.uid = void 0, this.touched = !1, this.required = !1, this.disabled = !1, this.readOnly = !1, this.value = void 0, this.valueField = void 0, this.label = void 0, this.hint = void 0, this.items = [], this.itemHeight = void 0, this.height = void 0, this._items = [], this._scrollTop = 0, this._viewportHeight = 0, this._focusedIndex = -1, this.buffer = 5;
70
+ }
71
+ willUpdate(e) {
72
+ super.willUpdate(e), e.has("items") && this.updateItems(), (e.has("items") || e.has("_scrollTop") || e.has("height")) && this.emitRangeChange();
73
+ }
74
+ firstUpdated() {
75
+ this.measureViewport(), new ResizeObserver(() => this.measureViewport()).observe(this.viewportElement);
76
+ }
77
+ render() {
78
+ const e = this.height ?? 300, t = this.itemHeight ?? 40, i = (this.items?.length ?? 0) * t, { offsetY: o } = this.calculateRange(), s = this._focusedIndex >= 0 ? `${this.uid}-item-${this._focusedIndex}` : void 0;
79
+ return m`
80
+ <div
81
+ role="listbox"
82
+ id=${this.uid}
83
+ tabindex=${this.disabled ? -1 : 0}
84
+ class="gui-list__scroll-viewport"
85
+ style="max-height: ${e}px; overflow-y: auto; position: relative; display: block;"
86
+ @scroll="${this.onScroll}"
87
+ @keydown="${this.onKeyDown}"
88
+ @focus="${this.onFocus}"
89
+ @focusout="${this.onFocusOut}"
90
+ aria-required=${this.required ? "true" : u}
91
+ aria-disabled=${this.disabled || this.readOnly ? "true" : u}
92
+ aria-activedescendant="${s ?? u}"
93
+ aria-label=${this.label ?? u}
94
+ aria-description=${this.hint ?? u}
95
+ >
96
+ <div
97
+ class="gui-list__spacer"
98
+ style="height: ${i}px; width: 1px; opacity: 0; pointer-events: none;"
99
+ ></div>
100
+
101
+ <div
102
+ class="gui-list__content"
103
+ style="transform: translateY(${o}px); position: absolute; top: 0; left: 0; width: 100%;"
104
+ >
105
+ <slot></slot>
106
+ </div>
107
+ </div>
108
+ `;
109
+ }
110
+ focus(e) {
111
+ this.viewportElement ? this.viewportElement.focus(e) : super.focus(e);
112
+ }
113
+ focusItemAtIndex(e) {
114
+ this._focusedIndex = e;
115
+ }
116
+ scrollToSelectedIndex() {
117
+ const e = this.items.findIndex((t) => (this.valueField ? t[this.valueField] : t) === this.value);
118
+ this.scrollToIndex(e);
119
+ }
120
+ onKeyDown(e) {
121
+ if (this.disabled || this.readOnly) return;
122
+ const t = this.itemHeight ?? 40, i = Math.ceil(this._viewportHeight / t), o = this.items.length - 1;
123
+ let s = !1;
124
+ switch (e.key) {
125
+ case "ArrowDown":
126
+ this.setFocusedIndex(Math.min(this._focusedIndex + 1, o)), s = !0;
127
+ break;
128
+ case "ArrowUp":
129
+ this.setFocusedIndex(Math.max(this._focusedIndex - 1, 0)), s = !0;
130
+ break;
131
+ case "PageDown":
132
+ this.setFocusedIndex(Math.min(this._focusedIndex + i, o)), s = !0;
133
+ break;
134
+ case "PageUp":
135
+ this.setFocusedIndex(Math.max(this._focusedIndex - i, 0)), s = !0;
136
+ break;
137
+ case "Home":
138
+ this.setFocusedIndex(0), s = !0;
139
+ break;
140
+ case "End":
141
+ this.setFocusedIndex(o), s = !0;
142
+ break;
143
+ case "Enter":
144
+ case " ": {
145
+ const n = this.items[this._focusedIndex], h = n != null;
146
+ this._focusedIndex >= 0 && h && this.selectItem(this.items[this._focusedIndex]), s = !0;
147
+ break;
148
+ }
149
+ }
150
+ s && e.preventDefault();
151
+ }
152
+ onFocus() {
153
+ if (!this.value || !this.items.length) return;
154
+ const e = this.items.findIndex((t) => (this.valueField ? t[this.valueField] : t) === this.value);
155
+ this._focusedIndex = e, this.scrollToIndex(e), this.dispatchEvent(
156
+ new CustomEvent("gui-focus-change", {
157
+ detail: { index: e },
158
+ bubbles: !0,
159
+ composed: !0
160
+ })
161
+ );
162
+ }
163
+ onFocusOut(e) {
164
+ e.relatedTarget && this.contains(e.relatedTarget) || (this._focusedIndex = -1, this.dispatchEvent(
165
+ new CustomEvent("gui-focus-change", {
166
+ detail: { index: -1 },
167
+ bubbles: !0,
168
+ composed: !0
169
+ })
170
+ ), this.dispatchEvent(new CustomEvent("blur", { bubbles: !0, composed: !0 })));
171
+ }
172
+ scrollToIndex(e) {
173
+ const t = this.itemHeight ?? 40, i = this.height ?? 300, o = e * t, s = o + t, n = this.viewportElement.scrollTop, h = n + i;
174
+ o < n ? this.viewportElement.scrollTop = o : s > h && (this.viewportElement.scrollTop = s - i);
175
+ }
176
+ selectItem(e) {
177
+ this.dispatchEvent(
178
+ new CustomEvent("change", {
179
+ detail: { value: this.valueField ? e[this.valueField] : e },
180
+ bubbles: !0,
181
+ composed: !0
182
+ })
183
+ );
184
+ }
185
+ setFocusedIndex(e) {
186
+ e < 0 || e >= this.items.length || (this._focusedIndex = e, this.scrollToIndex(e), this.dispatchEvent(
187
+ new CustomEvent("gui-focus-change", {
188
+ detail: { index: e },
189
+ bubbles: !0,
190
+ composed: !0
191
+ })
192
+ ));
193
+ }
194
+ updateItems() {
195
+ this._items = I(this.items, { valueField: this.valueField }), this.dispatchEvent(
196
+ new CustomEvent("gui-update-items", {
197
+ detail: this._items,
198
+ bubbles: !0,
199
+ composed: !0
200
+ })
201
+ );
202
+ }
203
+ emitRangeChange() {
204
+ const { startIndex: e, endIndex: t } = this.calculateRange();
205
+ this.dispatchEvent(
206
+ new CustomEvent("gui-range-change", {
207
+ detail: { startIndex: e, endIndex: t },
208
+ bubbles: !0,
209
+ composed: !0
210
+ })
211
+ );
212
+ }
213
+ measureViewport() {
214
+ this.viewportElement && (this._viewportHeight = this.viewportElement.offsetHeight, this.emitRangeChange());
215
+ }
216
+ onScroll(e) {
217
+ const t = e.target;
218
+ this._scrollTop = t.scrollTop;
219
+ }
220
+ calculateRange() {
221
+ const e = this.itemHeight ?? 40, t = this.items?.length ?? 0, i = Math.ceil(this._viewportHeight / e), o = Math.floor(this._scrollTop / e), s = Math.max(0, o - this.buffer), n = Math.min(t, o + i + this.buffer), h = s * e;
222
+ return { startIndex: s, endIndex: n, offsetY: h };
223
+ }
224
+ };
225
+ l([
226
+ a({ type: String })
227
+ ], r.prototype, "uid", 2);
228
+ l([
229
+ a({ type: Boolean })
230
+ ], r.prototype, "touched", 2);
231
+ l([
232
+ a({ type: Boolean })
233
+ ], r.prototype, "required", 2);
234
+ l([
235
+ a({ type: Boolean })
236
+ ], r.prototype, "disabled", 2);
237
+ l([
238
+ a({ type: Boolean, attribute: "readonly" })
239
+ ], r.prototype, "readOnly", 2);
240
+ l([
241
+ a({ type: String })
242
+ ], r.prototype, "value", 2);
243
+ l([
244
+ a({ type: String })
245
+ ], r.prototype, "valueField", 2);
246
+ l([
247
+ a({ type: String })
248
+ ], r.prototype, "label", 2);
249
+ l([
250
+ a({ type: String })
251
+ ], r.prototype, "hint", 2);
252
+ l([
253
+ a({ type: Array })
254
+ ], r.prototype, "items", 2);
255
+ l([
256
+ a({ type: Number })
257
+ ], r.prototype, "itemHeight", 2);
258
+ l([
259
+ a({ type: Number })
260
+ ], r.prototype, "height", 2);
261
+ l([
262
+ c()
263
+ ], r.prototype, "_items", 2);
264
+ l([
265
+ c()
266
+ ], r.prototype, "_scrollTop", 2);
267
+ l([
268
+ c()
269
+ ], r.prototype, "_viewportHeight", 2);
270
+ l([
271
+ c()
272
+ ], r.prototype, "_focusedIndex", 2);
273
+ l([
274
+ v(".gui-list__scroll-viewport")
275
+ ], r.prototype, "viewportElement", 2);
276
+ r = l([
277
+ f("gui-list")
278
+ ], r);
279
+ typeof customElements < "u" && !customElements.get("gui-list") && customElements.define("gui-list", r);
280
+ export {
281
+ $ as D
282
+ };
@@ -0,0 +1,24 @@
1
+ import { e as s, a as T, c as t, E as n, A as l } from "./directive-1yd1wdny.js";
2
+ import { r as p, p as a } from "./repeat-BucBfSPF.js";
3
+ const c = s(class extends T {
4
+ constructor(e) {
5
+ if (super(e), e.type !== t.PROPERTY && e.type !== t.ATTRIBUTE && e.type !== t.BOOLEAN_ATTRIBUTE) throw Error("The `live` directive is not allowed on child or event bindings");
6
+ if (!p(e)) throw Error("`live` bindings can only contain a single expression");
7
+ }
8
+ render(e) {
9
+ return e;
10
+ }
11
+ update(e, [r]) {
12
+ if (r === n || r === l) return r;
13
+ const i = e.element, o = e.name;
14
+ if (e.type === t.PROPERTY) {
15
+ if (r === i[o]) return n;
16
+ } else if (e.type === t.BOOLEAN_ATTRIBUTE) {
17
+ if (!!r === i.hasAttribute(o)) return n;
18
+ } else if (e.type === t.ATTRIBUTE && i.getAttribute(o) === r + "") return n;
19
+ return a(e), r;
20
+ }
21
+ });
22
+ export {
23
+ c as l
24
+ };
@@ -0,0 +1,44 @@
1
+ import { a as h, A as a, c as l, E as m, e as f, i as v, b as w, n as p, t as y } from "./directive-1yd1wdny.js";
2
+ import "@golemui/gui-shared";
3
+ class u extends h {
4
+ constructor(t) {
5
+ if (super(t), this.it = a, t.type !== l.CHILD) throw Error(this.constructor.directiveName + "() can only be used in child bindings");
6
+ }
7
+ render(t) {
8
+ if (t === a || t == null) return this._t = void 0, this.it = t;
9
+ if (t === m) return t;
10
+ if (typeof t != "string") throw Error(this.constructor.directiveName + "() called with a non-string value");
11
+ if (t === this.it) return this._t;
12
+ this.it = t;
13
+ const e = [t];
14
+ return e.raw = e, this._t = { _$litType$: this.constructor.resultType, strings: e, values: [] };
15
+ }
16
+ }
17
+ u.directiveName = "unsafeHTML", u.resultType = 1;
18
+ const g = f(u);
19
+ var _ = Object.defineProperty, b = Object.getOwnPropertyDescriptor, d = (n, t, e, i) => {
20
+ for (var r = i > 1 ? void 0 : i ? b(t, e) : t, o = n.length - 1, c; o >= 0; o--)
21
+ (c = n[o]) && (r = (i ? c(t, e, r) : c(r)) || r);
22
+ return i && r && _(t, e, r), r;
23
+ };
24
+ let s = class extends v {
25
+ constructor() {
26
+ super(...arguments), this.md = void 0, this.dependencies = void 0;
27
+ }
28
+ createRenderRoot() {
29
+ return this;
30
+ }
31
+ render() {
32
+ return w`${g(this.dependencies?.markdown?.parse(this.md ?? ""))}`;
33
+ }
34
+ };
35
+ d([
36
+ p({ type: String })
37
+ ], s.prototype, "md", 2);
38
+ d([
39
+ p({ type: Object })
40
+ ], s.prototype, "dependencies", 2);
41
+ s = d([
42
+ y("gui-markdown-text")
43
+ ], s);
44
+ typeof customElements < "u" && !customElements.get("gui-markdown-text") && customElements.define("gui-markdown-text", s);
@@ -0,0 +1,48 @@
1
+ import { isOption as c } from "@golemui/gui-shared";
2
+ function l(e) {
3
+ const r = typeof e;
4
+ return r === "string" || r === "number";
5
+ }
6
+ function b(e, r) {
7
+ return r.find((t) => t.value.toString() === e)?.value;
8
+ }
9
+ const h = (e, r) => {
10
+ if (Array.isArray(e) && e.length > 0 && !c(e[0])) {
11
+ if (l(e[0]))
12
+ return e.map((t) => ({
13
+ label: t.toString(),
14
+ value: t
15
+ }));
16
+ if (u(e[0], r)) {
17
+ const t = f(e[0], r);
18
+ return e.map(t);
19
+ } else
20
+ throw new Error("Invalid option shape");
21
+ }
22
+ return e;
23
+ }, u = (e, { labelField: r, valueField: t }) => {
24
+ if (e === null || typeof e != "object")
25
+ return !1;
26
+ const n = e, o = r ? Object.prototype.hasOwnProperty.call(n, r) : !1, a = t ? Object.prototype.hasOwnProperty.call(n, t) : !1;
27
+ return r && !o ? !1 : !(t && !a);
28
+ };
29
+ function f(e, { labelField: r, valueField: t }) {
30
+ if (e === null || typeof e != "object")
31
+ throw new Error("Provided value is not an object");
32
+ const n = e, o = r && Object.prototype.hasOwnProperty.call(n, r) ? r : void 0, a = t && Object.prototype.hasOwnProperty.call(n, t) ? t : void 0;
33
+ if (!o && !a)
34
+ throw new Error("Neither labelField nor valueField exists on the object");
35
+ return (i) => {
36
+ if (i === null || typeof i != "object")
37
+ throw new Error("Item is not an object");
38
+ const s = i;
39
+ return {
40
+ label: o ? s[o] : "",
41
+ value: a ? s[a] : ""
42
+ };
43
+ };
44
+ }
45
+ export {
46
+ b as i,
47
+ h as u
48
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@golemui/gui-react",
3
- "version": "0.12.2",
3
+ "version": "0.13.1",
4
4
  "type": "module",
5
5
  "main": "./index.umd.cjs",
6
6
  "module": "./index.js",
@@ -23,11 +23,11 @@
23
23
  "peerDependencies": {
24
24
  "react": ">=18.0.0",
25
25
  "react-dom": ">=18.0.0",
26
- "@golemui/react": "0.12.2",
27
- "@golemui/core": "0.12.2",
28
- "@golemui/gui-components": "0.12.2",
29
- "@golemui/gui-shared": "0.12.2",
30
- "@golemui/gui-validators": "0.12.2"
26
+ "@golemui/react": "0.13.1",
27
+ "@golemui/core": "0.13.1",
28
+ "@golemui/gui-components": "0.13.1",
29
+ "@golemui/gui-shared": "0.13.1",
30
+ "@golemui/gui-validators": "0.13.1"
31
31
  },
32
32
  "repository": {
33
33
  "type": "git",
@@ -0,0 +1,12 @@
1
+ const c = (r, t, e) => (e.configurable = !0, e.enumerable = !0, Reflect.decorate && typeof t != "object" && Object.defineProperty(r, t, e), e);
2
+ function f(r, t) {
3
+ return (e, o, l) => {
4
+ const n = (u) => u.renderRoot?.querySelector(r) ?? null;
5
+ return c(e, o, { get() {
6
+ return n(this);
7
+ } });
8
+ };
9
+ }
10
+ export {
11
+ f as e
12
+ };