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

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,4 +1,6 @@
1
1
  import { ComponentProps, FC, PropsWithChildren } from 'react';
2
- export type InlineCodeProps = PropsWithChildren<ComponentProps<"code">>;
2
+ export interface InlineCodeProps extends PropsWithChildren<ComponentProps<"code">> {
3
+ color?: "neutral" | "light" | "dark";
4
+ }
3
5
  export declare const InlineCode: FC<InlineCodeProps>;
4
6
  export default InlineCode;
@@ -10,6 +10,10 @@ import { ItemView } from './item/ItemView';
10
10
  import { Table } from './table/Table';
11
11
  import { Dispatch, SetStateAction } from 'react';
12
12
  export declare class List<T> {
13
+ readonly settingStorageKey?: string;
14
+ readonly supportsSettingsStorage: boolean;
15
+ private readonly filterSettingsStorageKey?;
16
+ private readonly defaultSettings?;
13
17
  readonly filters: Filter<T, never, never>[];
14
18
  readonly itemView?: ItemView<T>;
15
19
  readonly table?: Table<T>;
@@ -28,9 +32,11 @@ export declare class List<T> {
28
32
  static useNew<T>(shape: ListShape<T>): List<T>;
29
33
  get isFiltered(): boolean;
30
34
  get visibleSorting(): Sorting<T>[];
35
+ storeFilterDefaultSettings(): void;
36
+ getStoredFilterDefaultSettings(): Record<string, unknown[]> | undefined;
31
37
  getSorting(id: string): Sorting<T>;
32
38
  clearSorting(): void;
33
- clearFilters(): void;
39
+ resetFilters(): void;
34
40
  useIsEmpty(): boolean;
35
41
  }
36
42
  export default List;
@@ -3,7 +3,9 @@ import { default as List } from '../List';
3
3
  import { FilterMatcher, FilterMode, FilterShape } from './types';
4
4
  import { PropertyName, PropertyValueRenderMethod } from '../types';
5
5
  import { FilterValue } from './FilterValue';
6
+ import { default as z } from 'zod';
6
7
  export declare class Filter<T, TProp extends PropertyName<T>, TMatchValue> {
8
+ static readonly settingsStorageSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodUnknown, "many">>>;
7
9
  private _values?;
8
10
  private _valuesFromTableState?;
9
11
  readonly list: List<T>;
@@ -13,8 +15,9 @@ export declare class Filter<T, TProp extends PropertyName<T>, TMatchValue> {
13
15
  readonly renderItem: PropertyValueRenderMethod<TMatchValue>;
14
16
  readonly name?: string;
15
17
  private onFilterUpdateCallbacks;
16
- private readonly defaultSelectedValues;
18
+ private readonly defaultSelectedValues?;
17
19
  constructor(list: List<T>, shape: FilterShape<T, TProp, TMatchValue>);
20
+ private getStoredDefaultSelectedValues;
18
21
  updateInitialState(initialState: InitialTableState): void;
19
22
  updateTableColumnDef(def: ColumnDef<T>): void;
20
23
  private getReactTableFilterFn;
@@ -31,7 +34,9 @@ export declare class Filter<T, TProp extends PropertyName<T>, TMatchValue> {
31
34
  isValueActive(value: FilterValue): boolean;
32
35
  isActive(): boolean;
33
36
  deactivateValue(value: FilterValue): void;
34
- clearValues(): void;
37
+ hasChanged(): boolean;
38
+ private getInitialValues;
39
+ resetValues(): void;
35
40
  toggleValue(newValue: FilterValue): void;
36
41
  onFilterUpdated(cb: () => unknown): void;
37
42
  }
@@ -22,6 +22,7 @@ export interface ListSupportedComponentProps extends MultipleSelection {
22
22
  selectionBehavior?: SelectionBehavior;
23
23
  }
24
24
  export interface ListShape<T> extends ListSupportedComponentProps {
25
+ settingStorageKey?: string;
25
26
  loader?: IncrementalLoaderShape<T>;
26
27
  filters?: FilterShape<T, never, never>[];
27
28
  itemView?: ItemViewShape<T>;
@@ -0,0 +1,7 @@
1
+ import { FC, PropsWithChildren } from 'react';
2
+ import { SupportedSettingsBackend } from './backends/types';
3
+ import { SettingsStore } from './models/SettingsStore';
4
+ type Props = PropsWithChildren & SupportedSettingsBackend;
5
+ export declare const useSettings: () => SettingsStore | undefined;
6
+ export declare const SettingsProvider: FC<Props>;
7
+ export {};
@@ -0,0 +1,8 @@
1
+ import { SettingsBackend } from './types';
2
+ import { SettingsJson } from '../models/SettingsStore';
3
+ export declare class LocalStorageSettingsBackend implements SettingsBackend {
4
+ private readonly storageKey;
5
+ constructor(storageKey: string);
6
+ load(): Promise<SettingsJson>;
7
+ store(settings: SettingsJson): Promise<void>;
8
+ }
@@ -0,0 +1,2 @@
1
+ import { SupportedSettingsBackend, SettingsBackend } from './types';
2
+ export declare const settingsBackendFactory: (backend: SupportedSettingsBackend) => SettingsBackend;
@@ -0,0 +1,15 @@
1
+ import { SettingsJson } from '../models/SettingsStore';
2
+ export interface SettingsBackend {
3
+ store(settings: SettingsJson): Promise<void>;
4
+ load(): Promise<SettingsJson>;
5
+ }
6
+ interface LocalStorageSettingsBackend {
7
+ type: "localStorage";
8
+ storageKey: string;
9
+ }
10
+ interface CustomSettingsBackend {
11
+ type: "custom";
12
+ store: SettingsBackend;
13
+ }
14
+ export type SupportedSettingsBackend = LocalStorageSettingsBackend | CustomSettingsBackend;
15
+ export {};
@@ -0,0 +1,4 @@
1
+ import { SettingsProvider } from './SettingsProvider';
2
+ export { SettingsProvider } from './SettingsProvider';
3
+ export type { SettingsBackend } from './backends/types';
4
+ export default SettingsProvider;
@@ -0,0 +1,12 @@
1
+ import { ObservableMap } from 'mobx';
2
+ import { ZodSchema, default as z } from 'zod';
3
+ export declare class ComponentSettings {
4
+ readonly settings: ObservableMap<string, unknown>;
5
+ constructor(settings?: ObservableMap<string, unknown>);
6
+ set<T extends ZodSchema>(settingKey: string, schema: T, value: z.infer<T>): void;
7
+ get<T extends ZodSchema>(settingKey: string, schema: T): z.infer<T>;
8
+ clear(settingKey: string): void;
9
+ get asJson(): [string, unknown][];
10
+ static fromJson(json: ComponentSettingsJson): ComponentSettings;
11
+ }
12
+ export type ComponentSettingsJson = ComponentSettings["asJson"];
@@ -0,0 +1,16 @@
1
+ import { ObservableMap } from 'mobx';
2
+ import { ComponentSettings } from './ComponentSettings';
3
+ import { FlowComponentName } from '../../propTypes';
4
+ import { ZodSchema, default as z } from 'zod';
5
+ export declare class SettingsStore {
6
+ readonly componentSettings: ObservableMap<FlowComponentName, ComponentSettings>;
7
+ constructor(settings?: ObservableMap<keyof import('../../propTypes').FlowComponentPropsTypes, ComponentSettings>);
8
+ set<T extends ZodSchema>(componentName: FlowComponentName, settingKey: string, schema: T, value: z.infer<T>): void;
9
+ get<T extends ZodSchema>(componentName: FlowComponentName, settingKey: string, schema: T): z.infer<T>;
10
+ clear(componentName: FlowComponentName, settingKey: string): void;
11
+ get asJson(): {
12
+ [k: string]: [string, unknown][];
13
+ };
14
+ static fromJson(json: SettingsJson): SettingsStore;
15
+ }
16
+ export type SettingsJson = SettingsStore["asJson"];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mittwald/flow-react-components",
3
- "version": "0.1.0-alpha.225",
3
+ "version": "0.1.0-alpha.227",
4
4
  "type": "module",
5
5
  "description": "A React implementation of Flow, mittwald’s design system",
6
6
  "homepage": "https://mittwald.github.io/flow",
@@ -218,6 +218,10 @@
218
218
  "types": "./dist/types/components/Separator/index.d.ts",
219
219
  "import": "./dist/Separator.js"
220
220
  },
221
+ "./SettingsProvider": {
222
+ "types": "./dist/types/components/SettingsProvider/index.d.ts",
223
+ "import": "./dist/SettingsProvider.js"
224
+ },
221
225
  "./Skeleton": {
222
226
  "types": "./dist/types/components/Skeleton/index.d.ts",
223
227
  "import": "./dist/Skeleton.js"
@@ -301,7 +305,7 @@
301
305
  "@chakra-ui/live-region": "^2.1.0",
302
306
  "@internationalized/date": "^3.5.5",
303
307
  "@internationalized/string-compiler": "^3.2.4",
304
- "@mittwald/react-tunnel": "^0.1.0-alpha.225",
308
+ "@mittwald/react-tunnel": "^0.1.0-alpha.227",
305
309
  "@mittwald/react-use-promise": "^2.4.0",
306
310
  "@react-aria/utils": "^3.25.2",
307
311
  "@react-types/shared": "^3.24.1",
@@ -323,11 +327,12 @@
323
327
  "react-children-utilities": "^2.10.0",
324
328
  "react-stately": "^3.32.2",
325
329
  "remeda": "^2.11.0",
326
- "use-callback-ref": "^1.3.2"
330
+ "use-callback-ref": "^1.3.2",
331
+ "zod": "^3.23.8"
327
332
  },
328
333
  "devDependencies": {
329
334
  "@faker-js/faker": "^8.4.1",
330
- "@mittwald/flow-design-tokens": "^0.1.0-alpha.225",
335
+ "@mittwald/flow-design-tokens": "^0.1.0-alpha.227",
331
336
  "@mittwald/react-use-promise": "^2.4.0",
332
337
  "@nx/storybook": "^19.6.4",
333
338
  "@storybook/addon-a11y": "^8.2.9",
@@ -405,5 +410,5 @@
405
410
  "optional": true
406
411
  }
407
412
  },
408
- "gitHead": "7445ae14a45ac757363d72adf1da7aeaa3bb3043"
413
+ "gitHead": "b97287d9170c04ea38d37c613961ef2cd3c7fab0"
409
414
  }
@@ -1,9 +0,0 @@
1
- "use client"
2
- /* */
3
- import t from "react";
4
- import { IconSettings as o } from "@tabler/icons-react";
5
- import { I as n } from "./Icon-0QYDidQk.js";
6
- const s = (e) => /* @__PURE__ */ t.createElement(n, { ...e }, /* @__PURE__ */ t.createElement(o, null));
7
- export {
8
- s as I
9
- };