@joanroucoux/cairn-ui 0.8.2 → 0.9.1
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/CHANGELOG.md +114 -0
- package/fesm2022/joanroucoux-cairn-ui-action-bar.mjs +57 -53
- package/fesm2022/joanroucoux-cairn-ui-action-bar.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-alert.mjs +155 -47
- package/fesm2022/joanroucoux-cairn-ui-alert.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-amount.mjs +220 -110
- package/fesm2022/joanroucoux-cairn-ui-amount.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-async.mjs +392 -216
- package/fesm2022/joanroucoux-cairn-ui-async.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-avatar.mjs +145 -68
- package/fesm2022/joanroucoux-cairn-ui-avatar.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-back-link.mjs +87 -47
- package/fesm2022/joanroucoux-cairn-ui-back-link.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-badge.mjs +83 -43
- package/fesm2022/joanroucoux-cairn-ui-badge.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-button.mjs +184 -104
- package/fesm2022/joanroucoux-cairn-ui-button.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-card.mjs +232 -137
- package/fesm2022/joanroucoux-cairn-ui-card.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-choice-chips.mjs +298 -102
- package/fesm2022/joanroucoux-cairn-ui-choice-chips.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-control.mjs +4 -17
- package/fesm2022/joanroucoux-cairn-ui-control.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-delta.mjs +150 -83
- package/fesm2022/joanroucoux-cairn-ui-delta.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-dialog.mjs +508 -471
- package/fesm2022/joanroucoux-cairn-ui-dialog.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-donut.mjs +255 -157
- package/fesm2022/joanroucoux-cairn-ui-donut.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-drawer.mjs +303 -0
- package/fesm2022/joanroucoux-cairn-ui-drawer.mjs.map +1 -0
- package/fesm2022/joanroucoux-cairn-ui-empty.mjs +76 -35
- package/fesm2022/joanroucoux-cairn-ui-empty.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-external-link.mjs +40 -31
- package/fesm2022/joanroucoux-cairn-ui-external-link.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-fact.mjs +188 -79
- package/fesm2022/joanroucoux-cairn-ui-fact.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-field.mjs +309 -173
- package/fesm2022/joanroucoux-cairn-ui-field.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-filter-chips.mjs +165 -87
- package/fesm2022/joanroucoux-cairn-ui-filter-chips.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-group-header.mjs +269 -0
- package/fesm2022/joanroucoux-cairn-ui-group-header.mjs.map +1 -0
- package/fesm2022/joanroucoux-cairn-ui-input.mjs +205 -85
- package/fesm2022/joanroucoux-cairn-ui-input.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-line-chart.mjs +838 -512
- package/fesm2022/joanroucoux-cairn-ui-line-chart.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-menu.mjs +401 -225
- package/fesm2022/joanroucoux-cairn-ui-menu.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-meter.mjs +143 -57
- package/fesm2022/joanroucoux-cairn-ui-meter.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-motion.mjs +367 -399
- package/fesm2022/joanroucoux-cairn-ui-motion.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-nav-item.mjs +73 -44
- package/fesm2022/joanroucoux-cairn-ui-nav-item.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-result-group.mjs +191 -0
- package/fesm2022/joanroucoux-cairn-ui-result-group.mjs.map +1 -0
- package/fesm2022/joanroucoux-cairn-ui-row.mjs +408 -146
- package/fesm2022/joanroucoux-cairn-ui-row.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-segmented.mjs +183 -81
- package/fesm2022/joanroucoux-cairn-ui-segmented.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-select-pill.mjs +270 -0
- package/fesm2022/joanroucoux-cairn-ui-select-pill.mjs.map +1 -0
- package/fesm2022/joanroucoux-cairn-ui-select.mjs +121 -67
- package/fesm2022/joanroucoux-cairn-ui-select.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-skeleton.mjs +129 -51
- package/fesm2022/joanroucoux-cairn-ui-skeleton.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-stale-link.mjs +80 -39
- package/fesm2022/joanroucoux-cairn-ui-stale-link.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-stat.mjs +85 -55
- package/fesm2022/joanroucoux-cairn-ui-stat.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-switch.mjs +48 -35
- package/fesm2022/joanroucoux-cairn-ui-switch.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-tab-bar.mjs +113 -69
- package/fesm2022/joanroucoux-cairn-ui-tab-bar.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-table.mjs +1036 -310
- package/fesm2022/joanroucoux-cairn-ui-table.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-toast.mjs +240 -127
- package/fesm2022/joanroucoux-cairn-ui-toast.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui.mjs +0 -4
- package/package.json +17 -1
- package/styles/motion.css +1 -13
- package/styles/tokens.css +35 -64
- package/types/joanroucoux-cairn-ui-action-bar.d.ts +9 -14
- package/types/joanroucoux-cairn-ui-alert.d.ts +29 -15
- package/types/joanroucoux-cairn-ui-amount.d.ts +64 -32
- package/types/joanroucoux-cairn-ui-async.d.ts +85 -38
- package/types/joanroucoux-cairn-ui-avatar.d.ts +34 -22
- package/types/joanroucoux-cairn-ui-back-link.d.ts +20 -15
- package/types/joanroucoux-cairn-ui-badge.d.ts +22 -14
- package/types/joanroucoux-cairn-ui-button.d.ts +36 -18
- package/types/joanroucoux-cairn-ui-card.d.ts +48 -23
- package/types/joanroucoux-cairn-ui-choice-chips.d.ts +91 -35
- package/types/joanroucoux-cairn-ui-control.d.ts +9 -18
- package/types/joanroucoux-cairn-ui-delta.d.ts +46 -24
- package/types/joanroucoux-cairn-ui-dialog.d.ts +124 -57
- package/types/joanroucoux-cairn-ui-donut.d.ts +83 -46
- package/types/joanroucoux-cairn-ui-drawer.d.ts +73 -0
- package/types/joanroucoux-cairn-ui-empty.d.ts +20 -13
- package/types/joanroucoux-cairn-ui-external-link.d.ts +6 -10
- package/types/joanroucoux-cairn-ui-fact.d.ts +49 -25
- package/types/joanroucoux-cairn-ui-field.d.ts +72 -49
- package/types/joanroucoux-cairn-ui-filter-chips.d.ts +35 -20
- package/types/joanroucoux-cairn-ui-group-header.d.ts +58 -0
- package/types/joanroucoux-cairn-ui-input.d.ts +59 -37
- package/types/joanroucoux-cairn-ui-line-chart.d.ts +199 -89
- package/types/joanroucoux-cairn-ui-menu.d.ts +81 -44
- package/types/joanroucoux-cairn-ui-meter.d.ts +44 -22
- package/types/joanroucoux-cairn-ui-motion.d.ts +61 -75
- package/types/joanroucoux-cairn-ui-nav-item.d.ts +15 -13
- package/types/joanroucoux-cairn-ui-result-group.d.ts +52 -0
- package/types/joanroucoux-cairn-ui-row.d.ts +92 -37
- package/types/joanroucoux-cairn-ui-segmented.d.ts +51 -27
- package/types/joanroucoux-cairn-ui-select-pill.d.ts +59 -0
- package/types/joanroucoux-cairn-ui-select.d.ts +28 -18
- package/types/joanroucoux-cairn-ui-skeleton.d.ts +35 -18
- package/types/joanroucoux-cairn-ui-stale-link.d.ts +23 -16
- package/types/joanroucoux-cairn-ui-stat.d.ts +26 -21
- package/types/joanroucoux-cairn-ui-switch.d.ts +7 -11
- package/types/joanroucoux-cairn-ui-tab-bar.d.ts +20 -17
- package/types/joanroucoux-cairn-ui-table.d.ts +251 -89
- package/types/joanroucoux-cairn-ui-toast.d.ts +46 -36
- package/types/joanroucoux-cairn-ui.d.ts +1 -2
- package/fesm2022/joanroucoux-cairn-ui.mjs.map +0 -1
|
@@ -1,48 +1,88 @@
|
|
|
1
|
-
import * as i0 from
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const BADGE_SIZES = ['md', 'sm'];
|
|
7
|
-
const BASE_CLASSES = 'inline-flex items-center rounded-pill text-caption font-medium';
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { Component, computed, input } from "@angular/core";
|
|
3
|
+
const BADGE_VARIANTS = ["neutral", "outline"];
|
|
4
|
+
const BADGE_SIZES = ["md", "sm"];
|
|
5
|
+
const BASE_CLASSES = "inline-flex items-center rounded-pill text-caption font-medium";
|
|
8
6
|
const SIZE_CLASSES = {
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
md: "h-6 px-2.5",
|
|
8
|
+
sm: "h-[22px] px-2"
|
|
11
9
|
};
|
|
12
10
|
const VARIANT_CLASSES = {
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
neutral: "bg-(--muted) text-(--foreground)",
|
|
12
|
+
outline: "shadow-[inset_0_0_0_1px_var(--border)] text-(--foreground)"
|
|
15
13
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
14
|
+
var UiBadge = class UiBadge {
|
|
15
|
+
variant = input("neutral", ...ngDevMode ? [{ debugName: "variant" }] : /* istanbul ignore next */ []);
|
|
16
|
+
size = input("md", ...ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []);
|
|
17
|
+
classes = computed(() => `${BASE_CLASSES} ${SIZE_CLASSES[this.size()]} ${VARIANT_CLASSES[this.variant()]}`, ...ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []);
|
|
18
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
19
|
+
minVersion: "12.0.0",
|
|
20
|
+
version: "22.2.0",
|
|
21
|
+
ngImport: i0,
|
|
22
|
+
type: UiBadge,
|
|
23
|
+
deps: [],
|
|
24
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
25
|
+
});
|
|
26
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
27
|
+
minVersion: "17.1.0",
|
|
28
|
+
version: "22.2.0",
|
|
29
|
+
type: UiBadge,
|
|
30
|
+
isStandalone: true,
|
|
31
|
+
selector: "ui-badge",
|
|
32
|
+
inputs: {
|
|
33
|
+
variant: {
|
|
34
|
+
classPropertyName: "variant",
|
|
35
|
+
publicName: "variant",
|
|
36
|
+
isSignal: true,
|
|
37
|
+
isRequired: false,
|
|
38
|
+
transformFunction: null
|
|
39
|
+
},
|
|
40
|
+
size: {
|
|
41
|
+
classPropertyName: "size",
|
|
42
|
+
publicName: "size",
|
|
43
|
+
isSignal: true,
|
|
44
|
+
isRequired: false,
|
|
45
|
+
transformFunction: null
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
host: { properties: { "class": "classes()" } },
|
|
49
|
+
ngImport: i0,
|
|
50
|
+
template: "<ng-content />",
|
|
51
|
+
isInline: true
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
55
|
+
minVersion: "12.0.0",
|
|
56
|
+
version: "22.2.0",
|
|
57
|
+
ngImport: i0,
|
|
58
|
+
type: UiBadge,
|
|
59
|
+
decorators: [{
|
|
60
|
+
type: Component,
|
|
61
|
+
args: [{
|
|
62
|
+
selector: "ui-badge",
|
|
63
|
+
template: "<ng-content />",
|
|
64
|
+
host: { "[class]": "classes()" }
|
|
65
|
+
}]
|
|
66
|
+
}],
|
|
67
|
+
propDecorators: {
|
|
68
|
+
variant: [{
|
|
69
|
+
type: i0.Input,
|
|
70
|
+
args: [{
|
|
71
|
+
isSignal: true,
|
|
72
|
+
alias: "variant",
|
|
73
|
+
required: false
|
|
74
|
+
}]
|
|
75
|
+
}],
|
|
76
|
+
size: [{
|
|
77
|
+
type: i0.Input,
|
|
78
|
+
args: [{
|
|
79
|
+
isSignal: true,
|
|
80
|
+
alias: "size",
|
|
81
|
+
required: false
|
|
82
|
+
}]
|
|
83
|
+
}]
|
|
84
|
+
}
|
|
85
|
+
});
|
|
47
86
|
export { BADGE_SIZES, BADGE_VARIANTS, UiBadge };
|
|
48
|
-
|
|
87
|
+
|
|
88
|
+
//# sourceMappingURL=joanroucoux-cairn-ui-badge.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"joanroucoux-cairn-ui-badge.mjs","
|
|
1
|
+
{"version":3,"file":"joanroucoux-cairn-ui-badge.mjs","names":[],"sources":["../../../projects/ui/badge/badge.ts"],"sourcesContent":["import { Component, computed, input } from '@angular/core';\n\n/** Available badge variants. */\nexport const BADGE_VARIANTS = ['neutral', 'outline'] as const;\nexport type BadgeVariant = (typeof BADGE_VARIANTS)[number];\n\nexport const BADGE_SIZES = ['md', 'sm'] as const;\nexport type BadgeSize = (typeof BADGE_SIZES)[number];\n\nconst BASE_CLASSES = 'inline-flex items-center rounded-pill text-caption font-medium';\n\nconst SIZE_CLASSES: Record<BadgeSize, string> = {\n md: 'h-6 px-2.5',\n sm: 'h-[22px] px-2',\n};\n\nconst VARIANT_CLASSES: Record<BadgeVariant, string> = {\n neutral: 'bg-(--muted) text-(--foreground)',\n outline: 'shadow-[inset_0_0_0_1px_var(--border)] text-(--foreground)',\n};\n\n/**\n * Small status descriptor for counts, states or labels, such as an instrument's asset class.\n *\n * @example\n * <ui-badge>ETF</ui-badge>\n */\n@Component({\n selector: 'ui-badge',\n template: '<ng-content />',\n host: {\n '[class]': 'classes()',\n },\n})\nexport class UiBadge {\n readonly variant = input<BadgeVariant>('neutral');\n readonly size = input<BadgeSize>('md');\n\n protected readonly classes = computed(\n () => `${BASE_CLASSES} ${SIZE_CLASSES[this.size()]} ${VARIANT_CLASSES[this.variant()]}`,\n );\n}\n"],"mappings":";;AAGA,MAAa,iBAAiB,CAAC,WAAW,SAAS;AAGnD,MAAa,cAAc,CAAC,MAAM,IAAI;AAGtC,MAAM,eAAe;AAErB,MAAM,eAA0C;CAC9C,IAAI;CACJ,IAAI;AACL;AAED,MAAM,kBAAgD;CACpD,SAAS;CACT,SAAS;AACV;AAeD,IAAa,UAAb,MAAa,QAAO;CACT,UAAU,MAAoB,WAAU,GAAA,YAAA,CAAA,EAAA,WAAA,UAAA,CAAA,+BAAA,CAAA,CAAA;CACxC,OAAO,MAAiB,MAAK,GAAA,YAAA,CAAA,EAAA,WAAA,OAAA,CAAA,+BAAA,CAAA,CAAA;CAEnB,UAAU,eACrB,GAAG,aAAY,GAAI,aAAa,KAAK,KAAI,GAAG,GAAI,gBAAgB,KAAK,QAAO,MACnF,GAAA,YAAA,CAAA,EAAA,WAAA,UAAA,CAAA,+BAAA,CAAA,CAAA;CANU,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAO,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAP,OAAA,OAAA,GAAA,qBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,MAAA;EAAO,cAAA;EAAA,UAAA;EAAA,QAAA;GAAA,SAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,MAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;EAAA;EAAA,MAAA,EAAA,YAAA,EAAA,SAAA,YAAA,EAAA;EAAA,UAAA;EAAA,UALR;EAAgB,UAAA;CAAA,CAAA;;AAKf,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAO,YAAA,CAAA;EAPnB,MAAA;EAAU,MAAA,CAAA;GACT,UAAU;GACV,UAAU;GACV,MAAM,EACJ,WAAW,YACZ;EACF,CAAA"}
|
|
@@ -1,95 +1,136 @@
|
|
|
1
|
-
import * as i0 from
|
|
2
|
-
import {
|
|
3
|
-
import { holdTransitionsUntilRendered } from
|
|
4
|
-
|
|
5
|
-
/** Available button variants. `ButtonVariant` is derived from this tuple. */
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { Component, DestroyRef, ElementRef, booleanAttribute, computed, inject, input } from "@angular/core";
|
|
3
|
+
import { holdTransitionsUntilRendered } from "@joanroucoux/cairn-ui/motion";
|
|
6
4
|
const BUTTON_VARIANTS = [
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
5
|
+
"primary",
|
|
6
|
+
"outline",
|
|
7
|
+
"ghost",
|
|
8
|
+
"destructive",
|
|
9
|
+
"quiet",
|
|
10
|
+
"quiet-destructive",
|
|
11
|
+
"outline-destructive",
|
|
12
|
+
"quiet-glow",
|
|
13
|
+
"tonal"
|
|
16
14
|
];
|
|
17
|
-
/** Available button sizes. */
|
|
18
15
|
const BUTTON_SIZES = [
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
16
|
+
"compact",
|
|
17
|
+
"slim",
|
|
18
|
+
"xs",
|
|
19
|
+
"sm",
|
|
20
|
+
"md",
|
|
21
|
+
"lg",
|
|
22
|
+
"xl",
|
|
23
|
+
"xxl",
|
|
24
|
+
"tall",
|
|
25
|
+
"block",
|
|
26
|
+
"icon",
|
|
27
|
+
"icon-sm"
|
|
31
28
|
];
|
|
32
|
-
const BASE_CLASSES =
|
|
33
|
-
const RING_OUTSIDE =
|
|
34
|
-
const RING_INSIDE =
|
|
35
|
-
const OUTLINE =
|
|
29
|
+
const BASE_CLASSES = "relative inline-flex items-center justify-center rounded-control font-medium whitespace-nowrap cursor-pointer select-none touch-manipulation transition-[scale,background-color] [transition-duration:var(--duration-press),var(--duration-fast)] ease-out active:scale-(--press-scale) focus-visible:outline-2 focus-visible:outline-(--ring) disabled:pointer-events-none disabled:opacity-40 aria-disabled:not-aria-busy:opacity-40";
|
|
30
|
+
const RING_OUTSIDE = "focus-visible:outline-offset-2";
|
|
31
|
+
const RING_INSIDE = "focus-visible:-outline-offset-2";
|
|
32
|
+
const OUTLINE = "bg-(--card) shadow-[inset_0_0_0_1px_var(--border)] hover:bg-(--glow) active:bg-(--soft)";
|
|
36
33
|
const VARIANT_CLASSES = {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
34
|
+
primary: `${RING_OUTSIDE} bg-(--primary) text-(--primary-foreground) hover:bg-(--primary-to)`,
|
|
35
|
+
outline: `${RING_OUTSIDE} ${OUTLINE} text-(--foreground)`,
|
|
36
|
+
ghost: `${RING_OUTSIDE} bg-transparent text-(--foreground) hover:bg-(--glow) active:bg-(--soft)`,
|
|
37
|
+
destructive: `${RING_OUTSIDE} bg-(--destructive) text-(--destructive-foreground)`,
|
|
38
|
+
tonal: `${RING_OUTSIDE} bg-(--muted) text-(--foreground) lg:bg-transparent lg:hover:bg-(--glow)`,
|
|
39
|
+
"quiet-glow": `${RING_INSIDE} bg-transparent text-(--muted-foreground) hover:bg-(--glow) hover:text-(--foreground)`,
|
|
40
|
+
quiet: `${RING_INSIDE} bg-transparent text-(--muted-foreground) hover:bg-(--soft) hover:text-(--foreground) active:bg-(--soft)`,
|
|
41
|
+
"quiet-destructive": `${RING_INSIDE} bg-transparent text-(--muted-foreground) hover:bg-(--glow) hover:text-(--negative) active:bg-(--soft)`,
|
|
42
|
+
"outline-destructive": `${RING_OUTSIDE} ${OUTLINE} text-(--negative)`
|
|
46
43
|
};
|
|
47
44
|
const SIZE_CLASSES = {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
45
|
+
compact: "h-8 lg:h-7 gap-1.5 px-2.5 lg:px-2 text-label before:absolute before:-inset-x-1 before:-inset-y-1.5 lg:before:hidden",
|
|
46
|
+
slim: "h-11 lg:h-8 gap-1.5 px-2.5 text-label",
|
|
47
|
+
xs: "h-8 gap-1.5 px-2.5 text-label",
|
|
48
|
+
sm: "h-9 gap-2 px-3 text-label",
|
|
49
|
+
md: "min-h-(--row-min) gap-2 px-4 text-label has-[>span>svg:first-child]:pl-3",
|
|
50
|
+
lg: "h-11 gap-2 px-[18px] text-label",
|
|
51
|
+
xl: "h-[50px] gap-2 px-6 text-body",
|
|
52
|
+
xxl: "h-[52px] lg:h-11 gap-2.5 px-6 lg:px-5 text-body lg:has-[>span>svg:first-child]:pl-4",
|
|
53
|
+
tall: "h-12 lg:h-10 gap-2 px-4 text-body",
|
|
54
|
+
block: "h-[50px] lg:h-11 gap-2 px-4 text-body",
|
|
55
|
+
icon: "size-(--row-min) gap-2 p-0",
|
|
56
|
+
"icon-sm": "size-11 pointer-fine:size-9 gap-2 p-0"
|
|
60
57
|
};
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
58
|
+
var UiButton = class UiButton {
|
|
59
|
+
variant = input("primary", ...ngDevMode ? [{ debugName: "variant" }] : /* istanbul ignore next */ []);
|
|
60
|
+
size = input("md", ...ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []);
|
|
61
|
+
loading = input(false, {
|
|
62
|
+
...ngDevMode ? { debugName: "loading" } : /* istanbul ignore next */ {},
|
|
63
|
+
transform: booleanAttribute
|
|
64
|
+
});
|
|
65
|
+
busy = input(false, {
|
|
66
|
+
...ngDevMode ? { debugName: "busy" } : /* istanbul ignore next */ {},
|
|
67
|
+
transform: booleanAttribute
|
|
68
|
+
});
|
|
69
|
+
inactive = computed(() => this.loading() || this.busy(), ...ngDevMode ? [{ debugName: "inactive" }] : /* istanbul ignore next */ []);
|
|
70
|
+
classes = computed(() => `${BASE_CLASSES} ${VARIANT_CLASSES[this.variant()]} ${SIZE_CLASSES[this.size()]}${this.inactive() ? " pointer-events-none opacity-70" : ""}`, ...ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []);
|
|
71
|
+
constructor() {
|
|
72
|
+
holdTransitionsUntilRendered();
|
|
73
|
+
const host = inject(ElementRef).nativeElement;
|
|
74
|
+
const guard = (event) => {
|
|
75
|
+
if (this.inactive()) {
|
|
76
|
+
event.preventDefault();
|
|
77
|
+
event.stopImmediatePropagation();
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
host.addEventListener("click", guard, { capture: true });
|
|
81
|
+
inject(DestroyRef).onDestroy(() => host.removeEventListener("click", guard, { capture: true }));
|
|
82
|
+
}
|
|
83
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
84
|
+
minVersion: "12.0.0",
|
|
85
|
+
version: "22.2.0",
|
|
86
|
+
ngImport: i0,
|
|
87
|
+
type: UiButton,
|
|
88
|
+
deps: [],
|
|
89
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
90
|
+
});
|
|
91
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
92
|
+
minVersion: "17.0.0",
|
|
93
|
+
version: "22.2.0",
|
|
94
|
+
type: UiButton,
|
|
95
|
+
isStandalone: true,
|
|
96
|
+
selector: "button[ui-button], a[ui-button]",
|
|
97
|
+
inputs: {
|
|
98
|
+
variant: {
|
|
99
|
+
classPropertyName: "variant",
|
|
100
|
+
publicName: "variant",
|
|
101
|
+
isSignal: true,
|
|
102
|
+
isRequired: false,
|
|
103
|
+
transformFunction: null
|
|
104
|
+
},
|
|
105
|
+
size: {
|
|
106
|
+
classPropertyName: "size",
|
|
107
|
+
publicName: "size",
|
|
108
|
+
isSignal: true,
|
|
109
|
+
isRequired: false,
|
|
110
|
+
transformFunction: null
|
|
111
|
+
},
|
|
112
|
+
loading: {
|
|
113
|
+
classPropertyName: "loading",
|
|
114
|
+
publicName: "loading",
|
|
115
|
+
isSignal: true,
|
|
116
|
+
isRequired: false,
|
|
117
|
+
transformFunction: null
|
|
118
|
+
},
|
|
119
|
+
busy: {
|
|
120
|
+
classPropertyName: "busy",
|
|
121
|
+
publicName: "busy",
|
|
122
|
+
isSignal: true,
|
|
123
|
+
isRequired: false,
|
|
124
|
+
transformFunction: null
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
host: { properties: {
|
|
128
|
+
"class": "classes()",
|
|
129
|
+
"attr.aria-busy": "inactive() || null",
|
|
130
|
+
"attr.aria-disabled": "inactive() || null"
|
|
131
|
+
} },
|
|
132
|
+
ngImport: i0,
|
|
133
|
+
template: `
|
|
93
134
|
@if (loading()) {
|
|
94
135
|
<span
|
|
95
136
|
aria-hidden="true"
|
|
@@ -97,13 +138,20 @@ class UiButton {
|
|
|
97
138
|
></span>
|
|
98
139
|
}
|
|
99
140
|
<span class="contents" [class.text-transparent]="loading()"><ng-content /></span>
|
|
100
|
-
`,
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
141
|
+
`,
|
|
142
|
+
isInline: true
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
146
|
+
minVersion: "12.0.0",
|
|
147
|
+
version: "22.2.0",
|
|
148
|
+
ngImport: i0,
|
|
149
|
+
type: UiButton,
|
|
150
|
+
decorators: [{
|
|
151
|
+
type: Component,
|
|
152
|
+
args: [{
|
|
153
|
+
selector: "button[ui-button], a[ui-button]",
|
|
154
|
+
template: `
|
|
107
155
|
@if (loading()) {
|
|
108
156
|
<span
|
|
109
157
|
aria-hidden="true"
|
|
@@ -112,17 +160,49 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImpor
|
|
|
112
160
|
}
|
|
113
161
|
<span class="contents" [class.text-transparent]="loading()"><ng-content /></span>
|
|
114
162
|
`,
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
163
|
+
host: {
|
|
164
|
+
"[class]": "classes()",
|
|
165
|
+
"[attr.aria-busy]": "inactive() || null",
|
|
166
|
+
"[attr.aria-disabled]": "inactive() || null"
|
|
167
|
+
}
|
|
168
|
+
}]
|
|
169
|
+
}],
|
|
170
|
+
ctorParameters: () => [],
|
|
171
|
+
propDecorators: {
|
|
172
|
+
variant: [{
|
|
173
|
+
type: i0.Input,
|
|
174
|
+
args: [{
|
|
175
|
+
isSignal: true,
|
|
176
|
+
alias: "variant",
|
|
177
|
+
required: false
|
|
178
|
+
}]
|
|
179
|
+
}],
|
|
180
|
+
size: [{
|
|
181
|
+
type: i0.Input,
|
|
182
|
+
args: [{
|
|
183
|
+
isSignal: true,
|
|
184
|
+
alias: "size",
|
|
185
|
+
required: false
|
|
186
|
+
}]
|
|
187
|
+
}],
|
|
188
|
+
loading: [{
|
|
189
|
+
type: i0.Input,
|
|
190
|
+
args: [{
|
|
191
|
+
isSignal: true,
|
|
192
|
+
alias: "loading",
|
|
193
|
+
required: false
|
|
194
|
+
}]
|
|
195
|
+
}],
|
|
196
|
+
busy: [{
|
|
197
|
+
type: i0.Input,
|
|
198
|
+
args: [{
|
|
199
|
+
isSignal: true,
|
|
200
|
+
alias: "busy",
|
|
201
|
+
required: false
|
|
202
|
+
}]
|
|
203
|
+
}]
|
|
204
|
+
}
|
|
205
|
+
});
|
|
127
206
|
export { BUTTON_SIZES, BUTTON_VARIANTS, UiButton };
|
|
128
|
-
|
|
207
|
+
|
|
208
|
+
//# sourceMappingURL=joanroucoux-cairn-ui-button.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"joanroucoux-cairn-ui-button.mjs","
|
|
1
|
+
{"version":3,"file":"joanroucoux-cairn-ui-button.mjs","names":[],"sources":["../../../projects/ui/button/button.ts"],"sourcesContent":["import { Component, DestroyRef, ElementRef, booleanAttribute, computed, inject, input } from '@angular/core';\n\nimport { holdTransitionsUntilRendered } from '@joanroucoux/cairn-ui/motion';\n\n/** Available button variants. */\nexport const BUTTON_VARIANTS = [\n 'primary',\n 'outline',\n 'ghost',\n 'destructive',\n 'quiet',\n 'quiet-destructive',\n 'outline-destructive',\n 'quiet-glow',\n 'tonal',\n] as const;\nexport type ButtonVariant = (typeof BUTTON_VARIANTS)[number];\n\n/** Available button sizes. */\nexport const BUTTON_SIZES = [\n 'compact',\n 'slim',\n 'xs',\n 'sm',\n 'md',\n 'lg',\n 'xl',\n 'xxl',\n 'tall',\n 'block',\n 'icon',\n 'icon-sm',\n] as const;\nexport type ButtonSize = (typeof BUTTON_SIZES)[number];\n\nconst BASE_CLASSES =\n 'relative inline-flex items-center justify-center rounded-control font-medium whitespace-nowrap cursor-pointer select-none touch-manipulation transition-[scale,background-color] [transition-duration:var(--duration-press),var(--duration-fast)] ease-out active:scale-(--press-scale) focus-visible:outline-2 focus-visible:outline-(--ring) disabled:pointer-events-none disabled:opacity-40 aria-disabled:not-aria-busy:opacity-40';\n\nconst RING_OUTSIDE = 'focus-visible:outline-offset-2';\nconst RING_INSIDE = 'focus-visible:-outline-offset-2';\nconst OUTLINE = 'bg-(--card) shadow-[inset_0_0_0_1px_var(--border)] hover:bg-(--glow) active:bg-(--soft)';\n\nconst VARIANT_CLASSES: Record<ButtonVariant, string> = {\n primary: `${RING_OUTSIDE} bg-(--primary) text-(--primary-foreground) hover:bg-(--primary-to)`,\n outline: `${RING_OUTSIDE} ${OUTLINE} text-(--foreground)`,\n ghost: `${RING_OUTSIDE} bg-transparent text-(--foreground) hover:bg-(--glow) active:bg-(--soft)`,\n destructive: `${RING_OUTSIDE} bg-(--destructive) text-(--destructive-foreground)`,\n tonal: `${RING_OUTSIDE} bg-(--muted) text-(--foreground) lg:bg-transparent lg:hover:bg-(--glow)`,\n 'quiet-glow': `${RING_INSIDE} bg-transparent text-(--muted-foreground) hover:bg-(--glow) hover:text-(--foreground)`,\n quiet: `${RING_INSIDE} bg-transparent text-(--muted-foreground) hover:bg-(--soft) hover:text-(--foreground) active:bg-(--soft)`,\n 'quiet-destructive': `${RING_INSIDE} bg-transparent text-(--muted-foreground) hover:bg-(--glow) hover:text-(--negative) active:bg-(--soft)`,\n 'outline-destructive': `${RING_OUTSIDE} ${OUTLINE} text-(--negative)`,\n};\n\nconst SIZE_CLASSES: Record<ButtonSize, string> = {\n compact:\n 'h-8 lg:h-7 gap-1.5 px-2.5 lg:px-2 text-label before:absolute before:-inset-x-1 before:-inset-y-1.5 lg:before:hidden',\n slim: 'h-11 lg:h-8 gap-1.5 px-2.5 text-label',\n xs: 'h-8 gap-1.5 px-2.5 text-label',\n sm: 'h-9 gap-2 px-3 text-label',\n md: 'min-h-(--row-min) gap-2 px-4 text-label has-[>span>svg:first-child]:pl-3',\n lg: 'h-11 gap-2 px-[18px] text-label',\n xl: 'h-[50px] gap-2 px-6 text-body',\n xxl: 'h-[52px] lg:h-11 gap-2.5 px-6 lg:px-5 text-body lg:has-[>span>svg:first-child]:pl-4',\n tall: 'h-12 lg:h-10 gap-2 px-4 text-body',\n block: 'h-[50px] lg:h-11 gap-2 px-4 text-body',\n icon: 'size-(--row-min) gap-2 p-0',\n 'icon-sm': 'size-11 pointer-fine:size-9 gap-2 p-0',\n};\n\n/**\n * Styled native button or anchor, applied as an attribute so the host keeps every native behavior.\n *\n * @example\n * <button ui-button variant=\"destructive\">Delete</button>\n * <button ui-button size=\"icon\" variant=\"ghost\" aria-label=\"More actions\">...</button>\n */\n@Component({\n selector: 'button[ui-button], a[ui-button]',\n template: `\n @if (loading()) {\n <span\n aria-hidden=\"true\"\n class=\"rounded-pill animate-cairn-spin absolute inset-0 m-auto size-4 border-2 border-current border-r-transparent\"\n ></span>\n }\n <span class=\"contents\" [class.text-transparent]=\"loading()\"><ng-content /></span>\n `,\n host: {\n '[class]': 'classes()',\n '[attr.aria-busy]': 'inactive() || null',\n '[attr.aria-disabled]': 'inactive() || null',\n },\n})\nexport class UiButton {\n readonly variant = input<ButtonVariant>('primary');\n readonly size = input<ButtonSize>('md');\n readonly loading = input(false, { transform: booleanAttribute });\n readonly busy = input(false, { transform: booleanAttribute });\n\n protected readonly inactive = computed(() => this.loading() || this.busy());\n\n protected readonly classes = computed(\n () =>\n `${BASE_CLASSES} ${VARIANT_CLASSES[this.variant()]} ${SIZE_CLASSES[this.size()]}${this.inactive() ? ' pointer-events-none opacity-70' : ''}`,\n );\n\n constructor() {\n holdTransitionsUntilRendered();\n const host = inject<ElementRef<HTMLElement>>(ElementRef).nativeElement;\n const guard = (event: Event): void => {\n if (this.inactive()) {\n event.preventDefault();\n event.stopImmediatePropagation();\n }\n };\n\n host.addEventListener('click', guard, { capture: true });\n inject(DestroyRef).onDestroy(() => host.removeEventListener('click', guard, { capture: true }));\n }\n}\n"],"mappings":"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"}
|