@mittwald/flow-react-components 0.1.0-alpha.227 → 0.1.0-alpha.229

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/List.js CHANGED
@@ -40,7 +40,7 @@ import { useReactTable as Se, getCoreRowModel as ve, getSortedRowModel as ye, ge
40
40
  import vt from "invariant";
41
41
  import { getAsyncResource as mt } from "@mittwald/react-use-promise";
42
42
  import { u as ht } from "./useSelector-DpU7_HMO.js";
43
- import { u as Te } from "./SettingsProvider-vAngjrSo.js";
43
+ import { u as Te } from "./SettingsProvider-DIICbSo0.js";
44
44
  import * as W from "react-aria-components";
45
45
  import { S as A } from "./SkeletonText-B5ZghZhO.js";
46
46
  import { I as Ce } from "./IllustratedMessage-B3MHD01M.js";
@@ -0,0 +1,102 @@
1
+ "use client"
2
+ /* */
3
+ var d = Object.defineProperty;
4
+ var w = (s, t, e) => t in s ? d(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
5
+ var c = (s, t, e) => w(s, typeof t != "symbol" ? t + "" : t, e);
6
+ import J, { createContext as y, useRef as l, useMemo as v, useEffect as O, useContext as K } from "react";
7
+ import { makeAutoObservable as h, ObservableMap as a, autorun as P } from "mobx";
8
+ import { usePromise as x } from "@mittwald/react-use-promise";
9
+ import { mapValues as E } from "remeda";
10
+ class i {
11
+ constructor(t = new a()) {
12
+ c(this, "settings");
13
+ this.settings = t, h(this);
14
+ }
15
+ set(t, e, n) {
16
+ this.settings.set(t, e.parse(n));
17
+ }
18
+ get(t, e) {
19
+ return e.parse(this.settings.get(t));
20
+ }
21
+ clear(t) {
22
+ this.settings.delete(t);
23
+ }
24
+ get asJson() {
25
+ return this.settings.toJSON();
26
+ }
27
+ static fromJson(t) {
28
+ return new i(new a(t));
29
+ }
30
+ }
31
+ class u {
32
+ constructor(t = new a()) {
33
+ c(this, "componentSettings");
34
+ this.componentSettings = t, h(this);
35
+ }
36
+ set(t, e, n, r) {
37
+ const o = this.componentSettings.get(t) ?? new i();
38
+ o.set(e, n, r), this.componentSettings.set(t, o);
39
+ }
40
+ get(t, e, n) {
41
+ return (this.componentSettings.get(t) ?? new i()).get(e, n);
42
+ }
43
+ clear(t, e) {
44
+ var n;
45
+ (n = this.componentSettings.get(t)) == null || n.clear(e);
46
+ }
47
+ get asJson() {
48
+ return Object.fromEntries(
49
+ Array.from(this.componentSettings.entries()).map(([t, e]) => [
50
+ t,
51
+ e.asJson
52
+ ])
53
+ );
54
+ }
55
+ static fromJson(t) {
56
+ const e = E(t, (n) => i.fromJson(n));
57
+ return new u(new a(e));
58
+ }
59
+ }
60
+ class b {
61
+ constructor(t) {
62
+ c(this, "storageKey");
63
+ this.storageKey = t;
64
+ }
65
+ async load() {
66
+ const t = localStorage.getItem(this.storageKey);
67
+ return t === null ? {} : JSON.parse(t);
68
+ }
69
+ async store(t) {
70
+ localStorage.setItem(this.storageKey, JSON.stringify(t));
71
+ }
72
+ }
73
+ const A = (s) => {
74
+ switch (s.type) {
75
+ case "custom":
76
+ return s.store;
77
+ case "localStorage":
78
+ return new b(s.storageKey);
79
+ }
80
+ throw new Error(`Unsupported setting backend: ${s}`);
81
+ }, p = y(void 0), N = () => K(p), R = (s) => {
82
+ const { children: t, id: e, ...n } = s, r = A(n), o = l(!0), m = l(Promise.resolve()), S = x(() => r.load(), [], {
83
+ loaderId: e
84
+ }), g = v(() => u.fromJson(S), []);
85
+ return O(
86
+ () => P(() => {
87
+ if (o.current) {
88
+ o.current = !1;
89
+ return;
90
+ }
91
+ const f = g.asJson;
92
+ m.current = m.current.then(
93
+ () => r.store(f)
94
+ );
95
+ }),
96
+ [g, e]
97
+ ), /* @__PURE__ */ J.createElement(p.Provider, { value: g }, t);
98
+ };
99
+ export {
100
+ R as S,
101
+ N as u
102
+ };
@@ -1,6 +1,6 @@
1
1
  "use client"
2
2
  /* */
3
- import { S as t } from "./SettingsProvider-vAngjrSo.js";
3
+ import { S as t } from "./SettingsProvider-DIICbSo0.js";
4
4
  export {
5
5
  t as SettingsProvider,
6
6
  t as default
@@ -1,7 +1,9 @@
1
1
  import { FC, PropsWithChildren } from 'react';
2
2
  import { SupportedSettingsBackend } from './backends/types';
3
3
  import { SettingsStore } from './models/SettingsStore';
4
- type Props = PropsWithChildren & SupportedSettingsBackend;
4
+ type Props = PropsWithChildren & SupportedSettingsBackend & {
5
+ id?: string;
6
+ };
5
7
  export declare const useSettings: () => SettingsStore | undefined;
6
8
  export declare const SettingsProvider: FC<Props>;
7
9
  export {};
@@ -1,4 +1,5 @@
1
1
  import { SettingsProvider } from './SettingsProvider';
2
2
  export { SettingsProvider } from './SettingsProvider';
3
3
  export type { SettingsBackend } from './backends/types';
4
+ export type { SettingsJson } from './models/SettingsStore';
4
5
  export default SettingsProvider;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mittwald/flow-react-components",
3
- "version": "0.1.0-alpha.227",
3
+ "version": "0.1.0-alpha.229",
4
4
  "type": "module",
5
5
  "description": "A React implementation of Flow, mittwald’s design system",
6
6
  "homepage": "https://mittwald.github.io/flow",
@@ -305,7 +305,7 @@
305
305
  "@chakra-ui/live-region": "^2.1.0",
306
306
  "@internationalized/date": "^3.5.5",
307
307
  "@internationalized/string-compiler": "^3.2.4",
308
- "@mittwald/react-tunnel": "^0.1.0-alpha.227",
308
+ "@mittwald/react-tunnel": "^0.1.0-alpha.229",
309
309
  "@mittwald/react-use-promise": "^2.4.0",
310
310
  "@react-aria/utils": "^3.25.2",
311
311
  "@react-types/shared": "^3.24.1",
@@ -332,7 +332,7 @@
332
332
  },
333
333
  "devDependencies": {
334
334
  "@faker-js/faker": "^8.4.1",
335
- "@mittwald/flow-design-tokens": "^0.1.0-alpha.227",
335
+ "@mittwald/flow-design-tokens": "^0.1.0-alpha.229",
336
336
  "@mittwald/react-use-promise": "^2.4.0",
337
337
  "@nx/storybook": "^19.6.4",
338
338
  "@storybook/addon-a11y": "^8.2.9",
@@ -410,5 +410,5 @@
410
410
  "optional": true
411
411
  }
412
412
  },
413
- "gitHead": "b97287d9170c04ea38d37c613961ef2cd3c7fab0"
413
+ "gitHead": "d5c92bef05a84630d231348f57789e8ac5f25f3d"
414
414
  }
