@workfort/ui-react 0.2.0 → 0.3.0

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.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  export { Panel, Button, Badge, StatusDot, Skeleton, Divider, TextInput, List, ListItem, ScrollArea, ErrorFallback, } from './components.js';
2
2
  export { useAuth } from './use-auth.js';
3
3
  export { useTheme } from './use-theme.js';
4
+ export { useIdleDetection } from './use-idle-detection.js';
5
+ export { usePermissions } from './use-permissions.js';
4
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAClD,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,aAAa,GACrD,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAClD,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,aAAa,GACrD,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC"}
package/dist/index.js CHANGED
@@ -1,29 +1,29 @@
1
- import b, { forwardRef as m, useRef as w, useCallback as l, useSyncExternalStore as p } from "react";
2
- import "@workfort/ui";
3
- import { getAuthClient as g } from "@workfort/auth";
4
- function k(t, s) {
5
- const r = w(null), c = w(/* @__PURE__ */ new Map()), n = {}, i = {};
6
- for (const [o, a] of Object.entries(s))
7
- if (o.startsWith("on") && o.length > 2 && typeof a == "function") {
8
- const d = (o[2].toLowerCase() + o.slice(3)).replace(/([A-Z])/g, "-$1").toLowerCase();
9
- i[d] = a;
1
+ import b, { forwardRef as g, useRef as w, useCallback as f, useSyncExternalStore as d, useEffect as k, useState as p } from "react";
2
+ import { IdleDetector as h, PermissionSet as S } from "@workfort/ui";
3
+ import { getAuthClient as v } from "@workfort/auth";
4
+ function x(t, n) {
5
+ const o = w(null), s = w(/* @__PURE__ */ new Map()), c = {}, a = {};
6
+ for (const [r, i] of Object.entries(n))
7
+ if (r.startsWith("on") && r.length > 2 && typeof i == "function") {
8
+ const m = (r[2].toLowerCase() + r.slice(3)).replace(/([A-Z])/g, "-$1").toLowerCase();
9
+ a[m] = i;
10
10
  } else
11
- n[o] = a;
12
- return { ref: l((o) => {
13
- if (r.current && (c.current.forEach((a, f) => r.current.removeEventListener(f, a)), c.current.clear()), r.current = o, o)
14
- for (const [a, f] of Object.entries(i))
15
- o.addEventListener(a, f), c.current.set(a, f);
16
- typeof t == "function" ? t(o) : t && (t.current = o);
17
- }, [t, ...Object.keys(i)]), cleanProps: n };
11
+ c[r] = i;
12
+ return { ref: f((r) => {
13
+ if (o.current && (s.current.forEach((i, u) => o.current.removeEventListener(u, i)), s.current.clear()), o.current = r, r)
14
+ for (const [i, u] of Object.entries(a))
15
+ r.addEventListener(i, u), s.current.set(i, u);
16
+ typeof t == "function" ? t(r) : t && (t.current = r);
17
+ }, [t, ...Object.keys(a)]), cleanProps: c };
18
18
  }
19
- function e(t, s) {
20
- const r = m(({ children: c, ...n }, i) => {
21
- const { ref: u, cleanProps: o } = k(i, n);
22
- return b.createElement(t, { ref: u, ...o }, c);
19
+ function e(t, n) {
20
+ const o = g(({ children: s, ...c }, a) => {
21
+ const { ref: l, cleanProps: r } = x(a, c);
22
+ return b.createElement(t, { ref: l, ...r }, s);
23
23
  });
24
- return r.displayName = s, r;
24
+ return o.displayName = n, o;
25
25
  }
26
- const C = e("wf-panel", "Panel"), A = e("wf-button", "Button"), E = e("wf-badge", "Badge"), P = e("wf-status-dot", "StatusDot"), T = e("wf-skeleton", "Skeleton"), y = e("wf-divider", "Divider"), D = e("wf-text-input", "TextInput"), L = e("wf-list", "List"), I = e("wf-list-item", "ListItem"), B = e("wf-scroll-area", "ScrollArea"), F = e("wf-error-fallback", "ErrorFallback");
26
+ const D = e("wf-panel", "Panel"), T = e("wf-button", "Button"), y = e("wf-badge", "Badge"), I = e("wf-status-dot", "StatusDot"), L = e("wf-skeleton", "Skeleton"), B = e("wf-divider", "Divider"), F = e("wf-text-input", "TextInput"), R = e("wf-list", "List"), O = e("wf-list-item", "ListItem"), j = e("wf-scroll-area", "ScrollArea"), W = e("wf-error-fallback", "ErrorFallback");
27
27
  e("wf-input", "Input");
28
28
  e("wf-textarea", "Textarea");
29
29
  e("wf-select", "Select");
@@ -54,36 +54,51 @@ e("wf-stepper", "Stepper");
54
54
  e("wf-step", "Step");
55
55
  e("wf-progress", "Progress");
56
56
  e("wf-alert-dialog", "AlertDialog");
57
- function O() {
58
- const t = g(), s = l((n) => (t.on("change", n), t.on("logout", n), () => {
59
- t.off("change", n), t.off("logout", n);
60
- }), [t]), r = l(() => t.getUser(), [t]), c = p(s, r);
61
- return { user: c, isAuthenticated: c !== null };
57
+ function G() {
58
+ const t = v(), n = f((c) => (t.on("change", c), t.on("logout", c), () => {
59
+ t.off("change", c), t.off("logout", c);
60
+ }), [t]), o = f(() => t.getUser(), [t]), s = d(n, o);
61
+ return { user: s, isAuthenticated: s !== null };
62
62
  }
63
- function h() {
63
+ function P() {
64
64
  return typeof document > "u" ? "dark" : document.documentElement.getAttribute("data-theme") ?? "dark";
65
65
  }
66
- function R() {
67
- const t = l((s) => {
66
+ function M() {
67
+ const t = f((n) => {
68
68
  if (typeof document > "u") return () => {
69
69
  };
70
- const r = new MutationObserver(() => s());
71
- return r.observe(document.documentElement, { attributes: !0, attributeFilter: ["data-theme"] }), () => r.disconnect();
70
+ const o = new MutationObserver(() => n());
71
+ return o.observe(document.documentElement, { attributes: !0, attributeFilter: ["data-theme"] }), () => o.disconnect();
72
72
  }, []);
73
- return p(t, h, () => "dark");
73
+ return d(t, P, () => "dark");
74
+ }
75
+ function N(t) {
76
+ const n = w(null);
77
+ k(() => {
78
+ const o = new h(t);
79
+ return o.start(), n.current = o, () => o.dispose();
80
+ }, []);
81
+ }
82
+ function U(t = []) {
83
+ const [n] = p(() => new S(t)), [, o] = p(0), s = f((a) => n.can(a), [n]), c = f((a) => {
84
+ n.update(a), o((l) => l + 1);
85
+ }, [n]);
86
+ return { can: s, update: c };
74
87
  }
75
88
  export {
76
- E as Badge,
77
- A as Button,
78
- y as Divider,
79
- F as ErrorFallback,
80
- L as List,
81
- I as ListItem,
82
- C as Panel,
83
- B as ScrollArea,
84
- T as Skeleton,
85
- P as StatusDot,
86
- D as TextInput,
87
- O as useAuth,
88
- R as useTheme
89
+ y as Badge,
90
+ T as Button,
91
+ B as Divider,
92
+ W as ErrorFallback,
93
+ R as List,
94
+ O as ListItem,
95
+ D as Panel,
96
+ j as ScrollArea,
97
+ L as Skeleton,
98
+ I as StatusDot,
99
+ F as TextInput,
100
+ G as useAuth,
101
+ N as useIdleDetection,
102
+ U as usePermissions,
103
+ M as useTheme
89
104
  };
@@ -0,0 +1,3 @@
1
+ import { IdleDetectorOptions } from '@workfort/ui';
2
+ export declare function useIdleDetection(opts: IdleDetectorOptions): void;
3
+ //# sourceMappingURL=use-idle-detection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-idle-detection.d.ts","sourceRoot":"","sources":["../src/use-idle-detection.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,KAAK,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEtE,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,mBAAmB,GAAG,IAAI,CAShE"}
@@ -0,0 +1,5 @@
1
+ export declare function usePermissions(initial?: string[]): {
2
+ can: (permission: string) => any;
3
+ update: (perms: string[]) => void;
4
+ };
5
+ //# sourceMappingURL=use-permissions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-permissions.d.ts","sourceRoot":"","sources":["../src/use-permissions.ts"],"names":[],"mappings":"AAGA,wBAAgB,cAAc,CAAC,OAAO,GAAE,MAAM,EAAO;sBAId,MAAM;oBAER,MAAM,EAAE;EAM5C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workfort/ui-react",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "exports": {