solid-tiny-ui 0.4.0 → 0.5.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 (60) hide show
  1. package/dist/_virtual/__viteSafe__/home/runner/work/solid-tiny-ui/solid-tiny-ui/packages/core/src/components/buttons/basic-button/basic-button.js +1 -1
  2. package/dist/_virtual/__viteSafe__/home/runner/work/solid-tiny-ui/solid-tiny-ui/packages/core/src/components/buttons/basic-button/basic-button.jsx +1 -1
  3. package/dist/_virtual/__viteSafe__/home/runner/work/solid-tiny-ui/solid-tiny-ui/packages/core/src/components/time-picker/time-picker.js +5 -0
  4. package/dist/_virtual/__viteSafe__/home/runner/work/solid-tiny-ui/solid-tiny-ui/packages/core/src/components/time-picker/time-picker.jsx +5 -0
  5. package/dist/_virtual/__viteSafe__/home/runner/work/solid-tiny-ui/solid-tiny-ui/packages/core/src/components/visually-hidden/visually-hidden.js +5 -0
  6. package/dist/_virtual/__viteSafe__/home/runner/work/solid-tiny-ui/solid-tiny-ui/packages/core/src/components/visually-hidden/visually-hidden.jsx +5 -0
  7. package/dist/components/buttons/state-button/state-button.d.ts +2 -2
  8. package/dist/components/combobox/combobox.d.ts +2 -2
  9. package/dist/components/input/input.d.ts +2 -2
  10. package/dist/components/modal/index.d.ts +2 -2
  11. package/dist/components/popover/index.js +4 -3
  12. package/dist/components/popover/index.jsx +2 -1
  13. package/dist/components/progress/line-progress.d.ts +2 -2
  14. package/dist/components/progress/loading-bar.d.ts +2 -2
  15. package/dist/components/spin/spin-ring.d.ts +2 -2
  16. package/dist/components/time-picker/index.d.ts +18 -0
  17. package/dist/components/time-picker/index.js +90 -0
  18. package/dist/components/time-picker/index.jsx +39 -0
  19. package/dist/components/time-picker/panel.js +185 -0
  20. package/dist/components/time-picker/panel.jsx +108 -0
  21. package/dist/components/time-picker/trigger.js +64 -0
  22. package/dist/components/time-picker/trigger.jsx +37 -0
  23. package/dist/components/visually-hidden/index.js +17 -0
  24. package/dist/components/visually-hidden/index.jsx +11 -0
  25. package/dist/icons/check-line.d.ts +6 -0
  26. package/dist/icons/check-line.js +13 -0
  27. package/dist/icons/check-line.jsx +11 -0
  28. package/dist/icons/index.d.ts +2 -1
  29. package/dist/icons/index.js +2 -1
  30. package/dist/icons/index.jsx +2 -1
  31. package/dist/index.d.ts +2 -1
  32. package/dist/index.js +2 -1
  33. package/dist/index.jsx +2 -1
  34. package/dist/primitives/animated-group/context.d.ts +9 -9
  35. package/dist/primitives/animated-group/root.d.ts +2 -2
  36. package/dist/primitives/fake-scroll-list/context.js +30 -0
  37. package/dist/primitives/fake-scroll-list/context.jsx +30 -0
  38. package/dist/primitives/fake-scroll-list/index.d.ts +52 -0
  39. package/dist/primitives/fake-scroll-list/index.js +36 -0
  40. package/dist/primitives/fake-scroll-list/index.jsx +36 -0
  41. package/dist/primitives/fake-scroll-list/item.d.ts +11 -0
  42. package/dist/primitives/fake-scroll-list/item.js +30 -0
  43. package/dist/primitives/fake-scroll-list/item.jsx +13 -0
  44. package/dist/primitives/fake-scroll-list/listbox.d.ts +8 -0
  45. package/dist/primitives/fake-scroll-list/listbox.js +72 -0
  46. package/dist/primitives/fake-scroll-list/listbox.jsx +61 -0
  47. package/dist/primitives/fake-scroll-list/root.d.ts +15 -0
  48. package/dist/primitives/fake-scroll-list/root.js +52 -0
  49. package/dist/primitives/fake-scroll-list/root.jsx +40 -0
  50. package/dist/primitives/floating/context.d.ts +6 -6
  51. package/dist/primitives/floating/index.d.ts +2 -2
  52. package/dist/primitives/index.d.ts +2 -1
  53. package/dist/primitives/index.js +2 -1
  54. package/dist/primitives/index.jsx +2 -1
  55. package/dist/primitives/listbox/listbox.d.ts +3 -3
  56. package/dist/primitives/modal/content.d.ts +3 -3
  57. package/dist/primitives/modal/context.d.ts +9 -9
  58. package/dist/primitives/modal/root.d.ts +2 -2
  59. package/dist/root-provider/context.d.ts +9 -9
  60. package/package.json +7 -6
