@tectra-ng/ui 0.4.2 → 0.4.3
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 +1 -1
- package/amount/README.md +2 -2
- package/analog-clock/README.md +3 -2
- package/button-group/README.md +34 -2
- package/chips-input/README.md +10 -0
- package/data-view/README.md +3 -0
- package/fesm2022/tectra-ng-ui-amount.mjs +11 -9
- package/fesm2022/tectra-ng-ui-amount.mjs.map +1 -1
- package/fesm2022/tectra-ng-ui-analog-clock.mjs +12 -6
- package/fesm2022/tectra-ng-ui-analog-clock.mjs.map +1 -1
- package/fesm2022/tectra-ng-ui-button-group.mjs +139 -6
- package/fesm2022/tectra-ng-ui-button-group.mjs.map +1 -1
- package/fesm2022/tectra-ng-ui-chips-input.mjs +36 -6
- package/fesm2022/tectra-ng-ui-chips-input.mjs.map +1 -1
- package/fesm2022/tectra-ng-ui-country-select.mjs +2 -2
- package/fesm2022/tectra-ng-ui-country-select.mjs.map +1 -1
- package/fesm2022/tectra-ng-ui-data-view.mjs +11 -3
- package/fesm2022/tectra-ng-ui-data-view.mjs.map +1 -1
- package/fesm2022/tectra-ng-ui-datepicker.mjs +2 -2
- package/fesm2022/tectra-ng-ui-datepicker.mjs.map +1 -1
- package/fesm2022/tectra-ng-ui-export.mjs +14 -19
- package/fesm2022/tectra-ng-ui-export.mjs.map +1 -1
- package/fesm2022/tectra-ng-ui-input-otp.mjs +6 -2
- package/fesm2022/tectra-ng-ui-input-otp.mjs.map +1 -1
- package/fesm2022/tectra-ng-ui-knob.mjs +12 -4
- package/fesm2022/tectra-ng-ui-knob.mjs.map +1 -1
- package/fesm2022/tectra-ng-ui-message.mjs +1 -1
- package/fesm2022/tectra-ng-ui-message.mjs.map +1 -1
- package/fesm2022/tectra-ng-ui-paginator.mjs +3 -20
- package/fesm2022/tectra-ng-ui-paginator.mjs.map +1 -1
- package/fesm2022/tectra-ng-ui-panel-menu.mjs +19 -2
- package/fesm2022/tectra-ng-ui-panel-menu.mjs.map +1 -1
- package/fesm2022/tectra-ng-ui-panel.mjs +2 -2
- package/fesm2022/tectra-ng-ui-panel.mjs.map +1 -1
- package/fesm2022/tectra-ng-ui-pill.mjs +3 -2
- package/fesm2022/tectra-ng-ui-pill.mjs.map +1 -1
- package/fesm2022/tectra-ng-ui-scroll-panel.mjs +4 -4
- package/fesm2022/tectra-ng-ui-scroll-panel.mjs.map +1 -1
- package/fesm2022/tectra-ng-ui-select-button.mjs +748 -0
- package/fesm2022/tectra-ng-ui-select-button.mjs.map +1 -0
- package/fesm2022/tectra-ng-ui-speed-dial.mjs +91 -60
- package/fesm2022/tectra-ng-ui-speed-dial.mjs.map +1 -1
- package/fesm2022/tectra-ng-ui-split-button.mjs +16 -5
- package/fesm2022/tectra-ng-ui-split-button.mjs.map +1 -1
- package/fesm2022/tectra-ng-ui-stat-tiles.mjs +8 -5
- package/fesm2022/tectra-ng-ui-stat-tiles.mjs.map +1 -1
- package/fesm2022/tectra-ng-ui-stepper.mjs +72 -29
- package/fesm2022/tectra-ng-ui-stepper.mjs.map +1 -1
- package/fesm2022/tectra-ng-ui-table.mjs +78 -141
- package/fesm2022/tectra-ng-ui-table.mjs.map +1 -1
- package/fesm2022/tectra-ng-ui-toggle-button.mjs +2 -2
- package/fesm2022/tectra-ng-ui-toggle-button.mjs.map +1 -1
- package/fesm2022/tectra-ng-ui-tree-select.mjs +17 -3
- package/fesm2022/tectra-ng-ui-tree-select.mjs.map +1 -1
- package/fesm2022/tectra-ng-ui-tree-table.mjs +4 -4
- package/fesm2022/tectra-ng-ui-tree-table.mjs.map +1 -1
- package/fesm2022/tectra-ng-ui-truncate-text.mjs +2 -2
- package/fesm2022/tectra-ng-ui-truncate-text.mjs.map +1 -1
- package/fesm2022/tectra-ng-ui.mjs +1 -1
- package/field/README.md +2 -2
- package/input-otp/README.md +1 -1
- package/knob/README.md +1 -1
- package/message/README.md +2 -2
- package/package.json +8 -4
- package/paginator/README.md +1 -1
- package/panel-menu/README.md +1 -1
- package/pill/README.md +1 -1
- package/select-button/README.md +70 -0
- package/speed-dial/README.md +2 -1
- package/stat-tiles/README.md +3 -3
- package/stepper/README.md +3 -2
- package/table/README.md +10 -7
- package/tabs/README.md +1 -1
- package/tree-select/README.md +1 -1
- package/tree-table/README.md +1 -1
- package/truncate-text/README.md +1 -1
- package/types/tectra-ng-ui-amount.d.ts +6 -3
- package/types/tectra-ng-ui-amount.d.ts.map +1 -1
- package/types/tectra-ng-ui-analog-clock.d.ts +9 -4
- package/types/tectra-ng-ui-analog-clock.d.ts.map +1 -1
- package/types/tectra-ng-ui-button-group.d.ts +58 -5
- package/types/tectra-ng-ui-button-group.d.ts.map +1 -1
- package/types/tectra-ng-ui-chips-input.d.ts +14 -1
- package/types/tectra-ng-ui-chips-input.d.ts.map +1 -1
- package/types/tectra-ng-ui-field.d.ts +2 -2
- package/types/tectra-ng-ui-input-otp.d.ts +1 -1
- package/types/tectra-ng-ui-input-otp.d.ts.map +1 -1
- package/types/tectra-ng-ui-knob.d.ts +2 -1
- package/types/tectra-ng-ui-knob.d.ts.map +1 -1
- package/types/tectra-ng-ui-message.d.ts +2 -2
- package/types/tectra-ng-ui-paginator.d.ts +2 -21
- package/types/tectra-ng-ui-paginator.d.ts.map +1 -1
- package/types/tectra-ng-ui-panel-menu.d.ts +9 -9
- package/types/tectra-ng-ui-panel-menu.d.ts.map +1 -1
- package/types/tectra-ng-ui-pill.d.ts +7 -3
- package/types/tectra-ng-ui-pill.d.ts.map +1 -1
- package/types/tectra-ng-ui-select-button.d.ts +256 -0
- package/types/tectra-ng-ui-select-button.d.ts.map +1 -0
- package/types/tectra-ng-ui-speed-dial.d.ts.map +1 -1
- package/types/tectra-ng-ui-stat-tiles.d.ts +4 -3
- package/types/tectra-ng-ui-stat-tiles.d.ts.map +1 -1
- package/types/tectra-ng-ui-stepper.d.ts +25 -10
- package/types/tectra-ng-ui-stepper.d.ts.map +1 -1
- package/types/tectra-ng-ui-table.d.ts +39 -42
- package/types/tectra-ng-ui-table.d.ts.map +1 -1
- package/types/tectra-ng-ui-tabs.d.ts +1 -1
- package/types/tectra-ng-ui-tree-select.d.ts +3 -1
- package/types/tectra-ng-ui-tree-select.d.ts.map +1 -1
- package/types/tectra-ng-ui-truncate-text.d.ts +1 -1
- package/types/tectra-ng-ui.d.ts +1 -1
package/README.md
CHANGED
|
@@ -53,7 +53,7 @@ Every component takes `dt` (design tokens of this instance), `pt` / `ptOptions`
|
|
|
53
53
|
|
|
54
54
|
| Group | `@tectra-ng/ui/…` |
|
|
55
55
|
|---|---|
|
|
56
|
-
| Form | `autocomplete`, `cascade-select`, `checkbox`, `chips-input`, `color-picker`, `color-swatches`, `country-select`, `datepicker`, `email-suggestion`, `field`, `icon-field`, `input`, `input-group`, `input-mask`, `input-number`, `input-otp`, `key-filter`, `knob`, `label`, `list-input`, `listbox`, `mention-textarea`, `multiselect`, `password`, `password-generator`, `radio-button`, `rating`, `select`, `slider`, `textarea`, `toggle-button`, `toggle-switch`, `tree-select` |
|
|
56
|
+
| Form | `autocomplete`, `cascade-select`, `checkbox`, `chips-input`, `color-picker`, `color-swatches`, `country-select`, `datepicker`, `email-suggestion`, `field`, `icon-field`, `input`, `input-group`, `input-mask`, `input-number`, `input-otp`, `key-filter`, `knob`, `label`, `list-input`, `listbox`, `mention-textarea`, `multiselect`, `password`, `password-generator`, `radio-button`, `rating`, `select`, `select-button`, `slider`, `textarea`, `toggle-button`, `toggle-switch`, `tree-select` |
|
|
57
57
|
| Actions | `button`, `button-group`, `speed-dial`, `split-button` |
|
|
58
58
|
| Data | `data-view`, `export`, `month-calendar`, `paginator`, `sparkline`, `stat-tiles`, `table`, `timeline`, `tree`, `tree-table`, `virtual-scroller` |
|
|
59
59
|
| Overlay | `confirm`, `dialog`, `drawer`, `menu`, `popover`, `toast`, `tooltip` |
|
package/amount/README.md
CHANGED
|
@@ -7,14 +7,14 @@ A number or a sum of money formatted for the current locale — grouping, decima
|
|
|
7
7
|
<tx-amount [amount]="delta" [signColor]="true" [showSign]="true" />
|
|
8
8
|
```
|
|
9
9
|
|
|
10
|
-
`format` uses the digits notation `minInteger.minFraction-maxFraction`: `1.0-2` (
|
|
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
12
|
## Inputs
|
|
13
13
|
| Name | Description |
|
|
14
14
|
|---|---|
|
|
15
15
|
| amount | The number; `null` or `undefined` shows `emptyText` |
|
|
16
16
|
| currency | ISO 4217 code (`USD`, `EUR`, `UAH`); an unknown code is shown after the number as is |
|
|
17
|
-
| format | Digits: `minInteger.minFraction-maxFraction` |
|
|
17
|
+
| format | Digits: `minInteger.minFraction-maxFraction`; by default the currency's own digits, or `1.0-2` without a currency |
|
|
18
18
|
| notation | `standard` or `compact` (`1.2K`, `3.4M`) |
|
|
19
19
|
| currencyDisplay | `narrowSymbol` ($), `symbol` (US$), `code` (USD) or `name` (US dollars) |
|
|
20
20
|
| showSign | Adds `+` to positive numbers |
|
package/analog-clock/README.md
CHANGED
|
@@ -10,7 +10,7 @@ A clock face with hour and minute hands (and an optional second hand) that shows
|
|
|
10
10
|
| Name | Description |
|
|
11
11
|
|---|---|
|
|
12
12
|
| timezone | IANA time zone such as `Europe/Kyiv`; empty or unknown is the local time |
|
|
13
|
-
| time | A fixed time (`Date
|
|
13
|
+
| time | A fixed time (`Date`, ms or an ISO string) instead of the running clock; an invalid string shows the running clock |
|
|
14
14
|
| showSeconds | Adds a second hand; the clock then updates every second instead of every minute |
|
|
15
15
|
| ariaLabel | Text before the time in the accessible name, e.g. the city |
|
|
16
16
|
| dt | Design tokens of this instance (`analogClock`) |
|
|
@@ -28,4 +28,5 @@ A clock face with hour and minute hands (and an optional second hand) that shows
|
|
|
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
30
|
- The clock updates at the start of each minute (or second), so it stays exact without polling.
|
|
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
|
+
- `txAnalogClockHands` (pipe) and `clockHands(time, timezone)` (a `Date`, ms or an ISO string) return `{ time, hourAngle, minuteAngle, secondAngle }`.
|
package/button-group/README.md
CHANGED
|
@@ -1,8 +1,40 @@
|
|
|
1
1
|
# ButtonGroup
|
|
2
2
|
|
|
3
|
-
Joins buttons into one
|
|
3
|
+
Joins related `txButton` buttons into one block: the inner corners go square, neighbouring borders merge into one line, and only the outer corners stay rounded. Use it for a few actions on the same object (save / delete / cancel), for a pager or a zoom control, or as the base of a split button. For a choice between options that stays selected use `tx-select-button` or `tx-tabs` instead — a button group only triggers actions.
|
|
4
|
+
|
|
5
|
+
Solid buttons next to each other get a thin divider in their own text colour, faded (`buttonGroup.dividerColor` and `buttonGroup.dividerWidth` tokens), so the group does not read as one wide button; outlined buttons share their border instead. The divider sits on the shared edge and stays in place while either neighbour is hovered or pressed.
|
|
6
|
+
|
|
7
|
+
Every button keeps its own inputs: severity, size, variant, icon, badge, loading and disabled work inside a group as they do alone. Give all buttons of a group the same size and variant.
|
|
8
|
+
|
|
9
|
+
```html
|
|
10
|
+
<tx-button-group aria-label="Document actions">
|
|
11
|
+
<button txButton icon="check">Save</button>
|
|
12
|
+
<button txButton icon="trash">Delete</button>
|
|
13
|
+
<button txButton icon="times">Cancel</button>
|
|
14
|
+
</tx-button-group>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Inputs
|
|
18
|
+
| Name | Description |
|
|
19
|
+
|---|---|
|
|
20
|
+
| orientation | `horizontal` (default) puts the buttons in a row, `vertical` stacks them in a column with the divider between rows |
|
|
21
|
+
| fluid | The group takes the full width of its container and the buttons share it equally; without the input it follows a parent `<tx-fluid>` |
|
|
22
|
+
| dt | Design tokens of this one group, e.g. `{ root: { dividerColor: 'var(--tx-surface-0)', dividerWidth: '2px' } }` |
|
|
23
|
+
| pt | Extra `class` / `style` for the `root` part — an object or a function `({ instance }) => ({ class, style })` |
|
|
24
|
+
| ptOptions | How this `pt` meets the global one from `provideTectra({ pt })`: `mergeSections` (default `true`), `mergeProps` (default `false`) |
|
|
25
|
+
| unstyled | Drops the joined borders, square inner corners and the divider; the classes `tx-button-group`, `tx-button-group--vertical` and `tx-button-group--fluid` stay for your own CSS; default from `provideTectra({ unstyled })` |
|
|
26
|
+
|
|
27
|
+
## Slots
|
|
28
|
+
| Name | Description |
|
|
29
|
+
|---|---|
|
|
30
|
+
| default | The `txButton` buttons (`button` or `a`) of the group |
|
|
4
31
|
|
|
5
32
|
## Keyboard
|
|
6
33
|
| Key | Action |
|
|
7
34
|
|---|---|
|
|
8
|
-
| Tab | Moves focus from one button to the next |
|
|
35
|
+
| Tab | Moves focus from one button to the next; disabled buttons are skipped |
|
|
36
|
+
| Enter / Space | Triggers the focused button |
|
|
37
|
+
|
|
38
|
+
## Accessibility
|
|
39
|
+
|
|
40
|
+
The host has `role="group"`. Give it a name with `aria-label` (or `aria-labelledby`) when the buttons alone do not say what they act on, and give icon-only buttons their own `aria-label`. A focused or hovered button is drawn above its neighbours, so the focus ring is never cut by the next button.
|
package/chips-input/README.md
CHANGED
|
@@ -5,6 +5,7 @@ A text field that turns what you type into chips — keywords, tags, emails, dom
|
|
|
5
5
|
## Inputs
|
|
6
6
|
| Name | Description |
|
|
7
7
|
|---|---|
|
|
8
|
+
| text | Typed text that is not a chip yet; two-way with `[(text)]` — setting it updates the field |
|
|
8
9
|
| placeholder | Text shown while the field is empty |
|
|
9
10
|
| separator | Text or pattern that ends a chip while typing and splits pasted text (`,` by default); Enter always adds |
|
|
10
11
|
| addOnBlur | Adds the typed text when the field loses focus (on by default) |
|
|
@@ -32,6 +33,15 @@ A text field that turns what you type into chips — keywords, tags, emails, dom
|
|
|
32
33
|
| added | A chip was added: `{ value, values }` |
|
|
33
34
|
| removed | A chip was removed: `{ value, values }` |
|
|
34
35
|
| rejected | A value was not added — duplicate, over `max` or not matching `itemPattern`: `{ value, values }` |
|
|
36
|
+
| textChange | The typed text changed |
|
|
37
|
+
|
|
38
|
+
## Methods
|
|
39
|
+
| Name | Description |
|
|
40
|
+
|---|---|
|
|
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 |
|
|
42
|
+
| clearText() | Clears the typed text and keeps the chips |
|
|
43
|
+
| clear() | Removes every chip and the typed text |
|
|
44
|
+
| removeAt(index) | Removes the chip at the index |
|
|
35
45
|
|
|
36
46
|
## Slots
|
|
37
47
|
| Name | Description |
|
package/data-view/README.md
CHANGED
|
@@ -69,6 +69,9 @@ Give the list and grid templates the items for typing — `<ng-template txDataVi
|
|
|
69
69
|
| txDataViewListOf | `txDataViewList`: the items, only for the type of `let-items` |
|
|
70
70
|
| txDataViewGridOf | `txDataViewGrid`: the items, only for the type of `let-items` |
|
|
71
71
|
|
|
72
|
+
## Frame
|
|
73
|
+
The data view is a content surface like a card: its corner radius and shadow come from `--tx-content-radius` and `--tx-content-shadow`, and the corners clip the header, items and paginator. The items get an inset from the `content.padding` token (none by default, for full-width rows) and `content.gridPadding` in the grid layout (12.25px), so cards never touch the rounded edge.
|
|
74
|
+
|
|
72
75
|
## Layout switch
|
|
73
76
|
`<tx-data-view-layout [(layout)]="layout" />` — two toggle buttons (list, grid) with `aria-pressed`.
|
|
74
77
|
|
|
@@ -6,6 +6,7 @@ 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
8
|
const DIGITS_INFO = /^(\d+)?(?:\.(\d+))?(?:-(\d+))?$/;
|
|
9
|
+
const DEFAULT_FORMAT = "1.0-2";
|
|
9
10
|
function parseDigitsInfo(format) {
|
|
10
11
|
const match = DIGITS_INFO.exec((format ?? "").trim());
|
|
11
12
|
if (!match) return {};
|
|
@@ -32,24 +33,25 @@ function toSegments(parts) {
|
|
|
32
33
|
return segments;
|
|
33
34
|
}
|
|
34
35
|
function formatAmount(amount, options) {
|
|
35
|
-
const
|
|
36
|
-
|
|
36
|
+
const currency = options.currency?.trim();
|
|
37
|
+
const base = (format) => ({
|
|
38
|
+
...parseDigitsInfo(format),
|
|
37
39
|
notation: options.notation ?? "standard",
|
|
38
40
|
signDisplay: options.showSign ? "exceptZero" : "auto"
|
|
39
|
-
};
|
|
40
|
-
const
|
|
41
|
+
});
|
|
42
|
+
const plain = base(options.format ?? DEFAULT_FORMAT);
|
|
41
43
|
if (currency) try {
|
|
42
44
|
return toSegments(new Intl.NumberFormat(options.locale, {
|
|
43
|
-
...base,
|
|
45
|
+
...base(options.format),
|
|
44
46
|
style: "currency",
|
|
45
47
|
currency,
|
|
46
48
|
currencyDisplay: options.currencyDisplay ?? "narrowSymbol"
|
|
47
49
|
}).formatToParts(amount));
|
|
48
50
|
} catch {
|
|
49
51
|
return [
|
|
50
|
-
...toSegments(new Intl.NumberFormat(options.locale,
|
|
52
|
+
...toSegments(new Intl.NumberFormat(options.locale, plain).formatToParts(amount)),
|
|
51
53
|
{
|
|
52
|
-
text: "
|
|
54
|
+
text: " ",
|
|
53
55
|
currency: false
|
|
54
56
|
},
|
|
55
57
|
{
|
|
@@ -58,7 +60,7 @@ function formatAmount(amount, options) {
|
|
|
58
60
|
}
|
|
59
61
|
];
|
|
60
62
|
}
|
|
61
|
-
return toSegments(new Intl.NumberFormat(options.locale,
|
|
63
|
+
return toSegments(new Intl.NumberFormat(options.locale, plain).formatToParts(amount));
|
|
62
64
|
}
|
|
63
65
|
const AMOUNT_ICON_DEFAULTS = { code: txIconCode };
|
|
64
66
|
const AMOUNT_THEME = { amount: amountTokens };
|
|
@@ -67,7 +69,7 @@ var TxAmount = class TxAmount {
|
|
|
67
69
|
localeService = inject(TxLocaleService);
|
|
68
70
|
amount = input(null, ...ngDevMode ? [{ debugName: "amount" }] : /* istanbul ignore next */ []);
|
|
69
71
|
currency = input(void 0, ...ngDevMode ? [{ debugName: "currency" }] : /* istanbul ignore next */ []);
|
|
70
|
-
format = input(
|
|
72
|
+
format = input(void 0, ...ngDevMode ? [{ debugName: "format" }] : /* istanbul ignore next */ []);
|
|
71
73
|
notation = input("standard", ...ngDevMode ? [{ debugName: "notation" }] : /* istanbul ignore next */ []);
|
|
72
74
|
currencyDisplay = input("narrowSymbol", ...ngDevMode ? [{ debugName: "currencyDisplay" }] : /* istanbul ignore next */ []);
|
|
73
75
|
showSign = input(false, {
|
|
@@ -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+))?$/;\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 base: Intl.NumberFormatOptions = {\n ...parseDigitsInfo(options.format),\n notation: options.notation ?? 'standard',\n signDisplay: options.showSign ? 'exceptZero' : 'auto',\n };\n const currency = options.currency?.trim();\n if (currency) {\n try {\n return toSegments(\n new Intl.NumberFormat(options.locale, { ...base, style: 'currency', currency, currencyDisplay: options.currencyDisplay ?? 'narrowSymbol' }).formatToParts(amount),\n );\n } catch {\n return [...toSegments(new Intl.NumberFormat(options.locale, base).formatToParts(amount)), { text: ' ', currency: false }, { text: currency, currency: true }];\n }\n }\n return toSegments(new Intl.NumberFormat(options.locale, base).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>('1.0-2');\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(() => ({ ...toStyleObject(this.dt(), '--tx-amount'), ...this.passThrough().root?.style }));\n}\n"],"mappings":";;;;;;;AAEA,MAAM,cAAc;AAKpB,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,sBAAqB;EACtE,GAAI,0BAA0B,SAAY,CAAA,IAAK,EAAE,sBAAqB;CACvE;AACH;AAEA,SAAS,WAA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AA,0BAAA;GAAA;GAAA,gBAAA;EAAA;EAAA,UAAA;EAAA,UA3BT;;;;;;;;;;;;;EAYT,UAAA;EAAA,QAAA,CAAA,q3BAAA;EAAA,eAac,CAAC,sBAAsB,oBAAoB,CAAC;EAAC,iBAAA,GAAA,wBAAA;CAAA,CAAA;;AAEjD,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAQ,YAAA,CAAA;EA7BpB,MAAA;EACW,MAAA,CAAA;GAAA,UAAA;GAAW,UACX;;;;;;;;;;;;;GAYT,iBAEgB,wBAAwB;GAAM,MACzC;IACJ,OAAO;IACP,WAAW;IACX,WAAW;IACX,sBAAsB;IACtB,oBAAoB;IACpB,6BAA6B;IAC7B,2BAA2B;IAC3B,4BAA4B;GAC7B;GAAA,eACc,CAAC,sBAAsB,oBAAoB,CAAC;GAAC,QAAA,CAAA,q3BAAA;EAAA,CAAA"}
|
|
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(() => ({ ...toStyleObject(this.dt(), '--tx-amount'), ...this.passThrough().root?.style }));\n}\n"],"mappings":";;;;;;;AAEA,MAAM,cAAc;AACpB,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,G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AA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,UAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;EAAA;EAAA,MAAA;GAAA,YAAA;IAAA,SAAA;IAAA,SAAA;IAAA,oBAAA;IAAA,kBAAA;IAAA,2BAAA;IAAA,yBAAA;IAAA,0BAAA;GAAA;GAAA,gBAAA;EAAA;EAAA,UAAA;EAAA,UA3BT;;;;;;;;;;;;;EAYT,UAAA;EAAA,QAAA,CAAA,q3BAAA;EAAA,eAac,CAAC,sBAAsB,oBAAoB,CAAC;EAAC,iBAAA,GAAA,wBAAA;CAAA,CAAA;;AAEjD,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAQ,YAAA,CAAA;EA7BpB,MAAA;EACW,MAAA,CAAA;GAAA,UAAA;GAAW,UACX;;;;;;;;;;;;;GAYT,iBAEgB,wBAAwB;GAAM,MACzC;IACJ,OAAO;IACP,WAAW;IACX,WAAW;IACX,sBAAsB;IACtB,oBAAoB;IACpB,6BAA6B;IAC7B,2BAA2B;IAC3B,4BAA4B;GAC7B;GAAA,eACc,CAAC,sBAAsB,oBAAoB,CAAC;GAAC,QAAA,CAAA,q3BAAA;EAAA,CAAA"}
|
|
@@ -12,6 +12,11 @@ function validTimeZone(timezone) {
|
|
|
12
12
|
return;
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
+
function clockTime(value) {
|
|
16
|
+
if (value === null || value === void 0 || value === "") return null;
|
|
17
|
+
const time = value instanceof Date ? value.getTime() : typeof value === "string" ? Date.parse(value) : value;
|
|
18
|
+
return Number.isFinite(time) ? time : null;
|
|
19
|
+
}
|
|
15
20
|
function clockHands(now, timezone) {
|
|
16
21
|
const parts = Object.fromEntries(new Intl.DateTimeFormat("en-GB", {
|
|
17
22
|
hour: "2-digit",
|
|
@@ -19,7 +24,7 @@ function clockHands(now, timezone) {
|
|
|
19
24
|
second: "2-digit",
|
|
20
25
|
hourCycle: "h23",
|
|
21
26
|
timeZone: validTimeZone(timezone)
|
|
22
|
-
}).formatToParts(new Date(now)).map((part) => [part.type, part.value]));
|
|
27
|
+
}).formatToParts(new Date(clockTime(now) ?? Date.now())).map((part) => [part.type, part.value]));
|
|
23
28
|
const hours = Number(parts["hour"]);
|
|
24
29
|
const minutes = Number(parts["minute"]);
|
|
25
30
|
const seconds = Number(parts["second"]);
|
|
@@ -106,7 +111,8 @@ var TxAnalogClock = class TxAnalogClock {
|
|
|
106
111
|
];
|
|
107
112
|
now = signal(Date.now(), ...ngDevMode ? [{ debugName: "now" }] : /* istanbul ignore next */ []);
|
|
108
113
|
timer = null;
|
|
109
|
-
|
|
114
|
+
fixedTime = computed(() => clockTime(this.time()), ...ngDevMode ? [{ debugName: "fixedTime" }] : /* istanbul ignore next */ []);
|
|
115
|
+
hands = computed(() => clockHands(this.fixedTime() ?? this.now(), this.timezone()), ...ngDevMode ? [{ debugName: "hands" }] : /* istanbul ignore next */ []);
|
|
110
116
|
label = computed(() => this.ariaLabel() ? `${this.ariaLabel()}, ${this.hands().time}` : this.hands().time, ...ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []);
|
|
111
117
|
hourAngle = linkedSignal({
|
|
112
118
|
...ngDevMode ? { debugName: "hourAngle" } : /* istanbul ignore next */ {},
|
|
@@ -125,7 +131,7 @@ var TxAnalogClock = class TxAnalogClock {
|
|
|
125
131
|
});
|
|
126
132
|
schedule = effect((onCleanup) => {
|
|
127
133
|
this.now();
|
|
128
|
-
if (this.
|
|
134
|
+
if (this.fixedTime() !== null) return;
|
|
129
135
|
const step = this.showSeconds() ? 1e3 : 6e4;
|
|
130
136
|
this.timer = setTimeout(() => this.now.set(Date.now()), step - Date.now() % step + 5);
|
|
131
137
|
onCleanup(() => {
|
|
@@ -255,7 +261,7 @@ var TxAnalogClock = class TxAnalogClock {
|
|
|
255
261
|
</div>
|
|
256
262
|
`,
|
|
257
263
|
isInline: true,
|
|
258
|
-
styles: [":host{display:block}.tx-analog-clock__face{position:relative;box-sizing:border-box;width:100%;
|
|
264
|
+
styles: [":host{display:block}.tx-analog-clock__face{position:relative;box-sizing:border-box;width:100%;aspect-ratio:1;border-radius:50%}.tx-analog-clock__tick,.tx-analog-clock__hand,.tx-analog-clock__pin{position:absolute;left:50%;border-radius:9999px}:host([data-styled]){width:var(--tx-analog-clock-size);max-width:100%;aspect-ratio:1}:host([data-styled]) .tx-analog-clock__face{background:var(--tx-analog-clock-background);box-shadow:0 0 0 1px var(--tx-analog-clock-border-color),var(--tx-analog-clock-shadow)}:host([data-styled]) .tx-analog-clock__tick{top:50%;width:var(--tx-analog-clock-tick-width);height:var(--tx-analog-clock-tick-height);margin-top:calc(var(--tx-analog-clock-tick-height) / -2);margin-left:calc(var(--tx-analog-clock-tick-width) / -2);background:var(--tx-analog-clock-tick-color);transform:rotate(var(--tx-analog-clock-angle)) translateY(var(--tx-analog-clock-tick-offset))}:host([data-styled]) .tx-analog-clock__tick--major{height:var(--tx-analog-clock-tick-major-height);margin-top:calc(var(--tx-analog-clock-tick-major-height) / -2);background:var(--tx-analog-clock-tick-major-color);transform:rotate(var(--tx-analog-clock-angle)) translateY(var(--tx-analog-clock-tick-major-offset))}:host([data-styled]) .tx-analog-clock__hand{bottom:50%;transform-origin:bottom;rotate:var(--tx-analog-clock-angle);transition:rotate var(--tx-analog-clock-transition-duration) var(--tx-analog-clock-transition-easing)}:host([data-styled]) .tx-analog-clock__hand--hour{width:var(--tx-analog-clock-hour-hand-width);height:var(--tx-analog-clock-hour-hand-length);margin-left:calc(var(--tx-analog-clock-hour-hand-width) / -2);background:var(--tx-analog-clock-hour-hand-color)}:host([data-styled]) .tx-analog-clock__hand--minute{width:var(--tx-analog-clock-minute-hand-width);height:var(--tx-analog-clock-minute-hand-length);margin-left:calc(var(--tx-analog-clock-minute-hand-width) / -2);background:var(--tx-analog-clock-minute-hand-color)}:host([data-styled]) .tx-analog-clock__hand--second{width:var(--tx-analog-clock-second-hand-width);height:var(--tx-analog-clock-second-hand-length);margin-left:calc(var(--tx-analog-clock-second-hand-width) / -2);background:var(--tx-analog-clock-second-hand-color)}:host([data-styled]) .tx-analog-clock__pin{top:50%;width:var(--tx-analog-clock-pin-size);height:var(--tx-analog-clock-pin-size);background:var(--tx-analog-clock-pin-color);box-shadow:0 0 0 var(--tx-analog-clock-pin-ring-width) var(--tx-analog-clock-pin-ring-color);transform:translate(-50%,-50%)}@media(prefers-reduced-motion:reduce){:host([data-styled]) .tx-analog-clock__hand{transition:none}}\n"],
|
|
259
265
|
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
260
266
|
});
|
|
261
267
|
};
|
|
@@ -313,7 +319,7 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
313
319
|
"[style]": "hostStyle()",
|
|
314
320
|
"[attr.data-styled]": "!isUnstyled() || null"
|
|
315
321
|
},
|
|
316
|
-
styles: [":host{display:block}.tx-analog-clock__face{position:relative;box-sizing:border-box;width:100%;
|
|
322
|
+
styles: [":host{display:block}.tx-analog-clock__face{position:relative;box-sizing:border-box;width:100%;aspect-ratio:1;border-radius:50%}.tx-analog-clock__tick,.tx-analog-clock__hand,.tx-analog-clock__pin{position:absolute;left:50%;border-radius:9999px}:host([data-styled]){width:var(--tx-analog-clock-size);max-width:100%;aspect-ratio:1}:host([data-styled]) .tx-analog-clock__face{background:var(--tx-analog-clock-background);box-shadow:0 0 0 1px var(--tx-analog-clock-border-color),var(--tx-analog-clock-shadow)}:host([data-styled]) .tx-analog-clock__tick{top:50%;width:var(--tx-analog-clock-tick-width);height:var(--tx-analog-clock-tick-height);margin-top:calc(var(--tx-analog-clock-tick-height) / -2);margin-left:calc(var(--tx-analog-clock-tick-width) / -2);background:var(--tx-analog-clock-tick-color);transform:rotate(var(--tx-analog-clock-angle)) translateY(var(--tx-analog-clock-tick-offset))}:host([data-styled]) .tx-analog-clock__tick--major{height:var(--tx-analog-clock-tick-major-height);margin-top:calc(var(--tx-analog-clock-tick-major-height) / -2);background:var(--tx-analog-clock-tick-major-color);transform:rotate(var(--tx-analog-clock-angle)) translateY(var(--tx-analog-clock-tick-major-offset))}:host([data-styled]) .tx-analog-clock__hand{bottom:50%;transform-origin:bottom;rotate:var(--tx-analog-clock-angle);transition:rotate var(--tx-analog-clock-transition-duration) var(--tx-analog-clock-transition-easing)}:host([data-styled]) .tx-analog-clock__hand--hour{width:var(--tx-analog-clock-hour-hand-width);height:var(--tx-analog-clock-hour-hand-length);margin-left:calc(var(--tx-analog-clock-hour-hand-width) / -2);background:var(--tx-analog-clock-hour-hand-color)}:host([data-styled]) .tx-analog-clock__hand--minute{width:var(--tx-analog-clock-minute-hand-width);height:var(--tx-analog-clock-minute-hand-length);margin-left:calc(var(--tx-analog-clock-minute-hand-width) / -2);background:var(--tx-analog-clock-minute-hand-color)}:host([data-styled]) .tx-analog-clock__hand--second{width:var(--tx-analog-clock-second-hand-width);height:var(--tx-analog-clock-second-hand-length);margin-left:calc(var(--tx-analog-clock-second-hand-width) / -2);background:var(--tx-analog-clock-second-hand-color)}:host([data-styled]) .tx-analog-clock__pin{top:50%;width:var(--tx-analog-clock-pin-size);height:var(--tx-analog-clock-pin-size);background:var(--tx-analog-clock-pin-color);box-shadow:0 0 0 var(--tx-analog-clock-pin-ring-width) var(--tx-analog-clock-pin-ring-color);transform:translate(-50%,-50%)}@media(prefers-reduced-motion:reduce){:host([data-styled]) .tx-analog-clock__hand{transition:none}}\n"]
|
|
317
323
|
}]
|
|
318
324
|
}],
|
|
319
325
|
propDecorators: {
|
|
@@ -383,6 +389,6 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
383
389
|
}]
|
|
384
390
|
}
|
|
385
391
|
});
|
|
386
|
-
export { TxAnalogClock, TxAnalogClockHandsPipe, clockHands, forwardAngle, validTimeZone };
|
|
392
|
+
export { TxAnalogClock, TxAnalogClockHandsPipe, clockHands, clockTime, forwardAngle, validTimeZone };
|
|
387
393
|
|
|
388
394
|
//# sourceMappingURL=tectra-ng-ui-analog-clock.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tectra-ng-ui-analog-clock.mjs","names":[],"sources":["../../../../packages/ui/analog-clock/src/analog-clock.utils.ts","../../../../packages/ui/analog-clock/src/analog-clock-hands.pipe.ts","../../../../packages/ui/analog-clock/src/analog-clock.theme.ts","../../../../packages/ui/analog-clock/src/analog-clock.component.ts"],"sourcesContent":["import { TxAnalogClockHands } from './analog-clock.types';\n\n/** Returns the time zone when the browser knows it, otherwise `undefined`. */\nexport function validTimeZone(timezone: string | null | undefined): string | undefined {\n if (!timezone) return undefined;\n try {\n new Intl.DateTimeFormat('en-GB', { timeZone: timezone });\n return timezone;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Computes the text time and the hand angles of a moment in the given time zone; the local zone is used when it is empty or unknown.\n */\nexport function clockHands(now: number | Date, timezone: string | null | undefined): TxAnalogClockHands {\n const parts = Object.fromEntries(\n new Intl.DateTimeFormat('en-GB', { hour: '2-digit', minute: '2-digit', second: '2-digit', hourCycle: 'h23', timeZone: validTimeZone(timezone) })\n .formatToParts(new Date(now))\n .map((part) => [part.type, part.value]),\n );\n const hours = Number(parts['hour']);\n const minutes = Number(parts['minute']);\n const seconds = Number(parts['second']);\n return {\n time: `${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')}`,\n hourAngle: ((hours % 12) + minutes / 60) * 30,\n minuteAngle: minutes * 6,\n secondAngle: seconds * 6,\n };\n}\n\n/**\n * Turns the next hand angle into one that never goes back past the previous angle, so a hand animates through 360 instead of rewinding.\n */\nexport function forwardAngle(previous: number | null, next: number): number {\n if (previous === null) return next;\n const turns = Math.floor(previous / 360);\n let angle = turns * 360 + next;\n if (angle < previous - 0.001) angle += 360;\n return angle;\n}\n","import { Pipe, PipeTransform } from '@angular/core';\nimport { TxAnalogClockHands } from './analog-clock.types';\nimport { clockHands } from './analog-clock.utils';\n\n/** Turns a time into the hand angles of an analog clock in an optional time zone, for custom clock faces. */\n@Pipe({ name: 'txAnalogClockHands' })\nexport class TxAnalogClockHandsPipe implements PipeTransform {\n transform(now: number | Date, timezone: string | null = null): TxAnalogClockHands {\n return clockHands(now, timezone);\n }\n}\n","import { analogClockTokens } from '@tectra-ng/themes';\n\nexport const ANALOG_CLOCK_THEME = {\n analogClock: analogClockTokens,\n};\n","import { ChangeDetectionStrategy, Component, DestroyRef, booleanAttribute, computed, effect, inject, input, linkedSignal, signal } from '@angular/core';\nimport { injectPassThrough, injectTokens, injectUnstyled, TxPassThrough, TxPassThroughOptions } from '@tectra-ng/core/config';\nimport { optionalBoolean } from '@tectra-ng/core/utils';\nimport { TectraAnalogClockTokens, TectraDeepPartial, toStyleObject } from '@tectra-ng/themes';\nimport { TxAnalogClockPart } from './analog-clock.types';\nimport { clockHands, forwardAngle } from './analog-clock.utils';\nimport { ANALOG_CLOCK_THEME } from './analog-clock.theme';\n\n@Component({\n selector: 'tx-analog-clock',\n template: `\n <div class=\"tx-analog-clock__face\" role=\"img\" [attr.aria-label]=\"label()\" [class]=\"passThrough().face?.class\" [style]=\"passThrough().face?.style\">\n @for (tick of ticks; track tick) {\n <span\n class=\"tx-analog-clock__tick\"\n aria-hidden=\"true\"\n [class.tx-analog-clock__tick--major]=\"tick % 3 === 0\"\n [style.--tx-analog-clock-angle]=\"tick * 30 + 'deg'\"\n [class]=\"passThrough().tick?.class\"\n [style]=\"passThrough().tick?.style\"\n ></span>\n }\n <span\n class=\"tx-analog-clock__hand tx-analog-clock__hand--hour\"\n aria-hidden=\"true\"\n [style.--tx-analog-clock-angle]=\"hourAngle() + 'deg'\"\n [class]=\"passThrough().hourHand?.class\"\n [style]=\"passThrough().hourHand?.style\"\n ></span>\n <span\n class=\"tx-analog-clock__hand tx-analog-clock__hand--minute\"\n aria-hidden=\"true\"\n [style.--tx-analog-clock-angle]=\"minuteAngle() + 'deg'\"\n [class]=\"passThrough().minuteHand?.class\"\n [style]=\"passThrough().minuteHand?.style\"\n ></span>\n @if (showSeconds()) {\n <span\n class=\"tx-analog-clock__hand tx-analog-clock__hand--second\"\n aria-hidden=\"true\"\n [style.--tx-analog-clock-angle]=\"secondAngle() + 'deg'\"\n [class]=\"passThrough().secondHand?.class\"\n [style]=\"passThrough().secondHand?.style\"\n ></span>\n }\n <span class=\"tx-analog-clock__pin\" aria-hidden=\"true\" [class]=\"passThrough().pin?.class\" [style]=\"passThrough().pin?.style\"></span>\n </div>\n `,\n styleUrl: './analog-clock.component.scss',\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: {\n class: 'tx-analog-clock',\n '[class]': 'passThrough().root?.class',\n '[style]': 'hostStyle()',\n '[attr.data-styled]': '!isUnstyled() || null',\n },\n})\nexport class TxAnalogClock {\n private readonly analogClockTheme = injectTokens(ANALOG_CLOCK_THEME);\n\n readonly timezone = input<string | null | undefined>(undefined);\n readonly time = input<Date | number | null | undefined>(undefined);\n readonly showSeconds = input<boolean, unknown>(false, { transform: booleanAttribute });\n readonly ariaLabel = input<string | undefined>(undefined);\n readonly dt = input<TectraDeepPartial<TectraAnalogClockTokens> | undefined>(undefined);\n readonly pt = input<TxPassThrough<TxAnalogClockPart, TxAnalogClock> | 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('analogClock', this, this.pt, this.ptOptions);\n readonly hostStyle = computed(() => ({ ...toStyleObject(this.dt(), '--tx-analog-clock'), ...this.passThrough().root?.style }));\n\n protected readonly ticks = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];\n private readonly now = signal(Date.now());\n private timer: ReturnType<typeof setTimeout> | null = null;\n\n readonly hands = computed(() => clockHands(this.time() ?? this.now(), this.timezone()));\n readonly label = computed(() => (this.ariaLabel() ? `${this.ariaLabel()}, ${this.hands().time}` : this.hands().time));\n readonly hourAngle = linkedSignal<number, number>({ source: () => this.hands().hourAngle, computation: (next, previous) => forwardAngle(previous?.value ?? null, next) });\n readonly minuteAngle = linkedSignal<number, number>({ source: () => this.hands().minuteAngle, computation: (next, previous) => forwardAngle(previous?.value ?? null, next) });\n readonly secondAngle = linkedSignal<number, number>({ source: () => this.hands().secondAngle, computation: (next, previous) => forwardAngle(previous?.value ?? null, next) });\n\n private readonly schedule = effect((onCleanup) => {\n this.now();\n if (this.time() !== undefined && this.time() !== null) return;\n const step = this.showSeconds() ? 1000 : 60000;\n this.timer = setTimeout(() => this.now.set(Date.now()), step - (Date.now() % step) + 5);\n onCleanup(() => {\n if (this.timer) clearTimeout(this.timer);\n });\n });\n\n private readonly cleanup = inject(DestroyRef).onDestroy(() => {\n if (this.timer) clearTimeout(this.timer);\n });\n}\n"],"mappings":";;;;;AAGA,SAAgB,cAAc,UAAmC;CAC/D,IAAI,CAAC,UAAU,OAAO;CACtB,IAAI;EACF,IAAI,KAAK,eAAe,SAAS,EAAE,UAAU,SAAQ,CAAE;EACvD,OAAO;CACT,QAAQ;EACN;CACF;AACF;AAKA,SAAgB,WAAW,KAAoB,UAAmC;CAChF,MAAM,QAAQ,OAAO,YACnB,IAAI,KAAK,eAAe,SAAS;EAAE,MAAM;EAAW,QAAQ;EAAW,QAAQ;EAAW,WAAW;EAAO,UAAU,cAAc,QAAQ;CAAC,CAAE,CAAC,CAC7I,cAAc,IAAI,KAAK,GAAG,CAAC,CAAC,CAC5B,KAAK,SAAS,CAAC,KAAK,MAAM,KAAK,KAAK,CAAC,CAAC;CAE3C,MAAM,QAAQ,OAAO,MAAM,OAAO;CAClC,MAAM,UAAU,OAAO,MAAM,SAAS;CACtC,MAAM,UAAU,OAAO,MAAM,SAAS;CACtC,OAAO;EACL,MAAM,GAAG,OAAO,KAAK,CAAC,CAAC,SAAS,GAAG,GAAG,EAAC,GAAI,OAAO,OAAO,CAAC,CAAC,SAAS,GAAG,GAAG;EAC1E,YAAa,QAAQ,KAAM,UAAU,MAAM;EAC3C,aAAa,UAAU;EAC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AA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,aAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,WAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,IAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,IAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,WAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,UAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;EAAA;EAAA,MAAA;GAAA,YAAA;IAAA,SAAA;IAAA,SAAA;IAAA,oBAAA;GAAA;GAAA,gBAAA;EAAA;EAAA,UAAA;EAAA,UA/Cd;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqCT,UAAA;EAAA,QAAA,CAAA,4iFAAA;EAAA,iBAAA,GAAA,wBAAA;CAAA,CAAA;;AAUU,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAa,YAAA,CAAA;EAjDzB,MAAA;EACW,MAAA,CAAA;GAAA,UAAA;GAAiB,UACjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCT,iBAEgB,wBAAwB;GAAM,MACzC;IACJ,OAAO;IACP,WAAW;IACX,WAAW;IACX,sBAAsB;GACvB;GAAA,QAAA,CAAA,4iFAAA;EAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"tectra-ng-ui-analog-clock.mjs","names":[],"sources":["../../../../packages/ui/analog-clock/src/analog-clock.utils.ts","../../../../packages/ui/analog-clock/src/analog-clock-hands.pipe.ts","../../../../packages/ui/analog-clock/src/analog-clock.theme.ts","../../../../packages/ui/analog-clock/src/analog-clock.component.ts"],"sourcesContent":["import { TxAnalogClockHands, TxAnalogClockTime } from './analog-clock.types';\n\n/** Returns the time zone when the browser knows it, otherwise `undefined`. */\nexport function validTimeZone(timezone: string | null | undefined): string | undefined {\n if (!timezone) return undefined;\n try {\n new Intl.DateTimeFormat('en-GB', { timeZone: timezone });\n return timezone;\n } catch {\n return undefined;\n }\n}\n\n/** Turns a `Date`, milliseconds or an ISO string into milliseconds; `null` when it is empty or not a valid time. */\nexport function clockTime(value: TxAnalogClockTime): number | null {\n if (value === null || value === undefined || value === '') return null;\n const time = value instanceof Date ? value.getTime() : typeof value === 'string' ? Date.parse(value) : value;\n return Number.isFinite(time) ? time : null;\n}\n\n/**\n * Computes the text time and the hand angles of a moment in the given time zone; the local zone is used when it is empty or unknown.\n */\nexport function clockHands(now: number | Date | string, timezone: string | null | undefined): TxAnalogClockHands {\n const parts = Object.fromEntries(\n new Intl.DateTimeFormat('en-GB', { hour: '2-digit', minute: '2-digit', second: '2-digit', hourCycle: 'h23', timeZone: validTimeZone(timezone) })\n .formatToParts(new Date(clockTime(now) ?? Date.now()))\n .map((part) => [part.type, part.value]),\n );\n const hours = Number(parts['hour']);\n const minutes = Number(parts['minute']);\n const seconds = Number(parts['second']);\n return {\n time: `${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')}`,\n hourAngle: ((hours % 12) + minutes / 60) * 30,\n minuteAngle: minutes * 6,\n secondAngle: seconds * 6,\n };\n}\n\n/**\n * Turns the next hand angle into one that never goes back past the previous angle, so a hand animates through 360 instead of rewinding.\n */\nexport function forwardAngle(previous: number | null, next: number): number {\n if (previous === null) return next;\n const turns = Math.floor(previous / 360);\n let angle = turns * 360 + next;\n if (angle < previous - 0.001) angle += 360;\n return angle;\n}\n","import { Pipe, PipeTransform } from '@angular/core';\nimport { TxAnalogClockHands } from './analog-clock.types';\nimport { clockHands } from './analog-clock.utils';\n\n/** Turns a time into the hand angles of an analog clock in an optional time zone, for custom clock faces. */\n@Pipe({ name: 'txAnalogClockHands' })\nexport class TxAnalogClockHandsPipe implements PipeTransform {\n transform(now: number | Date | string, timezone: string | null = null): TxAnalogClockHands {\n return clockHands(now, timezone);\n }\n}\n","import { analogClockTokens } from '@tectra-ng/themes';\n\nexport const ANALOG_CLOCK_THEME = {\n analogClock: analogClockTokens,\n};\n","import { ChangeDetectionStrategy, Component, DestroyRef, booleanAttribute, computed, effect, inject, input, linkedSignal, signal } from '@angular/core';\nimport { injectPassThrough, injectTokens, injectUnstyled, TxPassThrough, TxPassThroughOptions } from '@tectra-ng/core/config';\nimport { optionalBoolean } from '@tectra-ng/core/utils';\nimport { TectraAnalogClockTokens, TectraDeepPartial, toStyleObject } from '@tectra-ng/themes';\nimport { TxAnalogClockPart, TxAnalogClockTime } from './analog-clock.types';\nimport { clockHands, clockTime, forwardAngle } from './analog-clock.utils';\nimport { ANALOG_CLOCK_THEME } from './analog-clock.theme';\n\n@Component({\n selector: 'tx-analog-clock',\n template: `\n <div class=\"tx-analog-clock__face\" role=\"img\" [attr.aria-label]=\"label()\" [class]=\"passThrough().face?.class\" [style]=\"passThrough().face?.style\">\n @for (tick of ticks; track tick) {\n <span\n class=\"tx-analog-clock__tick\"\n aria-hidden=\"true\"\n [class.tx-analog-clock__tick--major]=\"tick % 3 === 0\"\n [style.--tx-analog-clock-angle]=\"tick * 30 + 'deg'\"\n [class]=\"passThrough().tick?.class\"\n [style]=\"passThrough().tick?.style\"\n ></span>\n }\n <span\n class=\"tx-analog-clock__hand tx-analog-clock__hand--hour\"\n aria-hidden=\"true\"\n [style.--tx-analog-clock-angle]=\"hourAngle() + 'deg'\"\n [class]=\"passThrough().hourHand?.class\"\n [style]=\"passThrough().hourHand?.style\"\n ></span>\n <span\n class=\"tx-analog-clock__hand tx-analog-clock__hand--minute\"\n aria-hidden=\"true\"\n [style.--tx-analog-clock-angle]=\"minuteAngle() + 'deg'\"\n [class]=\"passThrough().minuteHand?.class\"\n [style]=\"passThrough().minuteHand?.style\"\n ></span>\n @if (showSeconds()) {\n <span\n class=\"tx-analog-clock__hand tx-analog-clock__hand--second\"\n aria-hidden=\"true\"\n [style.--tx-analog-clock-angle]=\"secondAngle() + 'deg'\"\n [class]=\"passThrough().secondHand?.class\"\n [style]=\"passThrough().secondHand?.style\"\n ></span>\n }\n <span class=\"tx-analog-clock__pin\" aria-hidden=\"true\" [class]=\"passThrough().pin?.class\" [style]=\"passThrough().pin?.style\"></span>\n </div>\n `,\n styleUrl: './analog-clock.component.scss',\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: {\n class: 'tx-analog-clock',\n '[class]': 'passThrough().root?.class',\n '[style]': 'hostStyle()',\n '[attr.data-styled]': '!isUnstyled() || null',\n },\n})\nexport class TxAnalogClock {\n private readonly analogClockTheme = injectTokens(ANALOG_CLOCK_THEME);\n\n readonly timezone = input<string | null | undefined>(undefined);\n readonly time = input<TxAnalogClockTime>(undefined);\n readonly showSeconds = input<boolean, unknown>(false, { transform: booleanAttribute });\n readonly ariaLabel = input<string | undefined>(undefined);\n readonly dt = input<TectraDeepPartial<TectraAnalogClockTokens> | undefined>(undefined);\n readonly pt = input<TxPassThrough<TxAnalogClockPart, TxAnalogClock> | 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('analogClock', this, this.pt, this.ptOptions);\n readonly hostStyle = computed(() => ({ ...toStyleObject(this.dt(), '--tx-analog-clock'), ...this.passThrough().root?.style }));\n\n protected readonly ticks = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];\n private readonly now = signal(Date.now());\n private timer: ReturnType<typeof setTimeout> | null = null;\n\n private readonly fixedTime = computed(() => clockTime(this.time()));\n readonly hands = computed(() => clockHands(this.fixedTime() ?? this.now(), this.timezone()));\n readonly label = computed(() => (this.ariaLabel() ? `${this.ariaLabel()}, ${this.hands().time}` : this.hands().time));\n readonly hourAngle = linkedSignal<number, number>({ source: () => this.hands().hourAngle, computation: (next, previous) => forwardAngle(previous?.value ?? null, next) });\n readonly minuteAngle = linkedSignal<number, number>({ source: () => this.hands().minuteAngle, computation: (next, previous) => forwardAngle(previous?.value ?? null, next) });\n readonly secondAngle = linkedSignal<number, number>({ source: () => this.hands().secondAngle, computation: (next, previous) => forwardAngle(previous?.value ?? null, next) });\n\n private readonly schedule = effect((onCleanup) => {\n this.now();\n if (this.fixedTime() !== null) return;\n const step = this.showSeconds() ? 1000 : 60000;\n this.timer = setTimeout(() => this.now.set(Date.now()), step - (Date.now() % step) + 5);\n onCleanup(() => {\n if (this.timer) clearTimeout(this.timer);\n });\n });\n\n private readonly cleanup = inject(DestroyRef).onDestroy(() => {\n if (this.timer) clearTimeout(this.timer);\n });\n}\n"],"mappings":";;;;;AAGA,SAAgB,cAAc,UAAmC;CAC/D,IAAI,CAAC,UAAU,OAAO;CACtB,IAAI;EACF,IAAI,KAAK,eAAe,SAAS,EAAE,UAAU,SAAQ,CAAE;EACvD,OAAO;CACT,QAAQ;EACN;CACF;AACF;AAGA,SAAgB,UAAU,OAAwB;CAChD,IAAI,UAAU,QAAQ,UAAU,UAAa,UAAU,IAAI,OAAO;CAClE,MAAM,OAAO,iBAAiB,OAAO,MAAM,QAAO,IAAK,OAAO,UAAU,WAAW,KAAK,MAAM,KAAK,IAAI;CACvG,OAAO,OAAO,SAAS,IAAI,IAAI,OAAO;AACxC;AAKA,SAAgB,WAAW,KAA6B,UAAmC;CACzF,MAAM,QAAQ,OAAO,YACnB,IAAI,KAAK,eAAe,SAAS;EAAE,MAAM;EAAW,QAAQ;EAAW,QAAQ;EAAW,WAAW;EAAO,UAAU,cAAc,QAAQ;CAAC,CAAE,CAAC,CAC7I,cAAc,IAAI,KAAK,UAAU,GAAG,KAAK,KAAK,IAAG,CAAE,CAAC,CAAC,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,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAa,YAAA,CAAA;EAjDzB,MAAA;EACW,MAAA,CAAA;GAAA,UAAA;GAAiB,UACjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCT,iBAEgB,wBAAwB;GAAM,MACzC;IACJ,OAAO;IACP,WAAW;IACX,WAAW;IACX,sBAAsB;GACvB;GAAA,QAAA,CAAA,0iFAAA;EAAA,CAAA"}
|
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
import * as i0 from "@angular/core";
|
|
2
|
-
import { ChangeDetectionStrategy, Component } from "@angular/core";
|
|
2
|
+
import { ChangeDetectionStrategy, Component, computed, input } from "@angular/core";
|
|
3
|
+
import { injectPassThrough, injectTokens, injectUnstyled } from "@tectra-ng/core/config";
|
|
4
|
+
import { injectFluid } from "@tectra-ng/core/fluid";
|
|
5
|
+
import { optionalBoolean } from "@tectra-ng/core/utils";
|
|
6
|
+
import { buttonGroupTokens, toStyleObject } from "@tectra-ng/themes";
|
|
7
|
+
const BUTTON_GROUP_THEME = { buttonGroup: buttonGroupTokens };
|
|
3
8
|
var TxButtonGroup = class TxButtonGroup {
|
|
9
|
+
buttonGroupTheme = injectTokens(BUTTON_GROUP_THEME);
|
|
10
|
+
orientation = input("horizontal", ...ngDevMode ? [{ debugName: "orientation" }] : /* istanbul ignore next */ []);
|
|
11
|
+
fluid = input(void 0, {
|
|
12
|
+
...ngDevMode ? { debugName: "fluid" } : /* istanbul ignore next */ {},
|
|
13
|
+
transform: optionalBoolean
|
|
14
|
+
});
|
|
15
|
+
dt = input(void 0, ...ngDevMode ? [{ debugName: "dt" }] : /* istanbul ignore next */ []);
|
|
16
|
+
pt = input(void 0, ...ngDevMode ? [{ debugName: "pt" }] : /* istanbul ignore next */ []);
|
|
17
|
+
ptOptions = input(void 0, ...ngDevMode ? [{ debugName: "ptOptions" }] : /* istanbul ignore next */ []);
|
|
18
|
+
unstyled = input(void 0, {
|
|
19
|
+
...ngDevMode ? { debugName: "unstyled" } : /* istanbul ignore next */ {},
|
|
20
|
+
transform: optionalBoolean
|
|
21
|
+
});
|
|
22
|
+
isFluid = injectFluid(this.fluid);
|
|
23
|
+
isUnstyled = injectUnstyled(this.unstyled);
|
|
24
|
+
passThrough = injectPassThrough("buttonGroup", this, this.pt, this.ptOptions);
|
|
25
|
+
hostStyle = computed(() => ({
|
|
26
|
+
...toStyleObject(this.dt(), "--tx-button-group"),
|
|
27
|
+
...this.passThrough().root?.style
|
|
28
|
+
}), ...ngDevMode ? [{ debugName: "hostStyle" }] : /* istanbul ignore next */ []);
|
|
4
29
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
5
30
|
minVersion: "12.0.0",
|
|
6
31
|
version: "22.2.5",
|
|
@@ -10,19 +35,71 @@ var TxButtonGroup = class TxButtonGroup {
|
|
|
10
35
|
target: i0.ɵɵFactoryTarget.Component
|
|
11
36
|
});
|
|
12
37
|
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
13
|
-
minVersion: "
|
|
38
|
+
minVersion: "17.1.0",
|
|
14
39
|
version: "22.2.5",
|
|
15
40
|
type: TxButtonGroup,
|
|
16
41
|
isStandalone: true,
|
|
17
42
|
selector: "tx-button-group",
|
|
43
|
+
inputs: {
|
|
44
|
+
orientation: {
|
|
45
|
+
classPropertyName: "orientation",
|
|
46
|
+
publicName: "orientation",
|
|
47
|
+
isSignal: true,
|
|
48
|
+
isRequired: false,
|
|
49
|
+
transformFunction: null
|
|
50
|
+
},
|
|
51
|
+
fluid: {
|
|
52
|
+
classPropertyName: "fluid",
|
|
53
|
+
publicName: "fluid",
|
|
54
|
+
isSignal: true,
|
|
55
|
+
isRequired: false,
|
|
56
|
+
transformFunction: null
|
|
57
|
+
},
|
|
58
|
+
dt: {
|
|
59
|
+
classPropertyName: "dt",
|
|
60
|
+
publicName: "dt",
|
|
61
|
+
isSignal: true,
|
|
62
|
+
isRequired: false,
|
|
63
|
+
transformFunction: null
|
|
64
|
+
},
|
|
65
|
+
pt: {
|
|
66
|
+
classPropertyName: "pt",
|
|
67
|
+
publicName: "pt",
|
|
68
|
+
isSignal: true,
|
|
69
|
+
isRequired: false,
|
|
70
|
+
transformFunction: null
|
|
71
|
+
},
|
|
72
|
+
ptOptions: {
|
|
73
|
+
classPropertyName: "ptOptions",
|
|
74
|
+
publicName: "ptOptions",
|
|
75
|
+
isSignal: true,
|
|
76
|
+
isRequired: false,
|
|
77
|
+
transformFunction: null
|
|
78
|
+
},
|
|
79
|
+
unstyled: {
|
|
80
|
+
classPropertyName: "unstyled",
|
|
81
|
+
publicName: "unstyled",
|
|
82
|
+
isSignal: true,
|
|
83
|
+
isRequired: false,
|
|
84
|
+
transformFunction: null
|
|
85
|
+
}
|
|
86
|
+
},
|
|
18
87
|
host: {
|
|
19
88
|
attributes: { "role": "group" },
|
|
89
|
+
properties: {
|
|
90
|
+
"class": "passThrough().root?.class",
|
|
91
|
+
"class.tx-button-group--vertical": "orientation() === \"vertical\"",
|
|
92
|
+
"class.tx-button-group--fluid": "isFluid()",
|
|
93
|
+
"style": "hostStyle()",
|
|
94
|
+
"attr.data-orientation": "orientation()",
|
|
95
|
+
"attr.data-styled": "!isUnstyled() || null"
|
|
96
|
+
},
|
|
20
97
|
classAttribute: "tx-button-group"
|
|
21
98
|
},
|
|
22
99
|
ngImport: i0,
|
|
23
100
|
template: "<ng-content />",
|
|
24
101
|
isInline: true,
|
|
25
|
-
styles: [":host{display:inline-flex}:host ::ng-deep>.tx-button:not(:first-child){margin-left:-1px;border-top-left-radius:0;border-bottom-left-radius:0}:host ::ng-deep>.tx-button:not(:last-child){border-top-right-radius:0;border-bottom-right-radius:0}:host ::ng-deep>.tx-button:hover,:host ::ng-deep>.tx-button:focus-visible{position:relative;z-index:1}\n"],
|
|
102
|
+
styles: [":host{display:inline-flex}:host(.tx-button-group--fluid){display:flex;width:100%}:host(.tx-button-group--vertical){flex-direction:column}:host(.tx-button-group--fluid) ::ng-deep>.tx-button{flex:1 1 0;min-width:0}:host([data-styled]:not(.tx-button-group--vertical)) ::ng-deep>.tx-button:not(:first-child){margin-left:-1px;border-top-left-radius:0;border-bottom-left-radius:0}:host([data-styled]:not(.tx-button-group--vertical)) ::ng-deep>.tx-button:not(:last-child){border-top-right-radius:0;border-bottom-right-radius:0}:host([data-styled].tx-button-group--vertical) ::ng-deep>.tx-button:not(:first-child){margin-top:-1px;border-top-left-radius:0;border-top-right-radius:0}:host([data-styled].tx-button-group--vertical) ::ng-deep>.tx-button:not(:last-child){border-bottom-left-radius:0;border-bottom-right-radius:0}:host([data-styled]) ::ng-deep>.tx-button[data-styled]:not([data-variant])+.tx-button[data-styled]:not([data-variant]){position:relative}:host([data-styled]) ::ng-deep>.tx-button[data-styled]:not([data-variant])+.tx-button[data-styled]:not([data-variant]):before{content:\"\";position:absolute;z-index:2;background:var(--tx-button-group-divider-color);pointer-events:none}:host([data-styled]) ::ng-deep>.tx-button:hover,:host([data-styled]) ::ng-deep>.tx-button:focus-visible{position:relative;z-index:1}:host([data-styled]:not(.tx-button-group--vertical)) ::ng-deep>.tx-button[data-styled]:not([data-variant])+.tx-button[data-styled]:not([data-variant]):before{top:0;bottom:0;left:-1px;width:var(--tx-button-group-divider-width)}:host([data-styled].tx-button-group--vertical) ::ng-deep>.tx-button[data-styled]:not([data-variant])+.tx-button[data-styled]:not([data-variant]):before{top:-1px;right:0;left:0;height:var(--tx-button-group-divider-width)}\n"],
|
|
26
103
|
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
27
104
|
});
|
|
28
105
|
};
|
|
@@ -39,11 +116,67 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
39
116
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
40
117
|
host: {
|
|
41
118
|
class: "tx-button-group",
|
|
42
|
-
role: "group"
|
|
119
|
+
role: "group",
|
|
120
|
+
"[class]": "passThrough().root?.class",
|
|
121
|
+
"[class.tx-button-group--vertical]": "orientation() === \"vertical\"",
|
|
122
|
+
"[class.tx-button-group--fluid]": "isFluid()",
|
|
123
|
+
"[style]": "hostStyle()",
|
|
124
|
+
"[attr.data-orientation]": "orientation()",
|
|
125
|
+
"[attr.data-styled]": "!isUnstyled() || null"
|
|
43
126
|
},
|
|
44
|
-
styles: [":host{display:inline-flex}:host ::ng-deep>.tx-button:not(:first-child){margin-left:-1px;border-top-left-radius:0;border-bottom-left-radius:0}:host ::ng-deep>.tx-button:not(:last-child){border-top-right-radius:0;border-bottom-right-radius:0}:host ::ng-deep>.tx-button:hover,:host ::ng-deep>.tx-button:focus-visible{position:relative;z-index:1}\n"]
|
|
127
|
+
styles: [":host{display:inline-flex}:host(.tx-button-group--fluid){display:flex;width:100%}:host(.tx-button-group--vertical){flex-direction:column}:host(.tx-button-group--fluid) ::ng-deep>.tx-button{flex:1 1 0;min-width:0}:host([data-styled]:not(.tx-button-group--vertical)) ::ng-deep>.tx-button:not(:first-child){margin-left:-1px;border-top-left-radius:0;border-bottom-left-radius:0}:host([data-styled]:not(.tx-button-group--vertical)) ::ng-deep>.tx-button:not(:last-child){border-top-right-radius:0;border-bottom-right-radius:0}:host([data-styled].tx-button-group--vertical) ::ng-deep>.tx-button:not(:first-child){margin-top:-1px;border-top-left-radius:0;border-top-right-radius:0}:host([data-styled].tx-button-group--vertical) ::ng-deep>.tx-button:not(:last-child){border-bottom-left-radius:0;border-bottom-right-radius:0}:host([data-styled]) ::ng-deep>.tx-button[data-styled]:not([data-variant])+.tx-button[data-styled]:not([data-variant]){position:relative}:host([data-styled]) ::ng-deep>.tx-button[data-styled]:not([data-variant])+.tx-button[data-styled]:not([data-variant]):before{content:\"\";position:absolute;z-index:2;background:var(--tx-button-group-divider-color);pointer-events:none}:host([data-styled]) ::ng-deep>.tx-button:hover,:host([data-styled]) ::ng-deep>.tx-button:focus-visible{position:relative;z-index:1}:host([data-styled]:not(.tx-button-group--vertical)) ::ng-deep>.tx-button[data-styled]:not([data-variant])+.tx-button[data-styled]:not([data-variant]):before{top:0;bottom:0;left:-1px;width:var(--tx-button-group-divider-width)}:host([data-styled].tx-button-group--vertical) ::ng-deep>.tx-button[data-styled]:not([data-variant])+.tx-button[data-styled]:not([data-variant]):before{top:-1px;right:0;left:0;height:var(--tx-button-group-divider-width)}\n"]
|
|
128
|
+
}]
|
|
129
|
+
}],
|
|
130
|
+
propDecorators: {
|
|
131
|
+
orientation: [{
|
|
132
|
+
type: i0.Input,
|
|
133
|
+
args: [{
|
|
134
|
+
isSignal: true,
|
|
135
|
+
alias: "orientation",
|
|
136
|
+
required: false
|
|
137
|
+
}]
|
|
138
|
+
}],
|
|
139
|
+
fluid: [{
|
|
140
|
+
type: i0.Input,
|
|
141
|
+
args: [{
|
|
142
|
+
isSignal: true,
|
|
143
|
+
alias: "fluid",
|
|
144
|
+
required: false
|
|
145
|
+
}]
|
|
146
|
+
}],
|
|
147
|
+
dt: [{
|
|
148
|
+
type: i0.Input,
|
|
149
|
+
args: [{
|
|
150
|
+
isSignal: true,
|
|
151
|
+
alias: "dt",
|
|
152
|
+
required: false
|
|
153
|
+
}]
|
|
154
|
+
}],
|
|
155
|
+
pt: [{
|
|
156
|
+
type: i0.Input,
|
|
157
|
+
args: [{
|
|
158
|
+
isSignal: true,
|
|
159
|
+
alias: "pt",
|
|
160
|
+
required: false
|
|
161
|
+
}]
|
|
162
|
+
}],
|
|
163
|
+
ptOptions: [{
|
|
164
|
+
type: i0.Input,
|
|
165
|
+
args: [{
|
|
166
|
+
isSignal: true,
|
|
167
|
+
alias: "ptOptions",
|
|
168
|
+
required: false
|
|
169
|
+
}]
|
|
170
|
+
}],
|
|
171
|
+
unstyled: [{
|
|
172
|
+
type: i0.Input,
|
|
173
|
+
args: [{
|
|
174
|
+
isSignal: true,
|
|
175
|
+
alias: "unstyled",
|
|
176
|
+
required: false
|
|
177
|
+
}]
|
|
45
178
|
}]
|
|
46
|
-
}
|
|
179
|
+
}
|
|
47
180
|
});
|
|
48
181
|
export { TxButtonGroup };
|
|
49
182
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tectra-ng-ui-button-group.mjs","names":[],"sources":["../../../../packages/ui/button-group/src/button-group.component.ts"],"sourcesContent":["import { ChangeDetectionStrategy, Component } from '@angular/core';\n\n@Component({\n selector: 'tx-button-group',\n template: '<ng-content />',\n styleUrl: './button-group.component.scss',\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: {
|
|
1
|
+
{"version":3,"file":"tectra-ng-ui-button-group.mjs","names":[],"sources":["../../../../packages/ui/button-group/src/button-group.theme.ts","../../../../packages/ui/button-group/src/button-group.component.ts"],"sourcesContent":["import { buttonGroupTokens } from '@tectra-ng/themes';\n\nexport const BUTTON_GROUP_THEME = {\n buttonGroup: buttonGroupTokens,\n};\n","import { ChangeDetectionStrategy, Component, computed, input } from '@angular/core';\nimport {\n injectPassThrough,\n injectTokens,\n injectUnstyled,\n TxPassThrough,\n TxPassThroughOptions,\n} from '@tectra-ng/core/config';\nimport { injectFluid } from '@tectra-ng/core/fluid';\nimport { optionalBoolean } from '@tectra-ng/core/utils';\nimport { TectraButtonGroupTokens, TectraDeepPartial, toStyleObject } from '@tectra-ng/themes';\nimport { BUTTON_GROUP_THEME } from './button-group.theme';\nimport { TxButtonGroupOrientation, TxButtonGroupPart } from './button-group.types';\n\n/** Joins `txButton` buttons into one block: shared borders, outer corners only, a divider between solid buttons. */\n@Component({\n selector: 'tx-button-group',\n template: '<ng-content />',\n styleUrl: './button-group.component.scss',\n changeDetection: ChangeDetectionStrategy.OnPush,\n host: {\n class: 'tx-button-group',\n role: 'group',\n '[class]': 'passThrough().root?.class',\n '[class.tx-button-group--vertical]': 'orientation() === \"vertical\"',\n '[class.tx-button-group--fluid]': 'isFluid()',\n '[style]': 'hostStyle()',\n '[attr.data-orientation]': 'orientation()',\n '[attr.data-styled]': '!isUnstyled() || null',\n },\n})\nexport class TxButtonGroup {\n private readonly buttonGroupTheme = injectTokens(BUTTON_GROUP_THEME);\n\n readonly orientation = input<TxButtonGroupOrientation>('horizontal');\n readonly fluid = input<boolean | undefined, unknown>(undefined, { transform: optionalBoolean });\n readonly dt = input<TectraDeepPartial<TectraButtonGroupTokens> | undefined>(undefined);\n readonly pt = input<TxPassThrough<TxButtonGroupPart, TxButtonGroup> | undefined>(undefined);\n readonly ptOptions = input<TxPassThroughOptions | undefined>(undefined);\n readonly unstyled = input<boolean | undefined, unknown>(undefined, {\n transform: optionalBoolean,\n });\n\n readonly isFluid = injectFluid(this.fluid);\n readonly isUnstyled = injectUnstyled(this.unstyled);\n readonly passThrough = injectPassThrough('buttonGroup', this, this.pt, this.ptOptions);\n readonly hostStyle = computed(() => ({\n ...toStyleObject(this.dt(), '--tx-button-group'),\n ...this.passThrough().root?.style,\n }));\n}\n"],"mappings":";;;;;;AAEA,MAAa,qBAAqB,EAChC,aAAa,kBACd;AC2BD,IAAa,gBAAb,MAAa,cAAa;CACP,mBAAmB,aAAa,kBAAkB;CAE1D,cAAc,MAAgC,cAAa,GAAA,YAAA,CAAA,EAAA,WAAA,cAAA,CAAA,+BAAA,CAAA,CAAA;CAC3D,QAAQ,MAAoC,QAAS;EAAA,GAAA,YAAA,EAAA,WAAA,QAAA,+BAAA,CAAA;EAAI,WAAW;CAAe,CAAA;CACnF,KAAK,MAA8D,QAAU,GAAA,YAAA,CAAA,EAAA,WAAA,KAAA,CAAA,+BAAA,CAAA,CAAA;CAC7E,KAAK,MAAmE,QAAU,GAAA,YAAA,CAAA,EAAA,WAAA,KAAA,CAAA,+BAAA,CAAA,CAAA;CAClF,YAAY,MAAwC,QAAU,GAAA,YAAA,CAAA,EAAA,WAAA,YAAA,CAAA,+BAAA,CAAA,CAAA;CAC9D,WAAW,MAAoC,QAAS;EAAA,GAAA,YAAA,EAAA,WAAA,WAAA,+BAAA,CAAA;EAC/D,WAAW;CAAe,CAAA;CAGnB,UAAU,YAAY,KAAK,KAAK;CAChC,aAAa,eAAe,KAAK,QAAQ;CACzC,cAAc,kBAAkB,eAAe,MAAM,KAAK,IAAI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