ngwr 16.3.0 → 16.4.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.
Files changed (142) hide show
  1. package/carousel/styles/_index.scss +53 -1
  2. package/fesm2022/ngwr-breadcrumbs.mjs +2 -2
  3. package/fesm2022/ngwr-breadcrumbs.mjs.map +1 -1
  4. package/fesm2022/ngwr-carousel-testing.mjs +24 -1
  5. package/fesm2022/ngwr-carousel-testing.mjs.map +1 -1
  6. package/fesm2022/ngwr-carousel.mjs +67 -4
  7. package/fesm2022/ngwr-carousel.mjs.map +1 -1
  8. package/fesm2022/ngwr-cascader.mjs +10 -23
  9. package/fesm2022/ngwr-cascader.mjs.map +1 -1
  10. package/fesm2022/ngwr-context-menu.mjs +16 -1
  11. package/fesm2022/ngwr-context-menu.mjs.map +1 -1
  12. package/fesm2022/ngwr-dropdown.mjs +18 -4
  13. package/fesm2022/ngwr-dropdown.mjs.map +1 -1
  14. package/fesm2022/ngwr-file-upload.mjs +7 -3
  15. package/fesm2022/ngwr-file-upload.mjs.map +1 -1
  16. package/fesm2022/ngwr-graph-testing.mjs +27 -0
  17. package/fesm2022/ngwr-graph-testing.mjs.map +1 -1
  18. package/fesm2022/ngwr-graph.mjs +568 -7
  19. package/fesm2022/ngwr-graph.mjs.map +1 -1
  20. package/fesm2022/ngwr-i18n-ar.mjs +8 -4
  21. package/fesm2022/ngwr-i18n-ar.mjs.map +1 -1
  22. package/fesm2022/ngwr-i18n-cs.mjs +8 -4
  23. package/fesm2022/ngwr-i18n-cs.mjs.map +1 -1
  24. package/fesm2022/ngwr-i18n-de.mjs +8 -4
  25. package/fesm2022/ngwr-i18n-de.mjs.map +1 -1
  26. package/fesm2022/ngwr-i18n-en.mjs +8 -4
  27. package/fesm2022/ngwr-i18n-en.mjs.map +1 -1
  28. package/fesm2022/ngwr-i18n-es.mjs +8 -4
  29. package/fesm2022/ngwr-i18n-es.mjs.map +1 -1
  30. package/fesm2022/ngwr-i18n-fr.mjs +8 -4
  31. package/fesm2022/ngwr-i18n-fr.mjs.map +1 -1
  32. package/fesm2022/ngwr-i18n-he.mjs +8 -4
  33. package/fesm2022/ngwr-i18n-he.mjs.map +1 -1
  34. package/fesm2022/ngwr-i18n-hi.mjs +8 -4
  35. package/fesm2022/ngwr-i18n-hi.mjs.map +1 -1
  36. package/fesm2022/ngwr-i18n-id.mjs +8 -4
  37. package/fesm2022/ngwr-i18n-id.mjs.map +1 -1
  38. package/fesm2022/ngwr-i18n-it.mjs +8 -4
  39. package/fesm2022/ngwr-i18n-it.mjs.map +1 -1
  40. package/fesm2022/ngwr-i18n-ja.mjs +8 -4
  41. package/fesm2022/ngwr-i18n-ja.mjs.map +1 -1
  42. package/fesm2022/ngwr-i18n-ko.mjs +8 -4
  43. package/fesm2022/ngwr-i18n-ko.mjs.map +1 -1
  44. package/fesm2022/ngwr-i18n-nl.mjs +8 -4
  45. package/fesm2022/ngwr-i18n-nl.mjs.map +1 -1
  46. package/fesm2022/ngwr-i18n-pl.mjs +8 -4
  47. package/fesm2022/ngwr-i18n-pl.mjs.map +1 -1
  48. package/fesm2022/ngwr-i18n-pt.mjs +8 -4
  49. package/fesm2022/ngwr-i18n-pt.mjs.map +1 -1
  50. package/fesm2022/ngwr-i18n-ru.mjs +8 -4
  51. package/fesm2022/ngwr-i18n-ru.mjs.map +1 -1
  52. package/fesm2022/ngwr-i18n-sv.mjs +8 -4
  53. package/fesm2022/ngwr-i18n-sv.mjs.map +1 -1
  54. package/fesm2022/ngwr-i18n-tr.mjs +8 -4
  55. package/fesm2022/ngwr-i18n-tr.mjs.map +1 -1
  56. package/fesm2022/ngwr-i18n-uk.mjs +8 -4
  57. package/fesm2022/ngwr-i18n-uk.mjs.map +1 -1
  58. package/fesm2022/ngwr-i18n-vi.mjs +8 -4
  59. package/fesm2022/ngwr-i18n-vi.mjs.map +1 -1
  60. package/fesm2022/ngwr-i18n-zh-tw.mjs +8 -4
  61. package/fesm2022/ngwr-i18n-zh-tw.mjs.map +1 -1
  62. package/fesm2022/ngwr-i18n-zh.mjs +8 -4
  63. package/fesm2022/ngwr-i18n-zh.mjs.map +1 -1
  64. package/fesm2022/ngwr-lightbox.mjs +2 -2
  65. package/fesm2022/ngwr-lightbox.mjs.map +1 -1
  66. package/fesm2022/ngwr-list.mjs +2 -2
  67. package/fesm2022/ngwr-list.mjs.map +1 -1
  68. package/fesm2022/ngwr-pagination.mjs +1 -0
  69. package/fesm2022/ngwr-pagination.mjs.map +1 -1
  70. package/fesm2022/ngwr-schema-form.mjs +1 -0
  71. package/fesm2022/ngwr-schema-form.mjs.map +1 -1
  72. package/fesm2022/ngwr-select.mjs +100 -3
  73. package/fesm2022/ngwr-select.mjs.map +1 -1
  74. package/fesm2022/ngwr-sortable-list.mjs +2 -2
  75. package/fesm2022/ngwr-sortable-list.mjs.map +1 -1
  76. package/fesm2022/ngwr-table-testing.mjs +71 -3
  77. package/fesm2022/ngwr-table-testing.mjs.map +1 -1
  78. package/fesm2022/ngwr-table.mjs +171 -11
  79. package/fesm2022/ngwr-table.mjs.map +1 -1
  80. package/fesm2022/ngwr-tour-testing.mjs +13 -1
  81. package/fesm2022/ngwr-tour-testing.mjs.map +1 -1
  82. package/fesm2022/ngwr-tour.mjs +13 -9
  83. package/fesm2022/ngwr-tour.mjs.map +1 -1
  84. package/fesm2022/ngwr-tree.mjs +12 -1
  85. package/fesm2022/ngwr-tree.mjs.map +1 -1
  86. package/fesm2022/ngwr-utils.mjs +64 -1
  87. package/fesm2022/ngwr-utils.mjs.map +1 -1
  88. package/fesm2022/ngwr-version.mjs +1 -1
  89. package/fesm2022/ngwr-version.mjs.map +1 -1
  90. package/graph/styles/_index.scss +87 -0
  91. package/i18n/ar.json +8 -4
  92. package/i18n/cs.json +8 -4
  93. package/i18n/de.json +8 -4
  94. package/i18n/en.json +8 -4
  95. package/i18n/es.json +8 -4
  96. package/i18n/fr.json +8 -4
  97. package/i18n/he.json +8 -4
  98. package/i18n/hi.json +8 -4
  99. package/i18n/id.json +8 -4
  100. package/i18n/it.json +8 -4
  101. package/i18n/ja.json +8 -4
  102. package/i18n/ko.json +8 -4
  103. package/i18n/nl.json +8 -4
  104. package/i18n/pl.json +8 -4
  105. package/i18n/pt.json +8 -4
  106. package/i18n/ru.json +8 -4
  107. package/i18n/sv.json +8 -4
  108. package/i18n/tr.json +8 -4
  109. package/i18n/uk.json +8 -4
  110. package/i18n/vi.json +8 -4
  111. package/i18n/zh-TW.json +8 -4
  112. package/i18n/zh.json +8 -4
  113. package/llms-full.txt +4 -4
  114. package/llms.txt +57 -24
  115. package/package.json +1 -1
  116. package/schematics/collection.json +5 -0
  117. package/schematics/eject/index.js +158 -0
  118. package/schematics/eject/schema.js +8 -0
  119. package/schematics/eject/schema.json +24 -0
  120. package/schematics/eject/source.js +295 -0
  121. package/schematics/use/symbol-map.json +1 -0
  122. package/select/styles/_index.scss +13 -0
  123. package/skills/ngwr/SKILL.md +30 -3
  124. package/skills/ngwr/references/catalog.md +1 -1
  125. package/table/styles/_index.scss +24 -0
  126. package/theme/styles/_focus.scss +11 -1
  127. package/types/ngwr-carousel-testing.d.ts +27 -6
  128. package/types/ngwr-carousel.d.ts +42 -6
  129. package/types/ngwr-cascader.d.ts +3 -5
  130. package/types/ngwr-context-menu.d.ts +2 -0
  131. package/types/ngwr-dropdown.d.ts +2 -0
  132. package/types/ngwr-file-upload.d.ts +8 -2
  133. package/types/ngwr-graph-testing.d.ts +28 -0
  134. package/types/ngwr-graph.d.ts +247 -91
  135. package/types/ngwr-select.d.ts +37 -0
  136. package/types/ngwr-table-testing.d.ts +52 -1
  137. package/types/ngwr-table.d.ts +101 -9
  138. package/types/ngwr-tour-testing.d.ts +10 -0
  139. package/types/ngwr-tour.d.ts +11 -2
  140. package/types/ngwr-tree.d.ts +2 -0
  141. package/types/ngwr-utils.d.ts +79 -1
  142. package/types/ngwr-version.d.ts +1 -1