@@ -0,0 +1,108 @@
1
+ import { CheckLine } from "../../icons/check-line.jsx";
2
+ import { CloseLine } from "../../icons/close-line.jsx";
3
+ import "../../icons/index.jsx";
4
+ import { FakeScrollListCore } from "../../primitives/fake-scroll-list/index.jsx";
5
+ import "../../primitives/index.jsx";
6
+ import { Show, createMemo } from "solid-js";
7
+ import { createWatch, list } from "solid-tiny-utils";
8
+ import { createStore } from "solid-js/store";
9
+
10
+ //#region src/components/time-picker/panel.tsx
11
+ function CommonTimeList(props) {
12
+ return <FakeScrollListCore inViewIndex={props.inViewItem} itemHeight={props.itemHeight} items={props.items.map((v) => v.toString().padStart(2, "0"))} onInViewIndexChange={(i) => {
13
+ props.onChange(i);
14
+ }} visibleItemsCount={7}>
15
+ <FakeScrollListCore.Listbox>
16
+ {(label, key) => <FakeScrollListCore.Item class="tiny-time-picker__listbox-item" key={key}>
17
+ {label}
18
+ </FakeScrollListCore.Item>}
19
+ </FakeScrollListCore.Listbox>
20
+ </FakeScrollListCore>;
21
+ }
22
+ function HourList(props) {
23
+ return <CommonTimeList inViewItem={props.hour} itemHeight={props.itemHeight} items={list(0, 23)} onChange={(hour) => {
24
+ props.onChange(hour);
25
+ }} />;
26
+ }
27
+ function MinuteList(props) {
28
+ return <CommonTimeList inViewItem={props.minute} itemHeight={props.itemHeight} items={list(0, 59)} onChange={(minute) => {
29
+ props.onChange(minute);
30
+ }} />;
31
+ }
32
+ function SecondList(props) {
33
+ return <CommonTimeList inViewItem={props.second} itemHeight={props.itemHeight} items={list(0, 59)} onChange={(second) => {
34
+ props.onChange(second);
35
+ }} />;
36
+ }
37
+ function TimePanel(props) {
38
+ const [time, setTime] = createStore({
39
+ hour: 0,
40
+ minute: 0,
41
+ second: 0
42
+ });
43
+ createWatch(() => [
44
+ props.hour,
45
+ props.minute,
46
+ props.second
47
+ ], ([hour, minute, second]) => {
48
+ setTime({
49
+ hour,
50
+ minute,
51
+ second
52
+ });
53
+ });
54
+ createWatch(() => [
55
+ time.hour,
56
+ time.minute,
57
+ time.second
58
+ ], ([hour, minute, second]) => {
59
+ if (hour === props.hour && minute === props.minute && second === props.second) return;
60
+ props.onChange(hour, minute, second);
61
+ });
62
+ const typeIndex = createMemo(() => {
63
+ return [
64
+ "hour",
65
+ "minute",
66
+ "second"
67
+ ].indexOf(props.type);
68
+ });
69
+ return <div style={{
70
+ width: `${props.width}px`,
71
+ display: "flex",
72
+ "flex-direction": "column",
73
+ position: "relative"
74
+ }}>
75
+ <div class="tiny-time-picker__thumb" style={{
76
+ "--tiny-time-picker-thumb-height": `${props.itemHeight}px`,
77
+ "--tiny-time-picker-thumb-top": `${props.itemHeight * 7 / 2 - props.itemHeight / 2}px`
78
+ }} />
79
+ <div style={{
80
+ width: "100%",
81
+ display: "flex",
82
+ position: "relative"
83
+ }}>
84
+ <HourList hour={time.hour} itemHeight={props.itemHeight} onChange={(hour) => setTime("hour", hour)} />
85
+ <Show when={typeIndex() > 0}>
86
+ <MinuteList itemHeight={props.itemHeight} minute={time.minute} onChange={(minute) => setTime("minute", minute)} />
87
+ </Show>
88
+ <Show when={typeIndex() > 1}>
89
+ <SecondList itemHeight={props.itemHeight} onChange={(second) => setTime("second", second)} second={time.second} />
90
+ </Show>
91
+ </div>
92
+ <div class="tiny-time-picker__action">
93
+ <button onClick={() => {
94
+ props.onCancel(time.hour, time.minute, time.second);
95
+ }} type="button">
96
+ <CloseLine />
97
+ </button>
98
+ <button onClick={() => {
99
+ props.onConfirm(time.hour, time.minute, time.second);
100
+ }} type="button">
101
+ <CheckLine />
102
+ </button>
103
+ </div>
104
+ </div>;
105
+ }
106
+
107
+ //#endregion
108
+ export { TimePanel };
@@ -0,0 +1,64 @@
1
+ import { VisuallyHidden } from "../visually-hidden/index.js";
2
+ import { createComponent, effect, insert, memo, setAttribute, template } from "solid-js/web";
3
+ import { Show, createMemo } from "solid-js";
4
+ import { dataIf } from "solid-tiny-utils";
5
+
6
+ //#region src/components/time-picker/trigger.tsx
7
+ var _tmpl$ = /* @__PURE__ */ template(`<input readonly tabindex=-1 type=text>`), _tmpl$2 = /* @__PURE__ */ template(`<div class=tiny-time-picker-trigger__item>`), _tmpl$3 = /* @__PURE__ */ template(`<button class="tiny-time-picker-trigger tiny-time-picker-trigger-vars"type=button><div class=tiny-time-picker-trigger__item>`);
8
+ function TimeTrigger(props) {
9
+ const typeIndex = createMemo(() => [
10
+ "hour",
11
+ "minute",
12
+ "second"
13
+ ].indexOf(props.type));
14
+ const toStr = (num) => {
15
+ if (num === null) return "";
16
+ return num.toString().padStart(2, "0");
17
+ };
18
+ return (() => {
19
+ var _el$ = _tmpl$3(), _el$3 = _el$.firstChild;
20
+ insert(_el$, createComponent(VisuallyHidden, { get children() {
21
+ var _el$2 = _tmpl$();
22
+ effect(() => _el$2.disabled = props.disabled);
23
+ return _el$2;
24
+ } }), _el$3);
25
+ insert(_el$3, () => toStr(props.hour) || "hh");
26
+ insert(_el$, createComponent(Show, {
27
+ get when() {
28
+ return typeIndex() > 0;
29
+ },
30
+ get children() {
31
+ var _el$4 = _tmpl$2();
32
+ insert(_el$4, () => toStr(props.minute) || "mm");
33
+ effect(() => setAttribute(_el$4, "data-empty", dataIf(props.minute === null)));
34
+ return _el$4;
35
+ }
36
+ }), null);
37
+ insert(_el$, createComponent(Show, {
38
+ get when() {
39
+ return typeIndex() > 1;
40
+ },
41
+ get children() {
42
+ var _el$5 = _tmpl$2();
43
+ insert(_el$5, () => toStr(props.second) || "ss");
44
+ effect(() => setAttribute(_el$5, "data-empty", dataIf(props.second === null)));
45
+ return _el$5;
46
+ }
47
+ }), null);
48
+ effect((_p$) => {
49
+ var _v$ = dataIf(props.disabled), _v$2 = props.size, _v$3 = dataIf(props.hour === null);
50
+ _v$ !== _p$.e && setAttribute(_el$, "data-disabled", _p$.e = _v$);
51
+ _v$2 !== _p$.t && setAttribute(_el$, "data-size", _p$.t = _v$2);
52
+ _v$3 !== _p$.a && setAttribute(_el$3, "data-empty", _p$.a = _v$3);
53
+ return _p$;
54
+ }, {
55
+ e: void 0,
56
+ t: void 0,
57
+ a: void 0
58
+ });
59
+ return _el$;
60
+ })();
61
+ }
62
+
63
+ //#endregion
64
+ export { TimeTrigger };
@@ -0,0 +1,37 @@
1
+ import { VisuallyHidden } from "../visually-hidden/index.jsx";
2
+ import { Show, createMemo } from "solid-js";
3
+ import { dataIf } from "solid-tiny-utils";
4
+
5
+ //#region src/components/time-picker/trigger.tsx
6
+ function TimeTrigger(props) {
7
+ const typeIndex = createMemo(() => [
8
+ "hour",
9
+ "minute",
10
+ "second"
11
+ ].indexOf(props.type));
12
+ const toStr = (num) => {
13
+ if (num === null) return "";
14
+ return num.toString().padStart(2, "0");
15
+ };
16
+ return <button class="tiny-time-picker-trigger tiny-time-picker-trigger-vars" data-disabled={dataIf(props.disabled)} data-size={props.size} type="button">
17
+ <VisuallyHidden>
18
+ <input disabled={props.disabled} readonly tabIndex={-1} type="text" />
19
+ </VisuallyHidden>
20
+ <div class="tiny-time-picker-trigger__item" data-empty={dataIf(props.hour === null)}>
21
+ {toStr(props.hour) || "hh"}
22
+ </div>
23
+ <Show when={typeIndex() > 0}>
24
+ <div class="tiny-time-picker-trigger__item" data-empty={dataIf(props.minute === null)}>
25
+ {toStr(props.minute) || "mm"}
26
+ </div>
27
+ </Show>
28
+ <Show when={typeIndex() > 1}>
29
+ <div class="tiny-time-picker-trigger__item" data-empty={dataIf(props.second === null)}>
30
+ {toStr(props.second) || "ss"}
31
+ </div>
32
+ </Show>
33
+ </button>;
34
+ }
35
+
36
+ //#endregion
37
+ export { TimeTrigger };
@@ -0,0 +1,17 @@
1
+ import visually_hidden_default from "../../_virtual/__viteSafe__/home/runner/work/solid-tiny-ui/solid-tiny-ui/packages/core/src/components/visually-hidden/visually-hidden.js";
2
+ import { insert, template } from "solid-js/web";
3
+ import { mountStyle } from "solid-tiny-utils";
4
+
5
+ //#region src/components/visually-hidden/index.tsx
6
+ var _tmpl$ = /* @__PURE__ */ template(`<span class=tiny-visually-hidden>`);
7
+ function VisuallyHidden(props) {
8
+ mountStyle(visually_hidden_default, "tiny-visually-hidden");
9
+ return (() => {
10
+ var _el$ = _tmpl$();
11
+ insert(_el$, () => props.children);
12
+ return _el$;
13
+ })();
14
+ }
15
+
16
+ //#endregion
17
+ export { VisuallyHidden };
@@ -0,0 +1,11 @@
1
+ import visually_hidden_default from "../../_virtual/__viteSafe__/home/runner/work/solid-tiny-ui/solid-tiny-ui/packages/core/src/components/visually-hidden/visually-hidden.jsx";
2
+ import { mountStyle } from "solid-tiny-utils";
3
+
4
+ //#region src/components/visually-hidden/index.tsx
5
+ function VisuallyHidden(props) {
6
+ mountStyle(visually_hidden_default, "tiny-visually-hidden");
7
+ return <span class="tiny-visually-hidden">{props.children}</span>;
8
+ }
9
+
10
+ //#endregion
11
+ export { VisuallyHidden };
@@ -0,0 +1,6 @@
1
+ import * as solid_js1 from "solid-js";
2
+
3
+ //#region src/icons/check-line.d.ts
4
+ declare function CheckLine(): solid_js1.JSX.Element;
5
+ //#endregion
6
+ export { CheckLine };
@@ -0,0 +1,13 @@
1
+ import { SvgWrapper } from "./common.js";
2
+ import { createComponent, template } from "solid-js/web";
3
+
4
+ //#region src/icons/check-line.tsx
5
+ var _tmpl$ = /* @__PURE__ */ template(`<svg><path d="m10 15.17l9.192-9.191l1.414 1.414L10 17.999l-6.364-6.364l1.414-1.414z"fill=currentColor></svg>`, false, true, false);
6
+ function CheckLine() {
7
+ return createComponent(SvgWrapper, { get children() {
8
+ return _tmpl$();
9
+ } });
10
+ }
11
+
12
+ //#endregion
13
+ export { CheckLine };
@@ -0,0 +1,11 @@
1
+ import { SvgWrapper } from "./common.jsx";
2
+
3
+ //#region src/icons/check-line.tsx
4
+ function CheckLine() {
5
+ return <SvgWrapper>
6
+ <path d="m10 15.17l9.192-9.191l1.414 1.414L10 17.999l-6.364-6.364l1.414-1.414z" fill="currentColor" />
7
+ </SvgWrapper>;
8
+ }
9
+
10
+ //#endregion
11
+ export { CheckLine };
@@ -1,3 +1,4 @@
1
1
  import { ArrowDownSLine } from "./arrow-down-s-line.js";
