@tectra-ng/ui 0.4.4 → 0.4.6

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 (180) hide show
  1. package/amount/README.md +19 -1
  2. package/analog-clock/README.md +1 -1
  3. package/autocomplete/README.md +1 -1
  4. package/avatar/README.md +24 -4
  5. package/cascade-select/README.md +1 -1
  6. package/chips-input/README.md +11 -5
  7. package/color-picker/README.md +5 -0
  8. package/countdown/README.md +7 -1
  9. package/country/README.md +14 -1
  10. package/country-select/README.md +2 -1
  11. package/export/README.md +27 -2
  12. package/export-font/README.md +1 -1
  13. package/fesm2022/tectra-ng-ui-amount.mjs +96 -14
  14. package/fesm2022/tectra-ng-ui-amount.mjs.map +1 -1
  15. package/fesm2022/tectra-ng-ui-analog-clock.mjs +6 -19
  16. package/fesm2022/tectra-ng-ui-analog-clock.mjs.map +1 -1
  17. package/fesm2022/tectra-ng-ui-autocomplete.mjs +5 -4
  18. package/fesm2022/tectra-ng-ui-autocomplete.mjs.map +1 -1
  19. package/fesm2022/tectra-ng-ui-avatar.mjs +59 -17
  20. package/fesm2022/tectra-ng-ui-avatar.mjs.map +1 -1
  21. package/fesm2022/tectra-ng-ui-button.mjs +2 -2
  22. package/fesm2022/tectra-ng-ui-button.mjs.map +1 -1
  23. package/fesm2022/tectra-ng-ui-card.mjs +2 -2
  24. package/fesm2022/tectra-ng-ui-card.mjs.map +1 -1
  25. package/fesm2022/tectra-ng-ui-cascade-select.mjs +7 -4
  26. package/fesm2022/tectra-ng-ui-cascade-select.mjs.map +1 -1
  27. package/fesm2022/tectra-ng-ui-chips-input.mjs +142 -22
  28. package/fesm2022/tectra-ng-ui-chips-input.mjs.map +1 -1
  29. package/fesm2022/tectra-ng-ui-color-picker.mjs +93 -6
  30. package/fesm2022/tectra-ng-ui-color-picker.mjs.map +1 -1
  31. package/fesm2022/tectra-ng-ui-countdown.mjs +39 -10
  32. package/fesm2022/tectra-ng-ui-countdown.mjs.map +1 -1
  33. package/fesm2022/tectra-ng-ui-country-select.mjs +28 -5
  34. package/fesm2022/tectra-ng-ui-country-select.mjs.map +1 -1
  35. package/fesm2022/tectra-ng-ui-country.mjs +15 -6
  36. package/fesm2022/tectra-ng-ui-country.mjs.map +1 -1
  37. package/fesm2022/tectra-ng-ui-datepicker.mjs +10 -8
  38. package/fesm2022/tectra-ng-ui-datepicker.mjs.map +1 -1
  39. package/fesm2022/tectra-ng-ui-dialog.mjs +6 -6
  40. package/fesm2022/tectra-ng-ui-dialog.mjs.map +1 -1
  41. package/fesm2022/tectra-ng-ui-export.mjs +1237 -84
  42. package/fesm2022/tectra-ng-ui-export.mjs.map +1 -1
  43. package/fesm2022/tectra-ng-ui-field.mjs +1 -0
  44. package/fesm2022/tectra-ng-ui-field.mjs.map +1 -1
  45. package/fesm2022/tectra-ng-ui-fieldset.mjs +2 -2
  46. package/fesm2022/tectra-ng-ui-fieldset.mjs.map +1 -1
  47. package/fesm2022/tectra-ng-ui-icon-field.mjs +51 -23
  48. package/fesm2022/tectra-ng-ui-icon-field.mjs.map +1 -1
  49. package/fesm2022/tectra-ng-ui-input-number.mjs +2 -2
  50. package/fesm2022/tectra-ng-ui-input-number.mjs.map +1 -1
  51. package/fesm2022/tectra-ng-ui-input.mjs +5 -4
  52. package/fesm2022/tectra-ng-ui-input.mjs.map +1 -1
  53. package/fesm2022/tectra-ng-ui-key-filter.mjs +84 -19
  54. package/fesm2022/tectra-ng-ui-key-filter.mjs.map +1 -1
  55. package/fesm2022/tectra-ng-ui-knob.mjs +24 -2
  56. package/fesm2022/tectra-ng-ui-knob.mjs.map +1 -1
  57. package/fesm2022/tectra-ng-ui-label.mjs +68 -9
  58. package/fesm2022/tectra-ng-ui-label.mjs.map +1 -1
  59. package/fesm2022/tectra-ng-ui-link.mjs +38 -14
  60. package/fesm2022/tectra-ng-ui-link.mjs.map +1 -1
  61. package/fesm2022/tectra-ng-ui-mention-textarea.mjs +16 -5
  62. package/fesm2022/tectra-ng-ui-mention-textarea.mjs.map +1 -1
  63. package/fesm2022/tectra-ng-ui-message.mjs +17 -7
  64. package/fesm2022/tectra-ng-ui-message.mjs.map +1 -1
  65. package/fesm2022/tectra-ng-ui-month-calendar.mjs +26 -9
  66. package/fesm2022/tectra-ng-ui-month-calendar.mjs.map +1 -1
  67. package/fesm2022/tectra-ng-ui-multiselect.mjs +3 -2
  68. package/fesm2022/tectra-ng-ui-multiselect.mjs.map +1 -1
  69. package/fesm2022/tectra-ng-ui-panel-menu.mjs +45 -14
  70. package/fesm2022/tectra-ng-ui-panel-menu.mjs.map +1 -1
  71. package/fesm2022/tectra-ng-ui-panel.mjs +4 -2
  72. package/fesm2022/tectra-ng-ui-panel.mjs.map +1 -1
  73. package/fesm2022/tectra-ng-ui-password-generator.mjs +18 -1
  74. package/fesm2022/tectra-ng-ui-password-generator.mjs.map +1 -1
  75. package/fesm2022/tectra-ng-ui-password.mjs +2 -2
  76. package/fesm2022/tectra-ng-ui-password.mjs.map +1 -1
  77. package/fesm2022/tectra-ng-ui-pill.mjs +33 -17
  78. package/fesm2022/tectra-ng-ui-pill.mjs.map +1 -1
  79. package/fesm2022/tectra-ng-ui-rating.mjs +2 -2
  80. package/fesm2022/tectra-ng-ui-rating.mjs.map +1 -1
  81. package/fesm2022/tectra-ng-ui-select.mjs +30 -7
  82. package/fesm2022/tectra-ng-ui-select.mjs.map +1 -1
  83. package/fesm2022/tectra-ng-ui-stat-tiles.mjs +93 -8
  84. package/fesm2022/tectra-ng-ui-stat-tiles.mjs.map +1 -1
  85. package/fesm2022/tectra-ng-ui-status-icon.mjs +40 -3
  86. package/fesm2022/tectra-ng-ui-status-icon.mjs.map +1 -1
  87. package/fesm2022/tectra-ng-ui-table.mjs +20 -6
  88. package/fesm2022/tectra-ng-ui-table.mjs.map +1 -1
  89. package/fesm2022/tectra-ng-ui-tag.mjs +2 -2
  90. package/fesm2022/tectra-ng-ui-tag.mjs.map +1 -1
  91. package/fesm2022/tectra-ng-ui-toast.mjs +2 -2
  92. package/fesm2022/tectra-ng-ui-toast.mjs.map +1 -1
  93. package/fesm2022/tectra-ng-ui-tree-select.mjs +10 -8
  94. package/fesm2022/tectra-ng-ui-tree-select.mjs.map +1 -1
  95. package/fesm2022/tectra-ng-ui-tree-table.mjs +4 -4
  96. package/fesm2022/tectra-ng-ui-tree-table.mjs.map +1 -1
  97. package/fesm2022/tectra-ng-ui-truncate-text.mjs +33 -9
  98. package/fesm2022/tectra-ng-ui-truncate-text.mjs.map +1 -1
  99. package/fesm2022/tectra-ng-ui.mjs +1 -1
  100. package/icon-field/README.md +2 -1
  101. package/key-filter/README.md +3 -2
  102. package/knob/README.md +3 -1
  103. package/label/README.md +4 -1
  104. package/link/README.md +4 -1
  105. package/message/README.md +3 -3
  106. package/month-calendar/README.md +2 -1
  107. package/multiselect/README.md +1 -1
  108. package/package.json +4 -4
  109. package/panel/README.md +3 -1
  110. package/panel-menu/README.md +3 -2
  111. package/password-generator/README.md +2 -0
  112. package/pill/README.md +4 -4
  113. package/select/README.md +1 -1
  114. package/stat-tiles/README.md +17 -1
  115. package/status-icon/README.md +3 -1
  116. package/table/README.md +1 -1
  117. package/tag/README.md +2 -0
  118. package/tree-select/README.md +1 -1
  119. package/truncate-text/README.md +2 -1
  120. package/types/tectra-ng-ui-amount.d.ts +41 -1
  121. package/types/tectra-ng-ui-amount.d.ts.map +1 -1
  122. package/types/tectra-ng-ui-analog-clock.d.ts +1 -4
  123. package/types/tectra-ng-ui-analog-clock.d.ts.map +1 -1
  124. package/types/tectra-ng-ui-autocomplete.d.ts +1 -1
  125. package/types/tectra-ng-ui-avatar.d.ts +45 -12
  126. package/types/tectra-ng-ui-avatar.d.ts.map +1 -1
  127. package/types/tectra-ng-ui-cascade-select.d.ts +3 -2
  128. package/types/tectra-ng-ui-cascade-select.d.ts.map +1 -1
  129. package/types/tectra-ng-ui-chips-input.d.ts +62 -6
  130. package/types/tectra-ng-ui-chips-input.d.ts.map +1 -1
  131. package/types/tectra-ng-ui-color-picker.d.ts +38 -1
  132. package/types/tectra-ng-ui-color-picker.d.ts.map +1 -1
  133. package/types/tectra-ng-ui-countdown.d.ts +12 -1
  134. package/types/tectra-ng-ui-countdown.d.ts.map +1 -1
  135. package/types/tectra-ng-ui-country-select.d.ts +17 -4
  136. package/types/tectra-ng-ui-country-select.d.ts.map +1 -1
  137. package/types/tectra-ng-ui-country.d.ts +7 -1
  138. package/types/tectra-ng-ui-country.d.ts.map +1 -1
  139. package/types/tectra-ng-ui-datepicker.d.ts +2 -2
  140. package/types/tectra-ng-ui-datepicker.d.ts.map +1 -1
  141. package/types/tectra-ng-ui-export.d.ts +68 -8
  142. package/types/tectra-ng-ui-export.d.ts.map +1 -1
  143. package/types/tectra-ng-ui-icon-field.d.ts +9 -2
  144. package/types/tectra-ng-ui-icon-field.d.ts.map +1 -1
  145. package/types/tectra-ng-ui-key-filter.d.ts +19 -4
  146. package/types/tectra-ng-ui-key-filter.d.ts.map +1 -1
  147. package/types/tectra-ng-ui-knob.d.ts +10 -2
  148. package/types/tectra-ng-ui-knob.d.ts.map +1 -1
  149. package/types/tectra-ng-ui-label.d.ts +8 -1
  150. package/types/tectra-ng-ui-label.d.ts.map +1 -1
  151. package/types/tectra-ng-ui-link.d.ts +8 -2
  152. package/types/tectra-ng-ui-link.d.ts.map +1 -1
  153. package/types/tectra-ng-ui-mention-textarea.d.ts +5 -0
  154. package/types/tectra-ng-ui-mention-textarea.d.ts.map +1 -1
  155. package/types/tectra-ng-ui-message.d.ts +6 -3
  156. package/types/tectra-ng-ui-message.d.ts.map +1 -1
  157. package/types/tectra-ng-ui-month-calendar.d.ts +14 -4
  158. package/types/tectra-ng-ui-month-calendar.d.ts.map +1 -1
  159. package/types/tectra-ng-ui-multiselect.d.ts +1 -1
  160. package/types/tectra-ng-ui-panel-menu.d.ts +34 -6
  161. package/types/tectra-ng-ui-panel-menu.d.ts.map +1 -1
  162. package/types/tectra-ng-ui-panel.d.ts +1 -1
  163. package/types/tectra-ng-ui-panel.d.ts.map +1 -1
  164. package/types/tectra-ng-ui-password-generator.d.ts +10 -3
  165. package/types/tectra-ng-ui-password-generator.d.ts.map +1 -1
  166. package/types/tectra-ng-ui-pill.d.ts +9 -5
  167. package/types/tectra-ng-ui-pill.d.ts.map +1 -1
  168. package/types/tectra-ng-ui-select.d.ts +5 -2
  169. package/types/tectra-ng-ui-select.d.ts.map +1 -1
  170. package/types/tectra-ng-ui-stat-tiles.d.ts +49 -5
  171. package/types/tectra-ng-ui-stat-tiles.d.ts.map +1 -1
  172. package/types/tectra-ng-ui-status-icon.d.ts +20 -2
  173. package/types/tectra-ng-ui-status-icon.d.ts.map +1 -1
  174. package/types/tectra-ng-ui-table.d.ts +2 -1
  175. package/types/tectra-ng-ui-table.d.ts.map +1 -1
  176. package/types/tectra-ng-ui-tree-select.d.ts +3 -3
  177. package/types/tectra-ng-ui-tree-select.d.ts.map +1 -1
  178. package/types/tectra-ng-ui-truncate-text.d.ts +7 -2
  179. package/types/tectra-ng-ui-truncate-text.d.ts.map +1 -1
  180. package/types/tectra-ng-ui.d.ts +1 -1
