@ledgerhq/lumen-ui-react 0.1.4 → 0.1.6

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,12 +1,18 @@
1
1
  import { PropsWithChildren } from 'react';
2
2
  import { SupportedLocale } from '../../../i18n';
3
- export type ThemeMode = 'dark' | 'light' | 'system';
3
+ export declare const COLOR_SCHEMES: {
4
+ readonly light: "light";
5
+ readonly dark: "dark";
6
+ readonly system: "system";
7
+ };
8
+ export type ColorSchemeName = (typeof COLOR_SCHEMES)[keyof typeof COLOR_SCHEMES];
4
9
  export type ThemeProviderProps = PropsWithChildren & {
5
10
  /**
6
- * The default mode of the theme.
11
+ * The color scheme of the theme.
12
+ * system will follow the user's OS preference via `prefers-color-scheme`.
7
13
  * @default 'system'
8
14
  */
9
- defaultMode?: ThemeMode;
15
+ colorScheme?: ColorSchemeName;
10
16
  /**
11
17
  * The locale to use for translations.
12
18
  * When changed, translations will be lazy-loaded automatically.
@@ -1 +1 @@
1
- {"version":3,"file":"ThemeProvider.types.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/ThemeProvider/ThemeProvider.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEpD,MAAM,MAAM,kBAAkB,GAAG,iBAAiB,GAAG;IACnD;;;OAGG;IACH,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB;;;;OAIG;IACH,MAAM,CAAC,EAAE,eAAe,CAAC;CAC1B,CAAC"}
1
+ {"version":3,"file":"ThemeProvider.types.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/ThemeProvider/ThemeProvider.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD,eAAO,MAAM,aAAa;;;;CAIhB,CAAC;AAEX,MAAM,MAAM,eAAe,GACzB,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC;AAErD,MAAM,MAAM,kBAAkB,GAAG,iBAAiB,GAAG;IACnD;;;;OAIG;IACH,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B;;;;OAIG;IACH,MAAM,CAAC,EAAE,eAAe,CAAC;CAC1B,CAAC"}
@@ -0,0 +1,8 @@
1
+ const t = {
2
+ light: "light",
3
+ dark: "dark",
4
+ system: "system"
5
+ };
6
+ export {
7
+ t as COLOR_SCHEMES
8
+ };
@@ -1,4 +1,4 @@
1
- import { ThemeMode } from './ThemeProvider.types';
1
+ import { ColorSchemeName } from './ThemeProvider.types';
2
2
  export declare const LIGHT_MODE = "light";
3
3
  export declare const DARK_MODE = "dark";
4
4
  export declare const SYSTEM_MODE = "system";
@@ -6,7 +6,7 @@ export declare const SYSTEM_MODE = "system";
6
6
  * Updates the root element className when the theme mode changes.
7
7
  * This allows the design-system theme config to be applied
8
8
  */
9
- export declare const useRootColorModeSideEffect: ({ mode }: {
10
- mode: ThemeMode;
9
+ export declare const useRootColorModeSideEffect: ({ colorScheme, }: {
10
+ colorScheme: ColorSchemeName;
11
11
  }) => void;
12
12
  //# sourceMappingURL=useRootColorModeSideEffect.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useRootColorModeSideEffect.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/ThemeProvider/useRootColorModeSideEffect.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,eAAO,MAAM,UAAU,UAAU,CAAC;AAClC,eAAO,MAAM,SAAS,SAAS,CAAC;AAChC,eAAO,MAAM,WAAW,WAAW,CAAC;AAEpC;;;GAGG;AACH,eAAO,MAAM,0BAA0B,aAAc;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,SAiBvE,CAAC"}
1
+ {"version":3,"file":"useRootColorModeSideEffect.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/ThemeProvider/useRootColorModeSideEffect.tsx"],"names":[],"mappings":"AACA,OAAO,EAAiB,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAEvE,eAAO,MAAM,UAAU,UAAU,CAAC;AAClC,eAAO,MAAM,SAAS,SAAS,CAAC;AAChC,eAAO,MAAM,WAAW,WAAW,CAAC;AAEpC;;;GAGG;AACH,eAAO,MAAM,0BAA0B,qBAEpC;IACD,WAAW,EAAE,eAAe,CAAC;CAC9B,SA0BA,CAAC"}
@@ -1,18 +1,24 @@
1
- import { useEffect as r } from "react";
2
- const e = "light", o = "dark", n = "system", a = ({ mode: s }) => {
3
- r(() => {
4
- const t = window.document.documentElement;
5
- if (t.classList.remove(e, o), s === n) {
6
- const c = window.matchMedia("(prefers-color-scheme: dark)").matches ? o : e;
7
- t.classList.add(c);
8
- return;
1
+ import { useLayoutEffect as a } from "react";
2
+ import { COLOR_SCHEMES as c } from "./ThemeProvider.types.js";
3
+ const r = "light", n = "dark", m = ({
4
+ colorScheme: t
5
+ }) => {
6
+ a(() => {
7
+ const e = window.document.documentElement;
8
+ if (e.classList.remove(r, n), t === c.system) {
9
+ const s = window.matchMedia("(prefers-color-scheme: dark)"), o = () => {
10
+ e.classList.remove(r, n), e.classList.add(s.matches ? n : r);
11
+ };
12
+ return o(), s.addEventListener("change", o), () => {
13
+ s.removeEventListener("change", o);
14
+ };
9
15
  }
10
- t.classList.add(s);
11
- }, [s]);
16
+ return e.classList.add(t), () => {
17
+ };
18
+ }, [t]);
12
19
  };
13
20
  export {
14
- o as DARK_MODE,
15
- e as LIGHT_MODE,
16
- n as SYSTEM_MODE,
17
- a as useRootColorModeSideEffect
21
+ n as DARK_MODE,
22
+ r as LIGHT_MODE,
23
+ m as useRootColorModeSideEffect
18
24
  };
@@ -1,10 +1,10 @@
1
- import { jsx as r, jsxs as b } from "react/jsx-runtime";
2
- import { createSafeContext as T, cn as s } from "../../../libs/utils-shared/dist/index.js";
1
+ import { jsx as i, jsxs as b } from "react/jsx-runtime";
2
+ import { createSafeContext as T, cn as l } from "../../../libs/utils-shared/dist/index.js";
3
3
  import { cva as f } from "class-variance-authority";
4
4
  import { useCallback as x } from "react";
5
5
  import { Spot as v } from "../Spot/Spot.js";
6
6
  import { InteractiveIcon as y } from "../InteractiveIcon/InteractiveIcon.js";
7
- const [N, l] = T("Tile"), m = {
7
+ const [N, s] = T("Tile"), m = {
8
8
  root: f([
9
9
  "group relative flex flex-col items-center rounded-md text-base transition-colors focus-visible:outline-2 focus-visible:outline-focus"
10
10
  ]),
@@ -39,14 +39,14 @@ const [N, l] = T("Tile"), m = {
39
39
  ref: t,
40
40
  className: e,
41
41
  onClick: a,
42
- secondaryAction: i,
42
+ secondaryAction: o,
43
43
  appearance: c = "no-background",
44
- disabled: o = !1,
44
+ disabled: r = !1,
45
45
  centered: d = !1,
46
46
  children: u,
47
47
  style: p,
48
48
  ...n
49
- }) => /* @__PURE__ */ r(N, { value: { disabled: o }, children: /* @__PURE__ */ b(
49
+ }) => /* @__PURE__ */ i(N, { value: { disabled: r }, children: /* @__PURE__ */ b(
50
50
  "div",
51
51
  {
52
52
  ref: t,
@@ -55,61 +55,61 @@ const [N, l] = T("Tile"), m = {
55
55
  className: e
56
56
  }),
57
57
  children: [
58
- /* @__PURE__ */ r(
58
+ /* @__PURE__ */ i(
59
59
  "button",
60
60
  {
61
61
  ...n,
62
62
  onClick: a,
63
- disabled: o,
63
+ disabled: r,
64
64
  className: m.inner({
65
65
  appearance: c,
66
- disabled: o,
66
+ disabled: r,
67
67
  centered: d
68
68
  }),
69
69
  children: u
70
70
  }
71
71
  ),
72
- i
72
+ o
73
73
  ]
74
74
  }
75
75
  ) });
76
76
  g.displayName = "Tile";
77
77
  const h = ({ size: t = 48, ...e }) => {
78
- const { disabled: a } = l({
78
+ const { disabled: a } = s({
79
79
  consumerName: "TileSpot",
80
80
  contextRequired: !0
81
81
  });
82
- return /* @__PURE__ */ r(v, { ...e, size: t, disabled: a });
82
+ return /* @__PURE__ */ i(v, { ...e, size: t, disabled: a });
83
83
  };
84
84
  h.displayName = "TileSpot";
85
- const S = ({
85
+ const C = ({
86
86
  children: t,
87
87
  className: e,
88
88
  ...a
89
- }) => /* @__PURE__ */ r(
89
+ }) => /* @__PURE__ */ i(
90
90
  "div",
91
91
  {
92
- className: s("flex w-full flex-col items-center text-center", e),
92
+ className: l("flex w-full flex-col items-center text-center", e),
93
93
  ...a,
94
94
  children: t
95
95
  }
96
96
  );
97
- S.displayName = "TileContent";
98
- const w = ({
97
+ C.displayName = "TileContent";
98
+ const S = ({
99
99
  children: t,
100
100
  className: e,
101
101
  ...a
102
102
  }) => {
103
- const { disabled: i } = l({
103
+ const { disabled: o } = s({
104
104
  consumerName: "TileTitle",
105
105
  contextRequired: !0
106
106
  });
107
- return /* @__PURE__ */ r(
107
+ return /* @__PURE__ */ i(
108
108
  "div",
109
109
  {
110
- className: s(
110
+ className: l(
111
111
  "w-full truncate body-2-semi-bold",
112
- i && "text-disabled",
112
+ o && "text-disabled",
113
113
  e
114
114
  ),
115
115
  ...a,
@@ -117,22 +117,22 @@ const w = ({
117
117
  }
118
118
  );
119
119
  };
120
- w.displayName = "TileTitle";
121
- const q = ({
120
+ S.displayName = "TileTitle";
121
+ const k = ({
122
122
  children: t,
123
123
  className: e,
124
124
  ...a
125
125
  }) => {
126
- const { disabled: i } = l({
126
+ const { disabled: o } = s({
127
127
  consumerName: "TileDescription",
128
128
  contextRequired: !0
129
129
  });
130
- return /* @__PURE__ */ r(
130
+ return /* @__PURE__ */ i(
131
131
  "div",
132
132
  {
133
- className: s(
133
+ className: l(
134
134
  "w-full truncate body-3",
135
- i ? "text-disabled" : "text-muted",
135
+ o ? "text-disabled" : "text-muted",
136
136
  e
137
137
  ),
138
138
  ...a,
@@ -140,63 +140,63 @@ const q = ({
140
140
  }
141
141
  );
142
142
  };
143
- q.displayName = "TileDescription";
144
- const C = ({
143
+ k.displayName = "TileDescription";
144
+ const w = ({
145
145
  children: t,
146
146
  className: e,
147
147
  ...a
148
- }) => /* @__PURE__ */ r(
148
+ }) => /* @__PURE__ */ i(
149
149
  "div",
150
150
  {
151
- className: s("mt-4 flex w-full flex-col items-center gap-8", e),
151
+ className: l("mt-4 flex w-full flex-col items-center gap-8", e),
152
152
  ...a,
153
153
  children: t
154
154
  }
155
155
  );
156
- C.displayName = "TileTrailingContent";
157
- const D = ({
156
+ w.displayName = "TileTrailingContent";
157
+ const q = ({
158
158
  ref: t,
159
159
  onClick: e,
160
160
  icon: a,
161
- className: i,
161
+ className: o,
162
162
  "aria-label": c,
163
- ...o
163
+ ...r
164
164
  }) => {
165
- const { disabled: d } = l({
165
+ const { disabled: d } = s({
166
166
  consumerName: "TileSecondaryAction",
167
167
  contextRequired: !0
168
168
  }), u = x(
169
169
  (n) => {
170
- n.stopPropagation(), n.preventDefault(), e == null || e(n);
170
+ n.stopPropagation(), n.preventDefault(), e?.(n);
171
171
  },
172
172
  [e]
173
173
  );
174
174
  if (d) return null;
175
175
  const p = a;
176
- return /* @__PURE__ */ r(
176
+ return /* @__PURE__ */ i(
177
177
  y,
178
178
  {
179
- className: s(
179
+ className: l(
180
180
  "absolute top-8 right-4 opacity-0 transition-opacity duration-200 group-hover:opacity-100 focus-within:opacity-100",
181
- i
181
+ o
182
182
  ),
183
183
  "data-secondary-button-container": !0,
184
184
  iconType: "stroked",
185
185
  onClick: u,
186
186
  "aria-label": c,
187
187
  ref: t,
188
- ...o,
189
- children: /* @__PURE__ */ r(p, { size: 24 })
188
+ ...r,
189
+ children: /* @__PURE__ */ i(p, { size: 24 })
190
190
  }
191
191
  );
192
192
  };
193
- D.displayName = "TileSecondaryAction";
193
+ q.displayName = "TileSecondaryAction";
194
194
  export {
195
195
  g as Tile,
196
- S as TileContent,
197
- q as TileDescription,
198
- D as TileSecondaryAction,
196
+ C as TileContent,
197
+ k as TileDescription,
198
+ q as TileSecondaryAction,
199
199
  h as TileSpot,
200
- w as TileTitle,
201
- C as TileTrailingContent
200
+ S as TileTitle,
201
+ w as TileTrailingContent
202
202
  };
@@ -1,9 +1,9 @@
1
- import { jsxs as b, jsx as a } from "react/jsx-runtime";
1
+ import { jsxs as b, jsx as s } from "react/jsx-runtime";
2
2
  import { cn as p } from "../../../libs/utils-shared/dist/index.js";
3
3
  import { Slot as v, Slottable as x } from "@radix-ui/react-slot";
4
- import { cva as r } from "class-variance-authority";
4
+ import { cva as i } from "class-variance-authority";
5
5
  import { useCallback as g } from "react";
6
- const N = r(
6
+ const N = i(
7
7
  [
8
8
  "flex flex-col items-center gap-8 rounded-md p-12",
9
9
  "bg-muted body-2-semi-bold text-base transition-colors",
@@ -24,7 +24,7 @@ const N = r(
24
24
  isFull: !1
25
25
  }
26
26
  }
27
- ), V = r("shrink-0", {
27
+ ), V = i("shrink-0", {
28
28
  variants: {
29
29
  disabled: {
30
30
  true: "text-disabled",
@@ -34,17 +34,17 @@ const N = r(
34
34
  defaultVariants: {
35
35
  disabled: !1
36
36
  }
37
- }), y = ({
38
- ref: i,
37
+ }), k = ({
38
+ ref: r,
39
39
  icon: n,
40
- children: l,
41
- onClick: t,
40
+ children: a,
41
+ onClick: l,
42
42
  disabled: e = !1,
43
43
  isFull: u = !1,
44
- className: f,
45
- asChild: s = !1,
46
- "aria-label": m,
47
- ...c
44
+ className: c,
45
+ asChild: t = !1,
46
+ "aria-label": f,
47
+ ...m
48
48
  }) => {
49
49
  const d = g(
50
50
  (o) => {
@@ -52,29 +52,29 @@ const N = r(
52
52
  o.preventDefault();
53
53
  return;
54
54
  }
55
- t == null || t(o);
55
+ l?.(o);
56
56
  },
57
- [e, t]
57
+ [e, l]
58
58
  );
59
59
  return /* @__PURE__ */ b(
60
- s ? v : "button",
60
+ t ? v : "button",
61
61
  {
62
- ref: i,
63
- type: s ? void 0 : "button",
64
- className: p(N({ disabled: e, isFull: u }), f),
62
+ ref: r,
63
+ type: t ? void 0 : "button",
64
+ className: p(N({ disabled: e, isFull: u }), c),
65
65
  onClick: d,
66
66
  disabled: e,
67
67
  "data-disabled": e || void 0,
68
- "aria-label": m,
69
- ...c,
68
+ "aria-label": f,
69
+ ...m,
70
70
  children: [
71
- /* @__PURE__ */ a(n, { size: 20, className: V({ disabled: e }) }),
72
- s ? /* @__PURE__ */ a(x, { children: l }) : /* @__PURE__ */ a("span", { className: "line-clamp-2 text-center", children: l })
71
+ /* @__PURE__ */ s(n, { size: 20, className: V({ disabled: e }) }),
72
+ t ? /* @__PURE__ */ s(x, { children: a }) : /* @__PURE__ */ s("span", { className: "line-clamp-2 text-center", children: a })
73
73
  ]
74
74
  }
75
75
  );
76
76
  };
77
- y.displayName = "TileButton";
77
+ k.displayName = "TileButton";
78
78
  export {
79
- y as TileButton
79
+ k as TileButton
80
80
  };
@@ -1,20 +1,17 @@
1
- var c = Object.defineProperty;
2
- var o = (a, e, s) => e in a ? c(a, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : a[e] = s;
3
- var t = (a, e, s) => o(a, typeof e != "symbol" ? e + "" : e, s);
4
- import { createContext as p } from "react";
5
- const d = p();
6
- class N {
1
+ import { createContext as a } from "react";
2
+ const o = a();
3
+ class p {
7
4
  constructor() {
8
- t(this, "getUsedNamespaces", () => Object.keys(this.usedNamespaces));
9
5
  this.usedNamespaces = {};
10
6
  }
11
- addUsedNamespaces(e) {
12
- e.forEach((s) => {
13
- this.usedNamespaces[s] || (this.usedNamespaces[s] = !0);
7
+ addUsedNamespaces(s) {
8
+ s.forEach((e) => {
9
+ this.usedNamespaces[e] || (this.usedNamespaces[e] = !0);
14
10
  });
15
11
  }
12
+ getUsedNamespaces = () => Object.keys(this.usedNamespaces);
16
13
  }
17
14
  export {
18
- d as I18nContext,
19
- N as ReportNamespaces
15
+ o as I18nContext,
16
+ p as ReportNamespaces
20
17
  };
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ledgerhq/lumen-ui-react",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "keywords": [
@@ -1,25 +1,24 @@
1
- import { useState as d, useRef as i, useCallback as V, startTransition as b, useEffect as m } from "react";
2
- function y({
1
+ import { useState as S, useRef as l, useCallback as d, startTransition as C, useEffect as R } from "react";
2
+ function b({
3
3
  prop: t,
4
- defaultProp: f,
5
- onChange: r
4
+ defaultProp: i,
5
+ onChange: c
6
6
  }) {
7
- const [v, a] = d(t ?? f), n = t !== void 0, l = n ? t : v, e = i(r);
8
- e.current = r;
9
- const s = i(l), S = V(
10
- (u) => {
11
- var o;
12
- const c = typeof u == "function" ? u(s.current) : u;
13
- n || b(() => {
14
- a(c);
15
- }), (o = e.current) == null || o.call(e, c), s.current = c;
7
+ const [f, r] = S(t ?? i), e = t !== void 0, a = e ? t : f, o = l(c);
8
+ o.current = c;
9
+ const n = l(a), v = d(
10
+ (s) => {
11
+ const u = typeof s == "function" ? s(n.current) : s;
12
+ e || C(() => {
13
+ r(u);
14
+ }), o.current?.(u), n.current = u;
16
15
  },
17
- [n]
16
+ [e]
18
17
  );
19
- return m(() => {
20
- t !== void 0 && (a(t), s.current = t);
21
- }, [t]), [l, S];
18
+ return R(() => {
19
+ t !== void 0 && (r(t), n.current = t);
20
+ }, [t]), [a, v];
22
21
  }
23
22
  export {
24
- y as useControllableState
23
+ b as useControllableState
25
24
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ledgerhq/lumen-ui-react",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "keywords": [