@@ -1,96 +0,0 @@
1
- "use client"
2
- /* */
3
- var p = Object.defineProperty;
4
- var S = (s, t, e) => t in s ? p(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
5
- var c = (s, t, e) => S(s, typeof t != "symbol" ? t + "" : t, e);
6
- import f, { createContext as w, useRef as J, useMemo as y, useEffect as d, useContext as v } from "react";
7
- import { makeAutoObservable as m, ObservableMap as a, autorun as O } from "mobx";
8
- import { usePromise as K } from "@mittwald/react-use-promise";
9
- import { mapValues as P } from "remeda";
10
- class r {
11
- constructor(t = new a()) {
12
- c(this, "settings");
13
- this.settings = t, m(this);
14
- }
15
- set(t, e, n) {
16
- this.settings.set(t, e.parse(n));
17
- }
18
- get(t, e) {
19
- return e.parse(this.settings.get(t));
20
- }
21
- clear(t) {
22
- this.settings.delete(t);
23
- }
24
- get asJson() {
25
- return this.settings.toJSON();
26
- }
27
- static fromJson(t) {
28
- return new r(new a(t));
29
- }
30
- }
31
- class u {
32
- constructor(t = new a()) {
33
- c(this, "componentSettings");
34
- this.componentSettings = t, m(this);
35
- }
36
- set(t, e, n, o) {
37
- const i = this.componentSettings.get(t) ?? new r();
38
- i.set(e, n, o), this.componentSettings.set(t, i);
39
- }
40
- get(t, e, n) {
41
- return (this.componentSettings.get(t) ?? new r()).get(e, n);
42
- }
43
- clear(t, e) {
44
- var n;
45
- (n = this.componentSettings.get(t)) == null || n.clear(e);
46
- }
47
- get asJson() {
48
- return Object.fromEntries(
49
- Array.from(this.componentSettings.entries()).map(([t, e]) => [
50
- t,
51
- e.asJson
52
- ])
53
- );
54
- }
55
- static fromJson(t) {
56
- const e = P(t, (n) => r.fromJson(n));
57
- return new u(new a(e));
58
- }
59
- }
60
- class x {
61
- constructor(t) {
62
- c(this, "storageKey");
63
- this.storageKey = t;
64
- }
65
- async load() {
66
- const t = localStorage.getItem(this.storageKey);
67
- return t === null ? {} : JSON.parse(t);
68
- }
69
- async store(t) {
70
- localStorage.setItem(this.storageKey, JSON.stringify(t));
71
- }
72
- }
73
- const E = (s) => {
74
- switch (s.type) {
75
- case "custom":
76
- return s.store;
77
- case "localStorage":
78
- return new x(s.storageKey);
79
- }
80
- throw new Error(`Unsupported setting backend: ${s}`);
81
- }, l = w(void 0), I = () => v(l), M = (s) => {
82
- const { children: t, ...e } = s, n = E(e), o = J(Promise.resolve()), i = K(() => n.load(), []), g = y(() => u.fromJson(i), []);
83
- return d(
84
- () => O(() => {
85
- const h = g.asJson;
86
- o.current = o.current.then(
87
- () => n.store(h)
88
- );
89
- }),
90
- [g]
91
- ), /* @__PURE__ */ f.createElement(l.Provider, { value: g }, t);
92
- };
93
- export {
94
- M as S,
95
- I as u
96
- };