@@ -28,6 +28,11 @@
28
28
  "schema": "./component-style/schema.json",
29
29
  "aliases": ["style"]
30
30
  },
31
+ "eject": {
32
+ "description": "Copy a component's source into the app, with its imports of other entry points rewritten to their package paths. `ng update` no longer updates the copy.",
33
+ "factory": "./eject/index#default",
34
+ "schema": "./eject/schema.json"
35
+ },
31
36
  "page": {
32
37
  "description": "Scaffold a starter page (form / table / dashboard) wired up with ngwr components.",
33
38
  "factory": "./page/index#default",
@@ -0,0 +1,158 @@
1
+ "use strict";
2
+ /**
3
+ * @license
4
+ *
5
+ * Use of this source code is governed by an MIT-style license that can be
6
+ * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ const node_fs_1 = require("node:fs");
10
+ const node_path_1 = require("node:path");
11
+ const schematics_1 = require("@angular-devkit/schematics");
12
+ const source_1 = require("./source");
13
+ /**
14
+ * The manifest of the installed ngwr, two levels up from the compiled schematic:
15
+ * `node_modules/ngwr/package.json`. `null` where that cannot be read, as in a
16
+ * spec, which loads this source as an ES module and passes its own.
17
+ */
18
+ function shippedManifest() {
19
+ if (typeof __dirname !== 'string')
20
+ return null;
21
+ const file = (0, node_path_1.join)(__dirname, '..', '..', 'package.json');
22
+ if (!(0, node_fs_1.existsSync)(file))
23
+ return null;
24
+ const manifest = JSON.parse((0, node_fs_1.readFileSync)(file, 'utf8'));
25
+ return manifest.name === 'ngwr' && manifest.version && manifest.exports
26
+ ? { version: manifest.version, exports: manifest.exports, repository: manifest.repository }
27
+ : null;
28
+ }
29
+ /** The library folder of a checkout given as its root or as `projects/lib` itself. */
30
+ function localLibrary(from) {
31
+ const dir = (0, node_path_1.isAbsolute)(from) ? from : (0, node_path_1.resolve)(process.cwd(), from);
32
+ const lib = [(0, node_path_1.join)(dir, 'projects', 'lib'), dir].find(candidate => (0, node_fs_1.existsSync)((0, node_path_1.join)(candidate, 'package.json')));
33
+ if (!lib) {
34
+ throw new schematics_1.SchematicsException(`ngwr:eject: ${from} is not an ngwr checkout: no package.json there or under its projects/lib.`);
35
+ }
36
+ return lib;
37
+ }
38
+ /** Reads the sources of a release from GitHub, at the tag `v<version>`. */
39
+ function remoteSource(manifest, fetchFile) {
40
+ return async (file) => {
41
+ const url = (0, source_1.ejectRawUrl)(manifest.version, file, manifest.repository);
42
+ let response;
43
+ try {
44
+ response = await fetchFile(url);
45
+ }
46
+ catch (error) {
47
+ throw new schematics_1.SchematicsException(`ngwr:eject: could not reach ${url} (${error instanceof Error ? error.message : String(error)}). ` +
48
+ 'The published package carries no sources, so they are fetched from GitHub. Offline, pass ' +
49
+ '`--from <dir>` with a local checkout of the ngwr repository.');
50
+ }
51
+ if (response.status === 404)
52
+ return null;
53
+ if (!response.ok)
54
+ throw new schematics_1.SchematicsException(`ngwr:eject: ${url} answered ${response.status}.`);
55
+ return response.text();
56
+ };
57
+ }
58
+ /** How many of the files sit in the shared folder. */
59
+ function sharedCount(files, isShared) {
60
+ return files.filter(file => isShared(file.path)).length;
61
+ }
62
+ /**
63
+ * `ng g ngwr:eject <entry>`: copies one component's source into the app, where
64
+ * it can be edited freely and `ng update` no longer reaches it.
65
+ *
66
+ * The sources are fetched from the repository at the tag of the installed
67
+ * version, since the tarball ships compiled output only; `--from` reads a local
68
+ * checkout instead. Imports that reach other entry points are rewritten to
69
+ * their package paths, so the copy still uses the installed ngwr for everything
70
+ * but itself; a private file it reads, which no package path exposes, is copied
71
+ * into `_ngwr-internal` beside the ejected folder, once for every component
72
+ * ejected there. See `./source` for which files are copied and how.
73
+ *
74
+ * `manifest` and `fetchFile` are parameters so a spec can pass its own; the
75
+ * devkit calls this with the options alone.
76
+ */
77
+ function eject(options, manifest = shippedManifest(), fetchFile = url => fetch(url)) {
78
+ return async (tree, context) => {
79
+ const name = options.entry
80
+ .trim()
81
+ .replace(/^['"]+|['"]+$/g, '')
82
+ .replace(/^ngwr\//, '')
83
+ .replace(/^\/+|\/+$/g, '');
84
+ if (!name)
85
+ throw new schematics_1.SchematicsException('ngwr:eject: missing `entry`.');
86
+ if (!manifest)
87
+ throw new schematics_1.SchematicsException('ngwr:eject: could not read the installed ngwr manifest.');
88
+ const { logger } = context;
89
+ const entry = (0, source_1.ejectTarget)(name, manifest.exports);
90
+ if (entry !== name)
91
+ logger.info(`ngwr: ${name} is ngwr/${entry}.`);
92
+ const refusal = (0, source_1.ejectRefusal)(entry, manifest.exports);
93
+ if (refusal)
94
+ throw new schematics_1.SchematicsException(`ngwr:eject: ${refusal}`);
95
+ let read;
96
+ let version = manifest.version;
97
+ if (options.from) {
98
+ const lib = localLibrary(options.from);
99
+ version =
100
+ JSON.parse((0, node_fs_1.readFileSync)((0, node_path_1.join)(lib, 'package.json'), 'utf8')).version ?? version;
101
+ read = file => Promise.resolve((0, node_fs_1.existsSync)((0, node_path_1.join)(lib, file)) ? (0, node_fs_1.readFileSync)((0, node_path_1.join)(lib, file), 'utf8') : null);
102
+ }
103
+ else {
104
+ read = remoteSource(manifest, fetchFile);
105
+ }
106
+ const dest = (options.path?.trim() ? options.path.trim() : `src/app/ngwr/${entry}`).replace(/^\/+|\/+$/g, '');
107
+ const ejected = await (0, source_1.collectEjected)(entry, manifest.exports, version, read, node_path_1.posix.basename(dest));
108
+ if (!ejected) {
109
+ throw new schematics_1.SchematicsException(options.from
110
+ ? `ngwr:eject: ${options.from} has no ${entry}/public-api.ts.`
111
+ : `ngwr:eject: ${(0, source_1.ejectRawUrl)(version, `${entry}/public-api.ts`, manifest.repository)} does not exist: ` +
112
+ `there is no v${version} tag, or it has no ngwr/${entry}. Pass \`--from <dir>\` with a local checkout.`);
113
+ }
114
+ if (!ejected.declarable) {
115
+ throw new schematics_1.SchematicsException(`ngwr:eject: ngwr/${entry} declares no component or directive, so there is nothing to eject.`);
116
+ }
117
+ const shared = node_path_1.posix.join(dest, '..', source_1.EJECT_SHARED_DIR);
118
+ const placed = ejected.files.map(file => ({ ...file, path: node_path_1.posix.join(dest, file.path) }));
119
+ const isShared = (path) => path.startsWith(`${shared}/`);
120
+ const taken = placed.find(file => !isShared(file.path) && tree.exists(file.path));
121
+ if (taken) {
122
+ throw new schematics_1.SchematicsException(`ngwr:eject: ${taken.path} already exists. Delete the folder first, or pass another \`--path\`.`);
123
+ }
124
+ // A private file an earlier eject brought stays as it is: it may have been edited since.
125
+ const kept = [];
126
+ let brought = 0;
127
+ for (const file of placed) {
128
+ if (!tree.exists(file.path)) {
129
+ tree.create(file.path, file.content);
130
+ if (isShared(file.path))
131
+ brought++;
132
+ }
133
+ else if (tree.readText(file.path) !== file.content) {
134
+ kept.push(file.path);
135
+ }
136
+ }
137
+ logger.info(`✓ Copied ngwr/${entry}@${version} into ${dest} (${placed.length - sharedCount(placed, isShared)} files).`);
138
+ if (sharedCount(placed, isShared) > 0) {
139
+ logger.info(` It reads ${sharedCount(placed, isShared)} private files of ngwr, kept in ${shared} and shared by the ` +
140
+ `components ejected beside it (${brought} added now).`);
141
+ }
142
+ logger.info(` Import it from that folder instead of 'ngwr/${entry}'. \`ng update\` no longer updates this copy.`);
143
+ if (ejected.styles) {
144
+ const sheet = `${dest}/${ejected.styles.replace(/\/_index\.scss$/, '')}`;
145
+ logger.info(` In the global stylesheet, replace \`@use 'ngwr/${entry}';\` with a \`@use\` of ${sheet}.`);
146
+ }
147
+ logger.info(` The copy keeps its selectors and classes: never import it and 'ngwr/${entry}' into the same component. ` +
148
+ 'To use both, rename the selector and the `.wr-*` classes in the copy.');
149
+ for (const path of kept) {
150
+ logger.warn(`ngwr: ${path} already exists and differs from ngwr@${version}; it was left as it is.`);
151
+ }
152
+ for (const warning of ejected.warnings) {
153
+ logger.warn(`ngwr: ${node_path_1.posix.join(dest, warning.file)}:${warning.line} '${warning.specifier}' ${warning.reason}.`);
154
+ }
155
+ return tree;
156
+ };
157
+ }
158
+ exports.default = eject;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ /**
3
+ * @license
4
+ *
5
+ * Use of this source code is governed by an MIT-style license that can be
6
+ * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,24 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema",
3
+ "$id": "ngwr-eject",
4
+ "title": "ngwr eject",
5
+ "type": "object",
6
+ "properties": {
7
+ "entry": {
8
+ "type": "string",
9
+ "description": "The component's path under `ngwr/`, nested ones included — e.g. `button`, `select`, `charts/bar-chart`.",
10
+ "$default": { "$source": "argv", "index": 0 },
11
+ "x-prompt": "Which component? (e.g. button, select, charts/bar-chart)"
12
+ },
13
+ "path": {
14
+ "type": "string",
15
+ "format": "path",
16
+ "description": "Folder the copy is written to, from the workspace root. Defaults to `src/app/ngwr/<entry>`."
17
+ },
18
+ "from": {
19
+ "type": "string",
20
+ "description": "A local checkout of the ngwr repository (its root, or its `projects/lib`) to copy from, instead of fetching the sources of the installed version from GitHub."
21
+ }
22
+ },
23
+ "required": ["entry"]
24
+ }
@@ -0,0 +1,295 @@
1
+ "use strict";
2
+ /**
3
+ * @license
4
+ *
5
+ * Use of this source code is governed by an MIT-style license that can be
6
+ * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.EJECT_SHARED_DIR = void 0;
10
+ exports.collectEjected = collectEjected;
11
+ exports.ejectHeader = ejectHeader;
12
+ exports.ejectRawUrl = ejectRawUrl;
13
+ exports.ejectRefusal = ejectRefusal;
14
+ exports.ejectTarget = ejectTarget;
15
+ exports.ejectableEntryPoints = ejectableEntryPoints;
16
+ const node_path_1 = require("node:path");
17
+ const DEFAULT_REPOSITORY = 'thekhegay/ngwr';
18
+ const DEFAULT_DIRECTORY = 'projects/lib';
19
+ /**
20
+ * The raw-file URL of one source file at the tag of a release.
21
+ *
22
+ * `file` is a path under the library folder: `button/button.ts`.
23
+ */
24
+ function ejectRawUrl(version, file, repository = {}) {
25
+ const slug = /github\.com[/:]([^/]+\/[^/]+?)(?:\.git)?$/.exec(repository.url ?? '')?.[1] ?? DEFAULT_REPOSITORY;
26
+ const directory = (repository.directory ?? DEFAULT_DIRECTORY).replace(/^\/+|\/+$/g, '');
27
+ return `https://raw.githubusercontent.com/${slug}/v${version}/${directory}/${file}`;
28
+ }
29
+ const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
30
+ /** Every entry point with code behind it: no root, no wildcard, no stylesheet-only path. */
31
+ function codeEntryPoints(exports) {
32
+ return Object.keys(exports)
33
+ .filter(key => key.startsWith('./') &&
34
+ !key.includes('*') &&
35
+ !key.endsWith('.json') &&
36
+ isRecord(exports[key]) &&
37
+ 'default' in exports[key])
38
+ .map(key => key.slice(2));
39
+ }
40
+ /** Why an entry point is never ejected, read off its path alone. */
41
+ function structuralRefusal(entry) {
42
+ if (/(^|\/)testing$/.test(entry))
43
+ return 'a test harness';
44
+ if (/(^|\/)router$/.test(entry))
45
+ return 'a router adapter';
46
+ if (/^i18n(\/|$)/.test(entry))
47
+ return 'a translation catalogue';
48
+ return null;
49
+ }
50
+ /** The entry points `ng g ngwr:eject` accepts by name, from the `exports` map. */
51
+ function ejectableEntryPoints(exports) {
52
+ return codeEntryPoints(exports).filter(entry => structuralRefusal(entry) === null);
53
+ }
54
+ /** Why `entry` cannot be ejected, or `null` when its name is acceptable. */
55
+ function ejectRefusal(entry, exports) {
56
+ const reason = structuralRefusal(entry);
57
+ if (reason)
58
+ return `ngwr/${entry} is ${reason}, not a component. Eject the component it belongs to.`;
59
+ if (ejectableEntryPoints(exports).includes(entry))
60
+ return null;
61
+ return `ngwr/${entry} is not an entry point. Give a component's path under ngwr/: ${ejectableEntryPoints(exports).join(', ')}.`;
62
+ }
63
+ /** The entry point a path under the library folder belongs to: the longest one that contains it. */
64
+ function ownerOf(path, entryPoints) {
65
+ let owner = null;
66
+ for (const entry of entryPoints) {
67
+ if ((path === entry || path.startsWith(`${entry}/`)) && (owner === null || entry.length > owner.length)) {
68
+ owner = entry;
69
+ }
70
+ }
71
+ return owner;
72
+ }
73
+ const NOT_FOUND = 'reaches a file that could not be read from the source, so nothing was copied for it';
74
+ /** The folder private files are copied to, beside the ejected one and shared by its neighbours. */
75
+ const EJECT_SHARED_DIR = '_ngwr-internal';
76
+ exports.EJECT_SHARED_DIR = EJECT_SHARED_DIR;
77
+ /** The header each copied file opens with. `entry` is `null` for a private file in the shared folder. */
78
+ function ejectHeader(file, entry, version) {
79
+ const lines = [
80
+ entry === null
81
+ ? `Copied from ngwr@${version} by \`ng g ngwr:eject\`: a private file that ejected components share.`
82
+ : `Copied from ngwr@${version}, entry point ngwr/${entry}, by \`ng g ngwr:eject\`.`,
83
+ '`ng update` no longer updates this copy.',
84
+ ];
85
+ return file.endsWith('.html')
86
+ ? `<!--\n ${lines.join('\n ')}\n-->\n`
87
+ : `${lines.map(line => `// ${line}`).join('\n')}\n\n`;
88
+ }
89
+ /** Whether a line is commentary, where an `import … from` is prose or a usage example. */
90
+ const isCommentLine = (line) => /^\s*(\*|\/\*|\/\/)/.test(line);
91
+ const TS_SPECIFIER = /(\bfrom\s+|\bimport\s*\(\s*|^\s*import\s+)(['"])([^'"]+)\2/g;
92
+ const TS_RESOURCE = /\b(?:templateUrl|styleUrl)\s*:\s*(['"])([^'"]+)\1/g;
93
+ const TS_STYLE_URLS = /\bstyleUrls\s*:\s*\[([^\]]*)\]/g;
94
+ const SASS_LOAD = /^(\s*@(use|forward|import)\s+)(['"])([^'"]+)\3(.*)$/;
95
+ /**
96
+ * The files of one entry point, rewritten to live outside the library.
97
+ *
98
+ * Starts at `public-api.ts`, the barrel and the stylesheet the `exports` map
99
+ * names, and follows every relative import, `templateUrl`, `styleUrl` and Sass
100
+ * load. Where one lands decides what happens to it:
101
+ *
102
+ * - inside the entry point: the file is copied, at the same place in the folder;
103
+ * - on another entry point: the import becomes that entry point's package path
104
+ * (`../utils` reads `ngwr/utils`, `../../button/styles` reads `ngwr/button`),
105
+ * so the copy keeps using the installed package for everything but itself;
106
+ * - on a file no package path exposes (`animations/internal`, a theme partial):
107
+ * the file is copied too, under `../_ngwr-internal/<its path in the library>`,
108
+ * its own imports are followed the same way, and the import is rewritten to
109
+ * reach it there. Later ejects beside this one share that folder.
110
+ *
111
+ * A file path in the result is relative to the ejected folder, so a shared one
112
+ * starts with `../_ngwr-internal/`. Only an import whose file cannot be read is
113
+ * left as written and reported.
114
+ *
115
+ * `folder` is the name of the folder the copy is written to, which a private
116
+ * file reaching back into the component has to spell.
117
+ *
118
+ * Resolves to `null` when the entry point has no `public-api.ts` to start from.
119
+ */
120
+ async function collectEjected(entry, exports, version, read, folder = node_path_1.posix.basename(entry)) {
121
+ const entryPoints = codeEntryPoints(exports);
122
+ const loaded = new Map();
123
+ const files = new Map();
124
+ const warnings = [];
125
+ const queue = [];
126
+ const queued = new Set();
127
+ const load = async (path) => {
128
+ if (!loaded.has(path))
129
+ loaded.set(path, await read(path));
130
+ return loaded.get(path) ?? null;
131
+ };
132
+ /** Queues the first candidate that exists; `false` when none does. */
133
+ const follow = async (candidates) => {
134
+ for (const candidate of candidates) {
135
+ if ((await load(candidate)) !== null) {
136
+ if (!queued.has(candidate)) {
137
+ queued.add(candidate);
138
+ queue.push(candidate);
139
+ }
140
+ return true;
141
+ }
142
+ }
143
+ return false;
144
+ };
145
+ const own = (path) => ownerOf(path, entryPoints) === entry;
146
+ /** Where a library path lands, relative to the ejected folder. */
147
+ const placed = (path) => (own(path) ? node_path_1.posix.relative(entry, path) : `../${EJECT_SHARED_DIR}/${path}`);
148
+ const header = (file) => ejectHeader(file, own(file) ? entry : null, version);
149
+ /** `line` is 1-based in the source; the warning names the line in the copy, below its header. */
150
+ const warn = (file, line, specifier) => {
151
+ warnings.push({
152
+ file: placed(file),
153
+ line: line + header(file).split('\n').length - 1,
154
+ specifier,
155
+ reason: NOT_FOUND,
156
+ });
157
+ };
158
+ /** The package path a load that leaves the entry point should read, or `null` when it has none. */
159
+ const publicPath = (target, sass) => {
160
+ const owner = ownerOf(target, entryPoints);
161
+ if (owner === null || owner === entry)
162
+ return null;
163
+ const rest = target.slice(owner.length + 1);
164
+ if (!sass)
165
+ return rest === '' || rest === 'index' || rest === 'public-api' ? `ngwr/${owner}` : null;
166
+ // `<entry>/styles` is what the `sass` condition resolves to. The theme's is
167
+ // `theme/_index.scss`, which forwards `theme/styles` whole.
168
+ const entryExports = exports[`./${owner}`];
169
+ const shipsStyles = isRecord(entryExports) && 'sass' in entryExports;
170
+ return shipsStyles && /^styles(\/_?index(\.scss)?)?$/.test(rest) ? `ngwr/${owner}` : null;
171
+ };
172
+ /**
173
+ * What a relative specifier reads once both ends are placed, or `null` to
174
+ * leave it as written: two files on the same side keep their distance.
175
+ */
176
+ const relocated = (file, target) => {
177
+ if (own(file) === own(target))
178
+ return null;
179
+ // From the parent both folders sit in, where the ejected one has a name:
180
+ // a private file reaching back into the component has to spell it.
181
+ const fromParent = (path) => node_path_1.posix.join(folder, placed(path));
182
+ const relative = node_path_1.posix.relative(node_path_1.posix.dirname(fromParent(file)), fromParent(target));
183
+ return relative.startsWith('.') ? relative : `./${relative}`;
184
+ };
185
+ const sassCandidates = (target) => {
186
+ const base = node_path_1.posix.basename(target).replace(/\.scss$/, '');
187
+ const parent = node_path_1.posix.dirname(target);
188
+ return [
189
+ `${parent}/_${base}.scss`,
190
+ `${parent}/${base}.scss`,
191
+ `${parent}/${base}/_index.scss`,
192
+ `${parent}/${base}/index.scss`,
193
+ ];
194
+ };
195
+ const rewriteTs = async (file, source) => {
196
+ const dir = node_path_1.posix.dirname(file);
197
+ const lines = source.split('\n');
198
+ for (let index = 0; index < lines.length; index++) {
199
+ const line = lines[index];
200
+ if (isCommentLine(line))
201
+ continue;
202
+ for (const match of [...line.matchAll(TS_SPECIFIER)]) {
203
+ const specifier = match[3];
204
+ if (!specifier.startsWith('.'))
205
+ continue;
206
+ const target = node_path_1.posix.normalize(node_path_1.posix.join(dir, specifier));
207
+ let replacement = publicPath(target, false);
208
+ if (replacement === null) {
209
+ if (!(await follow(target === entry ? [`${entry}/index.ts`] : [`${target}.ts`, `${target}/index.ts`]))) {
210
+ warn(file, index + 1, specifier);
211
+ continue;
212
+ }
213
+ replacement = relocated(file, target);
214
+ }
215
+ if (replacement !== null) {
216
+ lines[index] = lines[index].replace(`${match[2]}${specifier}${match[2]}`, `'${replacement}'`);
217
+ }
218
+ }
219
+ }
220
+ const resources = [...source.matchAll(TS_RESOURCE)].map(match => match[2]);
221
+ for (const list of source.matchAll(TS_STYLE_URLS)) {
222
+ resources.push(...[...list[1].matchAll(/(['"])([^'"]+)\1/g)].map(match => match[2]));
223
+ }
224
+ for (const resource of resources)
225
+ await follow([node_path_1.posix.normalize(node_path_1.posix.join(dir, resource))]);
226
+ return lines.join('\n');
227
+ };
228
+ const rewriteSass = async (file, source) => {
229
+ const dir = node_path_1.posix.dirname(file);
230
+ const lines = source.split('\n');
231
+ for (let index = 0; index < lines.length; index++) {
232
+ const match = SASS_LOAD.exec(lines[index]);
233
+ if (!match)
234
+ continue;
235
+ const [, head, rule, quote, specifier, tail] = match;
236
+ if (/^(sass:|ngwr(\/|$)|https?:)/.test(specifier) || specifier.endsWith('.css'))
237
+ continue;
238
+ const target = node_path_1.posix.normalize(node_path_1.posix.join(dir, specifier));
239
+ const packagePath = publicPath(target, true);
240
+ if (packagePath !== null) {
241
+ // A `@use` with no `as` is named after its last segment, which the package path changes.
242
+ const namespace = rule === 'use' && !/^\s+as\s/.test(tail) ? ` as ${node_path_1.posix.basename(specifier)}` : '';
243
+ lines[index] = `${head}${quote}${packagePath}${quote}${namespace}${tail}`;
244
+ continue;
245
+ }
246
+ if (!(await follow(sassCandidates(target)))) {
247
+ warn(file, index + 1, specifier);
248
+ continue;
249
+ }
250
+ const replacement = relocated(file, target);
251
+ if (replacement !== null)
252
+ lines[index] = `${head}${quote}${replacement}${quote}${tail}`;
253
+ }
254
+ return lines.join('\n');
255
+ };
256
+ if (!(await follow([`${entry}/public-api.ts`])))
257
+ return null;
258
+ await follow([`${entry}/index.ts`]);
259
+ const entryExports = exports[`./${entry}`];
260
+ const sassEntry = isRecord(entryExports) ? entryExports.sass : null;
261
+ const stylesFile = typeof sassEntry === 'string' ? node_path_1.posix.normalize(sassEntry) : null;
262
+ const styles = stylesFile !== null && (await follow([stylesFile])) ? stylesFile : null;
263
+ let declarable = false;
264
+ for (let file = queue.shift(); file !== undefined; file = queue.shift()) {
265
+ const source = (await load(file)) ?? '';
266
+ let content = source;
267
+ if (file.endsWith('.ts')) {
268
+ declarable ||= own(file) && /^\s*@(Component|Directive)\s*\(/m.test(source);
269
+ content = await rewriteTs(file, source);
270
+ }
271
+ else if (file.endsWith('.scss')) {
272
+ content = await rewriteSass(file, source);
273
+ }
274
+ files.set(file, header(file) + content);
275
+ }
276
+ return {
277
+ files: [...files]
278
+ .map(([path, content]) => ({ path: placed(path), content }))
279
+ .sort((a, b) => (a.path < b.path ? -1 : 1)),
280
+ warnings,
281
+ declarable,
282
+ styles: styles === null ? null : placed(styles),
283
+ };
284
+ }
285
+ /**
286
+ * The entry point a name refers to: itself, or the one nested entry point a
287
+ * bare name ends, the way `component-style` reads `bar-chart`.
288
+ */
289
+ function ejectTarget(name, exports) {
290
+ const candidates = ejectableEntryPoints(exports);
291
+ if (candidates.includes(name) || name.includes('/'))
292
+ return name;
293
+ const nested = candidates.filter(candidate => candidate.endsWith(`/${name}`));
294
+ return nested.length === 1 ? nested[0] : name;
295
+ }
@@ -215,6 +215,7 @@
215
215
  "WrSwitch": "ngwr/switch",
216
216
  "WrTable": "ngwr/table",
217
217
  "WrTableCell": "ngwr/table",
218
+ "WrTableColumnChooser": "ngwr/table",
218
219
  "WrTableEditCell": "ngwr/table",
219
220
  "WrTableExpand": "ngwr/table",
220
221
  "WrTableGroupHeader": "ngwr/table",
@@ -119,6 +119,19 @@
119
119
  cursor: default;
120
120
  }
121
121
 
122
+ // The search status, inside the trigger: read out, never drawn.
123
+ &__status {
124
+ position: absolute;
125
+ width: 1px;
126
+ height: 1px;
127
+ padding: 0;
128
+ margin: -1px;
129
+ overflow: hidden;
130
+ clip: rect(0, 0, 0, 0);
131
+ white-space: nowrap;
132
+ border: 0;
133
+ }
134
+
122
135
  &__trigger {
123
136
  display: inline-flex;
124
137
  align-items: center;
@@ -54,10 +54,16 @@ guess gets backwards.
54
54
  `wr-btn`, not `wr-button`. Check `references/catalog.md` before writing a tag.
55
55
  - **Check for a MODE before reaching for another component.** The catalog is
56
56
  deliberately consolidated: `wr-select` covers single / multi / search / tag,
57
- `wr-date-picker` covers date / time / datetime, `wr-popover` has a tooltip
57
+ `wr-date-picker` covers date / time / datetime and, through the same
58
+ `mode`, a week, month, quarter or year held as its first day,
59
+ `wr-popover` has a tooltip
58
60
  mode, `wr-drawer` doubles as a bottom sheet (and, with `hasBackdrop` off,
59
61
  a non-modal side panel), `wr-table` owns pinning,
60
- resizing, grouping, tree rows, CSV export and virtual scroll. The charts too:
62
+ resizing, grouping, tree rows, CSV export, virtual scroll, hidden columns,
63
+ a bulk-action bar and inline cell editing, `wr-tree` owns lazy children
64
+ (`loadChildren`), a `filter`, cascading checks (`cascade`) and drag and
65
+ drop (`draggable`), `wr-select` in multi mode has `selectAll`, and
66
+ `wr-graph` zooms and pans with `zoomable`. The charts too:
61
67
  a pie is `wr-donut-chart` with `pie`, an area chart `wr-line-chart` with
62
68
  `showArea` (and `stacked` for a stacked area), a polar area chart
63
69
  `wr-radar-chart` with `variant="polar-area"`, a stacked, horizontal or
@@ -78,6 +84,24 @@ guess gets backwards.
78
84
  claims, `<wr-form-field>` shows the validator's own message
79
85
  (`required(path.email, { message: '…' })`), else `validation.<key>` from the
80
86
  APP's i18n catalog. With neither, nothing renders and only dev mode warns.
87
+ - **A data view reports a change and never writes your data.** `(cellEdit)`
88
+ on `wr-table`, `(nodeMove)` on `wr-tree` (apply it with
89
+ `wrMoveTreeNode` from `ngwr/tree`), `(eventChange)` on
90
+ `wr-event-calendar`: update `items`, `nodes` or `events` in the
91
+ handler, or the screen keeps the old value. `wr-file-upload` does not
92
+ upload either: the app does, and reports each file through `[status]`.
93
+ - **Table extras are templates and one state object.** A cell editor is
94
+ `<ng-template wrTableEditCell="price" let-value let-set="set">` inside the
95
+ table, and it is what makes the column editable. Bulk actions go in
96
+ `<ng-template wrTableSelectionBar let-rows let-clear="clear">`. Columns hide
97
+ through `[(hiddenColumns)]`, with `columnChooser` for the built-in button
98
+ or `<wr-table-column-chooser [table]="table" />` in a menu of your own. A
99
+ saved view is the `WrTableState` that `(stateChange)` emits, restored
100
+ through `[state]` with a new object each time.
101
+ - **A click on a `wr-tree` branch row opens it** (`expandOnClick`, on by
102
+ default since 16.3). `[expandOnClick]="false"` leaves that to the arrow.
103
+ - **There is no input mask.** Put `ngx-mask` on the same `<input wrInput>`;
104
+ do not look for a `wrMask`.
81
105
  - **`<wr-checkbox>` group identity is `checkboxValue`, not `value`.**
82
106
  `value` is reserved for the form value, so a leftover `value="x"` lands on the
83
107
  host as a plain DOM attribute, every box in the group keeps the default
@@ -124,12 +148,15 @@ guess gets backwards.
124
148
  ng add ngwr # prompts, installs peers, prints bootstrap
125
149
  ng g ngwr:use WrSelect --path src/app/some.ts # adds the import AND the @Component entry
126
150
  ng g ngwr:provider icons # splices a provider into bootstrap
151
+ ng g ngwr:eject select # copies the component's source into src/app/ngwr/select
127
152
  ```
128
153
 
129
154
  `--path` is a NAMED option on `ngwr:use`; only the symbol is positional, and
130
155
  passing the path bare fails with `Unknown argument`. It takes declarables only:
131
156
  a service such as `WrDialog` is refused, since the import line would compile and
132
- the `imports` entry would not — `inject()` it instead.
157
+ the `imports` entry would not — `inject()` it instead. `ngwr:eject` is for
158
+ a component you need to change beyond its inputs and `--wr-*` hooks: the copy
159
+ is yours, and `ng update` no longer reaches it.
133
160
 
134
161
  ### Providers a component cannot work without
135
162
 
@@ -221,7 +221,7 @@ root barrel for components: the root `ngwr` exports only `provideWr()`.
221
221
  | `ngwr/storage` | `import { WrStorage } from 'ngwr/storage'` | — |
222
222
  | `ngwr/switch` | `import { WrSwitch } from 'ngwr/switch'` | `wr-switch` |
223
223
  | `ngwr/switch/testing` | `import { WrSwitchHarness } from 'ngwr/switch/testing'` | — |
224
- | `ngwr/table` | `import { WrTable } from 'ngwr/table'` | `[wrTableCell]` `[wrTableEditCell]` `ng-template[wrTableExpand]` `wr-table-filter` `ng-template[wrTableGroupHeader]` `ng-template[wrTableSelectionBar]` `wr-table-sort` `wr-table` |
224
+ | `ngwr/table` | `import { WrTable } from 'ngwr/table'` | `[wrTableCell]` `wr-table-column-chooser` `[wrTableEditCell]` `ng-template[wrTableExpand]` `wr-table-filter` `ng-template[wrTableGroupHeader]` `ng-template[wrTableSelectionBar]` `wr-table-sort` `wr-table` |
225
225
  | `ngwr/table/testing` | `import { WrTableCellHarness } from 'ngwr/table/testing'` | — |
226
226
  | `ngwr/tabs` | `import { WrTabs } from 'ngwr/tabs'` | `wr-tab` `wr-tabs` |
227
227
  | `ngwr/tabs/router` | `import { WrTabsRouting } from 'ngwr/tabs/router'` | `[wrTabsRouting]` |
@@ -1460,3 +1460,27 @@ html.wr-table-dragging--blocked * {
1460
1460
  transform: translateX(250%);
1461
1461
  }
1462
1462
  }
1463
+
1464
+ // --- Column chooser ---------------------------------------------------------
1465
+ // The column list, in the built-in panel or in a menu of the consumer's own.
1466
+ // Its hooks are declared on itself: wherever it is placed, it inherits nothing
1467
+ // from the table.
1468
+ .wr-table-column-chooser {
1469
+ --wr-table-column-chooser-gap: var(--wr-space-sm);
1470
+ --wr-table-column-chooser-divider: var(--wr-border-base);
1471
+
1472
+ display: flex;
1473
+ flex-direction: column;
1474
+ gap: var(--wr-table-column-chooser-gap);
1475
+
1476
+ // "Show all" stands apart from the columns it acts on.
1477
+ &__all {
1478
+ padding-block-end: var(--wr-table-column-chooser-gap);
1479
+ border-block-end: 1px solid var(--wr-table-column-chooser-divider);
1480
+ }
1481
+ }
1482
+
1483
+ // The built-in panel keeps the gap it had before the list was a component.
1484
+ .wr-table__columns > .wr-table-column-chooser {
1485
+ --wr-table-column-chooser-gap: var(--wr-table-columns-gap);
1486
+ }
@@ -156,8 +156,9 @@
156
156
  @include focus-ring;
157
157
  }
158
158
 
159
- // Carousel nav + dots
159
+ // Carousel nav, pause button + dots
160
160
  .wr-carousel__nav:focus-visible,
161
+ .wr-carousel__toggle:focus-visible,
161
162
  .wr-carousel__dot:focus-visible {
162
163
  @include focus-ring;
163
164
  }
@@ -275,3 +276,12 @@
275
276
  position: relative;
276
277
  z-index: 1;
277
278
  }
279
+
280
+ // Graph — the viewport is the graph's one tab stop, the element a keyboard
281
+ // scrolls, or zooms and pans when the graph is `zoomable`. Its own `overflow`
282
+ // does not clip its outline, so the ring stays outset. The zoom buttons beside
283
+ // it are bare `<button>`s.
284
+ .wr-graph__viewport:focus-visible,
285
+ .wr-graph__control:focus-visible {
286
+ @include focus-ring;
287
+ }