2
+ import { CheckLine } from "./check-line.js";
2
3
  import { CloseLine } from "./close-line.js";
3
- export { ArrowDownSLine, CloseLine };
4
+ export { ArrowDownSLine, CheckLine, CloseLine };
@@ -1,4 +1,5 @@
1
1
  import { ArrowDownSLine } from "./arrow-down-s-line.js";
2
+ import { CheckLine } from "./check-line.js";
2
3
  import { CloseLine } from "./close-line.js";
3
4
 
4
- export { ArrowDownSLine, CloseLine };
5
+ export { ArrowDownSLine, CheckLine, CloseLine };
@@ -1,4 +1,5 @@
1
1
  import { ArrowDownSLine } from "./arrow-down-s-line.jsx";
2
+ import { CheckLine } from "./check-line.jsx";
2
3
  import { CloseLine } from "./close-line.jsx";
3
4
 
4
- export { ArrowDownSLine, CloseLine };
5
+ export { ArrowDownSLine, CheckLine, CloseLine };
package/dist/index.d.ts CHANGED
@@ -22,10 +22,11 @@ import "./components/spin/index.js";
22
22
  import { TabItem, Tabs, TabsProps } from "./components/tabs/index.js";
23
23
  import { Textarea } from "./components/textarea/textarea.js";
