@konstructio/ui 0.1.2-alpha.66 → 0.1.2-alpha.68

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 (50) hide show
  1. package/dist/AdditionalOptions-C2FDVZhu.js +45 -0
  2. package/dist/{DayPicker-PUEUVAST.js → DayPicker-CaeUXRCF.js} +475 -470
  3. package/dist/{Modal--z642-Wv.js → Modal-mwLmWbnA.js} +23 -20
  4. package/dist/assets/icons/components/CloudLockOutline.d.ts +3 -0
  5. package/dist/assets/icons/components/CloudLockOutline.js +28 -0
  6. package/dist/assets/icons/components/index.d.ts +1 -0
  7. package/dist/assets/icons/components/index.js +106 -104
  8. package/dist/assets/icons/index.js +106 -104
  9. package/dist/components/ButtonGroup/ButtonGroup.js +65 -61
  10. package/dist/components/ButtonGroup/ButtonGroup.types.d.ts +6 -0
  11. package/dist/components/ButtonGroup/components/ButtonGroupItem/ButtonGroupItem.js +32 -30
  12. package/dist/components/ButtonGroup/components/ButtonGroupItem/ButtonGroupItem.types.d.ts +3 -1
  13. package/dist/components/ButtonGroup/components/ButtonGroupItem/ButtonGroupItem.variants.d.ts +4 -1
  14. package/dist/components/ButtonGroup/components/ButtonGroupItem/ButtonGroupItem.variants.js +37 -17
  15. package/dist/components/DateRangePicker/components/CalendarPanel/components/CalendarMonth/CalendarMonth.js +1 -1
  16. package/dist/components/Datepicker/DatePicker.js +1 -1
  17. package/dist/components/Modal/Modal.js +1 -1
  18. package/dist/components/Modal/components/Wrapper/Wrapper.js +3 -2
  19. package/dist/components/Modal/components/Wrapper/Wrapper.variants.js +2 -2
  20. package/dist/components/Modal/components/index.js +1 -1
  21. package/dist/components/Select/Select.d.ts +1 -0
  22. package/dist/components/Select/Select.js +54 -40
  23. package/dist/components/Select/Select.types.d.ts +18 -2
  24. package/dist/components/Select/components/AdditionalOptions/AdditionalOptions.d.ts +3 -0
  25. package/dist/components/Select/components/AdditionalOptions/AdditionalOptions.js +11 -0
  26. package/dist/components/Select/components/AdditionalOptions/AdditionalOptions.types.d.ts +4 -0
  27. package/dist/components/Select/components/AdditionalOptions/AdditionalOptions.variants.d.ts +1 -0
  28. package/dist/components/Select/components/AdditionalOptions/AdditionalOptions.variants.js +26 -0
  29. package/dist/components/Select/components/List/List.js +131 -132
  30. package/dist/components/Select/components/List/List.types.d.ts +1 -0
  31. package/dist/components/Select/components/List/List.variants.d.ts +1 -0
  32. package/dist/components/Select/components/List/List.variants.js +17 -2
  33. package/dist/components/Select/components/Wrapper.d.ts +3 -1
  34. package/dist/components/Select/components/Wrapper.js +65 -63
  35. package/dist/components/Select/components/index.d.ts +1 -0
  36. package/dist/components/Select/components/index.js +8 -6
  37. package/dist/components/VirtualizedTable/VirtualizedTable.d.ts +5 -0
  38. package/dist/components/VirtualizedTable/VirtualizedTable.js +86 -80
  39. package/dist/components/VirtualizedTable/components/Body/Body.js +51 -49
  40. package/dist/components/VirtualizedTable/contexts/table.context.d.ts +2 -0
  41. package/dist/components/VirtualizedTable/contexts/table.provider.js +69 -67
  42. package/dist/components/VirtualizedTable/events/index.d.ts +3 -3
  43. package/dist/components/VirtualizedTable/events/index.js +22 -16
  44. package/dist/components/index.js +1 -1
  45. package/dist/icons.d.ts +1 -1
  46. package/dist/icons.js +106 -104
  47. package/dist/index.js +1 -1
  48. package/dist/package.json +21 -21
  49. package/dist/styles.css +1 -1
  50. package/package.json +21 -21
@@ -33,6 +33,22 @@ export type Option = {
33
33
  /** Unique value for the option */
34
34
  value: string;
35
35
  };
