@entifix/react-controls 0.20.3 → 0.22.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/i18n/catalog/en.d.ts.map +1 -1
- package/dist/i18n/catalog/en.js +7 -0
- package/dist/i18n/catalog/en.js.map +1 -1
- package/dist/i18n/catalog/es.d.ts +7 -0
- package/dist/i18n/catalog/es.d.ts.map +1 -1
- package/dist/i18n/catalog/es.js +7 -0
- package/dist/i18n/catalog/es.js.map +1 -1
- package/dist/i18n/catalog/index.d.ts +14 -0
- package/dist/i18n/catalog/index.d.ts.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/primitives.d.ts +2 -0
- package/dist/primitives.d.ts.map +1 -1
- package/dist/primitives.js +2 -0
- package/dist/primitives.js.map +1 -1
- package/dist/ui/atoms/cell-value/cell-value.d.ts +6 -0
- package/dist/ui/atoms/cell-value/cell-value.d.ts.map +1 -1
- package/dist/ui/atoms/cell-value/cell-value.js +108 -14
- package/dist/ui/atoms/cell-value/cell-value.js.map +1 -1
- package/dist/ui/atoms/cell-value/index.d.ts +1 -0
- package/dist/ui/atoms/cell-value/index.d.ts.map +1 -1
- package/dist/ui/atoms/cell-value/index.js +1 -0
- package/dist/ui/atoms/cell-value/index.js.map +1 -1
- package/dist/ui/atoms/cell-value/use-record-label.d.ts +16 -0
- package/dist/ui/atoms/cell-value/use-record-label.d.ts.map +1 -0
- package/dist/ui/atoms/cell-value/use-record-label.js +55 -0
- package/dist/ui/atoms/cell-value/use-record-label.js.map +1 -0
- package/dist/ui/atoms/media-image/index.d.ts +2 -0
- package/dist/ui/atoms/media-image/index.d.ts.map +1 -0
- package/dist/ui/atoms/media-image/index.js +3 -0
- package/dist/ui/atoms/media-image/index.js.map +1 -0
- package/dist/ui/atoms/media-image/media-image.d.ts +46 -0
- package/dist/ui/atoms/media-image/media-image.d.ts.map +1 -0
- package/dist/ui/atoms/media-image/media-image.js +57 -0
- package/dist/ui/atoms/media-image/media-image.js.map +1 -0
- package/dist/ui/atoms/status-tag/status-tag.d.ts +6 -2
- package/dist/ui/atoms/status-tag/status-tag.d.ts.map +1 -1
- package/dist/ui/atoms/status-tag/status-tag.js.map +1 -1
- package/dist/ui/atoms/table/table.d.ts +4 -2
- package/dist/ui/atoms/table/table.d.ts.map +1 -1
- package/dist/ui/atoms/table/table.js +3 -1
- package/dist/ui/atoms/table/table.js.map +1 -1
- package/dist/ui/molecules/media-gallery/media-gallery.d.ts +30 -3
- package/dist/ui/molecules/media-gallery/media-gallery.d.ts.map +1 -1
- package/dist/ui/molecules/media-gallery/media-gallery.js +26 -6
- package/dist/ui/molecules/media-gallery/media-gallery.js.map +1 -1
- package/dist/ui/molecules/summary-tile/index.d.ts +2 -0
- package/dist/ui/molecules/summary-tile/index.d.ts.map +1 -0
- package/dist/ui/molecules/summary-tile/index.js +3 -0
- package/dist/ui/molecules/summary-tile/index.js.map +1 -0
- package/dist/ui/molecules/summary-tile/summary-tile.d.ts +57 -0
- package/dist/ui/molecules/summary-tile/summary-tile.d.ts.map +1 -0
- package/dist/ui/molecules/summary-tile/summary-tile.js +114 -0
- package/dist/ui/molecules/summary-tile/summary-tile.js.map +1 -0
- package/dist/ui/organisms/entity-form/entity-form.d.ts +1 -1
- package/dist/ui/organisms/entity-form/entity-form.d.ts.map +1 -1
- package/dist/ui/organisms/entity-form/entity-form.js +7 -6
- package/dist/ui/organisms/entity-form/entity-form.js.map +1 -1
- package/dist/ui/organisms/entity-form/entity-form.types.d.ts +0 -8
- package/dist/ui/organisms/entity-form/entity-form.types.d.ts.map +1 -1
- package/dist/ui/organisms/entity-form/entity-form.types.js.map +1 -1
- package/dist/ui/organisms/entity-table/card-roles.d.ts +10 -0
- package/dist/ui/organisms/entity-table/card-roles.d.ts.map +1 -0
- package/dist/ui/organisms/entity-table/card-roles.js +14 -0
- package/dist/ui/organisms/entity-table/card-roles.js.map +1 -0
- package/dist/ui/organisms/entity-table/entity-table-slots.d.ts +2 -0
- package/dist/ui/organisms/entity-table/entity-table-slots.d.ts.map +1 -1
- package/dist/ui/organisms/entity-table/entity-table-slots.js.map +1 -1
- package/dist/ui/organisms/entity-table/entity-table.d.ts.map +1 -1
- package/dist/ui/organisms/entity-table/entity-table.js +217 -173
- package/dist/ui/organisms/entity-table/entity-table.js.map +1 -1
- package/dist/ui/organisms/entity-table/pivot.d.ts +32 -5
- package/dist/ui/organisms/entity-table/pivot.d.ts.map +1 -1
- package/dist/ui/organisms/entity-table/pivot.js +42 -9
- package/dist/ui/organisms/entity-table/pivot.js.map +1 -1
- package/dist/ui/organisms/entity-table/use-entity-table-columns.d.ts.map +1 -1
- package/dist/ui/organisms/entity-table/use-entity-table-columns.js +6 -3
- package/dist/ui/organisms/entity-table/use-entity-table-columns.js.map +1 -1
- package/dist/ui/utils/reference-labels.d.ts +59 -0
- package/dist/ui/utils/reference-labels.d.ts.map +1 -0
- package/dist/ui/utils/reference-labels.js +49 -0
- package/dist/ui/utils/reference-labels.js.map +1 -0
- package/package.json +5 -5
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { type LocalizedText } from '@entifix/core';
|
|
2
|
+
import { type ReactNode } from 'react';
|
|
3
|
+
import { type EntityNounSource } from '../../i18n/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* Where the name of one referenced record stands
|
|
6
|
+
* ([ADR 0030](../../../../../../docs/adr/0030-a-reference-names-its-target-through-the-owners-read-port.md)):
|
|
7
|
+
*
|
|
8
|
+
* - `resolving` — asked for and not here yet;
|
|
9
|
+
* - `named` — read, as a text or a text per locale;
|
|
10
|
+
* - `notFound` — read, and no record answered the id (deleted, or one the
|
|
11
|
+
* reader may not read);
|
|
12
|
+
* - `failed` — the read itself failed;
|
|
13
|
+
* - `unregistered` — the host registered nothing that reads this entity.
|
|
14
|
+
*/
|
|
15
|
+
export type ReferenceLabelState = {
|
|
16
|
+
readonly status: 'resolving';
|
|
17
|
+
} | {
|
|
18
|
+
readonly status: 'named';
|
|
19
|
+
readonly label: string | LocalizedText;
|
|
20
|
+
} | {
|
|
21
|
+
readonly status: 'notFound';
|
|
22
|
+
} | {
|
|
23
|
+
readonly status: 'failed';
|
|
24
|
+
} | {
|
|
25
|
+
readonly status: 'unregistered';
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* How the controls ask what a referenced record is called. A host fills it —
|
|
29
|
+
* batching what a render asks for into one read per target entity — and the
|
|
30
|
+
* controls only read it, so this package imports neither TanStack nor the
|
|
31
|
+
* integration layer.
|
|
32
|
+
*/
|
|
33
|
+
export interface ReferenceLabelLookup {
|
|
34
|
+
/** The name of the record of `entityKey` (`domain:key`) whose id is `id`. */
|
|
35
|
+
label(entityKey: string, id: string): ReferenceLabelState;
|
|
36
|
+
/** How to call the entity itself, when a record's name could not be read. */
|
|
37
|
+
noun?(entityKey: string): EntityNounSource | undefined;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Publishes a host's reference lookup to every control that renders a
|
|
41
|
+
* reference — a cell, a card, a read form, a confirm dialog. Without one, a
|
|
42
|
+
* reference reads as its raw id, muted, which is what tells a developer the
|
|
43
|
+
* registry is missing.
|
|
44
|
+
*/
|
|
45
|
+
export declare function ReferenceLabelsProvider({ lookup, children, }: {
|
|
46
|
+
lookup: ReferenceLabelLookup;
|
|
47
|
+
children: ReactNode;
|
|
48
|
+
}): import("react").JSX.Element;
|
|
49
|
+
/** The nearest {@link ReferenceLabelsProvider}'s lookup. */
|
|
50
|
+
export declare const useReferenceLabels: () => ReferenceLabelLookup;
|
|
51
|
+
/** Where one referenced record's name stands. */
|
|
52
|
+
export declare function useReferenceLabel(entityKey: string, id: string): ReferenceLabelState;
|
|
53
|
+
/**
|
|
54
|
+
* Words for a referenced record that has no name to show — its entity's noun
|
|
55
|
+
* and the id's short form ("Offering product-…"), so the reader still has
|
|
56
|
+
* something to quote. Never the whole id.
|
|
57
|
+
*/
|
|
58
|
+
export declare function useUnresolvedReference(): (entityKey: string, id: string) => string;
|
|
59
|
+
//# sourceMappingURL=reference-labels.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reference-labels.d.ts","sourceRoot":"","sources":["../../../src/ui/utils/reference-labels.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,aAAa,EAAW,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAiB,KAAK,SAAS,EAA2B,MAAM,OAAO,CAAC;AAE/E,OAAO,EACL,KAAK,gBAAgB,EAGtB,MAAM,qBAAqB,CAAC;AAE7B;;;;;;;;;;GAUG;AACH,MAAM,MAAM,mBAAmB,GAC3B;IAAE,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAA;CAAE,GAChC;IAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,CAAA;CAAE,GACpE;IAAE,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAA;CAAE,GAC/B;IAAE,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAA;CAAE,GAC7B;IAAE,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAA;CAAE,CAAC;AAExC;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB;IACnC,6EAA6E;IAC7E,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,mBAAmB,CAAC;IAC1D,6EAA6E;IAC7E,IAAI,CAAC,CAAC,SAAS,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS,CAAC;CACxD;AAQD;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,EACtC,MAAM,EACN,QAAQ,GACT,EAAE;IACD,MAAM,EAAE,oBAAoB,CAAC;IAC7B,QAAQ,EAAE,SAAS,CAAC;CACrB,+BAMA;AAED,4DAA4D;AAC5D,eAAO,MAAM,kBAAkB,QAAO,oBACF,CAAC;AAErC,iDAAiD;AACjD,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,MAAM,EACjB,EAAE,EAAE,MAAM,GACT,mBAAmB,CAErB;AAMD;;;;GAIG;AACH,wBAAgB,sBAAsB,IAAI,CACxC,SAAS,EAAE,MAAM,EACjB,EAAE,EAAE,MAAM,KACP,MAAM,CAcV"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { shortId } from '@entifix/core';
|
|
4
|
+
import { createContext, useCallback, useContext } from 'react';
|
|
5
|
+
import { useEntityNoun, useT } from '../../i18n/index.js';
|
|
6
|
+
const UNREGISTERED = {
|
|
7
|
+
status: 'unregistered'
|
|
8
|
+
};
|
|
9
|
+
const ReferenceLabelsContext = /*#__PURE__*/ createContext({
|
|
10
|
+
label: ()=>UNREGISTERED
|
|
11
|
+
});
|
|
12
|
+
/**
|
|
13
|
+
* Publishes a host's reference lookup to every control that renders a
|
|
14
|
+
* reference — a cell, a card, a read form, a confirm dialog. Without one, a
|
|
15
|
+
* reference reads as its raw id, muted, which is what tells a developer the
|
|
16
|
+
* registry is missing.
|
|
17
|
+
*/ export function ReferenceLabelsProvider({ lookup, children }) {
|
|
18
|
+
return /*#__PURE__*/ _jsx(ReferenceLabelsContext.Provider, {
|
|
19
|
+
value: lookup,
|
|
20
|
+
children: children
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
/** The nearest {@link ReferenceLabelsProvider}'s lookup. */ export const useReferenceLabels = ()=>useContext(ReferenceLabelsContext);
|
|
24
|
+
/** Where one referenced record's name stands. */ export function useReferenceLabel(entityKey, id) {
|
|
25
|
+
return useReferenceLabels().label(entityKey, id);
|
|
26
|
+
}
|
|
27
|
+
/** `catalog:product-offering` → `product-offering`: the entity's key, when it has no noun. */ const keyOf = (entityKey)=>entityKey.slice(entityKey.indexOf(':') + 1);
|
|
28
|
+
/**
|
|
29
|
+
* Words for a referenced record that has no name to show — its entity's noun
|
|
30
|
+
* and the id's short form ("Offering product-…"), so the reader still has
|
|
31
|
+
* something to quote. Never the whole id.
|
|
32
|
+
*/ export function useUnresolvedReference() {
|
|
33
|
+
const t = useT();
|
|
34
|
+
const noun = useEntityNoun();
|
|
35
|
+
const lookup = useReferenceLabels();
|
|
36
|
+
return useCallback((entityKey, id)=>{
|
|
37
|
+
const source = lookup.noun == null ? void 0 : lookup.noun.call(lookup, entityKey);
|
|
38
|
+
return t('reference.unresolved', {
|
|
39
|
+
noun: source === undefined ? keyOf(entityKey) : noun(source),
|
|
40
|
+
id: shortId(id)
|
|
41
|
+
});
|
|
42
|
+
}, [
|
|
43
|
+
lookup,
|
|
44
|
+
noun,
|
|
45
|
+
t
|
|
46
|
+
]);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
//# sourceMappingURL=reference-labels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/ui/utils/reference-labels.tsx"],"sourcesContent":["'use client';\n\nimport { type LocalizedText, shortId } from '@entifix/core';\nimport { createContext, type ReactNode, useCallback, useContext } from 'react';\n\nimport {\n type EntityNounSource,\n useEntityNoun,\n useT,\n} from '../../i18n/index.js';\n\n/**\n * Where the name of one referenced record stands\n * ([ADR 0030](../../../../../../docs/adr/0030-a-reference-names-its-target-through-the-owners-read-port.md)):\n *\n * - `resolving` — asked for and not here yet;\n * - `named` — read, as a text or a text per locale;\n * - `notFound` — read, and no record answered the id (deleted, or one the\n * reader may not read);\n * - `failed` — the read itself failed;\n * - `unregistered` — the host registered nothing that reads this entity.\n */\nexport type ReferenceLabelState =\n | { readonly status: 'resolving' }\n | { readonly status: 'named'; readonly label: string | LocalizedText }\n | { readonly status: 'notFound' }\n | { readonly status: 'failed' }\n | { readonly status: 'unregistered' };\n\n/**\n * How the controls ask what a referenced record is called. A host fills it —\n * batching what a render asks for into one read per target entity — and the\n * controls only read it, so this package imports neither TanStack nor the\n * integration layer.\n */\nexport interface ReferenceLabelLookup {\n /** The name of the record of `entityKey` (`domain:key`) whose id is `id`. */\n label(entityKey: string, id: string): ReferenceLabelState;\n /** How to call the entity itself, when a record's name could not be read. */\n noun?(entityKey: string): EntityNounSource | undefined;\n}\n\nconst UNREGISTERED: ReferenceLabelState = { status: 'unregistered' };\n\nconst ReferenceLabelsContext = createContext<ReferenceLabelLookup>({\n label: () => UNREGISTERED,\n});\n\n/**\n * Publishes a host's reference lookup to every control that renders a\n * reference — a cell, a card, a read form, a confirm dialog. Without one, a\n * reference reads as its raw id, muted, which is what tells a developer the\n * registry is missing.\n */\nexport function ReferenceLabelsProvider({\n lookup,\n children,\n}: {\n lookup: ReferenceLabelLookup;\n children: ReactNode;\n}) {\n return (\n <ReferenceLabelsContext.Provider value={lookup}>\n {children}\n </ReferenceLabelsContext.Provider>\n );\n}\n\n/** The nearest {@link ReferenceLabelsProvider}'s lookup. */\nexport const useReferenceLabels = (): ReferenceLabelLookup =>\n useContext(ReferenceLabelsContext);\n\n/** Where one referenced record's name stands. */\nexport function useReferenceLabel(\n entityKey: string,\n id: string,\n): ReferenceLabelState {\n return useReferenceLabels().label(entityKey, id);\n}\n\n/** `catalog:product-offering` → `product-offering`: the entity's key, when it has no noun. */\nconst keyOf = (entityKey: string) =>\n entityKey.slice(entityKey.indexOf(':') + 1);\n\n/**\n * Words for a referenced record that has no name to show — its entity's noun\n * and the id's short form (\"Offering product-…\"), so the reader still has\n * something to quote. Never the whole id.\n */\nexport function useUnresolvedReference(): (\n entityKey: string,\n id: string,\n) => string {\n const t = useT();\n const noun = useEntityNoun();\n const lookup = useReferenceLabels();\n return useCallback(\n (entityKey, id) => {\n const source = lookup.noun?.(entityKey);\n return t('reference.unresolved', {\n noun: source === undefined ? keyOf(entityKey) : noun(source),\n id: shortId(id),\n });\n },\n [lookup, noun, t],\n );\n}\n"],"names":["shortId","createContext","useCallback","useContext","useEntityNoun","useT","UNREGISTERED","status","ReferenceLabelsContext","label","ReferenceLabelsProvider","lookup","children","Provider","value","useReferenceLabels","useReferenceLabel","entityKey","id","keyOf","slice","indexOf","useUnresolvedReference","t","noun","source","undefined"],"mappings":"AAAA;;AAEA,SAA6BA,OAAO,QAAQ,gBAAgB;AAC5D,SAASC,aAAa,EAAkBC,WAAW,EAAEC,UAAU,QAAQ,QAAQ;AAE/E,SAEEC,aAAa,EACbC,IAAI,QACC,sBAAsB;AAiC7B,MAAMC,eAAoC;IAAEC,QAAQ;AAAe;AAEnE,MAAMC,uCAAyBP,cAAoC;IACjEQ,OAAO,IAAMH;AACf;AAEA;;;;;CAKC,GACD,OAAO,SAASI,wBAAwB,EACtCC,MAAM,EACNC,QAAQ,EAIT;IACC,qBACE,KAACJ,uBAAuBK,QAAQ;QAACC,OAAOH;kBACrCC;;AAGP;AAEA,0DAA0D,GAC1D,OAAO,MAAMG,qBAAqB,IAChCZ,WAAWK,wBAAwB;AAErC,+CAA+C,GAC/C,OAAO,SAASQ,kBACdC,SAAiB,EACjBC,EAAU;IAEV,OAAOH,qBAAqBN,KAAK,CAACQ,WAAWC;AAC/C;AAEA,4FAA4F,GAC5F,MAAMC,QAAQ,CAACF,YACbA,UAAUG,KAAK,CAACH,UAAUI,OAAO,CAAC,OAAO;AAE3C;;;;CAIC,GACD,OAAO,SAASC;IAId,MAAMC,IAAIlB;IACV,MAAMmB,OAAOpB;IACb,MAAMO,SAASI;IACf,OAAOb,YACL,CAACe,WAAWC;QACV,MAAMO,SAASd,OAAOa,IAAI,oBAAXb,OAAOa,IAAI,MAAXb,QAAcM;QAC7B,OAAOM,EAAE,wBAAwB;YAC/BC,MAAMC,WAAWC,YAAYP,MAAMF,aAAaO,KAAKC;YACrDP,IAAIlB,QAAQkB;QACd;IACF,GACA;QAACP;QAAQa;QAAMD;KAAE;AAErB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@entifix/react-controls",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"description": "Entity-agnostic React UI — table, form, filters, wizard, command palette — rendered from entity metadata, plus layout primitives.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"@headlessui/react": "^2.2.10",
|
|
20
20
|
"class-variance-authority": "^0.7.1",
|
|
21
21
|
"idb": "^8.0.4",
|
|
22
|
-
"@entifix/core": "0.
|
|
22
|
+
"@entifix/core": "0.22.0"
|
|
23
23
|
},
|
|
24
24
|
"exports": {
|
|
25
25
|
"./package.json": "./package.json",
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
"react": "19.3.1",
|
|
56
56
|
"react-i18next": "17.1.10",
|
|
57
57
|
"storybook": "^10.6.6",
|
|
58
|
-
"@entifix/
|
|
59
|
-
"@entifix/
|
|
58
|
+
"@entifix/i18n": "0.22.0",
|
|
59
|
+
"@entifix/style": "0.22.0"
|
|
60
60
|
},
|
|
61
61
|
"nx": {
|
|
62
62
|
"tags": [
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
"i18next": ">=26 <27",
|
|
112
112
|
"react": ">=19 <20",
|
|
113
113
|
"react-i18next": ">=17 <18",
|
|
114
|
-
"@entifix/i18n": "0.
|
|
114
|
+
"@entifix/i18n": "0.22.0"
|
|
115
115
|
},
|
|
116
116
|
"peerDependenciesMeta": {
|
|
117
117
|
"@entifix/i18n": {
|