24
24
  import "./components/textarea/index.js";
25
+ import { TimePicker } from "./components/time-picker/index.js";
25
26
  import { Tooltip, TooltipProps } from "./components/tooltip/tooltip.js";
26
27
  import "./components/tooltip/index.js";
27
28
  import { context } from "./root-provider/context.js";
28
29
  import { RootProvider } from "./root-provider/provider.js";
29
30
  import "./root-provider/index.js";
30
31
  import { getGlobalToken } from "./utils/index.js";
31
- export { Button, ButtonColors, ButtonFields, ButtonProps, ButtonState, ButtonVariants, CircleProgress, type ClassNames, Combobox, ComboboxProps, Flex, type GlobalToken, Input, InputCompact, InputProps, LineProgress, LineProgressState, LoadingBar, Modal, ModalHelper, Popover, Spin, SpinRing, StateButton, StateButtonProps, type Styles, TabItem, Tabs, TabsProps, Textarea, RootProvider as TinyUiProvider, Tooltip, TooltipProps, getGlobalToken, context as tinyUiContext };
32
+ export { Button, ButtonColors, ButtonFields, ButtonProps, ButtonState, ButtonVariants, CircleProgress, type ClassNames, Combobox, ComboboxProps, Flex, type GlobalToken, Input, InputCompact, InputProps, LineProgress, LineProgressState, LoadingBar, Modal, ModalHelper, Popover, Spin, SpinRing, StateButton, StateButtonProps, type Styles, TabItem, Tabs, TabsProps, Textarea, TimePicker, RootProvider as TinyUiProvider, Tooltip, TooltipProps, getGlobalToken, context as tinyUiContext };
package/dist/index.js CHANGED
@@ -24,8 +24,9 @@ import "./components/progress/index.js";
24
24
  import { Tabs } from "./components/tabs/index.js";
