@companix/uikit 0.0.43 → 0.0.44

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.
@@ -1,4 +1,9 @@
1
1
  import { Option } from '..';
2
+ export interface SelectAddOption {
3
+ text: string;
4
+ closeOnClick?: boolean;
5
+ onClick: () => void;
6
+ }
2
7
  interface SelectPopoverProps<T> {
3
8
  scrollboxRef?: React.RefObject<HTMLDivElement>;
4
9
  optionsWrapperRef?: React.RefObject<HTMLDivElement>;
@@ -7,12 +12,7 @@ interface SelectPopoverProps<T> {
7
12
  active?: T | null;
8
13
  onSelect?: (value: T) => void;
9
14
  onOpened?: () => void;
10
- close: () => void;
11
- addOption?: {
12
- text: string;
13
- closeOnClick?: boolean;
14
- onClick: () => void;
15
- };
15
+ addOption?: SelectAddOption;
16
16
  }
17
17
  export declare const SelectOptions: <T>(props: SelectPopoverProps<T>) => import("react/jsx-runtime").JSX.Element;
18
18
  export {};
@@ -1,5 +1,6 @@
1
1
  import { Option } from '../types';
2
2
  import { SelectFormProps } from './SelectInput';
3
+ import { SelectAddOption } from './SelectOptions';
3
4
  interface Cleanable<T> {
4
5
  clearButton: true;
5
6
  onChange: (event: T | null) => void;
@@ -9,20 +10,19 @@ interface UnCleanable<T> {
9
10
  onChange: (event: T) => void;
10
11
  }
11
12
  type DependedValueType<T> = Cleanable<T> | UnCleanable<T>;
12
- export type SelectProps<T> = Omit<SelectFormProps, 'value' | 'onChange' | 'closeButton'> & DependedValueType<T> & {
13
- value: T | null;
14
- options: Option<T>[];
15
- children?: React.ReactNode;
13
+ export interface SelectParams {
16
14
  minimalOptions?: boolean;
17
15
  matchTarget?: 'width' | 'min-width';
18
16
  popoverRef?: React.Ref<HTMLDivElement>;
19
17
  scrollRef?: React.Ref<{
20
18
  scrollTo: (index: number) => void;
21
19
  }>;
22
- addOption?: {
23
- text: string;
24
- onClick: () => void;
25
- };
20
+ addOption?: SelectAddOption;
21
+ }
22
+ export type SelectProps<T> = Omit<SelectFormProps, 'value' | 'onChange' | 'closeButton'> & DependedValueType<T> & SelectParams & {
23
+ value: T | null;
24
+ options: Option<T>[];
25
+ children?: React.ReactNode;
26
26
  };
27
27
  export declare const Select: <T>(props: SelectProps<T>) => import("react/jsx-runtime").JSX.Element;
28
28
  export {};
@@ -1,82 +1,79 @@
1
1
  import { jsx as l } from "react/jsx-runtime";
2
- import { useMemo as T, useImperativeHandle as b } from "react";
3
- import { Popover as z } from "./bundle.es10.js";
4
- import { useFroozeClosing as B } from "./bundle.es45.js";
5
- import { SelectInput as D } from "./bundle.es46.js";
6
- import { useScrollListController as j } from "./bundle.es47.js";
7
- import { SelectOptions as w } from "./bundle.es48.js";
8
- import { mergeRefs as H } from "react-merge-refs";
9
- const K = (m) => {
2
+ import { useMemo as I, useImperativeHandle as T } from "react";
3
+ import { Popover as b } from "./bundle.es10.js";
4
+ import { useFroozeClosing as z } from "./bundle.es45.js";
5
+ import { SelectInput as B } from "./bundle.es46.js";
6
+ import { useScrollListController as D } from "./bundle.es47.js";
7
+ import { SelectOptions as j } from "./bundle.es48.js";
8
+ import { mergeRefs as w } from "react-merge-refs";
9
+ const J = (a) => {
10
10
  const {
11
11
  options: n,
12
12
  onChange: i,
13
13
  value: r,
14
- minimalOptions: f,
15
- matchTarget: u = "width",
16
- children: d,
14
+ minimalOptions: m,
15
+ matchTarget: f = "width",
16
+ children: u,
17
17
  disabled: p,
18
- scrollRef: v,
19
- popoverRef: h,
18
+ scrollRef: d,
19
+ popoverRef: v,
20
20
  clearButton: s,
21
- addOption: x,
22
- ...C
23
- } = m, t = T(() => {
21
+ addOption: h,
22
+ ...x
23
+ } = a, t = I(() => {
24
24
  const o = r === null ? -1 : n.findIndex((e) => e.value === r);
25
25
  return {
26
26
  index: o,
27
27
  option: n[o]
28
28
  };
29
- }, [n, r]), R = t.option?.value ?? null, { popoverRef: O, froozePopoverPosition: c, handleAnimationEnd: g } = B(), { scrollToElement: a, optionsWrapperRef: P, scrollBoxRef: S } = j();
30
- b(v, () => ({
31
- scrollTo: (o) => a(o, "top")
29
+ }, [n, r]), R = t.option?.value ?? null, { popoverRef: C, froozePopoverPosition: O, handleAnimationEnd: g } = z(), { scrollToElement: c, optionsWrapperRef: P, scrollBoxRef: S } = D();
30
+ T(d, () => ({
31
+ scrollTo: (o) => c(o, "top")
32
32
  }));
33
33
  const A = (o, e) => {
34
- c(), i(o), e();
34
+ O(), i(o), e();
35
35
  }, E = (o) => {
36
- c(), o();
37
- }, F = (o) => {
38
36
  o.stopPropagation(), s && i(null);
39
- }, I = () => {
40
- t.index !== -1 && a(t.index, "center");
37
+ }, F = () => {
38
+ t.index !== -1 && c(t.index, "center");
41
39
  };
42
40
  return /* @__PURE__ */ l(
43
- z,
41
+ b,
44
42
  {
45
43
  minimal: !0,
46
- ref: H([O, h]),
44
+ ref: w([C, v]),
47
45
  sideOffset: 0,
48
- matchTarget: u,
46
+ matchTarget: f,
49
47
  onAnimationEnd: g,
50
48
  onOpenAutoFocus: (o) => o.preventDefault(),
51
49
  onCloseAutoFocus: (o) => o.preventDefault(),
52
50
  disabled: p,
53
51
  content: ({ close: o }) => /* @__PURE__ */ l(
54
- w,
52
+ j,
55
53
  {
56
54
  options: n,
57
55
  active: R,
58
56
  scrollboxRef: S,
59
57
  optionsWrapperRef: P,
60
- minimalOptions: f,
61
- close: () => E(o),
62
- addOption: x,
63
- onOpened: I,
58
+ minimalOptions: m,
59
+ addOption: h,
60
+ onOpened: F,
64
61
  onSelect: (e) => A(e, o)
65
62
  }
66
63
  ),
67
- children: d ?? /* @__PURE__ */ l(
68
- D,
64
+ children: u ?? /* @__PURE__ */ l(
65
+ B,
69
66
  {
70
- ...C,
67
+ ...x,
71
68
  disabled: p,
72
69
  clearButton: s,
73
70
  value: t.option?.title ?? "",
74
- onClear: F
71
+ onClear: E
75
72
  }
76
73
  )
77
74
  }
78
75
  );
79
76
  };
80
77
  export {
81
- K as Select
78
+ J as Select
82
79
  };
@@ -1,47 +1,44 @@
1
- import { jsxs as d, jsx as e } from "react/jsx-runtime";
2
- import { useEffect as u } from "react";
3
- import { OptionItem as i } from "./bundle.es14.js";
4
- import { OptionsList as x } from "./bundle.es16.js";
5
- import { Icon as k } from "./bundle.es33.js";
1
+ import { jsxs as d, jsx as i } from "react/jsx-runtime";
2
+ import { useEffect as x } from "react";
3
+ import { OptionItem as e } from "./bundle.es14.js";
4
+ import { OptionsList as O } from "./bundle.es16.js";
5
+ import { Icon as u } from "./bundle.es33.js";
6
6
  import { faPlus as v } from "@companix/icons-solid";
7
- const b = (n) => {
7
+ const S = (n) => {
8
8
  const {
9
- active: c,
10
- onOpened: l,
9
+ active: m,
10
+ onOpened: r,
11
11
  addOption: o,
12
- scrollboxRef: m,
13
- optionsWrapperRef: r,
12
+ scrollboxRef: c,
13
+ optionsWrapperRef: p,
14
14
  options: s,
15
- onSelect: p,
16
- close: a,
17
- minimalOptions: f
15
+ onSelect: l,
16
+ minimalOptions: a
18
17
  } = n;
19
- return u(() => {
20
- l?.();
21
- }, []), /* @__PURE__ */ d(x, { scrollboxRef: m, optionsWrapperRef: r, maxHeight: 300, children: [
22
- o && /* @__PURE__ */ e(
23
- i,
18
+ return x(() => {
19
+ r?.();
20
+ }, []), /* @__PURE__ */ d(O, { scrollboxRef: c, optionsWrapperRef: p, maxHeight: 300, children: [
21
+ o && /* @__PURE__ */ i(
22
+ e,
24
23
  {
25
24
  className: "select-add-option",
26
- icon: /* @__PURE__ */ e(k, { icon: v }),
25
+ icon: /* @__PURE__ */ i(u, { icon: v }),
27
26
  title: o.text,
28
- onClick: () => {
29
- (o.closeOnClick ?? !0) && a(), o.onClick();
30
- }
27
+ onClick: o.onClick
31
28
  }
32
29
  ),
33
- s.map((t, O) => /* @__PURE__ */ e(
34
- i,
30
+ s.map((t, f) => /* @__PURE__ */ i(
31
+ e,
35
32
  {
36
- active: c === t.value,
37
- onClick: () => p?.(t.value),
38
- minimal: f,
33
+ active: m === t.value,
34
+ onClick: () => l?.(t.value),
35
+ minimal: a,
39
36
  ...t
40
37
  },
41
- `select-option-${O}`
38
+ `select-option-${f}`
42
39
  ))
43
40
  ] });
44
41
  };
45
42
  export {
46
- b as SelectOptions
43
+ S as SelectOptions
47
44
  };
package/dist/index.d.ts CHANGED
@@ -18,7 +18,7 @@ export type { PopoverProps } from './Popover';
18
18
  export { Tooltip } from './Tooltip';
19
19
  export type { TooltipProps } from './Tooltip';
20
20
  export { Select } from './Select';
21
- export type { SelectProps } from './Select';
21
+ export type { SelectProps, SelectParams } from './Select';
22
22
  export { Input } from './Input/Input';
23
23
  export type { InputProps } from './Input/Input';
24
24
  export { OptionItem } from './OptionItem/OptionItem';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@companix/uikit",
3
- "version": "0.0.43",
3
+ "version": "0.0.44",
4
4
  "main": "./dist/bundle.es.js",
5
5
  "module": "./dist/bundle.es.js",
6
6
  "types": "./dist/index.d.ts",