@mittwald/flow-react-components 0.2.0-alpha.757 → 0.2.0-alpha.759

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.
Files changed (23) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/assets/doc-properties.json +4202 -4183
  3. package/dist/css/all.css +1 -1
  4. package/dist/js/packages/components/src/components/SettingsProvider/SettingsProvider.mjs +5 -5
  5. package/dist/js/packages/components/src/components/SettingsProvider/SettingsProvider.mjs.map +1 -1
  6. package/dist/js/packages/components/src/components/SettingsProvider/middleware/defaultImplementations.mjs +9 -0
  7. package/dist/js/packages/components/src/components/SettingsProvider/middleware/defaultImplementations.mjs.map +1 -0
  8. package/dist/js/packages/components/src/components/SettingsProvider/models/SettingsStore.mjs +55 -13
  9. package/dist/js/packages/components/src/components/SettingsProvider/models/SettingsStore.mjs.map +1 -1
  10. package/dist/js/packages/components/src/components/TextField/TextField.mjs +1 -0
  11. package/dist/js/packages/components/src/components/TextField/TextField.mjs.map +1 -1
  12. package/dist/types/components/SettingsProvider/SettingsProvider.browser.test.d.ts +2 -0
  13. package/dist/types/components/SettingsProvider/SettingsProvider.browser.test.d.ts.map +1 -0
  14. package/dist/types/components/SettingsProvider/SettingsProvider.d.ts +2 -2
  15. package/dist/types/components/SettingsProvider/SettingsProvider.d.ts.map +1 -1
  16. package/dist/types/components/SettingsProvider/middleware/defaultImplementations.d.ts +4 -0
  17. package/dist/types/components/SettingsProvider/middleware/defaultImplementations.d.ts.map +1 -0
  18. package/dist/types/components/SettingsProvider/middleware/types.d.ts +6 -0
  19. package/dist/types/components/SettingsProvider/middleware/types.d.ts.map +1 -0
  20. package/dist/types/components/SettingsProvider/models/SettingsStore.d.ts +12 -3
  21. package/dist/types/components/SettingsProvider/models/SettingsStore.d.ts.map +1 -1
  22. package/dist/types/components/TextField/TextField.d.ts.map +1 -1
  23. package/package.json +6 -6
@@ -10,22 +10,22 @@ import { settingsBackendFactory } from './backends/settingsBackendFactory.mjs';
10
10
  const context = createContext(void 0);
11
11
  const useSettings = () => useContext(context);
