@panneau/core 5.0.0-alpha.2 → 5.0.0-alpha.20
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/README.md +4 -2
- package/dist/commands.d.ts +38 -0
- package/dist/commands.d.ts.map +1 -0
- package/dist/commands.js +22 -0
- package/dist/commands.js.map +1 -0
- package/dist/definition/abilities.d.ts +33 -5
- package/dist/definition/abilities.d.ts.map +1 -1
- package/dist/definition/abilities.js +44 -6
- package/dist/definition/abilities.js.map +1 -1
- package/dist/definition/form.d.ts +8 -3
- package/dist/definition/form.d.ts.map +1 -1
- package/dist/definition/form.js +36 -4
- package/dist/definition/form.js.map +1 -1
- package/dist/definition/itemActions.d.ts +53 -0
- package/dist/definition/itemActions.d.ts.map +1 -0
- package/dist/definition/itemActions.js +64 -0
- package/dist/definition/itemActions.js.map +1 -0
- package/dist/definition/list.d.ts +42 -1
- package/dist/definition/list.d.ts.map +1 -1
- package/dist/definition/list.js +103 -16
- package/dist/definition/list.js.map +1 -1
- package/dist/definition/resource.d.ts +2 -2
- package/dist/definition/resource.js +1 -1
- package/dist/definition/resource.js.map +1 -1
- package/dist/form/form.d.ts +8 -3
- package/dist/form/form.d.ts.map +1 -1
- package/dist/form/form.js +1 -0
- package/dist/form/form.js.map +1 -1
- package/dist/form/messages.d.ts.map +1 -1
- package/dist/form/messages.js +11 -1
- package/dist/form/messages.js.map +1 -1
- package/dist/form/problem.d.ts +1 -1
- package/dist/form/problem.js.map +1 -1
- package/dist/form/selectors.d.ts +1 -1
- package/dist/form/selectors.js.map +1 -1
- package/dist/form/store.d.ts +1 -1
- package/dist/form/store.js.map +1 -1
- package/dist/index.d.ts +23 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -3
- package/dist/list/calendar.d.ts +15 -0
- package/dist/list/calendar.d.ts.map +1 -0
- package/dist/list/calendar.js +42 -0
- package/dist/list/calendar.js.map +1 -0
- package/dist/list/list.d.ts +40 -3
- package/dist/list/list.d.ts.map +1 -1
- package/dist/list/list.js +152 -16
- package/dist/list/list.js.map +1 -1
- package/dist/list/router.js.map +1 -1
- package/dist/list/viewStore.d.ts +36 -0
- package/dist/list/viewStore.d.ts.map +1 -0
- package/dist/list/viewStore.js +54 -0
- package/dist/list/viewStore.js.map +1 -0
- package/dist/plugins.d.ts +16 -2
- package/dist/plugins.d.ts.map +1 -1
- package/dist/plugins.js +4 -2
- package/dist/plugins.js.map +1 -1
- package/dist/preview.d.ts +14 -0
- package/dist/preview.d.ts.map +1 -0
- package/dist/react/leaveGuards.d.ts +34 -0
- package/dist/react/leaveGuards.d.ts.map +1 -0
- package/dist/react/leaveGuards.js +84 -0
- package/dist/react/leaveGuards.js.map +1 -0
- package/dist/react/provider.d.ts +4 -4
- package/dist/react/provider.js +3 -1
- package/dist/react/provider.js.map +1 -1
- package/dist/react/useForm.d.ts +1 -1
- package/dist/react/useForm.js.map +1 -1
- package/dist/react/useList.d.ts +1 -1
- package/dist/react/useList.js.map +1 -1
- package/dist/values.d.ts +1 -1
- package/dist/values.d.ts.map +1 -1
- package/dist/values.js +5 -1
- package/dist/values.js.map +1 -1
- package/dist/widget.d.ts +15 -0
- package/dist/widget.d.ts.map +1 -0
- package/package.json +4 -4
package/dist/react/useForm.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Form, type FormOptions, type FormState } from '../form/form';
|
|
1
|
+
import { type Form, type FormOptions, type FormState } from '../form/form.js';
|
|
2
2
|
export interface UseFormResult extends FormState {
|
|
3
3
|
/** The form, to change values, submit, reset or resolve a conflict. */
|
|
4
4
|
form: Form;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useForm.js","names":["_c"],"sources":["../../src/react/useForm.ts"],"sourcesContent":["import { useLayoutEffect, useState, useSyncExternalStore } from 'react';\n\nimport { type Form, type FormOptions, type FormState, createForm } from '../form/form';\nimport { selectErrors, selectValue } from '../form/selectors';\n\nexport interface UseFormResult extends FormState {\n /** The form, to change values, submit, reset or resolve a conflict. */\n form: Form;\n}\n\n/**\n * Creates a form for the life of the component. `fields`, `locales`, `formatError` and `onSubmit`\n * follow the latest render; initial values and the version don't: call `form.reset()`, or give\n * the component a new `key`, to start from another item.\n *\n * Read the returned state with the selectors (`selectErrors(state, path)`,\n * `selectVisible(state, field)`…), not with the form's reading methods, which go stale with the\n * React Compiler (see {@link Form}).\n */\nexport function useForm(options: FormOptions): UseFormResult {\n const [form] = useState(() => createForm(options));\n const { fields, locales, formatError, onSubmit } = options;\n useLayoutEffect(() => {\n form.setOptions({ fields, locales, formatError, onSubmit });\n });\n const state = useSyncExternalStore(form.subscribe, form.getState, form.getState);\n return { ...state, form };\n}\n\nexport interface UseFormFieldResult {\n value: unknown;\n onChange: (value: unknown) => void;\n onBlur: () => void;\n /** Errors at the path, and at nested paths (`title.fr` for `title`). */\n errors: string[];\n touched: boolean;\n}\n\n/** Props for a controlled field at a dot path of a form. */\nexport function useFormField(form: Form, path: string): UseFormFieldResult {\n const state = useSyncExternalStore(form.subscribe, form.getState, form.getState);\n return {\n value: selectValue(state, path),\n onChange: (value) => form.setValue(path, value),\n onBlur: () => form.blur(path),\n errors: selectErrors(state, path, { nested: true }),\n touched: state.touched.has(path),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;AAmBA,
|
|
1
|
+
{"version":3,"file":"useForm.js","names":["useLayoutEffect","useState","useSyncExternalStore","Form","FormOptions","FormState","createForm","selectErrors","selectValue","UseFormResult","form","useForm","options","$","_c","t0","fields","locales","formatError","onSubmit","t1","setOptions","state","subscribe","getState","t2","UseFormFieldResult","value","onChange","onBlur","errors","touched","useFormField","path","setValue","blur","t3","nested","t4","has","t5","_c"],"sources":["../../src/react/useForm.ts"],"sourcesContent":["import { useLayoutEffect, useState, useSyncExternalStore } from 'react';\n\nimport { type Form, type FormOptions, type FormState, createForm } from '../form/form';\nimport { selectErrors, selectValue } from '../form/selectors';\n\nexport interface UseFormResult extends FormState {\n /** The form, to change values, submit, reset or resolve a conflict. */\n form: Form;\n}\n\n/**\n * Creates a form for the life of the component. `fields`, `locales`, `formatError` and `onSubmit`\n * follow the latest render; initial values and the version don't: call `form.reset()`, or give\n * the component a new `key`, to start from another item.\n *\n * Read the returned state with the selectors (`selectErrors(state, path)`,\n * `selectVisible(state, field)`…), not with the form's reading methods, which go stale with the\n * React Compiler (see {@link Form}).\n */\nexport function useForm(options: FormOptions): UseFormResult {\n const [form] = useState(() => createForm(options));\n const { fields, locales, formatError, onSubmit } = options;\n useLayoutEffect(() => {\n form.setOptions({ fields, locales, formatError, onSubmit });\n });\n const state = useSyncExternalStore(form.subscribe, form.getState, form.getState);\n return { ...state, form };\n}\n\nexport interface UseFormFieldResult {\n value: unknown;\n onChange: (value: unknown) => void;\n onBlur: () => void;\n /** Errors at the path, and at nested paths (`title.fr` for `title`). */\n errors: string[];\n touched: boolean;\n}\n\n/** Props for a controlled field at a dot path of a form. */\nexport function useFormField(form: Form, path: string): UseFormFieldResult {\n const state = useSyncExternalStore(form.subscribe, form.getState, form.getState);\n return {\n value: selectValue(state, path),\n onChange: (value) => form.setValue(path, value),\n onBlur: () => form.blur(path),\n errors: selectErrors(state, path, { nested: true }),\n touched: state.touched.has(path),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;AAmBA,SAAOW,QAAAC,SAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAAC;CAAA,IAAAF,EAAA,OAAAD,SAAA;EACqBG,WAAMT,WAAWM,OAAO;EAACC,EAAA,KAAAD;EAAAC,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAAjD,MAAA,CAAAH,QAAeT,SAASc,EAAyB;CACjD,MAAA,EAAAC,QAAAC,SAAAC,aAAAC,aAAmDP;CAAQ,IAAAQ;CAAA,IAAAP,EAAA,OAAAG,UAAAH,EAAA,OAAAH,QAAAG,EAAA,OAAAK,eAAAL,EAAA,OAAAI,WAAAJ,EAAA,OAAAM,UAAA;EAC3CC,WAAA;GACZV,K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AA,OAAAS,OAAA;EACrBc,KAAA7B,aAAae,OAAOW,MAAM,EAAAI,QAAU,KAAK,CAAC;EAACxB,EAAA,KAAAoB;EAAApB,EAAA,KAAAS;EAAAT,EAAA,KAAAuB;CAAA,OAAAA,KAAAvB,EAAA;CAAA,IAAAyB;CAAA,IAAAzB,EAAA,QAAAoB,QAAApB,EAAA,QAAAS,MAAAS,SAAA;EAC1CO,KAAAhB,MAAKS,QAAQQ,IAAKN,IAAI;EAACpB,EAAA,MAAAoB;EAAApB,EAAA,MAAAS,MAAAS;EAAAlB,EAAA,MAAAyB;CAAA,OAAAA,KAAAzB,EAAA;CAAA,IAAA2B;CAAA,IAAA3B,EAAA,QAAAE,MAAAF,EAAA,QAAAO,MAAAP,EAAA,QAAAY,MAAAZ,EAAA,QAAAuB,MAAAvB,EAAA,QAAAyB,IAAA;EAL7BE,KAAA;GAAAb,OACIZ;GAAwBa,UACrBR;GAAqCS,QACvCJ;GAAqBK,QACrBM;GAA2CL,SAC1CO;EACb;EAACzB,EAAA,MAAAE;EAAAF,EAAA,MAAAO;EAAAP,EAAA,MAAAY;EAAAZ,EAAA,MAAAuB;EAAAvB,EAAA,MAAAyB;EAAAzB,EAAA,MAAA2B;CAAA,OAAAA,KAAA3B,EAAA;CAAA,OANM2B;AAMN"}
|
package/dist/react/useList.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type List, type ListOptions, type ListState } from '../list/list';
|
|
1
|
+
import { type List, type ListOptions, type ListState } from '../list/list.js';
|
|
2
2
|
export interface UseListResult extends ListState {
|
|
3
3
|
/** The list, to change the query and the selection. */
|
|
4
4
|
list: List;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useList.js","names":["_c"],"sources":["../../src/react/useList.ts"],"sourcesContent":["import { useState, useSyncExternalStore } from 'react';\n\nimport { type List, type ListOptions, type ListState, createList } from '../list/list';\nimport { usePanneau } from './provider';\n\nexport interface UseListResult extends ListState {\n /** The list, to change the query and the selection. */\n list: List;\n}\n\n/**\n * Creates a list for the life of the component. Without a `router` option, the query is kept in\n * the router of the closest `PanneauProvider`, if any. Pass `router: null` to keep it in memory.\n */\nexport function useList(options: ListOptions = {}): UseListResult {\n const context = usePanneau();\n const [list] = useState(() =>\n createList({\n ...options,\n router: options.router === undefined ? context.router : options.router,\n }),\n );\n const state = useSyncExternalStore(list.subscribe, list.getState, list.getState);\n return { ...state, list };\n}\n"],"mappings":";;;;;;;;;AAcA,
|
|
1
|
+
{"version":3,"file":"useList.js","names":["useState","useSyncExternalStore","List","ListOptions","ListState","createList","usePanneau","UseListResult","list","useList","t0","$","_c","t1","undefined","options","context","t2","router","state","subscribe","getState","t3","_c"],"sources":["../../src/react/useList.ts"],"sourcesContent":["import { useState, useSyncExternalStore } from 'react';\n\nimport { type List, type ListOptions, type ListState, createList } from '../list/list';\nimport { usePanneau } from './provider';\n\nexport interface UseListResult extends ListState {\n /** The list, to change the query and the selection. */\n list: List;\n}\n\n/**\n * Creates a list for the life of the component. Without a `router` option, the query is kept in\n * the router of the closest `PanneauProvider`, if any. Pass `router: null` to keep it in memory.\n */\nexport function useList(options: ListOptions = {}): UseListResult {\n const context = usePanneau();\n const [list] = useState(() =>\n createList({\n ...options,\n router: options.router === undefined ? context.router : options.router,\n }),\n );\n const state = useSyncExternalStore(list.subscribe, list.getState, list.getState);\n return { ...state, list };\n}\n"],"mappings":";;;;;;;;;AAcA,SAAOS,QAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAA,IAAAC;CAAA,IAAAF,EAAA,OAAAD,IAAA;EAAiBG,KAAAH,OAAAI,KAAAA,IAAA,CAAwB,IAAxBJ;EAAyBC,EAAA,KAAAD;EAAAC,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAAzB,MAAAI,UAAAF;CACpB,MAAAG,UAAgBV,WAAW;CAAE,IAAAW;CAAA,IAAAN,EAAA,OAAAK,WAAAL,EAAA,OAAAI,SAAA;EACLE,WACpBZ,WAAW;GAAA,GACJU;GAAOG,QACFH,QAAOG,WAAYJ,KAAAA,IAAYE,QAAOE,SAAUH,QAAOG;EACnE,CAAC;EAACP,EAAA,KAAAK;EAAAL,EAAA,KAAAI;EAAAJ,EAAA,KAAAM;CAAA,OAAAA,KAAAN,EAAA;CAJN,MAAA,CAAAH,QAAeR,SAASiB,EAKxB;CACA,MAAAE,QAAclB,qBAAqBO,KAAIY,WAAYZ,KAAIa,UAAWb,KAAIa,QAAS;CAAE,IAAAC;CAAA,IAAAX,EAAA,OAAAH,QAAAG,EAAA,OAAAQ,OAAA;EAC1EG,KAAA;GAAA,GAAKH;GAAKX;EAAO;EAACG,EAAA,KAAAH;EAAAG,EAAA,KAAAQ;EAAAR,EAAA,KAAAW;CAAA,OAAAA,KAAAX,EAAA;CAAA,OAAlBW;AAAkB"}
|
package/dist/values.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export type Values = Record<string, unknown>;
|
|
|
5
5
|
* objects and arrays are created: numeric segments create arrays.
|
|
6
6
|
*/
|
|
7
7
|
export declare function setValue<T extends Values>(values: T, path: string, value: unknown): T;
|
|
8
|
-
/** Deep equality of JSON-like values. */
|
|
8
|
+
/** Deep equality of JSON-like values. Files (`Blob`, `File`) are only equal to themselves. */
|
|
9
9
|
export declare function isEqual(a: unknown, b: unknown): boolean;
|
|
10
10
|
/** Whether `path` is `parent` or inside it (`title.fr` is inside `title`). */
|
|
11
11
|
export declare function isPathWithin(path: string, parent: string): boolean;
|
package/dist/values.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"values.d.ts","sourceRoot":"","sources":["../src/values.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAuB7C;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,CAAC,CAKrF;
|
|
1
|
+
{"version":3,"file":"values.d.ts","sourceRoot":"","sources":["../src/values.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAuB7C;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,CAAC,CAKrF;AAMD,8FAA8F;AAC9F,wBAAgB,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAoBvD;AAED,8EAA8E;AAC9E,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAElE"}
|
package/dist/values.js
CHANGED
|
@@ -24,10 +24,14 @@ function setValue(values, path, value) {
|
|
|
24
24
|
if (path === "") return value;
|
|
25
25
|
return setIn(values, path.split("."), value);
|
|
26
26
|
}
|
|
27
|
-
|
|
27
|
+
function isBlob(value) {
|
|
28
|
+
return typeof Blob !== "undefined" && value instanceof Blob;
|
|
29
|
+
}
|
|
30
|
+
/** Deep equality of JSON-like values. Files (`Blob`, `File`) are only equal to themselves. */
|
|
28
31
|
function isEqual(a, b) {
|
|
29
32
|
if (Object.is(a, b)) return true;
|
|
30
33
|
if (a === null || b === null || typeof a !== "object" || typeof b !== "object") return false;
|
|
34
|
+
if (isBlob(a) || isBlob(b)) return false;
|
|
31
35
|
if (Array.isArray(a) !== Array.isArray(b)) return false;
|
|
32
36
|
if (Array.isArray(a) && Array.isArray(b)) return a.length === b.length && a.every((item, index) => isEqual(item, b[index]));
|
|
33
37
|
const left = a;
|
package/dist/values.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"values.js","names":[],"sources":["../src/values.ts"],"sourcesContent":["/** Values of a form or an item, keyed by field name. */\nexport type Values = Record<string, unknown>;\n\nfunction isIndex(segment: string): boolean {\n return /^\\d+$/.test(segment);\n}\n\nfunction setIn(current: unknown, segments: string[], value: unknown): unknown {\n const [segment, ...rest] = segments;\n if (segment === undefined) {\n return value;\n }\n if (isIndex(segment)) {\n const array = Array.isArray(current) ? [...(current as unknown[])] : [];\n array[Number(segment)] = setIn(array[Number(segment)], rest, value);\n return array;\n }\n const record =\n current !== null && typeof current === 'object' && !Array.isArray(current)\n ? (current as Record<string, unknown>)\n : {};\n return { ...record, [segment]: setIn(record[segment], rest, value) };\n}\n\n/**\n * Returns a copy of `values` with `value` at a dot path (`title.fr`, `blocks.2.body`). Missing\n * objects and arrays are created: numeric segments create arrays.\n */\nexport function setValue<T extends Values>(values: T, path: string, value: unknown): T {\n if (path === '') {\n return value as T;\n }\n return setIn(values, path.split('.'), value) as T;\n}\n\n/** Deep equality of JSON-like values. */\nexport function isEqual(a: unknown, b: unknown): boolean {\n if (Object.is(a, b)) {\n return true;\n }\n if (a === null || b === null || typeof a !== 'object' || typeof b !== 'object') {\n return false;\n }\n if (Array.isArray(a) !== Array.isArray(b)) {\n return false;\n }\n if (Array.isArray(a) && Array.isArray(b)) {\n return a.length === b.length && a.every((item, index) => isEqual(item, b[index]));\n }\n const left = a as Record<string, unknown>;\n const right = b as Record<string, unknown>;\n const keys = new Set([...Object.keys(left), ...Object.keys(right)]);\n return [...keys].every((key) => isEqual(left[key], right[key]));\n}\n\n/** Whether `path` is `parent` or inside it (`title.fr` is inside `title`). */\nexport function isPathWithin(path: string, parent: string): boolean {\n return parent === '' || path === parent || path.startsWith(`${parent}.`);\n}\n"],"mappings":";AAGA,
|
|
1
|
+
{"version":3,"file":"values.js","names":["Values","Record","isIndex","segment","test","setIn","current","segments","value","rest","undefined","array","Array","isArray","Number","record","setValue","values","T","path","split","isBlob","Blob","isEqual","a","b","Object","is","length","every","item","index","left","right","keys","Set","key","isPathWithin","parent","startsWith"],"sources":["../src/values.ts"],"sourcesContent":["/** Values of a form or an item, keyed by field name. */\nexport type Values = Record<string, unknown>;\n\nfunction isIndex(segment: string): boolean {\n return /^\\d+$/.test(segment);\n}\n\nfunction setIn(current: unknown, segments: string[], value: unknown): unknown {\n const [segment, ...rest] = segments;\n if (segment === undefined) {\n return value;\n }\n if (isIndex(segment)) {\n const array = Array.isArray(current) ? [...(current as unknown[])] : [];\n array[Number(segment)] = setIn(array[Number(segment)], rest, value);\n return array;\n }\n const record =\n current !== null && typeof current === 'object' && !Array.isArray(current)\n ? (current as Record<string, unknown>)\n : {};\n return { ...record, [segment]: setIn(record[segment], rest, value) };\n}\n\n/**\n * Returns a copy of `values` with `value` at a dot path (`title.fr`, `blocks.2.body`). Missing\n * objects and arrays are created: numeric segments create arrays.\n */\nexport function setValue<T extends Values>(values: T, path: string, value: unknown): T {\n if (path === '') {\n return value as T;\n }\n return setIn(values, path.split('.'), value) as T;\n}\n\nfunction isBlob(value: unknown): value is Blob {\n return typeof Blob !== 'undefined' && value instanceof Blob;\n}\n\n/** Deep equality of JSON-like values. Files (`Blob`, `File`) are only equal to themselves. */\nexport function isEqual(a: unknown, b: unknown): boolean {\n if (Object.is(a, b)) {\n return true;\n }\n if (a === null || b === null || typeof a !== 'object' || typeof b !== 'object') {\n return false;\n }\n if (isBlob(a) || isBlob(b)) {\n return false;\n }\n if (Array.isArray(a) !== Array.isArray(b)) {\n return false;\n }\n if (Array.isArray(a) && Array.isArray(b)) {\n return a.length === b.length && a.every((item, index) => isEqual(item, b[index]));\n }\n const left = a as Record<string, unknown>;\n const right = b as Record<string, unknown>;\n const keys = new Set([...Object.keys(left), ...Object.keys(right)]);\n return [...keys].every((key) => isEqual(left[key], right[key]));\n}\n\n/** Whether `path` is `parent` or inside it (`title.fr` is inside `title`). */\nexport function isPathWithin(path: string, parent: string): boolean {\n return parent === '' || path === parent || path.startsWith(`${parent}.`);\n}\n"],"mappings":";AAGA,SAASE,QAAQC,SAA0B;CACvC,OAAO,Q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AEM,MAAM,CAAC;CAEpF,MAAMC,OAAOR;CACb,MAAMS,QAAQR;CAEd,OAAO,CAAC,mBAAGS,IADMC,IAAI,CAAC,GAAGT,OAAOQ,KAAKF,IAAI,GAAG,GAAGN,OAAOQ,KAAKD,KAAK,CAAC,CACtDC,CAAI,CAAC,CAACL,OAAOO,QAAQb,QAAQS,KAAKI,MAAMH,MAAMG,IAAI,CAAC;AAClE;;AAGA,SAAgBC,aAAalB,MAAcmB,QAAyB;CAChE,OAAOA,WAAW,MAAMnB,SAASmB,UAAUnB,KAAKoB,WAAW,GAAGD,OAAM,EAAG;AAC3E"}
|
package/dist/widget.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Definition, Widget } from '@panneau/protocol';
|
|
2
|
+
/**
|
|
3
|
+
* Props of a widget of a plugin (the `widgets` of a plugin), for a widget of the dashboard whose
|
|
4
|
+
* `type` it provides (decision 0064). The dashboard gets the data from
|
|
5
|
+
* `GET /dashboard/widgets/{widget}` and draws the frame, the label, the skeleton, the error with
|
|
6
|
+
* its retry, and nothing on a `403`: the component draws the data.
|
|
7
|
+
*/
|
|
8
|
+
export interface WidgetProps {
|
|
9
|
+
/** The widget, as declared in the definition: its `settings` are the plugin's own. */
|
|
10
|
+
widget: Widget;
|
|
11
|
+
/** The data of the widget, in the shape the plugin's backend gives it. */
|
|
12
|
+
data: unknown;
|
|
13
|
+
definition: Definition;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=widget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widget.d.ts","sourceRoot":"","sources":["../src/widget.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE5D;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IACxB,sFAAsF;IACtF,MAAM,EAAE,MAAM,CAAC;IACf,0EAA0E;IAC1E,IAAI,EAAE,OAAO,CAAC;IACd,UAAU,EAAE,UAAU,CAAC;CAC1B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@panneau/core",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.20",
|
|
4
4
|
"description": "The engine of Panneau: plugin registry, definition to forms and lists, form and list state, with React hooks. No UI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"dist"
|
|
23
23
|
],
|
|
24
24
|
"scripts": {
|
|
25
|
-
"build": "vite build &&
|
|
25
|
+
"build": "vite build && node ../../scripts/declarations.js",
|
|
26
26
|
"typecheck": "tsc --noEmit",
|
|
27
|
-
"api": "
|
|
27
|
+
"api": "node ../../scripts/declarations.js && node ../../scripts/api-report.js"
|
|
28
28
|
},
|
|
29
29
|
"publishConfig": {
|
|
30
30
|
"access": "public"
|
|
@@ -33,6 +33,6 @@
|
|
|
33
33
|
"react": "^19.2.0"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@panneau/protocol": "5.0.0-alpha.
|
|
36
|
+
"@panneau/protocol": "5.0.0-alpha.20"
|
|
37
37
|
}
|
|
38
38
|
}
|