25
25
  import { Textarea } from "./components/textarea/textarea.js";
26
26
  import "./components/textarea/index.js";
27
+ import { TimePicker } from "./components/time-picker/index.js";
27
28
  import { context } from "./root-provider/context.js";
28
29
  import { RootProvider } from "./root-provider/provider.js";
29
30
  import "./root-provider/index.js";
30
31
 
31
- export { Button, CircleProgress, Combobox, Flex, Input, InputCompact, LineProgress, LoadingBar, Modal, ModalHelper, Popover, Spin, SpinRing, StateButton, Tabs, Textarea, RootProvider as TinyUiProvider, Tooltip, getGlobalToken, context as tinyUiContext };
32
+ export { Button, CircleProgress, Combobox, Flex, Input, InputCompact, LineProgress, LoadingBar, Modal, ModalHelper, Popover, Spin, SpinRing, StateButton, Tabs, Textarea, TimePicker, RootProvider as TinyUiProvider, Tooltip, getGlobalToken, context as tinyUiContext };
package/dist/index.jsx CHANGED
@@ -24,8 +24,9 @@ import "./components/progress/index.jsx";
24
24
  import { Tabs } from "./components/tabs/index.jsx";
25
25
  import { Textarea } from "./components/textarea/textarea.jsx";
26
26
  import "./components/textarea/index.jsx";