package/amount/README.md CHANGED
@@ -9,6 +9,12 @@ A number or a sum of money formatted for the current locale — grouping, decima
9
9
 
10
10
  `format` uses the digits notation `minInteger.minFraction-maxFraction`: `1.0-2` (up to two decimals), `1.2-2` (always two), `1.0-0` (whole numbers). Without it a sum of money shows the digits of its currency (`$318.60`, `¥318`) and a plain number shows up to two decimals. `formatAmount(value, options)` returns the formatted parts for own markup.
11
11
 
12
+ App-wide defaults — a number locale apart from the language of the interface, the place of the currency and own currency texts:
13
+
14
+ ```ts
15
+ provideTxAmount({ locale: 'uk-UA', symbolPosition: 'after', symbols: { USDT: 'USDT', BTC: '₿' } })
16
+ ```
17
+
12
18
  ## Inputs
13
19
  | Name | Description |
14
20
  |---|---|
@@ -20,9 +26,21 @@ A number or a sum of money formatted for the current locale — grouping, decima
20
26
  | showSign | Adds `+` to positive numbers |
21
27
  | signColor | Positive numbers green, negative red |
22
28
  | strong | Bolder number |
23
- | locale | Own `Intl` locale instead of the current tectra locale |
29
+ | locale | Own `Intl` locale instead of the current tectra locale (or the `locale` of `provideTxAmount`) |
30
+ | symbolPosition | Where the currency goes: `auto` (as the locale writes it, by default), `before` or `after` the number, in any locale |
31
+ | symbols | Own currency texts by code, e.g. `{ USDT: '₮' }`; merged over the `symbols` of `provideTxAmount` |
24
32
  | emptyText | Shown when there is no number |
25
33
  | dt | Design tokens of this instance (`amount`) |
26
34
  | pt | Classes and styles of the parts: `root`, `value`, `currency` |
27
35
  | ptOptions | How `pt` merges with the global pass-through |
28
36
  | unstyled | Removes the tectra styles |
37
+
38
+ ## Providers
39
+ | Name | Description |
40
+ |---|---|
41
+ | provideTxAmount({ locale?, symbolPosition?, symbols? }) | App-wide defaults of every `tx-amount`: the `Intl` locale of numbers, where the currency goes, own currency texts by code |
42
+
43
+ ## Functions
44
+ | Name | Description |
45
+ |---|---|
46
+ | formatAmount(value, options) | The formatted parts `{ text, currency }` for own markup; options: `locale`, `currency`, `format`, `notation`, `currencyDisplay`, `showSign`, `symbolPosition`, `symbols` |
@@ -27,6 +27,6 @@ A clock face with hour and minute hands (and an optional second hand) that shows
27
27
 
28
28
  - The face is `role="img"` named by the time (`14:30`, after `ariaLabel` when set).
29
29
  - Hands turn with a soft spring and always forward — from :59 to :00 they go on, not back around the face; with reduced motion they jump.
30
- - The clock updates at the start of each minute (or second), so it stays exact without polling.
30
+ - The clock updates at the start of each minute (or second), so it stays exact without polling. Every clock of the app reads the one `TxTimeSource` of `@tectra-ng/core/utils` (also behind `TxClock.now`): one timer per step for any number of clocks, and they all tick together. A clock with a fixed `time` starts no timer, and none runs on the server.
31
31
  - The face is always round: its width is the `size` token (`210px`), at most the width of its container, and the height follows; ticks and hands are sized in percent of the face.
32
32
  - `txAnalogClockHands` (pipe) and `clockHands(time, timezone)` (a `Date`, ms or an ISO string) return `{ time, hourAngle, minuteAngle, secondAngle }`.
@@ -1,6 +1,6 @@
1
1
  # Autocomplete
2
2
 