36
+ /**
37
+ * A group of options with a non-interactive header label.
38
+ */
39
+ export type OptionGroup = {
40
+ groupLabel: string;
41
+ options: Option[];
42
+ };
43
+ /**
44
+ * A group of additional options with a non-interactive header label.
45
+ */
46
+ export type AdditionalOptionGroup = {
47
+ groupLabel: string;
48
+ options: ReactNode[];
49
+ };
50
+ export declare const isOptionGroup: (item: Option | OptionGroup) => item is OptionGroup;
51
+ export declare const isAdditionalOptionGroup: (item: unknown) => item is AdditionalOptionGroup;
36
52
  type OnChangeFn = (params: {
37
53
  target: {
38
54
  value: string;
@@ -74,7 +90,7 @@ type OnChangeFn = (params: {
74
90
  * @see {@link https://konstructio.github.io/konstruct-ui/?path=/docs/components-select--docs Storybook}
75
91
  */
76
92
  export type SelectProps = VariantProps<typeof selectVariants> & Omit<InputHTMLAttributes<HTMLInputElement>, 'value' | 'onChange'> & {
77
- additionalOptions?: ReactNode[] | string[];
93
+ additionalOptions?: ReactNode[] | string[] | AdditionalOptionGroup[];
78
94
  className?: string;
79
95
  disabled?: boolean;
80
96
  error?: string;
@@ -95,7 +111,7 @@ export type SelectProps = VariantProps<typeof selectVariants> & Omit<InputHTMLAt
95
111
  listItemSecondRowClassName?: string;
96
112
  mainWrapperClassName?: string;
97
113
  noOptionsText?: string;
98
- options: Option[];
114
+ options: Option[] | OptionGroup[];
99
115
  searchable?: boolean;
100
116
  showSearchIcon?: boolean;
101
117
  theme?: Theme;
@@ -0,0 +1,3 @@
1
+ import { FC } from 'react';
2
+ import { Props } from './AdditionalOptions.types';
3
+ export declare const AdditionalOptions: FC<Props>;
@@ -0,0 +1,11 @@
1
+ import "react/jsx-runtime";
2
+ import "../../../../index-BvoZGpli.js";
3
+ import "react";
4
+ import "../../../../utils/index.js";
5
+ import { A as s } from "../../../../AdditionalOptions-C2FDVZhu.js";
6
+ import "../List/List.variants.js";
7
+ import "./AdditionalOptions.variants.js";
8
+ import "../../contexts/select.hook.js";
9
+ export {
10
+ s as AdditionalOptions
11
+ };
@@ -0,0 +1,4 @@
1
+ import { SelectProps } from '../../Select.types';
2
+ export type Props = {
3
+ additionalOptions?: SelectProps['additionalOptions'];
4
+ };
@@ -0,0 +1 @@
1
+ export declare const additionalOptionSlotClassName: string;
@@ -0,0 +1,26 @@
1
+ import { cn as e } from "../../../../utils/index.js";
2
+ const o = e(
3
+ "flex",
4
+ "min-h-10",
5
+ "py-2",
6
+ "px-6",
7
+ "w-full",
8
+ "h-full",
9
+ "gap-1",
10
+ "items-center",
11
+ "text-sm",
12
+ "[&>svg]:-ml-1",
13
+ "[&>svg]:w-3.5",
14
+ "[&>svg]:h-3.5",
15
+ "[&>svg]:shrink-0",
16
+ "cursor-pointer",
17
+ "select-none",
18
+ "hover:bg-gray-50",
19
+ "hover:dark:bg-metal-700",
20
+ "focus:outline-0",
21
+ "text-blue-600",
22
+ "dark:text-aurora-500"
23
+ );
24
+ export {
25
+ o as additionalOptionSlotClassName
26
+ };
@@ -1,182 +1,181 @@
1
- import { jsxs as Z, jsx as r } from "react/jsx-runtime";
2
- import { S as B } from "../../../../index-BvoZGpli.js";
3
- import { d as G } from "../../../../debounce-DJveWHr_.js";
4
- import { forwardRef as J, useRef as C, useState as K, useImperativeHandle as M, useMemo as Q, useEffect as R } from "react";
5
- import { Loading as W } from "../../../Loading/Loading.js";
6
- import { cn as o } from "../../../../utils/index.js";
7
- import { useNavigationUlList as X } from "../../hooks/useNavigationList.js";
8
- import { ListItem as b } from "../ListItem/ListItem.js";
9
- import { listVariants as Y } from "./List.variants.js";
10
- import { DEFAULT_LIST_SIZE as $ } from "../../constants/pagination.js";
11
- import { useSelectContext as ee } from "../../contexts/select.hook.js";
12
- const me = J(
1
+ import { jsxs as N, jsx as o } from "react/jsx-runtime";
2
+ import { d as K } from "../../../../debounce-DJveWHr_.js";
3
+ import { forwardRef as Q, useRef as O, useState as W, useImperativeHandle as X, useMemo as j, useEffect as Y, Fragment as $ } from "react";
4
+ import { Loading as R } from "../../../Loading/Loading.js";
5
+ import { cn as s } from "../../../../utils/index.js";
6
+ import { useNavigationUlList as ee } from "../../hooks/useNavigationList.js";
7
+ import { A as te, i as re } from "../../../../AdditionalOptions-C2FDVZhu.js";
8
+ import { ListItem as g } from "../ListItem/ListItem.js";
9
+ import { listGroupLabelVariants as oe, listVariants as ne } from "./List.variants.js";
10
+ import { DEFAULT_LIST_SIZE as se } from "../../constants/pagination.js";
11
+ import { useSelectContext as ae } from "../../contexts/select.hook.js";
12
+ const Le = Q(
13
13
  ({
14
- additionalOptions: F,
15
- className: N,
16
- inputRef: l,
17
- isLoading: E,
18
- itemClassName: i,
19
- name: I,
20
- searchable: x = !1,
21
- listItemSecondRowClassName: c,
22
- wrapperInputRef: O,
23
- isInfiniteScrollEnabled: u,
24
- onFetchMoreOptions: f,
25
- noOptionsText: y
26
- }, S) => {
27
- const n = C(null), m = C(null), [p, L] = K(!1), {
28
- canContinueFetching: a,
29
- canFilter: j,
30
- isOpen: P,
31
- isTyping: k,
32
- options: w,
33
- page: g,
34
- searchTerm: d,
35
- setCanContinueFetching: T,
36
- setOptions: U,
37
- setPage: _,
38
- toggleOpen: q
39
- } = ee();
40
- M(S, () => n.current, [n]);
41
- const h = x && j ? w.filter((e) => {
42
- const t = d.toLowerCase();
14
+ additionalOptions: A,
15
+ className: I,
16
+ groupedOptions: l,
17
+ inputRef: c,
18
+ isLoading: P,
19
+ itemClassName: u,
20
+ name: T,
21
+ searchable: f = !1,
22
+ listItemSecondRowClassName: p,
23
+ wrapperInputRef: U,
24
+ isInfiniteScrollEnabled: h,
25
+ noOptionsText: F,
26
+ onFetchMoreOptions: b
27
+ }, V) => {
28
+ const m = O(null), L = O(null), [v, k] = W(!1), {
29
+ canContinueFetching: d,
30
+ canFilter: y,
31
+ isOpen: _,
32
+ isTyping: E,
33
+ options: G,
34
+ page: w,
35
+ searchTerm: n,
36
+ setCanContinueFetching: q,
37
+ setOptions: z,
38
+ setPage: D
39
+ } = ae();
40
+ X(V, () => m.current, [m]);
41
+ const a = l.length > 0 && re(l[0]), x = f && y ? G.filter((e) => {
42
+ const t = n.toLowerCase();
43
43
  return (typeof e.label == "string" ? e.label.toLowerCase() : "").includes(t);
44
- }) : w;
45
- X({
46
- ulRef: n,
47
- wrapperInputRef: O,
48
- searchable: x,
49
- filteredOptions: h
44
+ }) : G, C = j(() => {
45
+ if (!a)
46
+ return [];
47
+ const e = l;
48
+ if (!f || !y || !n)
49
+ return e;
50
+ const t = n.toLowerCase();
51
+ return e.map((r) => ({
52
+ ...r,
53
+ options: r.options.filter(
54
+ (i) => i.label.toLowerCase().includes(t)
55
+ )
56
+ })).filter((r) => r.options.length > 0);
57
+ }, [a, l, f, y, n]), H = a ? C.flatMap((e) => e.options) : x;
58
+ ee({
59
+ ulRef: m,
60
+ wrapperInputRef: U,
61
+ searchable: f,
62
+ filteredOptions: H
50
63
  });
51
- const z = h.filter(
52
- (e, t, s) => t === s.findIndex((v) => v.value === e.value)
53
- ), A = h.length === 0, D = Q(
54
- () => G(async (e) => {
64
+ const M = x.filter(
65
+ (e, t, r) => t === r.findIndex((i) => i.value === e.value)
66
+ ), S = a ? C.length === 0 : x.length === 0, Z = j(
67
+ () => K(async (e) => {
55
68
  const [t] = e;
56
- if (t.isIntersecting && !p && f && a)
69
+ if (t.isIntersecting && !v && b && d)
57
70
  try {
58
- L(!0);
59
- const s = g + 1, { data: v, hasMore: H } = await f({
60
- page: s,
61
- pageSize: $,
62
- termOfSearch: d
71
+ k(!0);
72
+ const r = w + 1, { data: i, hasMore: B } = await b({
73
+ page: r,
74
+ pageSize: se,
75
+ termOfSearch: n
63
76
  });
64
- _(s), T(H), U((V) => [...V, ...v]);
77
+ D(r), q(B), z((J) => [...J, ...i]);
65
78
  } catch {
66
79
  console.error("Error fetching more options");
67
80
  } finally {
68
- L(!1);
81
+ k(!1);
69
82
  }
70
83
  }, 100),
71
- [p, f, d, g]
84
+ [v, b, n, w]
72
85
  );
73
- return R(() => {
74
- if (u && a && m.current && !k) {
75
- const e = new IntersectionObserver(D, {
86
+ return Y(() => {
87
+ if (h && d && L.current && !E) {
88
+ const e = new IntersectionObserver(Z, {
76
89
  threshold: 0.1
77
90
  });
78
- return e.observe(m.current), () => e.disconnect();
91
+ return e.observe(L.current), () => e.disconnect();
79
92
  }
80
93
  }, [
81
- u,
82
- a,
83
- p,
84
- k,
85
- g
86
- ]), /* @__PURE__ */ Z(
94
+ h,
95
+ d,
96
+ v,
97
+ E,
98
+ w
99
+ ]), /* @__PURE__ */ N(
87
100
  "ul",
88
101
  {
89
- ref: n,
90
- title: I,
102
+ ref: m,
103
+ title: T,
91
104
  role: "listbox",
92
- className: o(Y({ className: N })),
93
- "data-state": P ? "open" : "closed",
105
+ className: s(ne({ className: I })),
106
+ "data-state": _ ? "open" : "closed",
94
107
  children: [
95
- E ? /* @__PURE__ */ r(
96
- b,
108
+ P ? /* @__PURE__ */ o(
109
+ g,
97
110
  {
98
- className: o("select-none", i),
111
+ className: s("select-none", u),
99
112
  isClickable: !1,
100
- inputRef: l,
113
+ inputRef: c,
101
114
  value: "Loading...",
102
115
  label: "Loading...",
103
- listItemSecondRowClassName: c
116
+ listItemSecondRowClassName: p
104
117
  }
105
- ) : A ? /* @__PURE__ */ r(
106
- b,
118
+ ) : S ? /* @__PURE__ */ o(
119
+ g,
107
120
  {
108
121
  isEmpty: !0,
109
- className: o("select-none", i),
122
+ className: s("select-none", u),
110
123
  isClickable: !1,
111
- inputRef: l,
112
- value: y ?? "",
113
- label: y ?? "No options",
114
- listItemSecondRowClassName: c
124
+ inputRef: c,
125
+ value: F ?? "",
126
+ label: F ?? "No options",
127
+ listItemSecondRowClassName: p
115
128
  }
116
- ) : z.map((e) => /* @__PURE__ */ r(
117
- b,
129
+ ) : a ? C.map((e) => /* @__PURE__ */ N($, { children: [
130
+ /* @__PURE__ */ o(
131
+ "li",
132
+ {
133
+ role: "presentation",
134
+ "aria-hidden": "true",
135
+ "data-action": "true",
136
+ className: s(oe()),
137
+ children: e.groupLabel
138
+ }
139
+ ),
140
+ e.options.map((t) => /* @__PURE__ */ o(
141
+ g,
142
+ {
143
+ className: s("select-none", u),
144
+ isClickable: !0,
145
+ inputRef: c,
146
+ listItemSecondRowClassName: p,
147
+ ...t
148
+ },
149
+ t.value
150
+ ))
151
+ ] }, e.groupLabel)) : M.map((e) => /* @__PURE__ */ o(
152
+ g,
118
153
  {
119
- className: o("select-none", i),
154
+ className: s("select-none", u),
120
155
  isClickable: !0,
121
- inputRef: l,
122
- listItemSecondRowClassName: c,
156
+ inputRef: c,
157
+ listItemSecondRowClassName: p,
123
158
  ...e
124
159
  },
125
160
  e.value
126
161
  )),
127
- u && a && /* @__PURE__ */ r(
162
+ h && d && /* @__PURE__ */ o(
128
163
  "li",
129
164
  {
130
- ref: m,
165
+ ref: L,
131
166
  role: "option",
132
167
  "data-action": "true",
133
168
  className: "flex items-center justify-center py-3",
134
169
  onClick: (e) => e.stopPropagation(),
135
- children: /* @__PURE__ */ r(W, { className: "w-4 h-4 text-aurora-500 select-none" })
170
+ children: /* @__PURE__ */ o(R, { className: "w-4 h-4 text-aurora-500 select-none" })
136
171
  }
137
172
  ),
138
- F?.map((e, t) => /* @__PURE__ */ r(
139
- "li",
140
- {
141
- role: "option",
142
- "data-action": "true",
143
- onClick: () => q(!1),
144
- children: /* @__PURE__ */ r(
145
- B,
146
- {
147
- className: o(
148
- "flex",
149
- "min-h-10",
150
- "py-2",
151
- "px-6",
152
- "w-full",
153
- "h-full",
154
- "gap-1",
155
- "items-center",
156
- "text-sm",
157
- "[&>svg]:-ml-1",
158
- "[&>svg]:w-3.5",
159
- "[&>svg]:h-3.5",
160
- "[&>svg]:shrink-0",
161
- "cursor-pointer",
162
- "select-none",
163
- "hover:bg-gray-50",
164
- "hover:dark:bg-metal-700",
165
- "focus:outline-0",
166
- "text-blue-600",
167
- "dark:text-aurora-500"
168
- ),
169
- children: e
170
- }
171
- )
172
- },
173
- t
174
- ))
173
+ /* @__PURE__ */ o(te, { additionalOptions: A })
175
174
  ]
176
175
  }
177
176
  );
178
177
  }
179
178
  );
180
179
  export {
181
- me as List
180
+ Le as List
182
181
  };
@@ -2,6 +2,7 @@ import { ComponentRef, RefObject } from 'react';
2
2
  import { SelectProps } from '../../Select.types';
3
3
  export type ListProps = Pick<SelectProps, 'name' | 'options' | 'theme' | 'additionalOptions'> & {
4
4
  className?: string;
5
+ groupedOptions: SelectProps['options'];
5
6
  inputRef?: RefObject<ComponentRef<'input'> | null>;
6
7
  isLoading: boolean;
7
8
  itemClassName?: string;
@@ -1 +1,2 @@
1
+ export declare const listGroupLabelVariants: (props?: import('class-variance-authority/types').ClassProp | undefined) => string;
1
2
  export declare const listVariants: (props?: import('class-variance-authority/types').ClassProp | undefined) => string;
@@ -1,5 +1,19 @@
1
1
  import { c as t } from "../../../../index-D29mdTf5.js";
2
- const o = t([
2
+ const r = t([
3
+ "flex",
4
+ "items-center",
5
+ "h-8",
6
+ "px-6",
7
+ "py-1.5",
8
+ "text-[11px]",
9
+ "font-medium",
10
+ "uppercase",
11
+ "tracking-[0.25px]",
12
+ "text-metal-50",
13
+ "pointer-events-none",
14
+ "select-none",
15
+ "cursor-default"
16
+ ]), a = t([
3
17
  "scrollbar",
4
18
  "absolute",
5
19
  "bg-white",
@@ -27,5 +41,6 @@ const o = t([
27
41
  "[&>li:last-child]:mb-2"
28
42
  ]);
29
43
  export {
30
- o as listVariants
44
+ r as listGroupLabelVariants,
45
+ a as listVariants
31
46
  };
@@ -1,3 +1,5 @@
1
1
  import { ComponentRef, ForwardRefExoticComponent, RefAttributes } from 'react';
2
2
  import { SelectProps } from '../Select.types';
3
- export declare const Wrapper: ForwardRefExoticComponent<Omit<SelectProps, 'options'> & RefAttributes<ComponentRef<'input'>>>;
3
+ export declare const Wrapper: ForwardRefExoticComponent<Omit<SelectProps, 'options'> & {
4
+ groupedOptions: SelectProps['options'];
5
+ } & RefAttributes<ComponentRef<'input'>>>;