27
+ import { TimePicker } from "./components/time-picker/index.jsx";
27
28
  import { context } from "./root-provider/context.jsx";
28
29
  import { RootProvider } from "./root-provider/provider.jsx";
29
30
  import "./root-provider/index.jsx";
30
31
 
31
- export { Button, CircleProgress, Combobox, Flex, Input, InputCompact, LineProgress, LoadingBar, Modal, ModalHelper, Popover, Spin, SpinRing, StateButton, Tabs, Textarea, RootProvider as TinyUiProvider, Tooltip, getGlobalToken, context as tinyUiContext };
32
+ export { Button, CircleProgress, Combobox, Flex, Input, InputCompact, LineProgress, LoadingBar, Modal, ModalHelper, Popover, Spin, SpinRing, StateButton, Tabs, Textarea, TimePicker, RootProvider as TinyUiProvider, Tooltip, getGlobalToken, context as tinyUiContext };
@@ -1,28 +1,28 @@
1
- import * as solid_js18 from "solid-js";
2
- import * as solid_tiny_context3 from "solid-tiny-context";
3
- import * as solid_js_store7 from "solid-js/store";
1
+ import * as solid_js13 from "solid-js";
2
+ import * as solid_tiny_context1 from "solid-tiny-context";
3
+ import * as solid_js_store5 from "solid-js/store";
4
4
 
5
5
  //#region src/primitives/animated-group/context.d.ts
