@molecule/app-ui-angular 1.2.1 → 1.3.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/README.md +2744 -912
- package/dist/components/accordion.component.d.ts +17 -2
- package/dist/components/accordion.component.d.ts.map +1 -1
- package/dist/components/accordion.component.js +31 -7
- package/dist/components/accordion.component.js.map +1 -1
- package/dist/components/alert.component.d.ts +15 -2
- package/dist/components/alert.component.d.ts.map +1 -1
- package/dist/components/alert.component.js +25 -4
- package/dist/components/alert.component.js.map +1 -1
- package/dist/components/auth-guard.component.d.ts +41 -9
- package/dist/components/auth-guard.component.d.ts.map +1 -1
- package/dist/components/auth-guard.component.js +58 -23
- package/dist/components/auth-guard.component.js.map +1 -1
- package/dist/components/avatar.component.d.ts +15 -2
- package/dist/components/avatar.component.d.ts.map +1 -1
- package/dist/components/avatar.component.js +35 -5
- package/dist/components/avatar.component.js.map +1 -1
- package/dist/components/badge.component.d.ts +15 -2
- package/dist/components/badge.component.d.ts.map +1 -1
- package/dist/components/badge.component.js +35 -6
- package/dist/components/badge.component.js.map +1 -1
- package/dist/components/button.component.d.ts +20 -2
- package/dist/components/button.component.d.ts.map +1 -1
- package/dist/components/button.component.js +30 -4
- package/dist/components/button.component.js.map +1 -1
- package/dist/components/card.component.d.ts +67 -9
- package/dist/components/card.component.d.ts.map +1 -1
- package/dist/components/card.component.js +99 -17
- package/dist/components/card.component.js.map +1 -1
- package/dist/components/checkbox.component.d.ts +35 -5
- package/dist/components/checkbox.component.d.ts.map +1 -1
- package/dist/components/checkbox.component.js +59 -9
- package/dist/components/checkbox.component.js.map +1 -1
- package/dist/components/confirm-button.component.d.ts +85 -17
- package/dist/components/confirm-button.component.d.ts.map +1 -1
- package/dist/components/confirm-button.component.js +112 -25
- package/dist/components/confirm-button.component.js.map +1 -1
- package/dist/components/confirm-dialog.component.d.ts +50 -13
- package/dist/components/confirm-dialog.component.d.ts.map +1 -1
- package/dist/components/confirm-dialog.component.js +118 -31
- package/dist/components/confirm-dialog.component.js.map +1 -1
- package/dist/components/dropdown.component.d.ts +30 -4
- package/dist/components/dropdown.component.d.ts.map +1 -1
- package/dist/components/dropdown.component.js +80 -13
- package/dist/components/dropdown.component.js.map +1 -1
- package/dist/components/empty-state.component.d.ts +5 -1
- package/dist/components/empty-state.component.d.ts.map +1 -1
- package/dist/components/empty-state.component.js +5 -1
- package/dist/components/empty-state.component.js.map +1 -1
- package/dist/components/floating-input.component.d.ts +18 -4
- package/dist/components/floating-input.component.d.ts.map +1 -1
- package/dist/components/floating-input.component.js +38 -8
- package/dist/components/floating-input.component.js.map +1 -1
- package/dist/components/form-field.component.d.ts +14 -2
- package/dist/components/form-field.component.d.ts.map +1 -1
- package/dist/components/form-field.component.js +34 -5
- package/dist/components/form-field.component.js.map +1 -1
- package/dist/components/form.component.d.ts +61 -15
- package/dist/components/form.component.d.ts.map +1 -1
- package/dist/components/form.component.js +65 -14
- package/dist/components/form.component.js.map +1 -1
- package/dist/components/icon.component.d.ts +22 -4
- package/dist/components/icon.component.d.ts.map +1 -1
- package/dist/components/icon.component.js +1 -1
- package/dist/components/icon.component.js.map +1 -1
- package/dist/components/input.component.d.ts +34 -4
- package/dist/components/input.component.d.ts.map +1 -1
- package/dist/components/input.component.js +66 -11
- package/dist/components/input.component.js.map +1 -1
- package/dist/components/label.component.d.ts +5 -1
- package/dist/components/label.component.d.ts.map +1 -1
- package/dist/components/label.component.js +6 -2
- package/dist/components/label.component.js.map +1 -1
- package/dist/components/language-picker.component.d.ts +44 -8
- package/dist/components/language-picker.component.d.ts.map +1 -1
- package/dist/components/language-picker.component.js +29 -17
- package/dist/components/language-picker.component.js.map +1 -1
- package/dist/components/layout.component.d.ts +57 -8
- package/dist/components/layout.component.d.ts.map +1 -1
- package/dist/components/layout.component.js +134 -21
- package/dist/components/layout.component.js.map +1 -1
- package/dist/components/load-error-banner.component.d.ts +39 -7
- package/dist/components/load-error-banner.component.d.ts.map +1 -1
- package/dist/components/load-error-banner.component.js +68 -21
- package/dist/components/load-error-banner.component.js.map +1 -1
- package/dist/components/modal.component.d.ts +20 -3
- package/dist/components/modal.component.d.ts.map +1 -1
- package/dist/components/modal.component.js +40 -6
- package/dist/components/modal.component.js.map +1 -1
- package/dist/components/optimistic-toggle-button.component.d.ts +80 -19
- package/dist/components/optimistic-toggle-button.component.d.ts.map +1 -1
- package/dist/components/optimistic-toggle-button.component.js +86 -25
- package/dist/components/optimistic-toggle-button.component.js.map +1 -1
- package/dist/components/page-header.component.d.ts +5 -1
- package/dist/components/page-header.component.d.ts.map +1 -1
- package/dist/components/page-header.component.js +5 -1
- package/dist/components/page-header.component.js.map +1 -1
- package/dist/components/page-shell.component.d.ts +5 -1
- package/dist/components/page-shell.component.d.ts.map +1 -1
- package/dist/components/page-shell.component.js +5 -1
- package/dist/components/page-shell.component.js.map +1 -1
- package/dist/components/pagination.component.d.ts +15 -2
- package/dist/components/pagination.component.d.ts.map +1 -1
- package/dist/components/pagination.component.js +26 -5
- package/dist/components/pagination.component.js.map +1 -1
- package/dist/components/panel-close.component.d.ts +10 -1
- package/dist/components/panel-close.component.d.ts.map +1 -1
- package/dist/components/panel-close.component.js +1 -1
- package/dist/components/panel-close.component.js.map +1 -1
- package/dist/components/progress.component.d.ts +51 -8
- package/dist/components/progress.component.d.ts.map +1 -1
- package/dist/components/progress.component.js +26 -5
- package/dist/components/progress.component.js.map +1 -1
- package/dist/components/prompt-dialog.component.d.ts +59 -16
- package/dist/components/prompt-dialog.component.d.ts.map +1 -1
- package/dist/components/prompt-dialog.component.js +129 -41
- package/dist/components/prompt-dialog.component.js.map +1 -1
- package/dist/components/radio-group.component.d.ts +16 -2
- package/dist/components/radio-group.component.d.ts.map +1 -1
- package/dist/components/radio-group.component.js +28 -5
- package/dist/components/radio-group.component.js.map +1 -1
- package/dist/components/responsive-app-shell.component.d.ts +155 -31
- package/dist/components/responsive-app-shell.component.d.ts.map +1 -1
- package/dist/components/responsive-app-shell.component.js +163 -54
- package/dist/components/responsive-app-shell.component.js.map +1 -1
- package/dist/components/select.component.d.ts +29 -4
- package/dist/components/select.component.d.ts.map +1 -1
- package/dist/components/select.component.js +55 -9
- package/dist/components/select.component.js.map +1 -1
- package/dist/components/separator.component.d.ts +37 -7
- package/dist/components/separator.component.d.ts.map +1 -1
- package/dist/components/separator.component.js +33 -6
- package/dist/components/separator.component.js.map +1 -1
- package/dist/components/sidebar-user-card.component.d.ts +28 -7
- package/dist/components/sidebar-user-card.component.d.ts.map +1 -1
- package/dist/components/sidebar-user-card.component.js +1 -1
- package/dist/components/sidebar-user-card.component.js.map +1 -1
- package/dist/components/skeleton.component.d.ts +23 -4
- package/dist/components/skeleton.component.d.ts.map +1 -1
- package/dist/components/skeleton.component.js +34 -7
- package/dist/components/skeleton.component.js.map +1 -1
- package/dist/components/spinner.component.d.ts +15 -2
- package/dist/components/spinner.component.d.ts.map +1 -1
- package/dist/components/spinner.component.js +34 -6
- package/dist/components/spinner.component.js.map +1 -1
- package/dist/components/switch.component.d.ts +30 -7
- package/dist/components/switch.component.d.ts.map +1 -1
- package/dist/components/switch.component.js +56 -11
- package/dist/components/switch.component.js.map +1 -1
- package/dist/components/table.component.d.ts +29 -3
- package/dist/components/table.component.d.ts.map +1 -1
- package/dist/components/table.component.js +63 -8
- package/dist/components/table.component.js.map +1 -1
- package/dist/components/tabs.component.d.ts +18 -3
- package/dist/components/tabs.component.d.ts.map +1 -1
- package/dist/components/tabs.component.js +74 -39
- package/dist/components/tabs.component.js.map +1 -1
- package/dist/components/textarea.component.d.ts +29 -4
- package/dist/components/textarea.component.d.ts.map +1 -1
- package/dist/components/textarea.component.js +55 -9
- package/dist/components/textarea.component.js.map +1 -1
- package/dist/components/theme-toggle.component.d.ts +25 -6
- package/dist/components/theme-toggle.component.d.ts.map +1 -1
- package/dist/components/theme-toggle.component.js +1 -1
- package/dist/components/theme-toggle.component.js.map +1 -1
- package/dist/components/toast.component.d.ts +27 -6
- package/dist/components/toast.component.d.ts.map +1 -1
- package/dist/components/toast.component.js +48 -14
- package/dist/components/toast.component.js.map +1 -1
- package/dist/components/tooltip.component.d.ts +57 -5
- package/dist/components/tooltip.component.d.ts.map +1 -1
- package/dist/components/tooltip.component.js +103 -11
- package/dist/components/tooltip.component.js.map +1 -1
- package/dist/components/user-menu-popover.component.d.ts +68 -14
- package/dist/components/user-menu-popover.component.d.ts.map +1 -1
- package/dist/components/user-menu-popover.component.js +4 -4
- package/dist/components/user-menu-popover.component.js.map +1 -1
- package/dist/components/user-menu.component.d.ts +33 -9
- package/dist/components/user-menu.component.d.ts.map +1 -1
- package/dist/components/user-menu.component.js +1 -1
- package/dist/components/user-menu.component.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utilities/element-props.d.ts +78 -0
- package/dist/utilities/element-props.d.ts.map +1 -0
- package/dist/utilities/element-props.js +166 -0
- package/dist/utilities/element-props.js.map +1 -0
- package/dist/utilities/element.d.ts +34 -0
- package/dist/utilities/element.d.ts.map +1 -0
- package/dist/utilities/element.js +24 -0
- package/dist/utilities/element.js.map +1 -0
- package/dist/utilities/index.d.ts +2 -0
- package/dist/utilities/index.d.ts.map +1 -1
- package/dist/utilities/index.js +2 -0
- package/dist/utilities/index.js.map +1 -1
- package/dist/utilities/node-value.d.ts +1 -1
- package/dist/utilities/node-value.d.ts.map +1 -1
- package/dist/utilities/node-value.js +6 -2
- package/dist/utilities/node-value.js.map +1 -1
- package/dist/utilities/render-icon.d.ts +3 -2
- package/dist/utilities/render-icon.d.ts.map +1 -1
- package/dist/utilities/render-icon.js +6 -3
- package/dist/utilities/render-icon.js.map +1 -1
- package/dist/utilities/rest-attrs.d.ts +26 -2
- package/dist/utilities/rest-attrs.d.ts.map +1 -1
- package/dist/utilities/rest-attrs.js +37 -0
- package/dist/utilities/rest-attrs.js.map +1 -1
- package/package.json +4 -3
package/dist/index.d.ts
CHANGED
|
@@ -62,6 +62,10 @@
|
|
|
62
62
|
* `display: contents`.
|
|
63
63
|
* - Hooks (`useToast`, `usePanelClose`, `useIsDesktop`, `useUserMenuPopoverClose`) are called in
|
|
64
64
|
* an injection context (a component field initializer or constructor).
|
|
65
|
+
* - Every component whose React export forwards a ref implements `HasElement`: take it with a
|
|
66
|
+
* template variable (`<div mol-input #email>`) or `viewChild`, then read `email.element()`.
|
|
67
|
+
* That is the same element React's ref receives and is `null` while it is not rendered (a
|
|
68
|
+
* closed Tooltip, Dropdown or Modal).
|
|
65
69
|
* - The original first-pass components remain exported under their `Molecule*` names
|
|
66
70
|
* (`MoleculeButton`, `MoleculeInput`, `MoleculeModal`, …) as deprecated aliases.
|
|
67
71
|
*
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwEG;AAEH,cAAc,uBAAuB,CAAA;AACrC,cAAc,kBAAkB,CAAA;AAChC,cAAc,YAAY,CAAA;AAC1B,cAAc,sBAAsB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -62,6 +62,10 @@
|
|
|
62
62
|
* `display: contents`.
|
|
63
63
|
* - Hooks (`useToast`, `usePanelClose`, `useIsDesktop`, `useUserMenuPopoverClose`) are called in
|
|
64
64
|
* an injection context (a component field initializer or constructor).
|
|
65
|
+
* - Every component whose React export forwards a ref implements `HasElement`: take it with a
|
|
66
|
+
* template variable (`<div mol-input #email>`) or `viewChild`, then read `email.element()`.
|
|
67
|
+
* That is the same element React's ref receives and is `null` while it is not rendered (a
|
|
68
|
+
* closed Tooltip, Dropdown or Modal).
|
|
65
69
|
* - The original first-pass components remain exported under their `Molecule*` names
|
|
66
70
|
* (`MoleculeButton`, `MoleculeInput`, `MoleculeModal`, …) as deprecated aliases.
|
|
67
71
|
*
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwEG;AAEH,cAAc,uBAAuB,CAAA;AACrC,cAAc,kBAAkB,CAAA;AAChC,cAAc,YAAY,CAAA;AAC1B,cAAc,sBAAsB,CAAA"}
|
package/dist/types.d.ts
CHANGED
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
|
-
export type { AccordionItem, AccordionProps, AlertProps, AvatarProps, BadgeProps, BaseProps, ButtonElementProps, ButtonProps, ButtonVariant, CardProps, ChangeEventHandler, CheckboxProps, Children, ColorVariant, ContainerProps, CSSProperties, EventHandler, FlexProps, FocusEventHandler, FormElementProps, FormEventHandler, FormFieldProps, FormProps, GridProps, HTMLElementProps, InputElementProps, InputProps, InputType, KeyboardEventHandler, ModalProps, ModalSize, MouseEventHandler, PaginationProps, RadioGroupProps, SelectElementProps, SelectOption, SelectProps, Size, SkeletonProps, SpacerProps, SpinnerProps, SwitchProps, TabItem, TableColumn, TableProps, TabsProps, TextareaElementProps, TextareaProps, ToastProps, TooltipPlacement, TooltipProps, } from '@molecule/app-ui';
|
|
6
|
+
export type { AccordionItem, AccordionProps, AlertProps, AvatarProps, BadgeProps, BaseProps, ButtonElementProps, ButtonProps, ButtonVariant, CardProps, ChangeEventHandler, CheckboxProps, Children, ColorVariant, ContainerProps, CSSProperties, EventHandler, FlexProps, FocusEventHandler, FormElementProps, FormEventHandler, FormFieldProps, FormProps, GridProps, HTMLElementProps, InputElementProps, InputProps, InputType, KeyboardEventHandler, KitEvent, KitFocusEvent, KitKeyboardEvent, KitModifierKeys, KitMouseEvent, ModalProps, ModalSize, MouseEventHandler, PaginationProps, RadioGroupProps, SelectElementProps, SelectOption, SelectProps, Size, SkeletonProps, SpacerProps, SpinnerProps, SwitchProps, TabItem, TableColumn, TableProps, TabsProps, TextareaElementProps, TextareaProps, ToastProps, TooltipPlacement, TooltipProps, } from '@molecule/app-ui';
|
|
7
7
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,YAAY,EAEV,aAAa,EACb,cAAc,EAEd,UAAU,EAEV,WAAW,EAEX,UAAU,EACV,SAAS,EACT,kBAAkB,EAClB,WAAW,EAEX,aAAa,EAEb,SAAS,EACT,kBAAkB,EAElB,aAAa,EACb,QAAQ,EACR,YAAY,EAEZ,cAAc,EAEd,aAAa,EACb,YAAY,EACZ,SAAS,EACT,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EAEd,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,EAEV,SAAS,EACT,oBAAoB,EACpB,UAAU,EAEV,SAAS,EACT,iBAAiB,EAEjB,eAAe,EACf,eAAe,EAEf,kBAAkB,EAElB,YAAY,EACZ,WAAW,EACX,IAAI,EAEJ,aAAa,EACb,WAAW,EAEX,YAAY,EAEZ,WAAW,EAEX,OAAO,EAEP,WAAW,EACX,UAAU,EACV,SAAS,EACT,oBAAoB,EAEpB,aAAa,EACb,UAAU,EAEV,gBAAgB,EAChB,YAAY,GACb,MAAM,kBAAkB,CAAA"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,YAAY,EAEV,aAAa,EACb,cAAc,EAEd,UAAU,EAEV,WAAW,EAEX,UAAU,EACV,SAAS,EACT,kBAAkB,EAClB,WAAW,EAEX,aAAa,EAEb,SAAS,EACT,kBAAkB,EAElB,aAAa,EACb,QAAQ,EACR,YAAY,EAEZ,cAAc,EAEd,aAAa,EACb,YAAY,EACZ,SAAS,EACT,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EAEd,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,EAEV,SAAS,EACT,oBAAoB,EACpB,QAAQ,EACR,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,UAAU,EAEV,SAAS,EACT,iBAAiB,EAEjB,eAAe,EACf,eAAe,EAEf,kBAAkB,EAElB,YAAY,EACZ,WAAW,EACX,IAAI,EAEJ,aAAa,EACb,WAAW,EAEX,YAAY,EAEZ,WAAW,EAEX,OAAO,EAEP,WAAW,EACX,UAAU,EACV,SAAS,EACT,oBAAoB,EAEpB,aAAa,EACb,UAAU,EAEV,gBAAgB,EAChB,YAAY,GACb,MAAM,kBAAkB,CAAA"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React-compatible writing of an element-prop record onto a live element.
|
|
3
|
+
*
|
|
4
|
+
* React spreads a props object onto an element on every render: `on[A-Z]*`
|
|
5
|
+
* functions become listeners, every other key becomes an attribute, and the
|
|
6
|
+
* difference against the previous render is what reaches the DOM. Angular
|
|
7
|
+
* ports that take such an object as data (a navigation link entry, a name
|
|
8
|
+
* link's props) need the same rules; this writer holds them once.
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
import type { Renderer2 } from '@angular/core';
|
|
13
|
+
/**
|
|
14
|
+
* Writes a React element-prop record onto one Angular element, re-applying
|
|
15
|
+
* only what changed since the previous {@link ElementPropsWriter.write}.
|
|
16
|
+
*
|
|
17
|
+
* The rules are React's spread:
|
|
18
|
+
*
|
|
19
|
+
* - `on[A-Z]*` functions become listeners (`onClick` → `click`, a `Capture`
|
|
20
|
+
* suffix → capture phase, `onDoubleClick` → `dblclick`); a non-function
|
|
21
|
+
* value removes the listener, and so does dropping the key.
|
|
22
|
+
* - `className` and `class` compose into one `class` attribute with `cn`.
|
|
23
|
+
* - An object `style` is serialized with `styleText`.
|
|
24
|
+
* - Every other key becomes an attribute: `null`/`undefined` removes it,
|
|
25
|
+
* `false` removes it (except text booleans, which write `"false"`), and
|
|
26
|
+
* `true` writes `""` (text booleans write `"true"`). Any other value is
|
|
27
|
+
* stringified.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* const writer = new ElementPropsWriter(renderer, anchor)
|
|
32
|
+
* writer.write({ target: '_blank', rel: 'noopener', onClick })
|
|
33
|
+
* writer.write({ target: '_self', rel: 'noopener' }) // replaces, removes the listener
|
|
34
|
+
* writer.destroy()
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare class ElementPropsWriter {
|
|
38
|
+
private readonly renderer;
|
|
39
|
+
private readonly element;
|
|
40
|
+
private applied;
|
|
41
|
+
private readonly listeners;
|
|
42
|
+
/**
|
|
43
|
+
* Creates a writer bound to one element.
|
|
44
|
+
*
|
|
45
|
+
* @param renderer - Angular's renderer, which owns the platform's DOM writes.
|
|
46
|
+
* @param element - The element the props are written onto.
|
|
47
|
+
*/
|
|
48
|
+
constructor(renderer: Renderer2, element: Element);
|
|
49
|
+
/**
|
|
50
|
+
* Applies `props` to the element, touching only the keys whose value
|
|
51
|
+
* changed since the previous call (and removing the ones that went).
|
|
52
|
+
*
|
|
53
|
+
* A key in `skip` is left alone: the caller's own template binding or
|
|
54
|
+
* router link owns it. The channel keys are controlled the same way —
|
|
55
|
+
* `className`/`class` compose into `class` unless `skip` holds `class`, and
|
|
56
|
+
* `style` is serialized unless `skip` holds `style` (so a component whose
|
|
57
|
+
* template already binds the class and style of the same element keeps
|
|
58
|
+
* them).
|
|
59
|
+
*
|
|
60
|
+
* @param props - The React-shaped props record to write.
|
|
61
|
+
* @param skip - Keys the caller owns; they are never written and any value
|
|
62
|
+
* written by an earlier call is removed.
|
|
63
|
+
*/
|
|
64
|
+
write(props: Readonly<Record<string, unknown>>, skip?: ReadonlySet<string>): void;
|
|
65
|
+
/**
|
|
66
|
+
* Removes every listener the writer added. The caller's element may outlive
|
|
67
|
+
* the props: an Angular port calls this when the element is destroyed or
|
|
68
|
+
* replaced.
|
|
69
|
+
*/
|
|
70
|
+
destroy(): void;
|
|
71
|
+
/**
|
|
72
|
+
* Removes the listener registered for one key, if any.
|
|
73
|
+
*
|
|
74
|
+
* @param key - The prop key whose listener goes.
|
|
75
|
+
*/
|
|
76
|
+
private removeListener;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=element-props.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"element-props.d.ts","sourceRoot":"","sources":["../../src/utilities/element-props.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAgC9C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAW;IACpC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAgC;IAE1D;;;;;OAKG;gBACS,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO;IAKjD;;;;;;;;;;;;;;OAcG;IACH,KAAK,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,IAAI;IAyDjF;;;;OAIG;IACH,OAAO,IAAI,IAAI;IAMf;;;;OAIG;IACH,OAAO,CAAC,cAAc;CAMvB"}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React-compatible writing of an element-prop record onto a live element.
|
|
3
|
+
*
|
|
4
|
+
* React spreads a props object onto an element on every render: `on[A-Z]*`
|
|
5
|
+
* functions become listeners, every other key becomes an attribute, and the
|
|
6
|
+
* difference against the previous render is what reaches the DOM. Angular
|
|
7
|
+
* ports that take such an object as data (a navigation link entry, a name
|
|
8
|
+
* link's props) need the same rules; this writer holds them once.
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
import { styleText } from './style.js';
|
|
13
|
+
import { cn } from './utilities.js';
|
|
14
|
+
/**
|
|
15
|
+
* Attribute names whose `false` is a real value rather than an absence, so
|
|
16
|
+
* React writes `"false"` instead of removing the attribute.
|
|
17
|
+
*/
|
|
18
|
+
const TEXT_BOOLEAN = /^(aria-|data-)|^(contentEditable|draggable|spellCheck)$/;
|
|
19
|
+
/**
|
|
20
|
+
* Whether a prop key is an event handler React would register as a listener
|
|
21
|
+
* (`onClick`, `onDoubleClickCapture`, …).
|
|
22
|
+
*
|
|
23
|
+
* @param key - The prop key.
|
|
24
|
+
* @returns True for an `on` + uppercase key.
|
|
25
|
+
*/
|
|
26
|
+
const isListener = (key) => /^on[A-Z]/.test(key);
|
|
27
|
+
/**
|
|
28
|
+
* Serializes a React style object for the `style` attribute, ignoring a value
|
|
29
|
+
* that is not an object (React only accepts an object there).
|
|
30
|
+
*
|
|
31
|
+
* @param style - The prop value.
|
|
32
|
+
* @returns The attribute text, or undefined when there is nothing to write.
|
|
33
|
+
*/
|
|
34
|
+
const styleAttribute = (style) => typeof style === 'object' && style !== null
|
|
35
|
+
? (styleText(style) ?? undefined)
|
|
36
|
+
: undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Writes a React element-prop record onto one Angular element, re-applying
|
|
39
|
+
* only what changed since the previous {@link ElementPropsWriter.write}.
|
|
40
|
+
*
|
|
41
|
+
* The rules are React's spread:
|
|
42
|
+
*
|
|
43
|
+
* - `on[A-Z]*` functions become listeners (`onClick` → `click`, a `Capture`
|
|
44
|
+
* suffix → capture phase, `onDoubleClick` → `dblclick`); a non-function
|
|
45
|
+
* value removes the listener, and so does dropping the key.
|
|
46
|
+
* - `className` and `class` compose into one `class` attribute with `cn`.
|
|
47
|
+
* - An object `style` is serialized with `styleText`.
|
|
48
|
+
* - Every other key becomes an attribute: `null`/`undefined` removes it,
|
|
49
|
+
* `false` removes it (except text booleans, which write `"false"`), and
|
|
50
|
+
* `true` writes `""` (text booleans write `"true"`). Any other value is
|
|
51
|
+
* stringified.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```ts
|
|
55
|
+
* const writer = new ElementPropsWriter(renderer, anchor)
|
|
56
|
+
* writer.write({ target: '_blank', rel: 'noopener', onClick })
|
|
57
|
+
* writer.write({ target: '_self', rel: 'noopener' }) // replaces, removes the listener
|
|
58
|
+
* writer.destroy()
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export class ElementPropsWriter {
|
|
62
|
+
renderer;
|
|
63
|
+
element;
|
|
64
|
+
applied = new Map();
|
|
65
|
+
listeners = new Map();
|
|
66
|
+
/**
|
|
67
|
+
* Creates a writer bound to one element.
|
|
68
|
+
*
|
|
69
|
+
* @param renderer - Angular's renderer, which owns the platform's DOM writes.
|
|
70
|
+
* @param element - The element the props are written onto.
|
|
71
|
+
*/
|
|
72
|
+
constructor(renderer, element) {
|
|
73
|
+
this.renderer = renderer;
|
|
74
|
+
this.element = element;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Applies `props` to the element, touching only the keys whose value
|
|
78
|
+
* changed since the previous call (and removing the ones that went).
|
|
79
|
+
*
|
|
80
|
+
* A key in `skip` is left alone: the caller's own template binding or
|
|
81
|
+
* router link owns it. The channel keys are controlled the same way —
|
|
82
|
+
* `className`/`class` compose into `class` unless `skip` holds `class`, and
|
|
83
|
+
* `style` is serialized unless `skip` holds `style` (so a component whose
|
|
84
|
+
* template already binds the class and style of the same element keeps
|
|
85
|
+
* them).
|
|
86
|
+
*
|
|
87
|
+
* @param props - The React-shaped props record to write.
|
|
88
|
+
* @param skip - Keys the caller owns; they are never written and any value
|
|
89
|
+
* written by an earlier call is removed.
|
|
90
|
+
*/
|
|
91
|
+
write(props, skip) {
|
|
92
|
+
const next = new Map();
|
|
93
|
+
for (const [key, value] of Object.entries(props)) {
|
|
94
|
+
if (skip?.has(key))
|
|
95
|
+
continue;
|
|
96
|
+
if (key === 'className' || key === 'class')
|
|
97
|
+
continue;
|
|
98
|
+
if (key === 'style') {
|
|
99
|
+
next.set('style', styleAttribute(value));
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
next.set(key, value);
|
|
103
|
+
}
|
|
104
|
+
if (!skip?.has('class')) {
|
|
105
|
+
const classes = cn(typeof props.className === 'string' ? props.className : undefined, typeof props.class === 'string' ? props.class : undefined);
|
|
106
|
+
if (classes)
|
|
107
|
+
next.set('class', classes);
|
|
108
|
+
}
|
|
109
|
+
// A key the caller has since taken over stays as it is, and stays tracked
|
|
110
|
+
// so a later call without the skip still removes what this writer applied.
|
|
111
|
+
const kept = new Map();
|
|
112
|
+
for (const [key, value] of this.applied)
|
|
113
|
+
if (skip?.has(key))
|
|
114
|
+
kept.set(key, value);
|
|
115
|
+
const keys = new Set(next.keys());
|
|
116
|
+
for (const key of this.applied.keys())
|
|
117
|
+
if (!skip?.has(key))
|
|
118
|
+
keys.add(key);
|
|
119
|
+
for (const key of keys) {
|
|
120
|
+
const value = next.get(key);
|
|
121
|
+
if (this.applied.has(key) && this.applied.get(key) === value)
|
|
122
|
+
continue;
|
|
123
|
+
this.removeListener(key);
|
|
124
|
+
if (isListener(key)) {
|
|
125
|
+
if (typeof value === 'function') {
|
|
126
|
+
const capture = key.endsWith('Capture');
|
|
127
|
+
const event = key.slice(2, capture ? -7 : undefined).toLowerCase();
|
|
128
|
+
this.listeners.set(key, this.renderer.listen(this.element, event === 'doubleclick' ? 'dblclick' : event, (browserEvent) => {
|
|
129
|
+
value(browserEvent);
|
|
130
|
+
}, { capture }));
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
else if (value == null || (value === false && !TEXT_BOOLEAN.test(key))) {
|
|
134
|
+
this.renderer.removeAttribute(this.element, key);
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
this.renderer.setAttribute(this.element, key, value === true && !TEXT_BOOLEAN.test(key) ? '' : String(value));
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
this.applied = new Map([...kept, ...next]);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Removes every listener the writer added. The caller's element may outlive
|
|
144
|
+
* the props: an Angular port calls this when the element is destroyed or
|
|
145
|
+
* replaced.
|
|
146
|
+
*/
|
|
147
|
+
destroy() {
|
|
148
|
+
for (const remove of this.listeners.values())
|
|
149
|
+
remove();
|
|
150
|
+
this.listeners.clear();
|
|
151
|
+
this.applied = new Map();
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Removes the listener registered for one key, if any.
|
|
155
|
+
*
|
|
156
|
+
* @param key - The prop key whose listener goes.
|
|
157
|
+
*/
|
|
158
|
+
removeListener(key) {
|
|
159
|
+
const remove = this.listeners.get(key);
|
|
160
|
+
if (!remove)
|
|
161
|
+
return;
|
|
162
|
+
remove();
|
|
163
|
+
this.listeners.delete(key);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=element-props.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"element-props.js","sourceRoot":"","sources":["../../src/utilities/element-props.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,EAAE,EAAE,EAA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AAI,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC,CAAA;IAC5C,CAAC;IAED;;;;OAIG;IACH,OAAO;QACL,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE;YAAE,MAAM,EAAE,CAAA;QACtD,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAA;QACtB,IAAI,CAAC,OAAO,GAAG,IAAI,GAAG,EAAE,CAAA;IAC1B,CAAC;IAED;;;;OAIG;IACK,cAAc,CAAC,GAAW;QAChC,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QACtC,IAAI,CAAC,MAAM;YAAE,OAAM;QACnB,MAAM,EAAE,CAAA;QACR,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;IAC5B,CAAC;CACF"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The element a component hands a caller's ref (see `BaseProps` in
|
|
3
|
+
* `@molecule/app-ui`).
|
|
4
|
+
*
|
|
5
|
+
* A component that renders one main element gives the caller that element —
|
|
6
|
+
* the one that takes `className` and `style` — as a read-only signal. A caller
|
|
7
|
+
* takes the component with a template variable or `viewChild` and reads
|
|
8
|
+
* `element()`; it is `null` while that element is not rendered (a closed
|
|
9
|
+
* Tooltip, Dropdown or Modal).
|
|
10
|
+
*
|
|
11
|
+
* @module
|
|
12
|
+
*/
|
|
13
|
+
import { type ElementRef, type Signal } from '@angular/core';
|
|
14
|
+
/**
|
|
15
|
+
* A component that gives callers its ref element.
|
|
16
|
+
*
|
|
17
|
+
* Implemented by every component whose React export forwards a ref. The
|
|
18
|
+
* generic is the element React's `forwardRef<E>` names.
|
|
19
|
+
*/
|
|
20
|
+
export interface HasElement<E extends Element> {
|
|
21
|
+
/** The ref element, or `null` while it is not rendered. */
|
|
22
|
+
readonly element: Signal<E | null>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The ref element of a component whose host IS the element React forwards.
|
|
26
|
+
*
|
|
27
|
+
* The kit's selectors name the native element React renders at its root, so
|
|
28
|
+
* the host element is that element.
|
|
29
|
+
*
|
|
30
|
+
* @param host - The component's host `ElementRef`.
|
|
31
|
+
* @returns A read-only signal holding the host element.
|
|
32
|
+
*/
|
|
33
|
+
export declare const hostElement: <E extends Element>(host: ElementRef<E>) => Signal<E | null>;
|
|
34
|
+
//# sourceMappingURL=element.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"element.d.ts","sourceRoot":"","sources":["../../src/utilities/element.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,MAAM,EAAU,MAAM,eAAe,CAAA;AAEpE;;;;;GAKG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC,SAAS,OAAO;IAC3C,2DAA2D;IAC3D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC,CAAA;CACnC;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,OAAO,EAAE,MAAM,UAAU,CAAC,CAAC,CAAC,KAAG,MAAM,CAAC,CAAC,GAAG,IAAI,CAC3C,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The element a component hands a caller's ref (see `BaseProps` in
|
|
3
|
+
* `@molecule/app-ui`).
|
|
4
|
+
*
|
|
5
|
+
* A component that renders one main element gives the caller that element —
|
|
6
|
+
* the one that takes `className` and `style` — as a read-only signal. A caller
|
|
7
|
+
* takes the component with a template variable or `viewChild` and reads
|
|
8
|
+
* `element()`; it is `null` while that element is not rendered (a closed
|
|
9
|
+
* Tooltip, Dropdown or Modal).
|
|
10
|
+
*
|
|
11
|
+
* @module
|
|
12
|
+
*/
|
|
13
|
+
import { signal } from '@angular/core';
|
|
14
|
+
/**
|
|
15
|
+
* The ref element of a component whose host IS the element React forwards.
|
|
16
|
+
*
|
|
17
|
+
* The kit's selectors name the native element React renders at its root, so
|
|
18
|
+
* the host element is that element.
|
|
19
|
+
*
|
|
20
|
+
* @param host - The component's host `ElementRef`.
|
|
21
|
+
* @returns A read-only signal holding the host element.
|
|
22
|
+
*/
|
|
23
|
+
export const hostElement = (host) => signal(host.nativeElement).asReadonly();
|
|
24
|
+
//# sourceMappingURL=element.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"element.js","sourceRoot":"","sources":["../../src/utilities/element.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAgC,MAAM,EAAE,MAAM,eAAe,CAAA;AAapE;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAoB,IAAmB,EAAoB,EAAE,CACtF,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,UAAU,EAAE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,kBAAkB,CAAA;AAChC,cAAc,YAAY,CAAA;AAC1B,cAAc,yBAAyB,CAAA;AACvC,cAAc,wBAAwB,CAAA;AACtC,cAAc,kBAAkB,CAAA;AAChC,cAAc,UAAU,CAAA;AACxB,cAAc,eAAe,CAAA;AAC7B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,uBAAuB,CAAA;AACrC,cAAc,kBAAkB,CAAA;AAChC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,kBAAkB,CAAA;AAChC,cAAc,cAAc,CAAA;AAC5B,cAAc,oBAAoB,CAAA;AAClC,cAAc,YAAY,CAAA;AAC1B,cAAc,yBAAyB,CAAA;AACvC,cAAc,wBAAwB,CAAA;AACtC,cAAc,kBAAkB,CAAA;AAChC,cAAc,UAAU,CAAA;AACxB,cAAc,eAAe,CAAA;AAC7B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,uBAAuB,CAAA;AACrC,cAAc,kBAAkB,CAAA;AAChC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA"}
|
package/dist/utilities/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,kBAAkB,CAAA;AAChC,cAAc,YAAY,CAAA;AAC1B,cAAc,yBAAyB,CAAA;AACvC,cAAc,wBAAwB,CAAA;AACtC,cAAc,kBAAkB,CAAA;AAChC,cAAc,UAAU,CAAA;AACxB,cAAc,eAAe,CAAA;AAC7B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,uBAAuB,CAAA;AACrC,cAAc,kBAAkB,CAAA;AAChC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,kBAAkB,CAAA;AAChC,cAAc,cAAc,CAAA;AAC5B,cAAc,oBAAoB,CAAA;AAClC,cAAc,YAAY,CAAA;AAC1B,cAAc,yBAAyB,CAAA;AACvC,cAAc,wBAAwB,CAAA;AACtC,cAAc,kBAAkB,CAAA;AAChC,cAAc,UAAU,CAAA;AACxB,cAAc,eAAe,CAAA;AAC7B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,uBAAuB,CAAA;AACrC,cAAc,kBAAkB,CAAA;AAChC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA"}
|
|
@@ -14,7 +14,7 @@ import { TemplateRef } from '@angular/core';
|
|
|
14
14
|
*/
|
|
15
15
|
export declare function asTemplate(value: unknown): TemplateRef<unknown> | null;
|
|
16
16
|
/**
|
|
17
|
-
* Renders a plain-string node value (React renders
|
|
17
|
+
* Renders a plain-string (or numeric) node value (React renders both as text).
|
|
18
18
|
*
|
|
19
19
|
* @param value - The prop value.
|
|
20
20
|
* @returns The text, or empty.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-value.d.ts","sourceRoot":"","sources":["../../src/utilities/node-value.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3C;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,GAAG,IAAI,CAEtE;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"node-value.d.ts","sourceRoot":"","sources":["../../src/utilities/node-value.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3C;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,GAAG,IAAI,CAEtE;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAI/C;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAE/C"}
|
|
@@ -16,13 +16,17 @@ export function asTemplate(value) {
|
|
|
16
16
|
return value instanceof TemplateRef ? value : null;
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
|
-
* Renders a plain-string node value (React renders
|
|
19
|
+
* Renders a plain-string (or numeric) node value (React renders both as text).
|
|
20
20
|
*
|
|
21
21
|
* @param value - The prop value.
|
|
22
22
|
* @returns The text, or empty.
|
|
23
23
|
*/
|
|
24
24
|
export function nodeText(value) {
|
|
25
|
-
|
|
25
|
+
if (typeof value === 'string')
|
|
26
|
+
return value;
|
|
27
|
+
if (typeof value === 'number')
|
|
28
|
+
return String(value);
|
|
29
|
+
return '';
|
|
26
30
|
}
|
|
27
31
|
/**
|
|
28
32
|
* Whether a node-valued prop was passed at all (presence check for
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-value.js","sourceRoot":"","sources":["../../src/utilities/node-value.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3C;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,KAAc;IACvC,OAAO,KAAK,YAAY,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAA;AACpD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,
|
|
1
|
+
{"version":3,"file":"node-value.js","sourceRoot":"","sources":["../../src/utilities/node-value.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3C;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,KAAc;IACvC,OAAO,KAAK,YAAY,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAA;AACpD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAA;IAC3C,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC,KAAK,CAAC,CAAA;IACnD,OAAO,EAAE,CAAA;AACX,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,OAAO,CAAC,KAAc;IACpC,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,CAAA;AAC9C,CAAC"}
|
|
@@ -48,8 +48,9 @@ export declare class MolIconSvg implements OnChanges {
|
|
|
48
48
|
/** The resolved icon data (plain field input, JIT-visible). */
|
|
49
49
|
data?: ResolvedIcon;
|
|
50
50
|
/**
|
|
51
|
-
* The fill attribute value
|
|
52
|
-
* `currentColor
|
|
51
|
+
* The fill attribute value, matching React's `renderIcon` (which writes the
|
|
52
|
+
* icon's own fill or `currentColor`, even for a stroked glyph) and React
|
|
53
|
+
* `Icon`'s svg-backed branch (`icon.fill` or `none`).
|
|
53
54
|
* @returns The fill value.
|
|
54
55
|
*/
|
|
55
56
|
get fill(): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-icon.d.ts","sourceRoot":"","sources":["../../src/utilities/render-icon.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAiC,KAAK,SAAS,EAAE,MAAM,eAAe,CAAA;AAE7E,OAAO,EAAW,KAAK,QAAQ,EAAE,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAA;;AAE3E;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,4BAA4B;IAC5B,IAAI,EAAE,QAAQ,CAAA;IACd,8DAA8D;IAC9D,SAAS,EAAE,MAAM,CAAA;IACjB,+CAA+C;IAC/C,OAAO,EAAE,OAAO,CAAA;IAChB,sEAAsE;IACtE,OAAO,EAAE,MAAM,CAAA;CAChB;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,YAAY,CAQ5E;AAED;;;;;;;;;;;GAWG;AACH,qBA0Ba,UAAW,YAAW,SAAS;IAC1C,+DAA+D;IAC/D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AI,CAAgD;yCAxD1D,UAAU;2CAAV,UAAU;CAyDtB"}
|
|
@@ -48,12 +48,15 @@ export class MolIconSvg {
|
|
|
48
48
|
/** The resolved icon data (plain field input, JIT-visible). */
|
|
49
49
|
data;
|
|
50
50
|
/**
|
|
51
|
-
* The fill attribute value
|
|
52
|
-
* `currentColor
|
|
51
|
+
* The fill attribute value, matching React's `renderIcon` (which writes the
|
|
52
|
+
* icon's own fill or `currentColor`, even for a stroked glyph) and React
|
|
53
|
+
* `Icon`'s svg-backed branch (`icon.fill` or `none`).
|
|
53
54
|
* @returns The fill value.
|
|
54
55
|
*/
|
|
55
56
|
get fill() {
|
|
56
|
-
|
|
57
|
+
if (this.data?.icon.svg)
|
|
58
|
+
return this.data.icon.fill || 'none';
|
|
59
|
+
return this.data?.icon.fill || 'currentColor';
|
|
57
60
|
}
|
|
58
61
|
/**
|
|
59
62
|
* Stroke attribute values (null when the icon is not stroked).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-icon.js","sourceRoot":"","sources":["../../src/utilities/render-icon.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAkB,MAAM,eAAe,CAAA;AAE7E,OAAO,EAAE,OAAO,EAAgC,MAAM,qBAAqB,CAAA;;;;IAkEvE,0BAME;;;;;AAtDN;;;;;;;;GAQG;AACH,MAAM,UAAU,WAAW,CAAC,IAAc,EAAE,SAAkB;IAC5D,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC1B,OAAO;QACL,IAAI;QACJ,SAAS,EAAE,SAAS,IAAI,EAAE;QAC1B,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM;QACtB,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,WAAW;KACrC,CAAA;AACH,CAAC;AAED;;;;;;;;;;;GAWG;AA2BH,MAAM,OAAO,UAAU;IACrB,+DAA+D;IAC/D,IAAI,CAA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;gBACD,QAAQ,EAAE;;;;;;;;IAQR;aACH;;kFACY,UAAU"}
|
|
@@ -19,8 +19,7 @@
|
|
|
19
19
|
* @returns The moved attribute names.
|
|
20
20
|
*/
|
|
21
21
|
export declare function moveRestAttributes(host: Element, target: Element | undefined | null): string[];
|
|
22
|
-
/** Options for {@link reapplyRestAttributes}. */
|
|
23
|
-
export interface ReapplyRestAttributesOptions {
|
|
22
|
+
/** Options for {@link reapplyRestAttributes}. */ export interface ReapplyRestAttributesOptions {
|
|
24
23
|
/**
|
|
25
24
|
* Move `aria-describedby` too. The default keeps it on the host: a
|
|
26
25
|
* component that MERGES the host's `aria-describedby` with its own target
|
|
@@ -51,4 +50,29 @@ export interface ReapplyRestAttributesOptions {
|
|
|
51
50
|
* @returns The moved attribute names.
|
|
52
51
|
*/
|
|
53
52
|
export declare function reapplyRestAttributes(host: Element, target: Element | undefined | null, options?: ReapplyRestAttributesOptions): string[];
|
|
53
|
+
/**
|
|
54
|
+
* Reads and removes a caller's `data-mol-id` from the host, for a component
|
|
55
|
+
* whose React `...rest` target is an inner element: the value is re-rendered
|
|
56
|
+
* on that element by the component's own `data-mol-id` binding, so it must not
|
|
57
|
+
* stay on the wrapper as a duplicate.
|
|
58
|
+
*
|
|
59
|
+
* @param host - The component host element.
|
|
60
|
+
* @returns The value, or undefined when the host had none.
|
|
61
|
+
*/
|
|
62
|
+
export declare function takeDataMolId(host: Element): string | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* Takes a `data-mol-id` the caller bound on the host (`[attr.data-mol-id]`) and writes the id the
|
|
65
|
+
* component renders onto its element in the same pass, as React spreads it there in the render that
|
|
66
|
+
* passed it. Call it from `ngAfterViewInit` and `ngAfterViewChecked`, before
|
|
67
|
+
* {@link moveRestAttributes} / {@link reapplyRestAttributes}: by then the host attribute of this pass
|
|
68
|
+
* is written, while the element's own `[attr.data-mol-id]` binding already ran. A component that
|
|
69
|
+
* only stored the id showed it a change detection late, and a move that ran first carried the raw
|
|
70
|
+
* host value over the component's own `automationId`.
|
|
71
|
+
*
|
|
72
|
+
* @param host - The component host element.
|
|
73
|
+
* @param target - The element that carries the id, when rendered.
|
|
74
|
+
* @param store - Keeps the taken host id for the component's `molId()`.
|
|
75
|
+
* @param molId - The id the component renders, read after `store`.
|
|
76
|
+
*/
|
|
77
|
+
export declare function adoptHostDataMolId(host: Element, target: Element | undefined | null, store: (hostId: string) => void, molId: () => string | undefined): void;
|
|
54
78
|
//# sourceMappingURL=rest-attrs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rest-attrs.d.ts","sourceRoot":"","sources":["../../src/utilities/rest-attrs.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI,GAAG,MAAM,EAAE,CAW9F;AAED,iDAAiD
|
|
1
|
+
{"version":3,"file":"rest-attrs.d.ts","sourceRoot":"","sources":["../../src/utilities/rest-attrs.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI,GAAG,MAAM,EAAE,CAW9F;AAED,iDAAiD,CAAC,MAAM,WAAW,4BAA4B;IAC7F;;;;;;;OAOG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAC7B;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,OAAO,EACb,MAAM,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI,EAClC,OAAO,GAAE,4BAAiC,GACzC,MAAM,EAAE,CAYV;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAI/D;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,OAAO,EACb,MAAM,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI,EAClC,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,EAC/B,KAAK,EAAE,MAAM,MAAM,GAAG,SAAS,GAC9B,IAAI,CAMN"}
|
|
@@ -70,4 +70,41 @@ export function reapplyRestAttributes(host, target, options = {}) {
|
|
|
70
70
|
}
|
|
71
71
|
return moved;
|
|
72
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Reads and removes a caller's `data-mol-id` from the host, for a component
|
|
75
|
+
* whose React `...rest` target is an inner element: the value is re-rendered
|
|
76
|
+
* on that element by the component's own `data-mol-id` binding, so it must not
|
|
77
|
+
* stay on the wrapper as a duplicate.
|
|
78
|
+
*
|
|
79
|
+
* @param host - The component host element.
|
|
80
|
+
* @returns The value, or undefined when the host had none.
|
|
81
|
+
*/
|
|
82
|
+
export function takeDataMolId(host) {
|
|
83
|
+
const value = host.getAttribute('data-mol-id') ?? undefined;
|
|
84
|
+
host.removeAttribute('data-mol-id');
|
|
85
|
+
return value;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Takes a `data-mol-id` the caller bound on the host (`[attr.data-mol-id]`) and writes the id the
|
|
89
|
+
* component renders onto its element in the same pass, as React spreads it there in the render that
|
|
90
|
+
* passed it. Call it from `ngAfterViewInit` and `ngAfterViewChecked`, before
|
|
91
|
+
* {@link moveRestAttributes} / {@link reapplyRestAttributes}: by then the host attribute of this pass
|
|
92
|
+
* is written, while the element's own `[attr.data-mol-id]` binding already ran. A component that
|
|
93
|
+
* only stored the id showed it a change detection late, and a move that ran first carried the raw
|
|
94
|
+
* host value over the component's own `automationId`.
|
|
95
|
+
*
|
|
96
|
+
* @param host - The component host element.
|
|
97
|
+
* @param target - The element that carries the id, when rendered.
|
|
98
|
+
* @param store - Keeps the taken host id for the component's `molId()`.
|
|
99
|
+
* @param molId - The id the component renders, read after `store`.
|
|
100
|
+
*/
|
|
101
|
+
export function adoptHostDataMolId(host, target, store, molId) {
|
|
102
|
+
const hostId = takeDataMolId(host);
|
|
103
|
+
if (hostId === undefined)
|
|
104
|
+
return;
|
|
105
|
+
store(hostId);
|
|
106
|
+
const id = molId();
|
|
107
|
+
if (id !== undefined)
|
|
108
|
+
target?.setAttribute('data-mol-id', id);
|
|
109
|
+
}
|
|
73
110
|
//# sourceMappingURL=rest-attrs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rest-attrs.js","sourceRoot":"","sources":["../../src/utilities/rest-attrs.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,4EAA4E;AAC5E,MAAM,IAAI,GAAG,6BAA6B,CAAA;AAE1C,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAW,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;AAE5F;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAa,EAAE,MAAkC;IAClF,IAAI,CAAC,MAAM;QAAE,OAAO,EAAE,CAAA;IACtB,MAAM,KAAK,GAAa,EAAE,CAAA;IAC1B,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;QAC/C,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAA;QACtB,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;YAAE,SAAQ;QAC1E,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;QACrC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAA;QAC1B,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IA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