@companix/uikit 0.0.43 → 0.0.45

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,14 +1,19 @@
1
+ @use '../mixins.scss';
2
+
1
3
  @keyframes spinner-border {
2
4
  to {
3
5
  transform: rotate(360deg);
4
6
  }
5
7
  }
6
8
 
7
- .spinner-border {
9
+ .spinner {
8
10
  display: inline-block;
9
11
  border-style: solid;
10
12
  border-color: currentColor;
13
+ border-width: 2px;
11
14
  border-right-color: transparent;
12
15
  border-radius: 50%;
13
16
  animation: 0.75s linear infinite spinner-border;
17
+
18
+ @include mixins.use-styles(spinner);
14
19
  }
@@ -1,7 +1,5 @@
1
1
  export interface SpinnerProps {
2
2
  size?: number;
3
- width?: number;
4
- color?: string;
5
3
  className?: string;
6
4
  }
7
- export declare const Spinner: ({ size, className, width, color }: SpinnerProps) => import("react/jsx-runtime").JSX.Element;
5
+ export declare const Spinner: ({ size, className }: SpinnerProps) => import("react/jsx-runtime").JSX.Element;
@@ -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,43 +1,43 @@
1
- import { jsx as e, jsxs as x, Fragment as h } from "react/jsx-runtime";
2
- import j from "classnames";
3
- import { Spinner as k } from "./bundle.es6.js";
4
- import { forwardRef as w } from "react";
1
+ import { jsx as e, jsxs as x, Fragment as j } from "react/jsx-runtime";
2
+ import k from "classnames";
3
+ import { Spinner as z } from "./bundle.es6.js";
4
+ import { forwardRef as N } from "react";
5
5
  import { attr as r } from "@companix/utils-browser";
6
- const F = w(
6
+ const F = N(
7
7
  ({
8
8
  children: d,
9
9
  fill: l,
10
- text: i,
10
+ text: m,
11
11
  active: c,
12
12
  mode: f = "default",
13
13
  appearance: s = "neutral",
14
14
  size: p = "md",
15
15
  align: u,
16
- icon: m,
16
+ icon: n,
17
17
  loading: t,
18
18
  className: b,
19
- iconRight: n,
20
- Component: o = "button",
19
+ iconRight: o,
20
+ Component: i = "button",
21
21
  ...a
22
22
  }, v) => /* @__PURE__ */ e(
23
- o,
23
+ i,
24
24
  {
25
25
  ref: v,
26
- className: j("button", b),
26
+ className: k("button", b),
27
27
  "data-size": p,
28
28
  "data-loading": r(t),
29
- "data-align": t ? "center" : u ?? (m && n ? "left" : "center"),
29
+ "data-align": t ? "center" : u ?? (n && o ? "left" : "center"),
30
30
  "data-appearance": s,
31
31
  "data-mode": f,
32
32
  "data-fill": r(l),
33
33
  "data-active": r(c),
34
- type: o === "button" ? "button" : void 0,
34
+ type: i === "button" ? "button" : void 0,
35
35
  ...a,
36
36
  onClick: t ?? a.disabled ? void 0 : a.onClick,
37
- children: t ? /* @__PURE__ */ e(k, { size: 14, width: 2 }) : /* @__PURE__ */ x(h, { children: [
38
- m,
39
- (d ?? i) && /* @__PURE__ */ e("span", { className: "button-text", children: i ?? d }),
40
- n
37
+ children: t ? /* @__PURE__ */ e(z, { size: 14 }) : /* @__PURE__ */ x(j, { children: [
38
+ n,
39
+ (d ?? m) && /* @__PURE__ */ e("span", { className: "button-text", children: m ?? d }),
40
+ o
41
41
  ] })
42
42
  }
43
43
  )
@@ -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
  };
@@ -1,13 +1,13 @@
1
- import { jsx as o } from "react/jsx-runtime";
1
+ import { jsx as e } from "react/jsx-runtime";
2
2
  import n from "classnames";
3
- const d = ({ size: r = 40, className: t, width: e = 2, color: i = "inherit" }) => /* @__PURE__ */ o(
3
+ const s = ({ size: r = 40, className: t }) => /* @__PURE__ */ e(
4
4
  "div",
5
5
  {
6
- style: { width: `${r}px`, height: `${r}px`, color: i, borderWidth: `${e}px` },
7
- className: n("spinner-border", t),
6
+ style: { width: `${r}px`, height: `${r}px` },
7
+ className: n("spinner", t),
8
8
  role: "status"
9
9
  }
10
10
  );
11
11
  export {
12
- d as Spinner
12
+ s as Spinner
13
13
  };
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.45",
4
4
  "main": "./dist/bundle.es.js",
5
5
  "module": "./dist/bundle.es.js",
6
6
  "types": "./dist/index.d.ts",