12
12
  const SettingsProvider = (props) => {
13
- const { children, id, ...storeShape } = props;
13
+ const { children, middleware, id = "static", ...storeShape } = props;
14
14
  const backend = settingsBackendFactory(storeShape);
15
- const storedSettingsResource = getAsyncResource(() => backend.load(), [], {
15
+ const settingsResource = getAsyncResource(() => backend.load(), [], {
16
16
  loaderId: id
17
17
  });
18
- const storedSettings = storedSettingsResource.use();
18
+ const settings = settingsResource.use();
19
19
  const storingPromise = useRef(Promise.resolve());
20
+ const parentStore = useSettings();
20
21
  const settingsStore = useMemo(
21
- () => SettingsStore.fromJson(storedSettings),
22
+ () => SettingsStore.fromJson(settings, { middleware, parentStore }),
22
23
  [id]
23
24
  );
24
25
  const watchAndStoreSettings = () => {
25
26
  const json = settingsStore.asJson;
26
27
  storingPromise.current = storingPromise.current.then(async () => {
27
28
  await backend.store(json);
28
- storedSettingsResource.refresh();
29
29
  });
30
30
  };
31
31
  useEffect(() => autorun(watchAndStoreSettings), [id]);
@@ -1 +1 @@
1
- {"version":3,"file":"SettingsProvider.mjs","sources":["../../../../../../../src/components/SettingsProvider/SettingsProvider.tsx"],"sourcesContent":["import type { FC, PropsWithChildren } from \"react\";\nimport React, {\n createContext,\n useContext,\n useEffect,\n useMemo,\n useRef,\n} from \"react\";\nimport type { SupportedSettingsBackend } from \"@/components/SettingsProvider/backends/types\";\nimport { autorun } from \"mobx\";\nimport { getAsyncResource } from \"@mittwald/react-use-promise\";\nimport { SettingsStore } from \"@/components/SettingsProvider/models/SettingsStore\";\nimport { settingsBackendFactory } from \"@/components/SettingsProvider/backends/settingsBackendFactory\";\n\ntype Props = PropsWithChildren &\n SupportedSettingsBackend & {\n id?: string;\n };\n\nconst context = createContext<SettingsStore | undefined>(undefined);\n\nexport const useSettings = () => useContext(context);\n\nexport const SettingsProvider: FC<Props> = (props) => {\n const { children, id, ...storeShape } = props;\n const backend = settingsBackendFactory(storeShape);\n\n const storedSettingsResource = getAsyncResource(() => backend.load(), [], {\n loaderId: id,\n });\n const storedSettings = storedSettingsResource.use();\n const storingPromise = useRef(Promise.resolve());\n\n const settingsStore = useMemo(\n () => SettingsStore.fromJson(storedSettings),\n [id],\n );\n\n const watchAndStoreSettings = () => {\n const json = settingsStore.asJson;\n storingPromise.current = storingPromise.current.then(async () => {\n await backend.store(json);\n storedSettingsResource.refresh();\n });\n };\n\n useEffect(() => autorun(watchAndStoreSettings), [id]);\n\n return <context.Provider value={settingsStore}>{children}</context.Provider>;\n};\n\nexport default SettingsProvider;\n"],"names":[],"mappings":";;;;;;;AAmBA,MAAM,OAAA,GAAU,cAAyC,MAAS,CAAA;AAE3D,MAAM,WAAA,GAAc,MAAM,UAAA,CAAW,OAAO;AAE5C,MAAM,gBAAA,GAA8B,CAAC,KAAA,KAAU;AACpD,EAAA,MAAM,EAAE,QAAA,EAAU,EAAA,EAAI,GAAG,YAAW,GAAI,KAAA;AACxC,EAAA,MAAM,OAAA,GAAU,uBAAuB,UAAU,CAAA;AAEjD,EAAA,MAAM,yBAAyB,gBAAA,CAAiB,MAAM,QAAQ,IAAA,EAAK,EAAG,EAAC,EAAG;AAAA,IACxE,QAAA,EAAU;AAAA,GACX,CAAA;AACD,EAAA,MAAM,cAAA,GAAiB,uBAAuB,GAAA,EAAI;AAClD,EAAA,MAAM,cAAA,GAAiB,MAAA,CAAO,OAAA,CAAQ,OAAA,EAAS,CAAA;AAE/C,EAAA,MAAM,aAAA,GAAgB,OAAA;AAAA,IACpB,MAAM,aAAA,CAAc,QAAA,CAAS,cAAc,CAAA;AAAA,IAC3C,CAAC,EAAE;AAAA,GACL;AAEA,EAAA,MAAM,wBAAwB,MAAM;AAClC,IAAA,MAAM,OAAO,aAAA,CAAc,MAAA;AAC3B,IAAA,cAAA,CAAe,OAAA,GAAU,cAAA,CAAe,OAAA,CAAQ,IAAA,CAAK,YAAY;AAC/D,MAAA,MAAM,OAAA,CAAQ,MAAM,IAAI,CAAA;AACxB,MAAA,sBAAA,CAAuB,OAAA,EAAQ;AAAA,IACjC,CAAC,CAAA;AAAA,EACH,CAAA;AAEA,EAAA,SAAA,CAAU,MAAM,OAAA,CAAQ,qBAAqB,CAAA,EAAG,CAAC,EAAE,CAAC,CAAA;AAEpD,EAAA,2BAAQ,OAAA,CAAQ,QAAA,EAAR,EAAiB,KAAA,EAAO,eAAgB,QAAA,EAAS,CAAA;AAC3D;;;;"}
1
+ {"version":3,"file":"SettingsProvider.mjs","sources":["../../../../../../../src/components/SettingsProvider/SettingsProvider.tsx"],"sourcesContent":["import type { FC, PropsWithChildren } from \"react\";\nimport { createContext, useContext, useEffect, useMemo, useRef } from \"react\";\nimport type { SupportedSettingsBackend } from \"@/components/SettingsProvider/backends/types\";\nimport { autorun } from \"mobx\";\nimport { getAsyncResource } from \"@mittwald/react-use-promise\";\nimport {\n SettingsStore,\n type SettingsStoreOptions,\n} from \"@/components/SettingsProvider/models/SettingsStore\";\nimport { settingsBackendFactory } from \"@/components/SettingsProvider/backends/settingsBackendFactory\";\n\ntype Props = PropsWithChildren &\n SupportedSettingsBackend & {\n id?: string;\n } & Pick<SettingsStoreOptions, \"middleware\">;\n\nconst context = createContext<SettingsStore | undefined>(undefined);\n\nexport const useSettings = () => useContext(context);\n\nexport const SettingsProvider: FC<Props> = (props) => {\n const { children, middleware, id = \"static\", ...storeShape } = props;\n const backend = settingsBackendFactory(storeShape);\n\n const settingsResource = getAsyncResource(() => backend.load(), [], {\n loaderId: id,\n });\n const settings = settingsResource.use();\n\n const storingPromise = useRef(Promise.resolve());\n const parentStore = useSettings();\n\n const settingsStore = useMemo(\n () => SettingsStore.fromJson(settings, { middleware, parentStore }),\n [id],\n );\n\n const watchAndStoreSettings = () => {\n const json = settingsStore.asJson;\n storingPromise.current = storingPromise.current.then(async () => {\n await backend.store(json);\n });\n };\n\n useEffect(() => autorun(watchAndStoreSettings), [id]);\n\n return <context.Provider value={settingsStore}>{children}</context.Provider>;\n};\n\nexport default SettingsProvider;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 const defaultGetMiddleware = (_, __, current, getParent) => current ?? getParent();
4
+ const defaultSetMiddleware = (_, __, settings) => {
5
+ return settings;
6
+ };
7
+
8
+ export { defaultGetMiddleware, defaultSetMiddleware };
9
+ //# sourceMappingURL=defaultImplementations.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaultImplementations.mjs","sources":["../../../../../../../../src/components/SettingsProvider/middleware/defaultImplementations.ts"],"sourcesContent":["import type { GetSettingsMiddleware, SetSettingsMiddleware } from \"./types\";\n\nexport const defaultGetMiddleware: GetSettingsMiddleware = (\n _,\n __,\n current,\n getParent,\n) => current ?? getParent();\n\nexport const defaultSetMiddleware: SetSettingsMiddleware = (\n _,\n __,\n settings,\n) => {\n return settings;\n};\n"],"names":[],"mappings":"AAEO,MAAM,uBAA8C,CACzD,CAAA,EACA,IACA,OAAA,EACA,SAAA,KACG,WAAW,SAAA;AAET,MAAM,oBAAA,GAA8C,CACzD,CAAA,EACA,EAAA,EACA,QAAA,KACG;AACH,EAAA,OAAO,QAAA;AACT;;;;"}
@@ -4,31 +4,73 @@ import { ObservableMap, makeAutoObservable } from 'mobx';
4
4
  import { ComponentSettings } from './ComponentSettings.mjs';
5
5
  import { mapValues } from 'remeda';
6
6
  import { mobxMapToObject } from '../../../lib/mobx/mobxMapToObject.mjs';
7
+ import { defaultSetMiddleware, defaultGetMiddleware } from '../middleware/defaultImplementations.mjs';
7
8
 
9
+ function subscribeMobxObject(ignored) {
10
+ }
8
11
  class SettingsStore {
9
- componentSettings;
10
- constructor(settings = new ObservableMap()) {
11
- this.componentSettings = settings;
12
- makeAutoObservable(this);
12
+ settings;
13
+ options;
14
+ constructor(settings = new ObservableMap(), options = {}) {
15
+ this.settings = settings;
16
+ this.options = Object.freeze(options);
17
+ makeAutoObservable(this, {
18
+ options: false
19
+ });
13
20
  }
14
21
  set(componentName, settingKey, schema, value) {
15
- const settings = this.componentSettings.get(componentName) ?? new ComponentSettings();
16
- settings.set(settingKey, schema, value);
17
- this.componentSettings.set(componentName, settings);
22
+ const settings = this.settings.get(componentName) ?? new ComponentSettings();
23
+ const middleware = this.options.middleware?.set ?? defaultSetMiddleware;
24
+ const processedValue = middleware(
25
+ componentName,
26
+ settingKey,
27
+ value,
28
+ (thisSettings) => {
29
+ if (this.options.parentStore) {
30
+ this.options.parentStore.set(
31
+ componentName,
32
+ settingKey,
33
+ schema,
34
+ thisSettings
35
+ );
36
+ }
37
+ return thisSettings;
38
+ }
39
+ );
40
+ if (processedValue !== void 0) {
41
+ settings.set(settingKey, schema, processedValue);
42
+ this.settings.set(componentName, settings);
43
+ }
18
44
  }
19
45
  get(componentName, settingKey, schema) {
20
- const settings = this.componentSettings.get(componentName) ?? new ComponentSettings();
21
- return settings.get(settingKey, schema);
46
+ const settings = this.settings.get(componentName) ?? new ComponentSettings();
47
+ const thisSettings = settings.get(settingKey, schema);
48
+ const parentSettings = this.options.parentStore?.get(
49
+ componentName,
50
+ settingKey,
51
+ schema
52
+ );
53
+ const middleware = this.options.middleware?.get ?? defaultGetMiddleware;
54
+ return middleware(
55
+ componentName,
56
+ settingKey,
57
+ thisSettings,
58
+ () => parentSettings
59
+ );
22
60
  }
23
61
  clear(componentName, settingKey) {
24
- this.componentSettings.get(componentName)?.clear(settingKey);
62
+ this.settings.get(componentName)?.clear(settingKey);
63
+ this.options.parentStore?.clear(componentName, settingKey);
25
64
  }
26
65
  get asJson() {
27
- return mapValues(mobxMapToObject(this.componentSettings), (v) => v.asJson);
66
+ const settingsObject = mobxMapToObject(this.settings);
67
+ const asJson = mapValues(settingsObject, (v) => v.asJson);
68
+ subscribeMobxObject(this.options.parentStore?.asJson);
69
+ return asJson;
28
70
  }
29
- static fromJson(json) {
71
+ static fromJson(json, options) {
30
72
  const settings = mapValues(json, (v) => ComponentSettings.fromJson(v));
31
- return new SettingsStore(new ObservableMap(settings));
73
+ return new SettingsStore(new ObservableMap(settings), options);
32
74
  }
33
75
  }
34
76
 
@@ -1 +1 @@
1
- {"version":3,"file":"SettingsStore.mjs","sources":["../../../../../../../../src/components/SettingsProvider/models/SettingsStore.ts"],"sourcesContent":["import { makeAutoObservable, ObservableMap } from \"mobx\";\nimport { ComponentSettings } from \"@/components/SettingsProvider/models/ComponentSettings\";\nimport type { FlowComponentName } from \"@/components/propTypes\";\nimport { mapValues } from \"remeda\";\nimport type { ZodSchema } from \"zod\";\nimport type z from \"zod\";\nimport { mobxMapToObject } from \"@/lib/mobx/mobxMapToObject\";\n\nexport class SettingsStore {\n public readonly componentSettings: ObservableMap<\n FlowComponentName,\n ComponentSettings\n >;\n\n public constructor(\n settings = new ObservableMap<FlowComponentName, ComponentSettings>(),\n ) {\n this.componentSettings = settings;\n makeAutoObservable(this);\n }\n\n public set<T extends ZodSchema>(\n componentName: FlowComponentName,\n settingKey: string,\n schema: T,\n value: z.infer<T>,\n ) {\n const settings =\n this.componentSettings.get(componentName) ?? new ComponentSettings();\n settings.set(settingKey, schema, value);\n this.componentSettings.set(componentName, settings);\n }\n\n public get<T extends ZodSchema>(\n componentName: FlowComponentName,\n settingKey: string,\n schema: T,\n ): z.infer<T> {\n const settings =\n this.componentSettings.get(componentName) ?? new ComponentSettings();\n return settings.get(settingKey, schema);\n }\n\n public clear(componentName: FlowComponentName, settingKey: string) {\n this.componentSettings.get(componentName)?.clear(settingKey);\n }\n\n public get asJson() {\n return mapValues(mobxMapToObject(this.componentSettings), (v) => v.asJson);\n }\n\n public static fromJson(json: SettingsJson) {\n const settings = mapValues(json, (v) => ComponentSettings.fromJson(v));\n return new SettingsStore(new ObservableMap(settings));\n }\n}\n\nexport type SettingsJson = SettingsStore[\"asJson\"];\n"],"names":[],"mappings":";;;;;AAQO,MAAM,aAAA,CAAc;AAAA,EACT,iBAAA;AAAA,EAKT,WAAA,CACL,QAAA,GAAW,IAAI,aAAA,EAAoD,EACnE;AACA,IAAA,IAAA,CAAK,iBAAA,GAAoB,QAAA;AACzB,IAAA,kBAAA,CAAmB,IAAI,CAAA;AAAA,EACzB;AAAA,EAEO,GAAA,CACL,aAAA,EACA,UAAA,EACA,MAAA,EACA,KAAA,EACA;AACA,IAAA,MAAM,WACJ,IAAA,CAAK,iBAAA,CAAkB,IAAI,aAAa,CAAA,IAAK,IAAI,iBAAA,EAAkB;AACrE,IAAA,QAAA,CAAS,GAAA,CAAI,UAAA,EAAY,MAAA,EAAQ,KAAK,CAAA;AACtC,IAAA,IAAA,CAAK,iBAAA,CAAkB,GAAA,CAAI,aAAA,EAAe,QAAQ,CAAA;AAAA,EACpD;AAAA,EAEO,GAAA,CACL,aAAA,EACA,UAAA,EACA,MAAA,EACY;AACZ,IAAA,MAAM,WACJ,IAAA,CAAK,iBAAA,CAAkB,IAAI,aAAa,CAAA,IAAK,IAAI,iBAAA,EAAkB;AACrE,IAAA,OAAO,QAAA,CAAS,GAAA,CAAI,UAAA,EAAY,MAAM,CAAA;AAAA,EACxC;AAAA,EAEO,KAAA,CAAM,eAAkC,UAAA,EAAoB;AACjE,IAAA,IAAA,CAAK,iBAAA,CAAkB,GAAA,CAAI,aAAa,CAAA,EAAG,MAAM,UAAU,CAAA;AAAA,EAC7D;AAAA,EAEA,IAAW,MAAA,GAAS;AAClB,IAAA,OAAO,SAAA,CAAU,gBAAgB,IAAA,CAAK,iBAAiB,GAAG,CAAC,CAAA,KAAM,EAAE,MAAM,CAAA;AAAA,EAC3E;AAAA,EAEA,OAAc,SAAS,IAAA,EAAoB;AACzC,IAAA,MAAM,QAAA,GAAW,UAAU,IAAA,EAAM,CAAC,MAAM,iBAAA,CAAkB,QAAA,CAAS,CAAC,CAAC,CAAA;AACrE,IAAA,OAAO,IAAI,aAAA,CAAc,IAAI,aAAA,CAAc,QAAQ,CAAC,CAAA;AAAA,EACtD;AACF;;;;"}
1
+ {"version":3,"file":"SettingsStore.mjs","sources":["../../../../../../../../src/components/SettingsProvider/models/SettingsStore.ts"],"sourcesContent":["import { makeAutoObservable, ObservableMap } from \"mobx\";\nimport { ComponentSettings } from \"@/components/SettingsProvider/models/ComponentSettings\";\nimport type { FlowComponentName } from \"@/components/propTypes\";\nimport { mapValues } from \"remeda\";\nimport type { ZodSchema } from \"zod\";\nimport type z from \"zod\";\nimport { mobxMapToObject } from \"@/lib/mobx/mobxMapToObject\";\nimport type {\n GetSettingsMiddleware,\n SetSettingsMiddleware,\n} from \"../middleware/types\";\nimport {\n defaultGetMiddleware,\n defaultSetMiddleware,\n} from \"../middleware/defaultImplementations\";\n\nexport interface SettingsStoreOptions {\n middleware?: {\n get?: GetSettingsMiddleware;\n set?: SetSettingsMiddleware;\n };\n parentStore?: SettingsStore;\n}\n\nfunction subscribeMobxObject(ignored: unknown) {\n // Accessing an object subscribes to it in MobX, so this function is used to subscribe to the parent store's JSON representation without actually using it here.\n}\n\nexport class SettingsStore {\n public readonly settings: ObservableMap<FlowComponentName, ComponentSettings>;\n\n public readonly options: Readonly<SettingsStoreOptions>;\n\n public constructor(\n settings = new ObservableMap<FlowComponentName, ComponentSettings>(),\n options: SettingsStoreOptions = {},\n ) {\n this.settings = settings;\n this.options = Object.freeze(options);\n makeAutoObservable(this, {\n options: false,\n });\n }\n\n public set<T extends ZodSchema>(\n componentName: FlowComponentName,\n settingKey: string,\n schema: T,\n value: z.infer<T>,\n ) {\n const settings =\n this.settings.get(componentName) ?? new ComponentSettings();\n\n const middleware = this.options.middleware?.set ?? defaultSetMiddleware;\n\n const processedValue = middleware(\n componentName,\n settingKey,\n value,\n (thisSettings) => {\n if (this.options.parentStore) {\n this.options.parentStore.set(\n componentName,\n settingKey,\n schema,\n thisSettings as z.infer<T>,\n );\n }\n return thisSettings;\n },\n ) as z.infer<T>;\n\n if (processedValue !== undefined) {\n settings.set(settingKey, schema, processedValue);\n this.settings.set(componentName, settings);\n }\n }\n\n public get<T extends ZodSchema>(\n componentName: FlowComponentName,\n settingKey: string,\n schema: T,\n ): z.infer<T> {\n const settings =\n this.settings.get(componentName) ?? new ComponentSettings();\n\n const thisSettings = settings.get(settingKey, schema);\n const parentSettings = this.options.parentStore?.get(\n componentName,\n settingKey,\n schema,\n );\n\n const middleware = this.options.middleware?.get ?? defaultGetMiddleware;\n\n return middleware(\n componentName,\n settingKey,\n thisSettings,\n () => parentSettings,\n ) as z.infer<T>;\n }\n\n public clear(componentName: FlowComponentName, settingKey: string) {\n this.settings.get(componentName)?.clear(settingKey);\n this.options.parentStore?.clear(componentName, settingKey);\n }\n\n public get asJson() {\n const settingsObject = mobxMapToObject(this.settings);\n const asJson = mapValues(settingsObject, (v) => v.asJson);\n subscribeMobxObject(this.options.parentStore?.asJson);\n return asJson;\n }\n\n public static fromJson(json: SettingsJson, options?: SettingsStoreOptions) {\n const settings = mapValues(json, (v) => ComponentSettings.fromJson(v));\n return new SettingsStore(new ObservableMap(settings), options);\n }\n}\n\nexport type SettingsJson = SettingsStore[\"asJson\"];\n"],"names":[],"mappings":";;;;;;AAwBA,SAAS,oBAAoB,OAAA,EAAkB;AAE/C;AAEO,MAAM,aAAA,CAAc;AAAA,EACT,QAAA;AAAA,EAEA,OAAA;AAAA,EAET,YACL,QAAA,GAAW,IAAI,eAAoD,EACnE,OAAA,GAAgC,EAAC,EACjC;AACA,IAAA,IAAA,CAAK,QAAA,GAAW,QAAA;AAChB,IAAA,IAAA,CAAK,OAAA,GAAU,MAAA,CAAO,MAAA,CAAO,OAAO,CAAA;AACpC,IAAA,kBAAA,CAAmB,IAAA,EAAM;AAAA,MACvB,OAAA,EAAS;AAAA,KACV,CAAA;AAAA,EACH;AAAA,EAEO,GAAA,CACL,aAAA,EACA,UAAA,EACA,MAAA,EACA,KAAA,EACA;AACA,IAAA,MAAM,WACJ,IAAA,CAAK,QAAA,CAAS,IAAI,aAAa,CAAA,IAAK,IAAI,iBAAA,EAAkB;AAE5D,IAAA,MAAM,UAAA,GAAa,IAAA,CAAK,OAAA,CAAQ,UAAA,EAAY,GAAA,IAAO,oBAAA;AAEnD,IAAA,MAAM,cAAA,GAAiB,UAAA;AAAA,MACrB,aAAA;AAAA,MACA,UAAA;AAAA,MACA,KAAA;AAAA,MACA,CAAC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A,EAC3D;AAAA,EAEA,IAAW,MAAA,GAAS;AAClB,IAAA,MAAM,cAAA,GAAiB,eAAA,CAAgB,IAAA,CAAK,QAAQ,CAAA;AACpD,IAAA,MAAM,SAAS,SAAA,CAAU,cAAA,EAAgB,CAAC,CAAA,KAAM,EAAE,MAAM,CAAA;AACxD,IAAA,mBAAA,CAAoB,IAAA,CAAK,OAAA,CAAQ,WAAA,EAAa,MAAM,CAAA;AACpD,IAAA,OAAO,MAAA;AAAA,EACT;AAAA,EAEA,OAAc,QAAA,CAAS,IAAA,EAAoB,OAAA,EAAgC;AACzE,IAAA,MAAM,QAAA,GAAW,UAAU,IAAA,EAAM,CAAC,MAAM,iBAAA,CAAkB,QAAA,CAAS,CAAC,CAAC,CAAA;AACrE,IAAA,OAAO,IAAI,aAAA,CAAc,IAAI,aAAA,CAAc,QAAQ,GAAG,OAAO,CAAA;AAAA,EAC/D;AACF;;;;"}
@@ -52,6 +52,7 @@ const TextField = flowComponent("TextField", (props) => {
52
52
  color: "secondary",
53
53
  tunnelId: "button"
54
54
  },
55
+ CopyButton: { className: styles.button, tunnelId: "button" },
55
56
  ...fieldPropsContext
56
57
  };
57
58
  const handleChange = (v) => {
@@ -1 +1 @@
1
- {"version":3,"file":"TextField.mjs","sources":["../../../../../../../src/components/TextField/TextField.tsx"],"sourcesContent":["import {\n flowComponent,\n type FlowComponentProps,\n} from \"@/lib/componentFactory/flowComponent\";\nimport * as Aria from \"react-aria-components\";\nimport { type PropsWithChildren, useState } from \"react\";\nimport { useControlledHostValueProps } from \"@/lib/remote/useControlledHostValueProps\";\nimport { type PropsContext, PropsContextProvider } from \"@/lib/propsContext\";\nimport { useFieldComponent } from \"@/lib/hooks/useFieldComponent\";\nimport styles from \"./TextField.module.scss\";\nimport { FieldDescription } from \"@/components/FieldDescription\";\nimport { useLocalizedStringFormatter } from \"react-aria\";\nimport locales from \"./locales/*.locale.json\";\nimport { Button } from \"@/components/Button\";\nimport { IconHide, IconShow } from \"@/components/Icon/components/icons\";\nimport clsx from \"clsx\";\nimport { TunnelExit, TunnelProvider } from \"@mittwald/react-tunnel\";\n\nexport interface TextFieldProps\n extends\n PropsWithChildren<Omit<Aria.TextFieldProps, \"children\">>,\n Pick<Aria.InputProps, \"placeholder\">,\n FlowComponentProps<HTMLInputElement> {\n /** Whether a character count should be displayed inside the field description. */\n showCharacterCount?: boolean;\n}\n\n/** @flr-generate all */\nexport const TextField = flowComponent(\"TextField\", (props) => {\n const {\n className,\n showCharacterCount,\n form,\n placeholder,\n ref,\n type: typeFromProps,\n children,\n onChange,\n ...rest\n } = useControlledHostValueProps(props);\n\n const [charactersCount, setCharactersCount] = useState(\n props.defaultValue?.length ?? props.value?.length ?? 0,\n );\n\n const [type, setType] = useState(typeFromProps);\n\n const {\n FieldErrorView,\n FieldErrorCaptureContext,\n fieldPropsContext,\n fieldProps,\n } = useFieldComponent(props);\n\n const rootClassName = clsx(fieldProps.className, className);\n\n const propsContext: PropsContext = {\n Button: {\n className: styles.button,\n variant: \"plain\",\n color: \"secondary\",\n tunnelId: \"button\",\n },\n ...fieldPropsContext,\n };\n\n const handleChange = (v: string) => {\n if (showCharacterCount) {\n setCharactersCount(v.length);\n }\n if (onChange) {\n onChange(v);\n }\n };\n\n const translation = useLocalizedStringFormatter(locales);\n\n const charactersCountDescription = translation.format(\n \"textField.characters\",\n {\n count: charactersCount,\n maxCount: props.maxLength ?? 0,\n },\n );\n\n return (\n <Aria.TextField\n {...rest}\n {...fieldProps}\n className={rootClassName}\n onChange={handleChange}\n type={type}\n >\n <TunnelProvider>\n <PropsContextProvider props={propsContext}>\n <FieldErrorCaptureContext>\n {children}\n <div className={styles.inputContainer}>\n <Aria.Input\n form={form}\n placeholder={placeholder}\n className={styles.input}\n ref={ref}\n />\n <TunnelExit id=\"button\" />\n {typeFromProps === \"password\" && (\n <Button\n color=\"secondary\"\n variant=\"plain\"\n className={styles.button}\n onPress={() =>\n setType(type === \"password\" ? \"text\" : \"password\")\n }\n aria-label={translation.format(\n `textField.password.${type === \"password\" ? \"show\" : \"hide\"}`,\n )}\n >\n {type === \"password\" ? <IconShow /> : <IconHide />}\n </Button>\n )}\n </div>\n {showCharacterCount && (\n <FieldDescription>{charactersCountDescription}</FieldDescription>\n )}\n </FieldErrorCaptureContext>\n <FieldErrorView />\n </PropsContextProvider>\n </TunnelProvider>\n </Aria.TextField>\n );\n});\n\nexport default TextField;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA4BO,MAAM,SAAA,GAAY,aAAA,CAAc,WAAA,EAAa,CAAC,KAAA,KAAU;AAC7D,EAAA,MAAM;AAAA,IACJ,SAAA;AAAA,IACA,kBAAA;AAAA,IACA,IAAA;AAAA,IACA,WAAA;AAAA,IACA,GAAA;AAAA,IACA,IAAA,EAAM,aAAA;AAAA,IACN,QAAA;AAAA,IACA,QAAA;AAAA,IACA,GAAG;AAAA,GACL,GAAI,4BAA4B,KAAK,CAAA;AAErC,EAAA,MAAM,CAAC,eAAA,EAAiB,kBAAkB,CAAA,GAAI,QAAA;AAAA,IAC5C,KAAA,CAAM,YAAA,EAAc,MAAA,IAAU,KAAA,CAAM,OAAO,MAAA,IAAU;AAAA,GACvD;AAEA,EAAA,MAAM,CAAC,IAAA,EAAM,OAAO,CAAA,GAAI,SAAS,aAAa,CAAA;AAE9C,EAAA,MAAM;AAAA,IACJ,cAAA;AAAA,IACA,wBAAA;AAAA,IACA,iBAAA;AAAA,IACA;AAAA,GACF,GAAI,kBAAkB,KAAK,CAAA;AAE3B,EAAA,MAAM,aAAA,GAAgB,IAAA,CAAK,UAAA,CAAW,SAAA,EAAW,SAAS,CAAA;AAE1D,EAAA,MAAM,YAAA,GAA6B;AAAA,IACjC,MAAA,EAAQ;AAAA,MACN,WAAW,MAAA,CAAO,MAAA;AAAA,MAClB,OAAA,EAAS,OAAA;AAAA,MACT,KAAA,EAAO,WAAA;AAAA,MACP,QAAA,EAAU;AAAA,KACZ;AAAA,IACA,GAAG;AAAA,GACL;AAEA,EAA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gBACC,KAAA,EAAM,WAAA;AAAA,gBACN,OAAA,EAAQ,OAAA;AAAA,gBACR,WAAW,MAAA,CAAO,MAAA;AAAA,gBAClB,SAAS,MACP,OAAA,CAAQ,IAAA,KAAS,UAAA,GAAa,SAAS,UAAU,CAAA;AAAA,gBAEnD,cAAY,WAAA,CAAY,MAAA;AAAA,kBACtB,CAAA,mBAAA,EAAsB,IAAA,KAAS,UAAA,GAAa,MAAA,GAAS,MAAM,CAAA;AAAA,iBAC7D;AAAA,gBAEC,mBAAS,UAAA,mBAAa,GAAA,CAAC,QAAA,EAAA,EAAS,CAAA,uBAAM,QAAA,EAAA,EAAS;AAAA;AAAA;AAClD,WAAA,EAEJ,CAAA;AAAA,UACC,kBAAA,oBACC,GAAA,CAAC,gBAAA,EAAA,EAAkB,QAAA,EAAA,0BAAA,EAA2B;AAAA,SAAA,EAElD,CAAA;AAAA,4BACC,cAAA,EAAA,EAAe;AAAA,OAAA,EAClB,CAAA,EACF;AAAA;AAAA,GACF;AAEJ,CAAC;;;;"}
1
+ {"version":3,"file":"TextField.mjs","sources":["../../../../../../../src/components/TextField/TextField.tsx"],"sourcesContent":["import {\n flowComponent,\n type FlowComponentProps,\n} from \"@/lib/componentFactory/flowComponent\";\nimport * as Aria from \"react-aria-components\";\nimport { type PropsWithChildren, useState } from \"react\";\nimport { useControlledHostValueProps } from \"@/lib/remote/useControlledHostValueProps\";\nimport { type PropsContext, PropsContextProvider } from \"@/lib/propsContext\";\nimport { useFieldComponent } from \"@/lib/hooks/useFieldComponent\";\nimport styles from \"./TextField.module.scss\";\nimport { FieldDescription } from \"@/components/FieldDescription\";\nimport { useLocalizedStringFormatter } from \"react-aria\";\nimport locales from \"./locales/*.locale.json\";\nimport { Button } from \"@/components/Button\";\nimport { IconHide, IconShow } from \"@/components/Icon/components/icons\";\nimport clsx from \"clsx\";\nimport { TunnelExit, TunnelProvider } from \"@mittwald/react-tunnel\";\n\nexport interface TextFieldProps\n extends\n PropsWithChildren<Omit<Aria.TextFieldProps, \"children\">>,\n Pick<Aria.InputProps, \"placeholder\">,\n FlowComponentProps<HTMLInputElement> {\n /** Whether a character count should be displayed inside the field description. */\n showCharacterCount?: boolean;\n}\n\n/** @flr-generate all */\nexport const TextField = flowComponent(\"TextField\", (props) => {\n const {\n className,\n showCharacterCount,\n form,\n placeholder,\n ref,\n type: typeFromProps,\n children,\n onChange,\n ...rest\n } = useControlledHostValueProps(props);\n\n const [charactersCount, setCharactersCount] = useState(\n props.defaultValue?.length ?? props.value?.length ?? 0,\n );\n\n const [type, setType] = useState(typeFromProps);\n\n const {\n FieldErrorView,\n FieldErrorCaptureContext,\n fieldPropsContext,\n fieldProps,\n } = useFieldComponent(props);\n\n const rootClassName = clsx(fieldProps.className, className);\n\n const propsContext: PropsContext = {\n Button: {\n className: styles.button,\n variant: \"plain\",\n color: \"secondary\",\n tunnelId: \"button\",\n },\n CopyButton: { className: styles.button, tunnelId: \"button\" },\n ...fieldPropsContext,\n };\n\n const handleChange = (v: string) => {\n if (showCharacterCount) {\n setCharactersCount(v.length);\n }\n if (onChange) {\n onChange(v);\n }\n };\n\n const translation = useLocalizedStringFormatter(locales);\n\n const charactersCountDescription = translation.format(\n \"textField.characters\",\n {\n count: charactersCount,\n maxCount: props.maxLength ?? 0,\n },\n );\n\n return (\n <Aria.TextField\n {...rest}\n {...fieldProps}\n className={rootClassName}\n onChange={handleChange}\n type={type}\n >\n <TunnelProvider>\n <PropsContextProvider props={propsContext}>\n <FieldErrorCaptureContext>\n {children}\n <div className={styles.inputContainer}>\n <Aria.Input\n form={form}\n placeholder={placeholder}\n className={styles.input}\n ref={ref}\n />\n <TunnelExit id=\"button\" />\n {typeFromProps === \"password\" && (\n <Button\n color=\"secondary\"\n variant=\"plain\"\n className={styles.button}\n onPress={() =>\n setType(type === \"password\" ? \"text\" : \"password\")\n }\n aria-label={translation.format(\n `textField.password.${type === \"password\" ? \"show\" : \"hide\"}`,\n )}\n >\n {type === \"password\" ? <IconShow /> : <IconHide />}\n </Button>\n )}\n </div>\n {showCharacterCount && (\n <FieldDescription>{charactersCountDescription}</FieldDescription>\n )}\n </FieldErrorCaptureContext>\n <FieldErrorView />\n </PropsContextProvider>\n </TunnelProvider>\n </Aria.TextField>\n );\n});\n\nexport default TextField;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA4BO,MAAM,SAAA,GAAY,aAAA,CAAc,WAAA,EAAa,CAAC,KAAA,KAAU;AAC7D,EAAA,MAAM;AAAA,IACJ,SAAA;AAAA,IACA,kBAAA;AAAA,IACA,IAAA;AAAA,IACA,WAAA;AAAA,IACA,GAAA;AAAA,IACA,IAAA,EAAM,aAAA;AAAA,IACN,QAAA;AAAA,IACA,QAAA;AAAA,IACA,GAAG;AAAA,GACL,GAAI,4BAA4B,KAAK,CAAA;AAErC,EAAA,MAAM,CAAC,eAAA,EAAiB,kBAAkB,CAAA,GAAI,QAAA;AAAA,IAC5C,KAAA,CAAM,YAAA,EAAc,MAAA,IAAU,KAAA,CAAM,OAAO,MAAA,IAAU;AAAA,GACvD;AAEA,EAAA,MAAM,CAAC,IAAA,EAAM,OAAO,CAAA,GAAI,SAAS,aAAa,CAAA;AAE9C,EAAA,MAAM;AAAA,IACJ,cAAA;AAAA,IACA,wBAAA;AAAA,IACA,iBAAA;AAAA,IACA;AAAA,GACF,GAAI,kBAAkB,KAAK,CAAA;AAE3B,EAAA,MAAM,aAAA,GAAgB,IAAA,CAAK,UAAA,CAAW,SAAA,EAAW,SAAS,CAAA;AAE1D,EAAA,MAAM,YAAA,GAA6B;AAAA,IACjC,MAAA,EAAQ;AAAA,MACN,WAAW,MAAA,CAAO,MAAA;AAAA,MAClB,OAAA,EAAS,OAAA;AAAA,MACT,KAAA,EAAO,WAAA;AAAA,MACP,QAAA,EAAU;AAAA,KACZ;AAAA,IACA,YAAY,EAAE,SAAA,EAAW,MAAA,CAAO,MAAA,EAAQ,UAAU,QAAA,EAAS;AAAA,IAC3D,GAAG;AAAA,GACL;AAEA,EA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,gBACC,KAAA,EAAM,WAAA;AAAA,gBACN,OAAA,EAAQ,OAAA;AAAA,gBACR,WAAW,MAAA,CAAO,MAAA;AAAA,gBAClB,SAAS,MACP,OAAA,CAAQ,IAAA,KAAS,UAAA,GAAa,SAAS,UAAU,CAAA;AAAA,gBAEnD,cAAY,WAAA,CAAY,MAAA;AAAA,kBACtB,CAAA,mBAAA,EAAsB,IAAA,KAAS,UAAA,GAAa,MAAA,GAAS,MAAM,CAAA;AAAA,iBAC7D;AAAA,gBAEC,mBAAS,UAAA,mBAAa,GAAA,CAAC,QAAA,EAAA,EAAS,CAAA,uBAAM,QAAA,EAAA,EAAS;AAAA;AAAA;AAClD,WAAA,EAEJ,CAAA;AAAA,UACC,kBAAA,oBACC,GAAA,CAAC,gBAAA,EAAA,EAAkB,QAAA,EAAA,0BAAA,EAA2B;AAAA,SAAA,EAElD,CAAA;AAAA,4BACC,cAAA,EAAA,EAAe;AAAA,OAAA,EAClB,CAAA,EACF;AAAA;AAAA,GACF;AAEJ,CAAC;;;;"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=SettingsProvider.browser.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SettingsProvider.browser.test.d.ts","sourceRoot":"","sources":["../../../../src/components/SettingsProvider/SettingsProvider.browser.test.tsx"],"names":[],"mappings":""}
@@ -1,9 +1,9 @@
1
1
  import { FC, PropsWithChildren } from 'react';
2
2
  import { SupportedSettingsBackend } from './backends/types';
3
- import { SettingsStore } from './models/SettingsStore';
3
+ import { SettingsStore, SettingsStoreOptions } from './models/SettingsStore';
4
4
  type Props = PropsWithChildren & SupportedSettingsBackend & {
5
5
  id?: string;
6
- };
6
+ } & Pick<SettingsStoreOptions, "middleware">;
7
7
  export declare const useSettings: () => SettingsStore | undefined;
8
8
  export declare const SettingsProvider: FC<Props>;
9
9
  export default SettingsProvider;
@@ -1 +1 @@
1
- {"version":3,"file":"SettingsProvider.d.ts","sourceRoot":"","sources":["../../../../src/components/SettingsProvider/SettingsProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAQnD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAC;AAG7F,OAAO,EAAE,aAAa,EAAE,MAAM,oDAAoD,CAAC;AAGnF,KAAK,KAAK,GAAG,iBAAiB,GAC5B,wBAAwB,GAAG;IACzB,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,CAAC;AAIJ,eAAO,MAAM,WAAW,iCAA4B,CAAC;AAErD,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,KAAK,CA0BtC,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"SettingsProvider.d.ts","sourceRoot":"","sources":["../../../../src/components/SettingsProvider/SettingsProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAEnD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAC;AAG7F,OAAO,EACL,aAAa,EACb,KAAK,oBAAoB,EAC1B,MAAM,oDAAoD,CAAC;AAG5D,KAAK,KAAK,GAAG,iBAAiB,GAC5B,wBAAwB,GAAG;IACzB,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,GAAG,IAAI,CAAC,oBAAoB,EAAE,YAAY,CAAC,CAAC;AAI/C,eAAO,MAAM,WAAW,iCAA4B,CAAC;AAErD,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,KAAK,CA2BtC,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { GetSettingsMiddleware, SetSettingsMiddleware } from './types';
2
+ export declare const defaultGetMiddleware: GetSettingsMiddleware;
3
+ export declare const defaultSetMiddleware: SetSettingsMiddleware;
4
+ //# sourceMappingURL=defaultImplementations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaultImplementations.d.ts","sourceRoot":"","sources":["../../../../../src/components/SettingsProvider/middleware/defaultImplementations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAE5E,eAAO,MAAM,oBAAoB,EAAE,qBAKR,CAAC;AAE5B,eAAO,MAAM,oBAAoB,EAAE,qBAMlC,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { FlowComponentName } from '../../propTypes';
2
+ type UnknownSettings = unknown;
3
+ export type SetSettingsMiddleware = (component: FlowComponentName, key: string, settings: UnknownSettings, setParent: (settings: UnknownSettings) => void) => UnknownSettings;
4
+ export type GetSettingsMiddleware = (component: FlowComponentName, key: string, settings: UnknownSettings, getParent: () => UnknownSettings) => UnknownSettings;
5
+ export {};
6
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/components/SettingsProvider/middleware/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,KAAK,eAAe,GAAG,OAAO,CAAC;AAE/B,MAAM,MAAM,qBAAqB,GAAG,CAClC,SAAS,EAAE,iBAAiB,EAC5B,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,eAAe,EACzB,SAAS,EAAE,CAAC,QAAQ,EAAE,eAAe,KAAK,IAAI,KAC3C,eAAe,CAAC;AAErB,MAAM,MAAM,qBAAqB,GAAG,CAClC,SAAS,EAAE,iBAAiB,EAC5B,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,eAAe,EACzB,SAAS,EAAE,MAAM,eAAe,KAC7B,eAAe,CAAC"}
@@ -2,16 +2,25 @@ import { ObservableMap } from 'mobx';
2
2
  import { ComponentSettings } from './ComponentSettings';
3
3
  import { FlowComponentName } from '../../propTypes';
4
4
  import { ZodSchema, default as z } from 'zod';
5
+ import { GetSettingsMiddleware, SetSettingsMiddleware } from '../middleware/types';
6
+ export interface SettingsStoreOptions {
7
+ middleware?: {
8
+ get?: GetSettingsMiddleware;
9
+ set?: SetSettingsMiddleware;
10
+ };
11
+ parentStore?: SettingsStore;
12
+ }
5
13
  export declare class SettingsStore {
6
- readonly componentSettings: ObservableMap<FlowComponentName, ComponentSettings>;
7
- constructor(settings?: ObservableMap<keyof import('../../propTypes').FlowComponentPropsTypes, ComponentSettings>);
14
+ readonly settings: ObservableMap<FlowComponentName, ComponentSettings>;
15
+ readonly options: Readonly<SettingsStoreOptions>;
16
+ constructor(settings?: ObservableMap<keyof import('../../propTypes').FlowComponentPropsTypes, ComponentSettings>, options?: SettingsStoreOptions);
8
17
  set<T extends ZodSchema>(componentName: FlowComponentName, settingKey: string, schema: T, value: z.infer<T>): void;
9
18
  get<T extends ZodSchema>(componentName: FlowComponentName, settingKey: string, schema: T): z.infer<T>;
10
19
  clear(componentName: FlowComponentName, settingKey: string): void;
11
20
  get asJson(): {
12
21
  [x: string]: import('./ComponentSettings').ComponentSettingsJson;
13
22
  };
14
- static fromJson(json: SettingsJson): SettingsStore;
23
+ static fromJson(json: SettingsJson, options?: SettingsStoreOptions): SettingsStore;
15
24
  }
16
25
  export type SettingsJson = SettingsStore["asJson"];
17
26
  //# sourceMappingURL=SettingsStore.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SettingsStore.d.ts","sourceRoot":"","sources":["../../../../../src/components/SettingsProvider/models/SettingsStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,aAAa,EAAE,MAAM,MAAM,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wDAAwD,CAAC;AAC3F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AACrC,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAGzB,qBAAa,aAAa;IACxB,SAAgB,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AC;CAC9B;AAED,wBAAwB;AACxB,eAAO,MAAM,SAAS,qGAsGpB,CAAC;AAEH,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"TextField.d.ts","sourceRoot":"","sources":["../../../../src/components/TextField/TextField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,kBAAkB,EACxB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,IAAI,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,KAAK,iBAAiB,EAAY,MAAM,OAAO,CAAC;AAazD,MAAM,WAAW,cACf,SACE,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC,EACxD,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,aAAa,CAAC,EACpC,kBAAkB,CAAC,gBAAgB,CAAC;IACtC,kFAAkF;IAClF,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,wBAAwB;AACxB,eAAO,MAAM,SAAS,qGAuGpB,CAAC;AAEH,eAAe,SAAS,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mittwald/flow-react-components",
3
- "version": "0.2.0-alpha.757",
3
+ "version": "0.2.0-alpha.759",
4
4
  "type": "module",
5
5
  "description": "A React implementation of Flow, mittwald’s design system",
6
6
  "homepage": "https://mittwald.github.io/flow",
@@ -60,9 +60,9 @@
60
60
  "@codemirror/lint": "^6.9.5",
61
61
  "@internationalized/string-compiler": "^3.2.6",
62
62
  "@lezer/highlight": "^1.2.3",
63
- "@mittwald/flow-icons": "0.2.0-alpha.757",
63
+ "@mittwald/flow-icons": "0.2.0-alpha.759",
64
64
  "@mittwald/password-tools-js": "3.0.0-alpha.18",
65
- "@mittwald/react-tunnel": "0.2.0-alpha.757",
65
+ "@mittwald/react-tunnel": "0.2.0-alpha.759",
66
66
  "@mittwald/react-use-promise": "^4.2.2",
67
67
  "@react-aria/form": "^3.1.3",
68
68
  "@react-aria/live-announcer": "^3.4.4",
@@ -112,7 +112,7 @@
112
112
  "@lezer/generator": "^1.8.0",
113
113
  "@lezer/lr": "^1.4.8",
114
114
  "@mittwald/flow-core": "",
115
- "@mittwald/flow-design-tokens": "0.2.0-alpha.757",
115
+ "@mittwald/flow-design-tokens": "0.2.0-alpha.759",
116
116
  "@mittwald/flow-icons-base": "",
117
117
  "@mittwald/react-use-promise": "^4.2.2",
118
118
  "@mittwald/remote-dom-react": "1.2.2-mittwald.10",
@@ -165,7 +165,7 @@
165
165
  },
166
166
  "peerDependencies": {
167
167
  "@internationalized/date": "^3.10.0",
168
- "@mittwald/flow-icons-pro": "0.2.0-alpha.756",
168
+ "@mittwald/flow-icons-pro": "0.2.0-alpha.758",
169
169
  "@mittwald/react-use-promise": "^4.2.2",
170
170
  "next": "*",
171
171
  "react": "^19.2.0",
@@ -186,5 +186,5 @@
186
186
  "optional": true
187
187
  }
188
188
  },
189
- "gitHead": "1df541d3d16b3ca43ca509dbc2bff675baaff310"
189
+ "gitHead": "d61fe182def3f559f9c16995a3af07dcc5fe743a"
190
190
  }