@venizia/ardor-admin 0.4.4 → 0.4.6-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.
@@ -4,11 +4,18 @@ export interface IUseDocumentTitleOptions {
4
4
  appTitle: string;
5
5
  separator?: string;
6
6
  enabled?: boolean;
7
+ /**
8
+ * A base title for a layout. It shows only while no other call is mounted, so a screen's title
9
+ * wins on the first mount although the layout's effect runs after the screen's. Of two fallbacks,
10
+ * the one mounted last shows. @default false
11
+ */
12
+ fallback?: boolean;
7
13
  }
8
14
  /**
9
15
  * Sets the tab title to the screen title before `appTitle` (`Orders · Back Office`). On unmount it
10
16
  * puts back the title it replaced - unless someone wrote a newer one since - so one call per screen
11
- * is enough, with no reset on navigation.
17
+ * is enough, with no reset on navigation. A layout passes `fallback: true` for a base title the
18
+ * screens override.
12
19
  */
13
20
  export declare const useDocumentTitle: (opts: IUseDocumentTitleOptions) => void;
14
21
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"use-document-title.d.ts","sourceRoot":"","sources":["../../src/hooks/use-document-title.ts"],"names":[],"mappings":"AAEA,KAAK,qBAAqB,GAAG,MAAM,GAAG,KAAK,GAAG,IAAI,GAAG,SAAS,CAAC;AAE/D,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,qBAAqB,GAAG,KAAK,CAAC,qBAAqB,CAAC,CAAC;IAC5D,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAAI,MAAM,wBAAwB,SAsB9D,CAAC"}
1
+ {"version":3,"file":"use-document-title.d.ts","sourceRoot":"","sources":["../../src/hooks/use-document-title.ts"],"names":[],"mappings":"AAEA,KAAK,qBAAqB,GAAG,MAAM,GAAG,KAAK,GAAG,IAAI,GAAG,SAAS,CAAC;AAE/D,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,qBAAqB,GAAG,KAAK,CAAC,qBAAqB,CAAC,CAAC;IAC5D,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AA+DD;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAAI,MAAM,wBAAwB,SAkB9D,CAAC"}
@@ -1,26 +1,67 @@
1
1
  import React from 'react';
2
+ // The calls mounted now, in the order they registered, with the tab title before the first one and
3
+ // the title this module wrote last: the last is how a later writer outside the hook is recognised.
4
+ const entries = [];
5
+ let originalTitle;
6
+ let writtenTitle;
7
+ /** The last screen title mounted; with none, the last fallback. */
8
+ const resolveTitle = () => {
9
+ let fallback;
10
+ for (let index = entries.length - 1; index >= 0; index--) {
11
+ const entry = entries[index];
12
+ if (!entry.isFallback) {
13
+ return entry.title;
14
+ }
15
+ fallback ??= entry.title;
16
+ }
17
+ return fallback;
18
+ };
19
+ const writeTitle = () => {
20
+ writtenTitle = resolveTitle();
21
+ if (writtenTitle !== undefined) {
22
+ document.title = writtenTitle;
23
+ }
24
+ };
25
+ const register = (entry) => {
26
+ if (entries.length === 0) {
27
+ originalTitle = document.title;
28
+ }
29
+ entries.push(entry);
30
+ writeTitle();
31
+ };
32
+ const unregister = (entry) => {
33
+ entries.splice(entries.indexOf(entry), 1);
34
+ if (entries.length > 0) {
35
+ writeTitle();
36
+ return;
37
+ }
38
+ // Restore only our own write: a later writer (a layout re-mounted for a new locale, or a twin
39
+ // call React cleans up first) owns the title now.
40
+ if (originalTitle !== undefined && document.title === writtenTitle) {
41
+ document.title = originalTitle;
42
+ }
43
+ originalTitle = undefined;
44
+ writtenTitle = undefined;
45
+ };
2
46
  /**
3
47
  * Sets the tab title to the screen title before `appTitle` (`Orders · Back Office`). On unmount it
4
48
  * puts back the title it replaced - unless someone wrote a newer one since - so one call per screen
5
- * is enough, with no reset on navigation.
49
+ * is enough, with no reset on navigation. A layout passes `fallback: true` for a base title the
50
+ * screens override.
6
51
  */