3
- A text field that suggests values while you type. Free text, or only a suggestion with `forceSelection`; one value or several as chips. You load the suggestions in `completed` (from a server or a local list), or let the field search a fixed list with `localSearch`. Works with `[formControl]`, `ngModel` and signal forms.
3
+ A text field that suggests values while you type. Free text, or only a suggestion with `forceSelection`; one value or several as chips. You load the suggestions in `completed` (from a server or a local list), or let the field search a fixed list with `localSearch`. Works with `[formControl]`, `ngModel` and signal forms. The panel is at least as wide as the field and grows with its suggestions up to `--tx-form-field-panel-max-width` (300px; one field changes it with `[dt]="{ overlay: { maxWidth: '520px' } }"`), never past the screen; it keeps the width it opened with while you type, and lines up with the end of the field when there is no room on the right.
4
4
 
5
5
  ## Inputs
6
6
  | Name | Description |
package/avatar/README.md CHANGED
@@ -12,16 +12,26 @@ A person or an item as a small picture: a photo, otherwise initials from the nam
12
12
  </tx-avatar-group>
13
13
  ```
14
14
 
15
+ App-wide settings — an own initials rule, placeholder photos that show initials instead, one tone for every avatar with initials:
16
+
17
+ ```ts
18
+ provideTxAvatar({
19
+ initials: (name) => (name.includes(' ') ? avatarInitials(name) : name.slice(0, 2).toUpperCase()),
20
+ placeholderImages: ['/assets/blank.png', /\/default-avatar\.\w+$/],
21
+ tone: 'solid',
22
+ })
23
+ ```
24
+
15
25
  ## Inputs
16
26
  | Name | Description |
17
27
  |---|---|
18
- | image | Photo URL; when it is empty or fails to load, initials or the icon show instead |
28
+ | image | Photo URL; when it is empty, a placeholder of `provideTxAvatar` or fails to load, initials or the icon show instead |
19
29
  | name | Person's name: initials, colour, accessible name and title |
20
30
  | label | Own text instead of initials, e.g. `+3` or `AI` |
21
31
  | icon | Icon when there is no photo and no name |
22
- | size | `small`, `medium`, `large`, `xlarge` or a number of px (inherits the group) |
32
+ | size | `small`, `medium`, `large`, `xlarge`, a number of px (inherits the group), or `fill`: the whole box of the parent (give it a width and height), with the text scaled to it |
23
33
  | shape | `circle` or `square` (inherits the group) |
24
- | tone | Own colour instead of the one picked from the name: `blue`, `green`, `sky`, `orange`, `purple`, `red` |
34
+ | tone | Own colour instead of the one picked from the name (or the `tone` of `provideTxAvatar`): `blue`, `green`, `sky`, `orange`, `purple`, `red`, or `solid` (the primary colour) |
25
35
  | ariaLabel | Accessible name instead of `name`; without both the avatar is decorative |
26
36
  | tooltip | Shows `name` (or `ariaLabel`) in a tooltip instead of the native title; `none` shows no hint at all (neither tooltip nor title); inherits `tooltips` of the group, off on its own |
27
37
  | tooltipPlacement | Where the name tooltip opens (`top` by default) |
@@ -31,7 +41,7 @@ A person or an item as a small picture: a photo, otherwise initials from the nam
31
41
  | addButton | `tx-avatar-group`: a dashed add button of the avatar size at the end; emits `add` |
32
42
  | addLabel | `tx-avatar-group`: tooltip and accessible name of the add button ("Add a person", translated, by default) |
33
43
  | moreLabel | `tx-avatar-group`: accessible name of `+N` and of its popover ("N more", translated, by default) |
34
- | dt | Design tokens of this instance (`avatar`) |
44
+ | dt | Design tokens of this instance (`avatar`); on a group they also reach the list of hidden people |
35
45
  | pt | Classes and styles of the parts: `root`, `image`, `label`, `icon`; group: `root`, `more`, `add`, `list`, `item`, `name` |
36
46
  | ptOptions | How `pt` merges with the global pass-through |
37
47
  | unstyled | Removes the tectra styles |
@@ -48,6 +58,16 @@ A person or an item as a small picture: a photo, otherwise initials from the nam
48
58
  | default | Avatar: extra content, e.g. a badge; group: the avatars |
49
59
  | txAvatarGroupEnd | `tx-avatar-group`: an element after the avatars, e.g. an add button |
50
60
 
61
+ ## Providers
62
+ | Name | Description |
63
+ |---|---|
64
+ | provideTxAvatar({ initials?, placeholderImages?, tone? }) | App-wide settings of every avatar: `initials(name)` turns a name into initials, `placeholderImages` (texts or patterns) are blank photos that show initials, `tone` is one colour for every avatar with initials |
65
+
66
+ ## Functions
67
+ | Name | Description |
68
+ |---|---|
69
+ | avatarInitials(name) | The default initials rule: first letters of the first and the last word (`Olena Kovalenko` → `OK`, `admin` → `A`) |
70
+
51
71
  ## Keyboard
52
72
  | Key | Action |
53
73
  |---|---|
@@ -1,6 +1,6 @@
1
1
  # Cascade select
2
2
 
3
- Pick a value through nested groups shown as columns — country → region → city, category → subcategory → item. The next column opens on hover or with ArrowRight; only leaves are values. Works with `[formControl]`, `ngModel` and signal forms.
3
+ Pick a value through nested groups shown as columns — country → region → city, category → subcategory → item. The next column opens on hover or with ArrowRight; only leaves are values. Works with `[formControl]`, `ngModel` and signal forms. The panel is at least as wide as the field and grows with its columns up to the width of the screen; past it the columns narrow and scroll sideways.
4
4
 
5
5
  ## Inputs
6
6
  | Name | Description |
@@ -1,10 +1,11 @@
1
1
  # Chips input
2
2
 
3
- A text field that turns what you type into chips — keywords, tags, emails, domains. The value is an array of strings; works with `[formControl]`, `ngModel` and signal forms.
3
+ A text field that turns what you type into chips — keywords, tags, emails, domains. The value is an array of strings; works with `[formControl]`, `ngModel`, signal forms and `[(value)]`. Every Enter, separator, blur, paste or `add()` call is one change: the form gets the new list once, and `committed` reports what was added and what was refused.
4
4
 
5
5
  ## Inputs
6
6
  | Name | Description |
7
7
  |---|---|
8
+ | value | Two-way: the list of chips; use it or a form control |
8
9
  | text | Typed text that is not a chip yet; two-way with `[(text)]` — setting it updates the field |
9
10
  | placeholder | Text shown while the field is empty |
10
11
  | separator | Text or pattern that ends a chip while typing and splits pasted text (`,` by default); Enter always adds |
@@ -12,7 +13,9 @@ A text field that turns what you type into chips — keywords, tags, emails, dom
12
13
  | allowDuplicate | Allows the same value twice |
13
14
  | caseSensitive | Compares values with case when looking for duplicates |
14
15
  | max | Maximum number of chips; the field becomes read-only when full |
15
- | maxLength | Maximum length of one chip |
16
+ | maxLength | Maximum length of one chip; also caps typing in the field |
17
+ | maxLengthMode | What happens to a longer pasted or added value: `truncate` cuts it (default), `reject` refuses it with the reason `length` |
18
+ | normalize | `(value) => string \| null` — turns the trimmed text into the chip text before the checks (duplicates compare the result); `null` or `''` drops the value |
16
19
  | itemPattern | Values that do not match are rejected (`rejected` output) |
17
20
  | showClear | Shows a button that removes all chips |
18
21
  | inputId | Id of the text field for a `<label for>` |
@@ -21,6 +24,7 @@ A text field that turns what you type into chips — keywords, tags, emails, dom
21
24
  | size | `small`, `medium`, `large` |
22
25
  | variant | `outlined` or `filled` |
23
26
  | invalid | Red border and `aria-invalid`; follows the form control by default |
27
+ | disabled | Disables the field (also from the form control), so `[(value)]` works without forms |
24
28
  | readonly | Shows the chips, cannot change them |
25
29
  | dt | Design tokens of this instance (`chipsInput`) |
26
30
  | pt | Classes and styles of the parts: `root`, `list`, `chip`, `input`, `clear` |
@@ -32,13 +36,15 @@ A text field that turns what you type into chips — keywords, tags, emails, dom
32
36
  |---|---|
33
37
  | added | A chip was added: `{ value, values }` |
34
38
  | removed | A chip was removed: `{ value, values }` |
35
- | rejected | A value was not added — duplicate, over `max` or not matching `itemPattern`: `{ value, values }` |
39
+ | rejected | A value was not added: `{ value, values, reason }`, `reason` is `duplicate`, `max`, `pattern` or `length` |
40
+ | committed | Once per Enter, separator, blur, paste or `add()` call: `{ added, rejected, values }` |
41
+ | valueChange | The list changed (also from the form control) |
36
42
  | textChange | The typed text changed |
37
43
 
38
44
  ## Methods
39
45
  | Name | Description |
40
46
  |---|---|
41
- | add(value) | Adds a chip or a list of chips with the same checks as typing (duplicates, `max`, `maxLength`, `itemPattern`); emits `added` / `rejected`; does nothing when disabled or read-only. The typed text stays |
47
+ | add(value) | Adds a chip or a list of chips with the same steps as typing (`normalize`, `maxLength`, `itemPattern`, duplicates, `max`); emits `added` / `rejected`; does nothing when disabled or read-only. The typed text stays |
42
48
  | clearText() | Clears the typed text and keeps the chips |
43
49
  | clear() | Removes every chip and the typed text |
44
50
  | removeAt(index) | Removes the chip at the index |
@@ -54,4 +60,4 @@ A text field that turns what you type into chips — keywords, tags, emails, dom
54
60
  | Enter / separator | Adds the typed text as a chip |
55
61
  | Backspace | In an empty field, removes the last chip |
56
62
  | Tab | Moves to the remove buttons of the chips; Delete / Backspace or Enter there removes the chip |
57
- | Ctrl / ⌘ + V | Pasted text is split into chips by lines and the separator |
63
+ | Ctrl / ⌘ + V | Pasted text goes in at the cursor; text with line breaks or the separator is split into chips (the typed text becomes part of them) |
@@ -16,6 +16,11 @@ Pick a colour in a popover, inline, or from a text field: a saturation / brightn
16
16
  | inputId | Id of the button (of the text field with `field`) for a `<label for>` |
17
17
  | ariaLabel | Accessible name of the button and the panel |
18
18
  | ariaLabelledBy | Id of the element that labels the button |
19
+ | areaLabel | Accessible name of the saturation / brightness area (translated "Saturation and brightness" by default) |
20
+ | hueLabel | Accessible name of the hue slider (translated "Hue" by default) |
21
+ | hexLabel | Accessible name of the hex field in the panel (translated "Hex colour" by default) |
22
+ | clearLabel | Accessible name of the clear button (translated "Clear" by default, none when `clearText` names it) |
23
+ | clearText | Text shown next to the clear icon; without it the button shows only the icon |
19
24
  | size | `small`, `medium`, `large` |
20
25
  | invalid | Red border and `aria-invalid`; follows the form control by default |
21
26
  | readonly | Shows the colour, cannot change it |
@@ -10,13 +10,14 @@ Counts down to zero — a number of seconds, minutes, hours or days, or the time
10
10
  ## Inputs
11
11
  | Name | Description |
12
12
  |---|---|
13
- | value | Number of `unit`s to count down from; a new value starts again |
13
+ | value | Number of `unit`s to count down from; a new value (or `unit`) starts again unless `restartOnChange` is off |
14
14
  | unit | `seconds`, `minutes`, `hours` or `days` |
15
15
  | target | A date (`Date`, ISO string or ms) to count down to, instead of `value` |
16
16
  | suffix | Text after the value, e.g. `s` or a translated unit |
17
17
  | format | `number` — whole units left (default with `value`), `clock` — `mm:ss` or `h:mm:ss` (default with `target`) |
18
18
  | endingSoon | Milliseconds before zero when the countdown turns to the "ending" colour (`tx-countdown--ending`); `0` never |
19
19
  | paused | Stops the countdown and keeps the time left; it goes on from there |
20
+ | restartOnChange | `true` (default) — a new `value` or `unit` starts the countdown again; `false` — a running countdown keeps its deadline and the new value is taken at the next start (after zero or `restart()`). A new `target` always moves the deadline |
20
21
  | ariaLive | `off` (default — a ticking timer would talk every second), `polite` or `assertive` |
21
22
  | dt | Design tokens of this instance (`countdown`) |
22
23
  | pt | Classes and styles of the root |
@@ -29,6 +30,11 @@ Counts down to zero — a number of seconds, minutes, hours or days, or the time
29
30
  | completed | Zero was reached; fires once per start |
30
31
  | tick | The time left in milliseconds, whenever the shown value changes |
31
32
 
33
+ ## Methods
34
+ | Name | Description |
35
+ |---|---|
36
+ | restart() | Starts again from the current `value` and `unit` (or `target`) |
37
+
32
38
  ## Slots
33
39
  | Name | Description |
34
40
  |---|---|
package/country/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Country
2
2
 
3
- A country as a flag and its name. The name comes from `Intl.DisplayNames` in the current tectra locale, so it follows `setLocale`. Unknown values are shown as plain text. Also exports the ISO 3166-1 code list (`TX_COUNTRY_CODES`), `countryName`, `countryEmoji` and `isCountryCode`.
3
+ A country as a flag and its name. The name comes from `Intl.DisplayNames` in the current tectra locale, so it follows `setLocale`. Unknown values are shown as plain text. Also exports the ISO 3166-1 code list (`TX_COUNTRY_CODES`), the region codes (`TX_REGION_CODES`), `countryName`, `countryEmoji` and `isCountryCode`.
4
4
 
5
5
  Flags are emoji by default — no assets to load. To draw them as images, provide a resolver once. The tectra flag set, loaded flag by flag on demand:
6
6
 
@@ -31,3 +31,16 @@ While an async flag loads, its box is already there (the `loading-background` to
31
31
  | pt | Classes and styles of the parts: `root`, `flag`, `name` |
32
32
  | ptOptions | How `pt` merges with the global pass-through |
33
33
  | unstyled | Removes the tectra styles |
34
+
35
+ ## Constants
36
+ | Name | Description |
37
+ |---|---|
38
+ | TX_COUNTRY_CODES | ISO 3166-1 alpha-2 codes of every country, plus `XK` (Kosovo) |
39
+ | TX_REGION_CODES | Codes with a name and a flag that are not countries: `EU` (European Union), `UN` (United Nations); add them with `[...TX_COUNTRY_CODES, ...TX_REGION_CODES]` |
40
+
41
+ ## Functions
42
+ | Name | Description |
43
+ |---|---|
44
+ | countryName(code, locale) | Localized name (`PL` → `Poland`); other text comes back as it is; a locale `Intl` does not accept falls back to `en-US` |
45
+ | countryEmoji(code) | Emoji flag of a two-letter code, an empty string otherwise |
46
+ | isCountryCode(code) | Whether the text is two letters, as a country code looks |
@@ -5,12 +5,13 @@ Pick one country or several. Built on `tx-select` and `tx-multiselect`: every IS
5
5
  ## Inputs
6
6
  | Name | Description |
7
7
  |---|---|
8
- | options | Countries to offer: codes, or `{ code, value?, label?, count?, hint?, disabled? }`; all countries by default |
8
+ | options | Countries to offer: codes, or `{ code, value?, label?, count?, hint?, disabled?, flag? }`; all countries by default. A code that is not a country or a region (`none`, `ZZ`) is a text row without a flag, and its value stays as written; `flag: false` drops the flag of any row |
9
9
  | multiple | Several countries; the value is an array |
10
10
  | filter | Search by name or code (on by default) |
11
11
  | sort | `name` (localized, by default) or `none` (keep the order of `options`) |
12
12
  | shape | Flag shape: `rectangle` or `circle` |
13
13
  | maxFlags | With `multiple`: flags shown in the field before "+N" |
14
+ | maxNamed | With `multiple`: up to this many picked countries show their names in the field, more show only flags (1 by default) |
14
15
  | virtualScrollThreshold | Above this many countries the list is virtual |
15
16
  | placeholder | Text shown while nothing is selected |
16
17
  | showClear | Shows a button that clears the value |
package/export/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Export
2
2
 
3
- Saves rows as a file in the browser — CSV, Excel (`.xlsx`), Word (`.docx`), PDF, JSON, HTML, Markdown — copies them as a table or prints them, without any third-party library. The Excel and Word files are written by the kit itself (zip + Office XML); the PDF embeds only the glyphs it uses from the Onest font (Latin and Cyrillic, loaded from `@tectra-ng/ui/export-font` on the first PDF export), so its text is real and searchable.
3
+ Saves rows as a file in the browser — CSV, Excel (`.xlsx`), Word (`.docx`), PDF, JSON, HTML, Markdown — copies them as a table or prints them, and turns rich HTML into a paged PDF, without any third-party library. The Excel and Word files are written by the kit itself (zip + Office XML); the PDF embeds only the glyphs it uses from the Onest font (Latin and Cyrillic, loaded from `@tectra-ng/ui/export-font` on the first PDF export), so its text is real and searchable.
4
4
 
5
5
  Each format has its own icon button — `<tx-export-csv>`, `<tx-export-excel>`, `<tx-export-word>`, `<tx-export-pdf>`, or `<tx-export-button format="…">` for any of them — and `<tx-export>` is one "Export" split button with a menu of formats. They all take the same `fields`, `data` / `fetchData` and `options`.
6
6
 
@@ -48,6 +48,17 @@ exportFields: TxExportField<User>[] = [
48
48
  | failed | `fetchData`, the writer or the clipboard threw; the button is ready for the next click |
49
49
  | dataChange | The rows changed after `fetchData` |
50
50
 
51
+ ## Methods
52
+ | Name | Description |
53
+ |---|---|
54
+ | TxExportService.exportHtmlPdf(source, options) | Turns rich HTML — a string, or an element whose content is read — into a paged PDF and saves it; resolves to the file name. `options`: `filename` plus the options of `writeHtmlPdf`, merged over the `title` and `pdf` options of `provideTxExport()` |
55
+ | TxExportService.htmlPdfFile(source, options) | The same without saving: resolves to `{ blob, filename }` |
56
+
57
+ ## Functions
58
+ | Name | Description |
59
+ |---|---|
60
+ | writeHtmlPdf(source, options) | Writes rich HTML (string or DOM node) as a PDF blob with real, selectable text. A string is read without a DOM, so it also runs on the server. See "Rich HTML to PDF" below |
61
+
51
62
  ## Keyboard
52
63
  | Key | Action |
53
64
  |---|---|
@@ -69,11 +80,25 @@ exportFields: TxExportField<User>[] = [
69
80
 
70
81
  `provideTxExport(options)` sets defaults for the app or for one component subtree.
71
82
 
83
+ ## Rich HTML to PDF
84
+
85
+ ```ts
86
+ const exporter = inject(TxExportService);
87
+ await exporter.exportHtmlPdf(this.article().nativeElement, { filename: 'release-notes', title: 'Release notes', pageSize: 'a4' });
88
+
89
+ const blob = await writeHtmlPdf('<h1>Report</h1><p>Hello <b>world</b></p>', { margin: 56 });
90
+ ```
91
+
92
+ - Draws headings `h1`–`h6`, paragraphs, `<br>`, bold / italic / underline / strike, `sub` / `sup`, `small`, links (clickable, `http`, `https`, `mailto`, `tel`), inline code and `<pre>` blocks (whitespace kept, long lines wrapped), ordered (`start`) and unordered lists nested to any depth, `blockquote`, `hr`, definition lists, figure captions and the alt text of images, and tables: `thead` rows (or a first row of `th` cells) repeat on every page, `colspan` spans columns, columns are sized by their content and rows taller than the rest of a page are split across pages.
93
+ - Lines wrap by the real widths of the font; a heading never ends a page. `text-align` (or `align`) of blocks and cells, `font-weight`, `font-style` and `text-decoration` of inline styles are read; other CSS is not. `break-before: page` and `break-after: page` (or `page-break-*: always`) start a new page.
94
+ - Options: `pageSize`, `orientation` (`portrait` by default), `margin` (48), `fontSize` (10; headings, code and tables follow it), `lineHeight` (1.45), `title` and `author` (file properties), `pageNumbers` (on), `textColor`, `mutedColor`, `linkColor`, `borderColor`, `headerBackground` (or `none`), `codeBackground`, `font`, `compress`.
95
+ - Text is set in Onest (Latin and Cyrillic); the font loader may add `italic` and `mono` TrueType files, otherwise italic is slanted and code uses the regular font. Images, forms, scripts and styles are left out.
96
+
72
97
  ## Accessibility
73
98
 
74
99
  Icon-only buttons are named by their tooltip. While an export runs the button spins, has `aria-busy` and ignores more clicks. After copying, the button shows a check, its name becomes "Table copied" and the text is announced.
75
100
 
76
101
  ## Notes
77
102
 
78
- - `TxExportService.export({ format, rows, fields, options })` runs an export from code; `buildExportTable`, `writeCsv`, `writeXlsx`, `writeDocx`, `writePdf`, `writeJson`, `writeHtml`, `writeMarkdown` and `zip` are exported for own flows. `tx-table` `exportCSV()` uses the same CSV writer.
103
+ - `TxExportService.export({ format, rows, fields, options })` runs an export from code; `buildExportTable`, `writeCsv`, `writeXlsx`, `writeDocx`, `writePdf`, `writeHtmlPdf`, `writeJson`, `writeHtml`, `writeMarkdown` and `zip` are exported for own flows. `tx-table` `exportCSV()` uses the same CSV writer.
79
104
  - PDF uses a TrueType font without shaping, so scripts that need it (Arabic, Indic) need their own font through `pdf.font`, and right-to-left text is not reordered.
@@ -1,6 +1,6 @@
1
1
  # Export font
2
2
 
3
- Onest Regular and SemiBold (Latin and Cyrillic) for `tx-export` PDF files, as base64 strings: `TX_EXPORT_FONT`. The PDF writer loads this entry point only on the first PDF export, keeps only the glyphs a file uses and embeds them, so the text in the PDF is real, selectable and searchable.
3
+ Onest Regular and SemiBold (Latin and Cyrillic) for `tx-export` PDF files and `writeHtmlPdf`, as base64 strings: `TX_EXPORT_FONT`. The PDF writer loads this entry point only on the first PDF export, keeps only the glyphs a file uses and embeds them, so the text in the PDF is real, selectable and searchable.
4
4
 
5
5
  Onest is © The Onest Project Authors, licensed under the SIL Open Font License 1.1 — see `OFL.txt` next to this file. Regenerate with `npm run export-font -- <folder of an Onest release>`.
6
6
 
@@ -1,12 +1,22 @@
1
1
  import * as i0 from "@angular/core";
2
- import { ChangeDetectionStrategy, Component, booleanAttribute, computed, inject, input } from "@angular/core";
2
+ import { ChangeDetectionStrategy, Component, InjectionToken, booleanAttribute, computed, inject, input } from "@angular/core";
3
3
  import { injectPassThrough, injectTokens, injectUnstyled } from "@tectra-ng/core/config";
4
4
  import { TxLocaleService } from "@tectra-ng/core/i18n";
5
5
  import { optionalBoolean } from "@tectra-ng/core/utils";
6
6
  import { amountTokens, toStyleObject } from "@tectra-ng/themes";
7
7
  import { provideTxIconDefaults, txIconCode } from "@tectra-ng/icons";
8
+ const TX_AMOUNT_OPTIONS = new InjectionToken("TX_AMOUNT_OPTIONS");
9
+ function provideTxAmount(options) {
10
+ return {
11
+ provide: TX_AMOUNT_OPTIONS,
12
+ useValue: options
13
+ };
14
+ }
8
15
  const DIGITS_INFO = /^(\d+)?(?:\.(\d+))?(?:-(\d+))?$/;
9
16
  const DEFAULT_FORMAT = "1.0-2";
17
+ const SPACE = /^\s+$/;
18
+ const ENDS_WITH_SYMBOL = /\p{Sc}$/u;
19
+ const NO_BREAK_SPACE = "\xA0";
10
20
  function parseDigitsInfo(format) {
11
21
  const match = DIGITS_INFO.exec((format ?? "").trim());
12
22
  if (!match) return {};
@@ -32,6 +42,34 @@ function toSegments(parts) {
32
42
  }
33
43
  return segments;
34
44
  }
45
+ function ownSymbol(symbols, currency) {
46
+ return symbols?.[currency] ?? symbols?.[currency.toUpperCase()];
47
+ }
48
+ function isSign(part) {
49
+ return part?.type === "minusSign" || part?.type === "plusSign";
50
+ }
51
+ function placeSymbol(parts, position) {
52
+ const index = parts.findIndex((part) => part.type === "currency");
53
+ if (position === "auto" || index < 0) return parts;
54
+ const currency = parts[index];
55
+ const number = parts.filter((part, at) => at !== index && !(Math.abs(at - index) === 1 && part.type === "literal" && SPACE.test(part.value)));
56
+ const space = {
57
+ type: "literal",
58
+ value: NO_BREAK_SPACE
59
+ };
60
+ if (position === "after") return [
61
+ ...number,
62
+ space,
63
+ currency
64
+ ];
65
+ const lead = isSign(number[0]) ? 1 : 0;
66
+ return [
67
+ ...number.slice(0, lead),
68
+ currency,
69
+ ...ENDS_WITH_SYMBOL.test(currency.value) ? [] : [space],
70
+ ...number.slice(lead)
71
+ ];
72
+ }
35
73
  function formatAmount(amount, options) {
36
74
  const currency = options.currency?.trim();
37
75
  const base = (format) => ({
@@ -40,33 +78,40 @@ function formatAmount(amount, options) {
40
78
  signDisplay: options.showSign ? "exceptZero" : "auto"
41
79
  });
42
80
  const plain = base(options.format ?? DEFAULT_FORMAT);
43
- if (currency) try {
44
- return toSegments(new Intl.NumberFormat(options.locale, {
81
+ if (!currency) return toSegments(new Intl.NumberFormat(options.locale, plain).formatToParts(amount));
82
+ let parts;
83
+ try {
84
+ parts = new Intl.NumberFormat(options.locale, {
45
85
  ...base(options.format),
46
86
  style: "currency",
47
87
  currency,
48
88
  currencyDisplay: options.currencyDisplay ?? "narrowSymbol"
49
- }).formatToParts(amount));
89
+ }).formatToParts(amount);
50
90
  } catch {
51
- return [
52
- ...toSegments(new Intl.NumberFormat(options.locale, plain).formatToParts(amount)),
91
+ parts = [
92
+ ...new Intl.NumberFormat(options.locale, plain).formatToParts(amount),
53
93
  {
54
- text: " ",
55
- currency: false
94
+ type: "literal",
95
+ value: " "
56
96
  },
57
97
  {
58
- text: currency,
59
- currency: true
98
+ type: "currency",
99
+ value: currency
60
100
  }
61
101
  ];
62
102
  }
63
- return toSegments(new Intl.NumberFormat(options.locale, plain).formatToParts(amount));
103
+ const symbol = ownSymbol(options.symbols, currency);
104
+ return toSegments(placeSymbol(symbol === void 0 ? parts : parts.map((part) => part.type === "currency" ? {
105
+ ...part,
106
+ value: symbol
107
+ } : part), options.symbolPosition ?? "auto"));
64
108
  }
65
109
  const AMOUNT_ICON_DEFAULTS = { code: txIconCode };
66
110
  const AMOUNT_THEME = { amount: amountTokens };
67
111
  var TxAmount = class TxAmount {
68
112
  amountTheme = injectTokens(AMOUNT_THEME);
69
113
  localeService = inject(TxLocaleService);
114
+ options = inject(TX_AMOUNT_OPTIONS, { optional: true });
70
115
  amount = input(null, ...ngDevMode ? [{ debugName: "amount" }] : /* istanbul ignore next */ []);
71
116
  currency = input(void 0, ...ngDevMode ? [{ debugName: "currency" }] : /* istanbul ignore next */ []);
72
117
  format = input(void 0, ...ngDevMode ? [{ debugName: "format" }] : /* istanbul ignore next */ []);
@@ -85,6 +130,8 @@ var TxAmount = class TxAmount {
85
130
  transform: booleanAttribute
86
131
  });
87
132
  locale = input(void 0, ...ngDevMode ? [{ debugName: "locale" }] : /* istanbul ignore next */ []);
133
+ symbolPosition = input(void 0, ...ngDevMode ? [{ debugName: "symbolPosition" }] : /* istanbul ignore next */ []);
134
+ symbols = input(void 0, ...ngDevMode ? [{ debugName: "symbols" }] : /* istanbul ignore next */ []);
88
135
  emptyText = input("—", ...ngDevMode ? [{ debugName: "emptyText" }] : /* istanbul ignore next */ []);
89
136
  dt = input(void 0, ...ngDevMode ? [{ debugName: "dt" }] : /* istanbul ignore next */ []);
90
137
  pt = input(void 0, ...ngDevMode ? [{ debugName: "pt" }] : /* istanbul ignore next */ []);
@@ -108,12 +155,17 @@ var TxAmount = class TxAmount {
108
155
  const amount = this.amount();
109
156
  if (this.isEmpty() || amount === null || amount === void 0) return [];
110
157
  return formatAmount(amount, {
111
- locale: this.locale() ?? this.localeService.locale().intl,
158
+ locale: this.locale() ?? this.options?.locale ?? this.localeService.locale().intl,
112
159
  currency: this.currency(),
113
160
  format: this.format(),
114
161
  notation: this.notation(),
115
162
  currencyDisplay: this.currencyDisplay(),
116
- showSign: this.showSign()
163
+ showSign: this.showSign(),
164
+ symbolPosition: this.symbolPosition() ?? this.options?.symbolPosition,
165
+ symbols: {
166
+ ...this.options?.symbols,
167
+ ...this.symbols()
168
+ }
117
169
  });
118
170
  }, ...ngDevMode ? [{ debugName: "segments" }] : /* istanbul ignore next */ []);
119
171
  hostStyle = computed(() => ({
@@ -198,6 +250,20 @@ var TxAmount = class TxAmount {
198
250
  isRequired: false,
199
251
  transformFunction: null
200
252
  },
253
+ symbolPosition: {
254
+ classPropertyName: "symbolPosition",
255
+ publicName: "symbolPosition",
256
+ isSignal: true,
257
+ isRequired: false,
258
+ transformFunction: null
259
+ },
260
+ symbols: {
261
+ classPropertyName: "symbols",
262
+ publicName: "symbols",
263
+ isSignal: true,
264
+ isRequired: false,
265
+ transformFunction: null
266
+ },
201
267
  emptyText: {
202
268
  classPropertyName: "emptyText",
203
269
  publicName: "emptyText",
@@ -376,6 +442,22 @@ i0.ɵɵngDeclareClassMetadata({
376
442
  required: false
377
443
  }]
378
444
  }],
445
+ symbolPosition: [{
446
+ type: i0.Input,
447
+ args: [{
448
+ isSignal: true,
449
+ alias: "symbolPosition",
450
+ required: false
451
+ }]
452
+ }],
453
+ symbols: [{
454
+ type: i0.Input,
455
+ args: [{
456
+ isSignal: true,
457
+ alias: "symbols",
458
+ required: false
459
+ }]
460
+ }],
379
461
  emptyText: [{
380
462
  type: i0.Input,
381
463
  args: [{
@@ -418,6 +500,6 @@ i0.ɵɵngDeclareClassMetadata({
418
500
  }]
419
501
  }
420
502
  });
421
- export { TxAmount, formatAmount, parseDigitsInfo };
503
+ export { TX_AMOUNT_OPTIONS, TxAmount, formatAmount, parseDigitsInfo, provideTxAmount };
422
504
 
423
505
  //# sourceMappingURL=tectra-ng-ui-amount.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"tectra-ng-ui-amount.mjs","names":[],"sources":["../../../../packages/ui/amount/src/format-amount.ts","../../../../packages/ui/amount/src/amount.icons.ts","../../../../packages/ui/amount/src/amount.theme.ts","../../../../packages/ui/amount/src/amount.component.ts"],"sourcesContent":["import { TxAmountFormatOptions, TxAmountSegment } from './amount.types';\n\nconst DIGITS_INFO = /^(\\d+)?(?:\\.(\\d+))?(?:-(\\d+))?$/;\nconst DEFAULT_FORMAT = '1.0-2';\n\n/**\n * Reads a digits-info string like `1.2-2` (integer digits, minimum and maximum fraction digits) into number format options; an invalid string gives no options.\n */\nexport function parseDigitsInfo(format: string | undefined): Pick<Intl.NumberFormatOptions, 'minimumIntegerDigits' | 'minimumFractionDigits' | 'maximumFractionDigits'> {\n const match = DIGITS_INFO.exec((format ?? '').trim());\n if (!match) {\n return {};\n }\n const [, integer, minFraction, maxFraction] = match;\n const minimumFractionDigits = minFraction === undefined ? undefined : Number(minFraction);\n const maximumFractionDigits = maxFraction === undefined ? minimumFractionDigits : Math.max(Number(maxFraction), minimumFractionDigits ?? 0);\n return {\n ...(integer === undefined ? {} : { minimumIntegerDigits: Math.max(1, Number(integer)) }),\n ...(minimumFractionDigits === undefined ? {} : { minimumFractionDigits }),\n ...(maximumFractionDigits === undefined ? {} : { maximumFractionDigits }),\n };\n}\n\nfunction toSegments(parts: Intl.NumberFormatPart[]): TxAmountSegment[] {\n const segments: TxAmountSegment[] = [];\n for (const part of parts) {\n const currency = part.type === 'currency';\n const last = segments[segments.length - 1];\n if (last && last.currency === currency) {\n last.text += part.value;\n } else {\n segments.push({ text: part.value, currency });\n }\n }\n return segments;\n}\n\n/**\n * Formats a number as money in the given locale and currency and splits the result into currency and number segments.\n */\nexport function formatAmount(amount: number, options: TxAmountFormatOptions): TxAmountSegment[] {\n const currency = options.currency?.trim();\n const base = (format: string | undefined): Intl.NumberFormatOptions => ({\n ...parseDigitsInfo(format),\n notation: options.notation ?? 'standard',\n signDisplay: options.showSign ? 'exceptZero' : 'auto',\n });\n const plain = base(options.format ?? DEFAULT_FORMAT);\n if (currency) {\n try {\n return toSegments(\n new Intl.NumberFormat(options.locale, { ...base(options.format), style: 'currency', currency, currencyDisplay: options.currencyDisplay ?? 'narrowSymbol' }).formatToParts(amount),\n );\n } catch {\n return [...toSegments(new Intl.NumberFormat(options.locale, plain).formatToParts(amount)), { text: ' ', currency: false }, { text: currency, currency: true }];\n }\n }\n return toSegments(new Intl.NumberFormat(options.locale, plain).formatToParts(amount));\n}\n","import { TxIconSet, txIconCode } from '@tectra-ng/icons';\n\nexport const AMOUNT_ICON_DEFAULTS: TxIconSet = {\n code: txIconCode,\n};\n","import { amountTokens } from '@tectra-ng/themes';\n\nexport const AMOUNT_THEME = {\n amount: amountTokens,\n};\n","import { ChangeDetectionStrategy, Component, booleanAttribute, computed, inject, input } from '@angular/core';\nimport { injectPassThrough, injectTokens, injectUnstyled, TxPassThrough, TxPassThroughOptions } from '@tectra-ng/core/config';\nimport { TxLocaleService } from '@tectra-ng/core/i18n';\nimport { optionalBoolean } from '@tectra-ng/core/utils';\nimport { TectraAmountTokens, TectraDeepPartial, toStyleObject } from '@tectra-ng/themes';\nimport { TxAmountCurrencyDisplay, TxAmountNotation, TxAmountPart, TxAmountSign } from './amount.types';\nimport { formatAmount } from './format-amount';\nimport { provideTxIconDefaults } from '@tectra-ng/icons';\nimport { AMOUNT_ICON_DEFAULTS } from './amount.icons';\nimport { AMOUNT_THEME } from './amount.theme';\n\n@Component({\n selector: 'tx-amount',\n template: `\n @if (isEmpty()) {\n <span class=\"tx-amount__empty\">{{ emptyText() }}</span>\n } @else {\n @for (segment of segments(); track $index) {\n @if (segment.currency) {\n <span class=\"tx-amount__currency\" [class]=\"passThrough().currency?.class\" [style]=\"passThrough().currency?.style\">{{ segment.text }}</span>\n } @else {\n <span class=\"tx-amount__value\" [class]=\"passThrough().value?.class\" [style]=\"passThrough().value?.style\">{{ segment.text }}</span>\n }\n }\n }\n `,\n styleUrl: './amount.component.scss',\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: {\n class: 'tx-amount',\n '[class]': 'passThrough().root?.class',\n '[style]': 'hostStyle()',\n '[attr.data-styled]': '!isUnstyled() || null',\n '[attr.data-sign]': 'signColor() ? sign() : null',\n '[class.tx-amount--strong]': 'strong()',\n '[class.tx-amount--zero]': 'sign() === \"zero\"',\n '[class.tx-amount--empty]': 'isEmpty()',\n },\n viewProviders: [provideTxIconDefaults(AMOUNT_ICON_DEFAULTS)],\n})\nexport class TxAmount {\n private readonly amountTheme = injectTokens(AMOUNT_THEME);\n\n private localeService = inject(TxLocaleService);\n\n readonly amount = input<number | null | undefined>(null);\n readonly currency = input<string | null | undefined>(undefined);\n readonly format = input<string | undefined>(undefined);\n readonly notation = input<TxAmountNotation>('standard');\n readonly currencyDisplay = input<TxAmountCurrencyDisplay>('narrowSymbol');\n readonly showSign = input<boolean, unknown>(false, { transform: booleanAttribute });\n readonly signColor = input<boolean, unknown>(false, { transform: booleanAttribute });\n readonly strong = input<boolean, unknown>(false, { transform: booleanAttribute });\n readonly locale = input<string | undefined>(undefined);\n readonly emptyText = input<string>('—');\n readonly dt = input<TectraDeepPartial<TectraAmountTokens> | undefined>(undefined);\n readonly pt = input<TxPassThrough<TxAmountPart, TxAmount> | undefined>(undefined);\n readonly ptOptions = input<TxPassThroughOptions | undefined>(undefined);\n readonly unstyled = input<boolean | undefined, unknown>(undefined, { transform: optionalBoolean });\n\n readonly isUnstyled = injectUnstyled(this.unstyled);\n readonly passThrough = injectPassThrough('amount', this, this.pt, this.ptOptions);\n readonly isEmpty = computed(() => {\n const amount = this.amount();\n return amount === null || amount === undefined || Number.isNaN(amount);\n });\n readonly sign = computed<TxAmountSign | null>(() => {\n const amount = this.amount();\n if (this.isEmpty() || amount === null || amount === undefined) {\n return null;\n }\n return amount > 0 ? 'positive' : amount < 0 ? 'negative' : 'zero';\n });\n readonly segments = computed(() => {\n const amount = this.amount();\n if (this.isEmpty() || amount === null || amount === undefined) {\n return [];\n }\n return formatAmount(amount, {\n locale: this.locale() ?? this.localeService.locale().intl,\n currency: this.currency(),\n format: this.format(),\n notation: this.notation(),\n currencyDisplay: this.currencyDisplay(),\n showSign: this.showSign(),\n });\n });\n readonly hostStyle = computed(() => ({ ...toSt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oBAAoB,CAAC;GAAC,QAAA,CAAA,q3BAAA;EAAA,CAAA"}
