@nice2dev/ui 1.4.24 → 1.4.26

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,76 +1,83 @@
1
- import { jsx as c, jsxs as x } from "react/jsx-runtime";
2
- import { useControlId as D, useNiceTranslation as R, useRovingFocus as j } from "@nice2dev/ui-core";
3
- import { forwardRef as y, useState as C, useCallback as E, useRef as T } from "react";
4
- const w = [], B = /* @__PURE__ */ Object.assign(
5
- /* @__PURE__ */ y(
1
+ import { jsx as s, jsxs as y } from "react/jsx-runtime";
2
+ import { useControlId as C, useNiceTranslation as w, useRovingFocus as z } from "@nice2dev/ui-core";
3
+ import { forwardRef as B, useState as i, useCallback as L, useRef as O } from "react";
4
+ const W = [], Y = /* @__PURE__ */ Object.assign(
5
+ /* @__PURE__ */ B(
6
6
  ({
7
- items: d = w,
8
- position: t = "bottom",
9
- size: u = "md",
10
- magnify: s = !0,
11
- magnifyScale: n = 1.5,
12
- activeKey: b,
13
- onItemClick: k,
14
- contained: f = !1,
15
- className: _,
16
- style: h,
17
- id: m,
18
- ...v
19
- }, N) => {
20
- const $ = D(m), { t: g } = R(), [l, r] = C(null), p = E(
7
+ items: k = W,
8
+ position: n = "bottom",
9
+ size: h = "md",
10
+ magnify: d = !0,
11
+ magnifyScale: r = 1.5,
12
+ activeKey: v,
13
+ onItemClick: _,
14
+ contained: m = !1,
15
+ autoHide: t = !1,
16
+ className: N,
17
+ style: g,
18
+ id: $,
19
+ ...M
20
+ }, p) => {
21
+ const I = C($), { t: T } = w(), [l, c] = i(null), [x, u] = i(!1), [D, b] = i(!1), E = t && !x && !D, F = L(
21
22
  (e) => {
22
- if (!s || l === null)
23
+ if (!d || l === null)
23
24
  return 1;
24
25
  const o = Math.abs(e - l);
25
- return o === 0 ? n : o === 1 ? 1 + (n - 1) * 0.5 : o === 2 ? 1 + (n - 1) * 0.2 : 1;
26
+ return o === 0 ? r : o === 1 ? 1 + (r - 1) * 0.5 : o === 2 ? 1 + (r - 1) * 0.2 : 1;
26
27
  },
27
- [s, l, n]
28
- ), a = t === "left" || t === "right", i = T(null);
29
- j(i, {
28
+ [d, l, r]
29
+ ), a = n === "left" || n === "right", f = O(null);
30
+ z(f, {
30
31
  orientation: a ? "vertical" : "horizontal",
31
32
  itemSelector: "button"
32
33
  });
33
- const I = t === "left" ? "left center" : t === "right" ? "right center" : "bottom center";
34
- return /* @__PURE__ */ c(
34
+ const R = n === "left" ? "left center" : n === "right" ? "right center" : "bottom center";
35
+ return /* @__PURE__ */ s(
35
36
  "div",
36
37
  {
37
- ref: N,
38
- id: $,
39
- className: `nice-dock nice-dock--${t} nice-dock--${u}${f ? " nice-dock--contained" : ""} ${_ ?? ""}`,
40
- style: h,
38
+ ref: p,
39
+ id: I,
40
+ className: `nice-dock nice-dock--${n} nice-dock--${h}${m ? " nice-dock--contained" : ""}${E ? " nice-dock--hidden" : ""} ${N ?? ""}`,
41
+ style: g,
42
+ onMouseEnter: t ? () => u(!0) : void 0,
43
+ onMouseLeave: t ? () => u(!1) : void 0,
44
+ onFocus: t ? () => b(!0) : void 0,
45
+ onBlur: t ? (e) => {
46
+ e.currentTarget.contains(e.relatedTarget) || b(!1);
47
+ } : void 0,
41
48
  role: "toolbar",
42
- "aria-label": g("dock.label", "Dock"),
49
+ "aria-label": T("dock.label", "Dock"),
43
50
  "aria-orientation": a ? "vertical" : "horizontal",
44
- ...v,
45
- children: /* @__PURE__ */ c(
51
+ ...M,
52
+ children: /* @__PURE__ */ s(
46
53
  "div",
47
54
  {
48
- ref: i,
55
+ ref: f,
49
56
  className: "nice-dock__bar",
50
57
  style: { flexDirection: a ? "column" : "row" },
51
- children: d.map((e, o) => {
52
- const M = p(o);
53
- return /* @__PURE__ */ x(
58
+ children: k.map((e, o) => {
59
+ const j = F(o);
60
+ return /* @__PURE__ */ y(
54
61
  "button",
55
62
  {
56
63
  type: "button",
57
- className: `nice-dock__item ${b === e.key ? "nice-dock__item--active" : ""} ${e.disabled ? "nice-dock__item--disabled" : ""}`,
64
+ className: `nice-dock__item ${v === e.key ? "nice-dock__item--active" : ""} ${e.disabled ? "nice-dock__item--disabled" : ""}`,
58
65
  style: {
59
- transform: `scale(${M})`,
60
- transformOrigin: I,
66
+ transform: `scale(${j})`,
67
+ transformOrigin: R,
61
68
  transition: "transform 0.15s ease-out"
62
69
  },
63
70
  disabled: e.disabled,
64
- onClick: () => k?.(e.key),
65
- onMouseEnter: () => r(o),
66
- onMouseLeave: () => r(null),
67
- onFocus: () => r(o),
68
- onBlur: () => r(null),
71
+ onClick: () => _?.(e.key),
72
+ onMouseEnter: () => c(o),
73
+ onMouseLeave: () => c(null),
74
+ onFocus: () => c(o),
75
+ onBlur: () => c(null),
69
76
  "aria-label": e.label,
70
77
  title: e.label,
71
78
  children: [
72
- /* @__PURE__ */ c("span", { className: "nice-dock__icon", children: e.icon }),
73
- e.badge !== void 0 && /* @__PURE__ */ c("span", { className: "nice-dock__badge", children: e.badge })
79
+ /* @__PURE__ */ s("span", { className: "nice-dock__icon", children: e.icon }),
80
+ e.badge !== void 0 && /* @__PURE__ */ s("span", { className: "nice-dock__badge", children: e.badge })
74
81
  ]
75
82
  },
76
83
  e.key
@@ -85,5 +92,5 @@ const w = [], B = /* @__PURE__ */ Object.assign(
85
92
  { displayName: "NiceDock" }
86
93
  );
87
94
  export {
88
- B as NiceDock
95
+ Y as NiceDock
89
96
  };