6
6
  declare const context: {
7
7
  useContext: () => [Readonly<{
8
8
  active: string;
9
9
  } & {}>, Omit<{}, "setState"> & {
10
- setState: solid_js_store7.SetStoreFunction<{
10
+ setState: solid_js_store5.SetStoreFunction<{
11
11
  active: string;
12
12
  }>;
13
13
  }, {}];
14
- initial(initialState?: Partial<solid_tiny_context3.MaybeSignals<{
14
+ initial(initialState?: Partial<solid_tiny_context1.MaybeSignals<{
15
15
  active: string;
16
16
  }>> | undefined): {
17
17
  Provider(props: {
18
- children?: solid_js18.JSX.Element;
19
- }): solid_js18.JSX.Element;
18
+ children?: solid_js13.JSX.Element;
19
+ }): solid_js13.JSX.Element;
20
20
  value: [Readonly<{
21
21
  active: string;
22
- } & {}>, Omit<ThisType<solid_tiny_context3.RealContextThis<{
22
+ } & {}>, Omit<ThisType<solid_tiny_context1.RealContextThis<{
23
23
  active: string;
24
24
  }, {}, {}, {}>>, "setState"> & {
25
- setState: solid_js_store7.SetStoreFunction<{
25
+ setState: solid_js_store5.SetStoreFunction<{
26
26
  active: string;
27
27
  }>;
28
28
  }, {}];
@@ -1,12 +1,12 @@
1
1
  import { MaybeContextChild } from "../../utils/types.js";
2
2
  import { context } from "./context.js";
3
- import * as solid_js6 from "solid-js";
3
+ import * as solid_js8 from "solid-js";
4
4
 
5
5
  //#region src/primitives/animated-group/root.d.ts
6
6
  declare function Root(props: {
7
7
  children: MaybeContextChild<typeof context>;
8
8
  activeKey?: string;
9
9
  onChange?: (key: string) => void;
10
- }): solid_js6.JSX.Element;
10
+ }): solid_js8.JSX.Element;
11
11
  //#endregion
12
12
  export { Root };
@@ -0,0 +1,30 @@
1
+ import { createComponentState } from "solid-tiny-context";
2
+
3
+ //#region src/primitives/fake-scroll-list/context.ts
4
+ /** biome-ignore-all lint/suspicious/noExplicitAny: any */
5
+ const context = createComponentState({
6
+ state: () => ({
7
+ inViewIndex: 0,
8
+ visibleItemsCount: 5,
9
+ itemHeight: 30,
10
+ items: []
11
+ }),
12
+ getters: {
13
+ shouldFake() {
14
+ return this.state.items.length > this.state.visibleItemsCount;
15
+ },
16
+ overScan() {
17
+ if (!this.state.shouldFake) return 0;
18
+ return Math.ceil(this.state.visibleItemsCount / 2) + 3;
19
+ },
20
+ fixedInViewIndex() {
21
+ let index = this.state.inViewIndex;
22
+ if (index < 0) index = this.state.items.length + index % this.state.items.length;
23
+ if (index >= this.state.items.length) index %= this.state.items.length;
24
+ return index;
25
+ }
26
+ }
27
+ });
28
+
29
+ //#endregion
30
+ export { context };
@@ -0,0 +1,30 @@
1
+ import { createComponentState } from "solid-tiny-context";
2
+
3
+ //#region src/primitives/fake-scroll-list/context.ts
4
+ /** biome-ignore-all lint/suspicious/noExplicitAny: any */
5
+ const context = createComponentState({
6
+ state: () => ({
7
+ inViewIndex: 0,
8
+ visibleItemsCount: 5,
9
+ itemHeight: 30,
10
+ items: []
11
+ }),
12
+ getters: {
13
+ shouldFake() {
14
+ return this.state.items.length > this.state.visibleItemsCount;
15
+ },
16
+ overScan() {
17
+ if (!this.state.shouldFake) return 0;
18
+ return Math.ceil(this.state.visibleItemsCount / 2) + 3;
19
+ },
20
+ fixedInViewIndex() {
21
+ let index = this.state.inViewIndex;
22
+ if (index < 0) index = this.state.items.length + index % this.state.items.length;
23
+ if (index >= this.state.items.length) index %= this.state.items.length;
24
+ return index;
25
+ }
26
+ }
27
+ });
28
+
29
+ //#endregion
30
+ export { context };
@@ -0,0 +1,52 @@
1
+ import { Item } from "./item.js";
2
+ import { Listbox } from "./listbox.js";
3
+ import { Root } from "./root.js";
4
+ import * as solid_js_store1 from "solid-js/store";
5
+
6
+ //#region src/primitives/fake-scroll-list/index.d.ts
7
+
8
+ /**
9
+ * create a fake scroll list component
10
+ *
11
+ * @example
12
+ * ```tsx
13
+ * <FakeScrollListCore
14
+ * items={items}
15
+ * visibleItemsCount={5}
16
+ * itemHeight={30}
17
+ * inViewIndex={inViewIndex}
18
+ * onInViewIndexChange={(index) => setInViewIndex(index)}
19
+ * >
20
+ * <FakeScrollListCore.Listbox>
21
+ * {(label, index) => (
22
+ * <FakeScrollListCore.Item index={index()}>
23
+ * {label}
24
+ * </FakeScrollListCore.Item>
25
+ * )}
26
+ * </FakeScrollListCore.Listbox>
27
+ * </FakeScrollListCore>
28
+ * ```
29
+ */
30
+ declare const FakeScrollListCore: typeof Root & {
31
+ Item: typeof Item;
32
+ Listbox: typeof Listbox;
33
+ useContext: () => [Readonly<{
34
+ inViewIndex: number;
35
+ visibleItemsCount: number;
36
+ itemHeight: number;
37
+ items: string[];
38
+ } & {
39
+ shouldFake: boolean;
40
+ overScan: number;
41
+ fixedInViewIndex: number;
42
+ }>, Omit<{}, "setState" | "shouldFake" | "overScan" | "fixedInViewIndex"> & {
43
+ setState: solid_js_store1.SetStoreFunction<{
44
+ inViewIndex: number;
45
+ visibleItemsCount: number;
46
+ itemHeight: number;
47
+ items: string[];
48
+ }>;
49
+ }, {}];
50
+ };
51
+ //#endregion
52
+ export { FakeScrollListCore };
@@ -0,0 +1,36 @@
1
+ import { context } from "./context.js";
2
+ import { Item } from "./item.js";
3
+ import { Listbox } from "./listbox.js";
4
+ import { Root } from "./root.js";
5
+
6
+ //#region src/primitives/fake-scroll-list/index.ts
7
+ /**
8
+ * create a fake scroll list component
9
+ *
10
+ * @example
11
+ * ```tsx
12
+ * <FakeScrollListCore
13
+ * items={items}
14
+ * visibleItemsCount={5}
15
+ * itemHeight={30}
16
+ * inViewIndex={inViewIndex}
17
+ * onInViewIndexChange={(index) => setInViewIndex(index)}
18
+ * >
19
+ * <FakeScrollListCore.Listbox>
20
+ * {(label, index) => (
21
+ * <FakeScrollListCore.Item index={index()}>
22
+ * {label}
23
+ * </FakeScrollListCore.Item>
24
+ * )}
25
+ * </FakeScrollListCore.Listbox>
26
+ * </FakeScrollListCore>
27
+ * ```
28
+ */
29
+ const FakeScrollListCore = Object.assign(Root, {
30
+ Item,
31
+ Listbox,
32
+ useContext: context.useContext
33
+ });
34
+
35
+ //#endregion
36
+ export { FakeScrollListCore };
@@ -0,0 +1,36 @@
1
+ import { context } from "./context.jsx";
2
+ import { Item } from "./item.jsx";
3
+ import { Listbox } from "./listbox.jsx";
4
+ import { Root } from "./root.jsx";
5
+
6
+ //#region src/primitives/fake-scroll-list/index.ts
7
+ /**
8
+ * create a fake scroll list component
9
+ *
10
+ * @example
11
+ * ```tsx
12
+ * <FakeScrollListCore
13
+ * items={items}
14
+ * visibleItemsCount={5}
15
+ * itemHeight={30}
16
+ * inViewIndex={inViewIndex}
17
+ * onInViewIndexChange={(index) => setInViewIndex(index)}
18
+ * >
19
+ * <FakeScrollListCore.Listbox>
20
+ * {(label, index) => (
21
+ * <FakeScrollListCore.Item index={index()}>
22
+ * {label}
23
+ * </FakeScrollListCore.Item>
24
+ * )}
25
+ * </FakeScrollListCore.Listbox>
26
+ * </FakeScrollListCore>
27
+ * ```
28
+ */
29
+ const FakeScrollListCore = Object.assign(Root, {
30
+ Item,
31
+ Listbox,
32
+ useContext: context.useContext
33
+ });
34
+
35
+ //#endregion
36
+ export { FakeScrollListCore };
@@ -0,0 +1,11 @@
1
+ import { JSX } from "solid-js";
2
+
3
+ //#region src/primitives/fake-scroll-list/item.d.ts
4
+ declare function Item(props: {
5
+ class?: string;
6
+ style?: JSX.CSSProperties | string;
7
+ children: JSX.Element;
8
+ key: string;
9
+ }): JSX.Element;
10
+ //#endregion
11
+ export { Item };
@@ -0,0 +1,30 @@
1
+ import { context } from "./context.js";
2
+ import { className, effect, insert, setAttribute, style, template } from "solid-js/web";
3
+ import { combineStyle, dataIf } from "solid-tiny-utils";
4
+
5
+ //#region src/primitives/fake-scroll-list/item.tsx
6
+ var _tmpl$ = /* @__PURE__ */ template(`<div>`);
7
+ function Item(props) {
8
+ const [state] = context.useContext();
9
+ return (() => {
10
+ var _el$ = _tmpl$();
11
+ insert(_el$, () => props.children);
12
+ effect((_p$) => {
13
+ var _v$ = props.class, _v$2 = dataIf(props.key === `${state.fixedInViewIndex}`), _v$3 = props.key, _v$4 = combineStyle({ height: `${state.itemHeight}px` }, props.style);
14
+ _v$ !== _p$.e && className(_el$, _p$.e = _v$);
15
+ _v$2 !== _p$.t && setAttribute(_el$, "data-in-view", _p$.t = _v$2);
16
+ _v$3 !== _p$.a && setAttribute(_el$, "data-key", _p$.a = _v$3);
17
+ _p$.o = style(_el$, _v$4, _p$.o);
18
+ return _p$;
19
+ }, {
20
+ e: void 0,
21
+ t: void 0,
22
+ a: void 0,
23
+ o: void 0
24
+ });
25
+ return _el$;
26
+ })();
27
+ }
28
+
29
+ //#endregion
30
+ export { Item };
@@ -0,0 +1,13 @@
1
+ import { context } from "./context.jsx";
2
+ import { combineStyle, dataIf } from "solid-tiny-utils";
3
+
4
+ //#region src/primitives/fake-scroll-list/item.tsx
5
+ function Item(props) {
6
+ const [state] = context.useContext();
7
+ return <div class={props.class} data-in-view={dataIf(props.key === `${state.fixedInViewIndex}`)} data-key={props.key} style={combineStyle({ height: `${state.itemHeight}px` }, props.style)}>
8
+ {props.children}
9
+ </div>;
10
+ }
11
+
12
+ //#endregion
13
+ export { Item };
@@ -0,0 +1,8 @@
1
+ import { JSX } from "solid-js";
2
+
3
+ //#region src/primitives/fake-scroll-list/listbox.d.ts
4
+ declare function Listbox(props: {
5
+ children: (label: string, key: string) => JSX.Element;
6
+ }): JSX.Element;
7
+ //#endregion
8
+ export { Listbox };