1
+ {"version":3,"file":"tectra-ng-ui-amount.mjs","names":[],"sources":["../../../../packages/ui/amount/src/amount.options.ts","../../../../packages/ui/amount/src/format-amount.ts","../../../../packages/ui/amount/src/amount.icons.ts","../../../../packages/ui/amount/src/amount.theme.ts","../../../../packages/ui/amount/src/amount.component.ts"],"sourcesContent":["import { InjectionToken, Provider } from '@angular/core';\nimport { TxAmountOptions } from './amount.types';\n\n/** App-wide defaults of every `tx-amount`; set them with `provideTxAmount`. */\nexport const TX_AMOUNT_OPTIONS = new InjectionToken<TxAmountOptions>('TX_AMOUNT_OPTIONS');\n\n/**\n * Sets app-wide defaults of every `tx-amount`: the number locale, where the currency goes and own currency texts,\n * e.g. `provideTxAmount({ locale: 'uk-UA', symbolPosition: 'after', symbols: { USDT: 'USDT' } })`.\n */\nexport function provideTxAmount(options: TxAmountOptions): Provider {\n return { provide: TX_AMOUNT_OPTIONS, useValue: options };\n}\n","import { TxAmountFormatOptions, TxAmountSegment, TxAmountSymbolPosition, TxAmountSymbols } from './amount.types';\n\nconst DIGITS_INFO = /^(\\d+)?(?:\\.(\\d+))?(?:-(\\d+))?$/;\nconst DEFAULT_FORMAT = '1.0-2';\nconst SPACE = /^\\s+$/;\nconst ENDS_WITH_SYMBOL = /\\p{Sc}$/u;\nconst NO_BREAK_SPACE = '\\u00a0';\n\n/**\n * Reads a digits-info string like `1.2-2` (integer digits, minimum and maximum fraction digits) into number format options; an invalid string gives no options.\n */\nexport function parseDigitsInfo(format: string | undefined): Pick<Intl.NumberFormatOptions, 'minimumIntegerDigits' | 'minimumFractionDigits' | 'maximumFractionDigits'> {\n const match = DIGITS_INFO.exec((format ?? '').trim());\n if (!match) {\n return {};\n }\n const [, integer, minFraction, maxFraction] = match;\n const minimumFractionDigits = minFraction === undefined ? undefined : Number(minFraction);\n const maximumFractionDigits = maxFraction === undefined ? minimumFractionDigits : Math.max(Number(maxFraction), minimumFractionDigits ?? 0);\n return {\n ...(integer === undefined ? {} : { minimumIntegerDigits: Math.max(1, Number(integer)) }),\n ...(minimumFractionDigits === undefined ? {} : { minimumFractionDigits }),\n ...(maximumFractionDigits === undefined ? {} : { maximumFractionDigits }),\n };\n}\n\nfunction toSegments(parts: Intl.NumberFormatPart[]): TxAmountSegment[] {\n const segments: TxAmountSegment[] = [];\n for (const part of parts) {\n const currency = part.type === 'currency';\n const last = segments[segments.length - 1];\n if (last && last.currency === currency) {\n last.text += part.value;\n } else {\n segments.push({ text: part.value, currency });\n }\n }\n return segments;\n}\n\nfunction ownSymbol(symbols: TxAmountSymbols | undefined, currency: string): string | undefined {\n return symbols?.[currency] ?? symbols?.[currency.toUpperCase()];\n}\n\nfunction isSign(part: Intl.NumberFormatPart | undefined): boolean {\n return part?.type === 'minusSign' || part?.type === 'plusSign';\n}\n\nfunction placeSymbol(parts: Intl.NumberFormatPart[], position: TxAmountSymbolPosition): Intl.NumberFormatPart[] {\n const index = parts.findIndex((part) => part.type === 'currency');\n if (position === 'auto' || index < 0) {\n return parts;\n }\n const currency = parts[index];\n const number = parts.filter((part, at) => at !== index && !(Math.abs(at - index) === 1 && part.type === 'literal' && SPACE.test(part.value)));\n const space: Intl.NumberFormatPart = { type: 'literal', value: NO_BREAK_SPACE };\n if (position === 'after') {\n return [...number, space, currency];\n }\n const lead = isSign(number[0]) ? 1 : 0;\n return [...number.slice(0, lead), currency, ...(ENDS_WITH_SYMBOL.test(currency.value) ? [] : [space]), ...number.slice(lead)];\n}\n\n/**\n * Formats a number as money in the given locale and currency and splits the result into currency and number segments.\n */\nexport function formatAmount(amount: number, options: TxAmountFormatOptions): TxAmountSegment[] {\n const currency = options.currency?.trim();\n const base = (format: string | undefined): Intl.NumberFormatOptions => ({\n ...parseDigitsInfo(format),\n notation: options.notation ?? 'standard',\n signDisplay: options.showSign ? 'exceptZero' : 'auto',\n });\n const plain = base(options.format ?? DEFAULT_FORMAT);\n if (!currency) {\n return toSegments(new Intl.NumberFormat(options.locale, plain).formatToParts(amount));\n }\n let parts: Intl.NumberFormatPart[];\n try {\n parts = new Intl.NumberFormat(options.locale, { ...base(options.format), style: 'currency', currency, currencyDisplay: options.currencyDisplay ?? 'narrowSymbol' }).formatToParts(amount);\n } catch {\n parts = [...new Intl.NumberFormat(options.locale, plain).formatToParts(amount), { type: 'literal', value: ' ' }, { type: 'currency', value: currency }];\n }\n const symbol = ownSymbol(options.symbols, currency);\n const named = symbol === undefined ? parts : parts.map((part) => (part.type === 'currency' ? { ...part, value: symbol } : part));\n return toSegments(placeSymbol(named, options.symbolPosition ?? 'auto'));\n}\n","import { TxIconSet, txIconCode } from '@tectra-ng/icons';\n\nexport const AMOUNT_ICON_DEFAULTS: TxIconSet = {\n code: txIconCode,\n};\n","import { amountTokens } from '@tectra-ng/themes';\n\nexport const AMOUNT_THEME = {\n amount: amountTokens,\n};\n","import { ChangeDetectionStrategy, Component, booleanAttribute, computed, inject, input } from '@angular/core';\nimport { injectPassThrough, injectTokens, injectUnstyled, TxPassThrough, TxPassThroughOptions } from '@tectra-ng/core/config';\nimport { TxLocaleService } from '@tectra-ng/core/i18n';\nimport { optionalBoolean } from '@tectra-ng/core/utils';\nimport { TectraAmountTokens, TectraDeepPartial, toStyleObject } from '@tectra-ng/themes';\nimport { TX_AMOUNT_OPTIONS } from './amount.options';\nimport { TxAmountCurrencyDisplay, TxAmountNotation, TxAmountPart, TxAmountSign, TxAmountSymbolPosition, TxAmountSymbols } from './amount.types';\nimport { formatAmount } from './format-amount';\nimport { provideTxIconDefaults } from '@tectra-ng/icons';\nimport { AMOUNT_ICON_DEFAULTS } from './amount.icons';\nimport { AMOUNT_THEME } from './amount.theme';\n\n@Component({\n selector: 'tx-amount',\n template: `\n @if (isEmpty()) {\n <span class=\"tx-amount__empty\">{{ emptyText() }}</span>\n } @else {\n @for (segment of segments(); track $index) {\n @if (segment.currency) {\n <span class=\"tx-amount__currency\" [class]=\"passThrough().currency?.class\" [style]=\"passThrough().currency?.style\">{{ segment.text }}</span>\n } @else {\n <span class=\"tx-amount__value\" [class]=\"passThrough().value?.class\" [style]=\"passThrough().value?.style\">{{ segment.text }}</span>\n }\n }\n }\n `,\n styleUrl: './amount.component.scss',\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: {\n class: 'tx-amount',\n '[class]': 'passThrough().root?.class',\n '[style]': 'hostStyle()',\n '[attr.data-styled]': '!isUnstyled() || null',\n '[attr.data-sign]': 'signColor() ? sign() : null',\n '[class.tx-amount--strong]': 'strong()',\n '[class.tx-amount--zero]': 'sign() === \"zero\"',\n '[class.tx-amount--empty]': 'isEmpty()',\n },\n viewProviders: [provideTxIconDefaults(AMOUNT_ICON_DEFAULTS)],\n})\nexport class TxAmount {\n private readonly amountTheme = injectTokens(AMOUNT_THEME);\n\n private localeService = inject(TxLocaleService);\n private options = inject(TX_AMOUNT_OPTIONS, { optional: true });\n\n readonly amount = input<number | null | undefined>(null);\n readonly currency = input<string | null | undefined>(undefined);\n readonly format = input<string | undefined>(undefined);\n readonly notation = input<TxAmountNotation>('standard');\n readonly currencyDisplay = input<TxAmountCurrencyDisplay>('narrowSymbol');\n readonly showSign = input<boolean, unknown>(false, { transform: booleanAttribute });\n readonly signColor = input<boolean, unknown>(false, { transform: booleanAttribute });\n readonly strong = input<boolean, unknown>(false, { transform: booleanAttribute });\n readonly locale = input<string | undefined>(undefined);\n readonly symbolPosition = input<TxAmountSymbolPosition | undefined>(undefined);\n readonly symbols = input<TxAmountSymbols | undefined>(undefined);\n readonly emptyText = input<string>('—');\n readonly dt = input<TectraDeepPartial<TectraAmountTokens> | undefined>(undefined);\n readonly pt = input<TxPassThrough<TxAmountPart, TxAmount> | undefined>(undefined);\n readonly ptOptions = input<TxPassThroughOptions | undefined>(undefined);\n readonly unstyled = input<boolean | undefined, unknown>(undefined, { transform: optionalBoolean });\n\n readonly isUnstyled = injectUnstyled(this.unstyled);\n readonly passThrough = injectPassThrough('amount', this, this.pt, this.ptOptions);\n readonly isEmpty = computed(() => {\n const amount = this.amount();\n return amount === null || amount === undefined || Number.isNaN(amount);\n });\n readonly sign = computed<TxAmountSign | null>(() => {\n const amount = this.amount();\n if (this.isEmpty() || amount === null || amount === undefined) {\n return null;\n }\n return amount > 0 ? 'positive' : amount < 0 ? 'negative' : 'zero';\n });\n readonly segments = computed(() => {\n const amount = this.amount();\n if (this.isEmpty() || amount === null || amount === undefined) {\n return [];\n }\n return formatAmount(amount, {\n locale: this.locale() ?? this.options?.locale ?? this.localeService.locale().intl,\n currency: this.currency(),\n format: this.format(),\n notation: this.notation(),\n currencyDisplay: this.currencyDisplay(),\n showSign: this.showSign(),\n symbolPosition: this.symbolPosition() ?? this.options?.symbolPosition,\n symbols: { ...this.options?.symbols, ...this.symbols() },\n });\n });\n readonly hostStyle = computed(() => ({ ...toStyleObject(this.dt(), '--tx-amount'), ...this.passThrough().root?.style }));\n}\n"],"mappings":";;;;;;;AAIA,MAAa,oBAAoB,IAAI,eAAgC,mBAAmB;AAMxF,SAAgB,gBAAgB,SAAwB;CACtD,OAAO;EAAE,SAAS;EAAmB,UAAU;CAAO;AACxD;ACVA,MAAM,cAAc;AACpB,MAAM,iBAAiB;AACvB,MAAM,QAAQ;AACd,MAAM,mBAAmB;AACzB,MAAM,iBAAiB;AAKvB,SAAgB,gBAAgB,QAA0B;CACxD,MAAM,QAAQ,YAAY,MAAM,UAAU,GAAA,CAAI,KAAI,CAAE;CACpD,IAAI,CAAC,OACH,OAAO,CAAA;CAET,MAAM,GAAG,SAAS,aAAa,eAAe;CAC9C,MAAM,wBAAwB,gBAAgB,SAAY,SAAY,OAAO,WAAW;CACxF,MAAM,wBAAwB,gBAAgB,SAAY,wBAAwB,KAAK,IAAI,OAAO,WAAW,GAAG,yBAAyB,CAAC;CAC1I,OAAO;EACL,GAAI,YAAY,SAAY,CAAA,IAAK,EAAE,sBAAsB,KAAK,IAAI,GAAG,OAAO,OAAO,CAAC,EAAC;EACrF,GAAI,0BAA0B,SAAY,CAAA,IAAK,EAAE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