7
52
  export const useDocumentTitle = (opts) => {
8
- const { title, appTitle, separator = ' · ', enabled = true } = opts;
53
+ const { title, appTitle, separator = ' · ', enabled = true, fallback = false } = opts;
9
54
  const segments = Array.isArray(title) ? title : [title];
10
55
  const documentTitle = [...segments, appTitle].filter(Boolean).join(separator);
11
56
  React.useEffect(() => {
12
57
  if (!enabled) {
13
58
  return;
14
59
  }
15
- const previousTitle = document.title;
16
- document.title = documentTitle;
60
+ const entry = { title: documentTitle, isFallback: fallback };
61
+ register(entry);
17
62
  return () => {
18
- // Restore only our own write: a later writer (a layout re-mounted for a new locale, or a twin
19
- // call React cleans up first) owns the title now.
20
- if (document.title === documentTitle) {
21
- document.title = previousTitle;
22
- }
63
+ unregister(entry);
23
64
  };
24
- }, [enabled, documentTitle]);
65
+ }, [enabled, documentTitle, fallback]);
25
66
  };
26
67
  //# sourceMappingURL=use-document-title.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-document-title.js","sourceRoot":"","sources":["../../src/hooks/use-document-title.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAW1B;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,IAA8B,EAAE,EAAE;IACjE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,GAAG,KAAK,EAAE,OAAO,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;IAEpE,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IACxD,MAAM,aAAa,GAAG,CAAC,GAAG,QAAQ,EAAE,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAE9E,KAAK,CAA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,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAE9E,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO;QACT,CAAC;QAED,MAAM,KAAK,GAAgB,EAAE,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC;QAC1E,QAAQ,CAAC,KAAK,CAAC,CAAC;QAEhB,OAAO,GAAG,EAAE;YACV,UAAU,CAAC,KAAK,CAAC,CAAC;QACpB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,OAAO,EAAE,aAAa,EAAE,QAAQ,CAAC,CAAC,CAAC;AACzC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@venizia/ardor-admin",
3
- "version": "0.4.4",
3
+ "version": "0.4.6-0",
4
4
  "description": "ARDOR react-admin adapter - the REST data provider, auth provider and i18n provider wired through IGNIS inversion, the ArdorApplication root component, the translate and notify hooks, and the English and Vietnamese message bundles.",
5
5
  "keywords": [
6
6
  "admin",
@@ -60,8 +60,8 @@
60
60
  "prepublishOnly": "make rebuild"
61
61
  },
62
62
  "dependencies": {
63
- "@venizia/ardor-kernel": "0.4.4",
64
- "@venizia/ardor-react": "0.4.4",
63
+ "@venizia/ardor-kernel": "0.4.6-0",
64
+ "@venizia/ardor-react": "0.4.6-0",
65
65
  "lodash": "^4.18.1"
66
66
  },
67
67
  "devDependencies": {
@@ -73,11 +73,11 @@
73
73
  "@types/bun": "^1.4.3",
74
74
  "@types/lodash": "^4.17.27",
75
75
  "@types/react": "^19",
76
- "@venizia/dev-configs": "^0.4.4",
77
- "@venizia/ignis-filter": "^0.4.4",
78
- "@venizia/ignis-helpers": "^0.4.4",
79
- "@venizia/ignis-inversion": "^0.4.4",
80
- "@venizia/ignis-kernel": "^0.4.4",
76
+ "@venizia/dev-configs": "^0.4.6-0",
77
+ "@venizia/ignis-filter": "^0.4.5-0",
78
+ "@venizia/ignis-helpers": "^0.4.6-0",
79
+ "@venizia/ignis-inversion": "^0.4.5-0",
80
+ "@venizia/ignis-kernel": "^0.4.6-0",
81
81
  "eslint": "^10.13.0",
82
82
  "oxlint": "1.89.0",
83
83
  "oxlint-tsgolint": "7.0.2004",