@nanahoshi/mona-ui 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -0
- package/fesm2022/nanahoshi-mona-ui-auto-complete.mjs +590 -0
- package/fesm2022/nanahoshi-mona-ui-avatar.mjs +168 -0
- package/fesm2022/nanahoshi-mona-ui-breadcrumb.mjs +220 -0
- package/fesm2022/nanahoshi-mona-ui-button-group.mjs +225 -0
- package/fesm2022/nanahoshi-mona-ui-button.mjs +497 -0
- package/fesm2022/nanahoshi-mona-ui-calendar.mjs +1569 -0
- package/fesm2022/nanahoshi-mona-ui-check-box.mjs +339 -0
- package/fesm2022/nanahoshi-mona-ui-chip.mjs +453 -0
- package/fesm2022/nanahoshi-mona-ui-circular-progress-bar.mjs +200 -0
- package/fesm2022/nanahoshi-mona-ui-color-gradient.mjs +853 -0
- package/fesm2022/nanahoshi-mona-ui-color-palette.mjs +923 -0
- package/fesm2022/nanahoshi-mona-ui-color-picker.mjs +495 -0
- package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +686 -0
- package/fesm2022/nanahoshi-mona-ui-common.mjs +642 -0
- package/fesm2022/nanahoshi-mona-ui-contextmenu.mjs +485 -0
- package/fesm2022/nanahoshi-mona-ui-date-input.mjs +132 -0
- package/fesm2022/nanahoshi-mona-ui-date-picker.mjs +460 -0
- package/fesm2022/nanahoshi-mona-ui-datetime-picker.mjs +659 -0
- package/fesm2022/nanahoshi-mona-ui-dialog.mjs +828 -0
- package/fesm2022/nanahoshi-mona-ui-dropdown-button.mjs +523 -0
- package/fesm2022/nanahoshi-mona-ui-dropdown-list.mjs +615 -0
- package/fesm2022/nanahoshi-mona-ui-dropdowns.mjs +701 -0
- package/fesm2022/nanahoshi-mona-ui-editor.mjs +1400 -0
- package/fesm2022/nanahoshi-mona-ui-expansion-panel.mjs +245 -0
- package/fesm2022/nanahoshi-mona-ui-fieldset.mjs +170 -0
- package/fesm2022/nanahoshi-mona-ui-filter.mjs +680 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-cell.component-B9SQH5N-.mjs +105 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-table-cell.directive-DlLwcCFT.mjs +42 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-list.component-Dgea-O0X.mjs +130 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-toggle.component-DIUutx9s.mjs +773 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-virtual-list.component-DRHycGIh.mjs +240 -0
- package/fesm2022/nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-C3eZIaJK.mjs +5374 -0
- package/fesm2022/nanahoshi-mona-ui-grid.mjs +2 -0
- package/fesm2022/nanahoshi-mona-ui-internal-filter-input.mjs +87 -0
- package/fesm2022/nanahoshi-mona-ui-internal-indicator-icon.mjs +154 -0
- package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +1356 -0
- package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +2263 -0
- package/fesm2022/nanahoshi-mona-ui-internal.mjs +379 -0
- package/fesm2022/nanahoshi-mona-ui-list-box.mjs +630 -0
- package/fesm2022/nanahoshi-mona-ui-list-view.mjs +527 -0
- package/fesm2022/nanahoshi-mona-ui-list.mjs +4 -0
- package/fesm2022/nanahoshi-mona-ui-menubar.mjs +966 -0
- package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +641 -0
- package/fesm2022/nanahoshi-mona-ui-notification.mjs +536 -0
- package/fesm2022/nanahoshi-mona-ui-numeric-text-box.mjs +597 -0
- package/fesm2022/nanahoshi-mona-ui-pager.mjs +790 -0
- package/fesm2022/nanahoshi-mona-ui-placeholder.mjs +83 -0
- package/fesm2022/nanahoshi-mona-ui-popover.mjs +325 -0
- package/fesm2022/nanahoshi-mona-ui-popup-menu.mjs +1559 -0
- package/fesm2022/nanahoshi-mona-ui-popup.mjs +1321 -0
- package/fesm2022/nanahoshi-mona-ui-progress-bar.mjs +294 -0
- package/fesm2022/nanahoshi-mona-ui-query.mjs +175 -0
- package/fesm2022/nanahoshi-mona-ui-radio-button.mjs +339 -0
- package/fesm2022/nanahoshi-mona-ui-scroll-view.mjs +565 -0
- package/fesm2022/nanahoshi-mona-ui-slider.mjs +1049 -0
- package/fesm2022/nanahoshi-mona-ui-split-button.mjs +636 -0
- package/fesm2022/nanahoshi-mona-ui-splitter.mjs +843 -0
- package/fesm2022/nanahoshi-mona-ui-stepper.mjs +537 -0
- package/fesm2022/nanahoshi-mona-ui-switch.mjs +308 -0
- package/fesm2022/nanahoshi-mona-ui-tabs.mjs +664 -0
- package/fesm2022/nanahoshi-mona-ui-text-area.mjs +111 -0
- package/fesm2022/nanahoshi-mona-ui-text-box.mjs +369 -0
- package/fesm2022/nanahoshi-mona-ui-theme.mjs +314 -0
- package/fesm2022/nanahoshi-mona-ui-time-picker.mjs +450 -0
- package/fesm2022/nanahoshi-mona-ui-time-selector.mjs +723 -0
- package/fesm2022/nanahoshi-mona-ui-tooltip.mjs +716 -0
- package/fesm2022/nanahoshi-mona-ui-tree-view.mjs +733 -0
- package/fesm2022/nanahoshi-mona-ui-window.mjs +1329 -0
- package/fesm2022/nanahoshi-mona-ui.mjs +9 -0
- package/package.json +289 -0
- package/types/nanahoshi-mona-ui-auto-complete.d.ts +223 -0
- package/types/nanahoshi-mona-ui-avatar.d.ts +642 -0
- package/types/nanahoshi-mona-ui-breadcrumb.d.ts +70 -0
- package/types/nanahoshi-mona-ui-button-group.d.ts +77 -0
- package/types/nanahoshi-mona-ui-button.d.ts +111 -0
- package/types/nanahoshi-mona-ui-calendar.d.ts +262 -0
- package/types/nanahoshi-mona-ui-check-box.d.ts +133 -0
- package/types/nanahoshi-mona-ui-chip.d.ts +130 -0
- package/types/nanahoshi-mona-ui-circular-progress-bar.d.ts +113 -0
- package/types/nanahoshi-mona-ui-color-gradient.d.ts +201 -0
- package/types/nanahoshi-mona-ui-color-palette.d.ts +102 -0
- package/types/nanahoshi-mona-ui-color-picker.d.ts +156 -0
- package/types/nanahoshi-mona-ui-combo-box.d.ts +232 -0
- package/types/nanahoshi-mona-ui-common.d.ts +386 -0
- package/types/nanahoshi-mona-ui-contextmenu.d.ts +129 -0
- package/types/nanahoshi-mona-ui-date-input.d.ts +60 -0
- package/types/nanahoshi-mona-ui-date-picker.d.ts +177 -0
- package/types/nanahoshi-mona-ui-datetime-picker.d.ts +199 -0
- package/types/nanahoshi-mona-ui-dialog.d.ts +261 -0
- package/types/nanahoshi-mona-ui-dropdown-button.d.ts +159 -0
- package/types/nanahoshi-mona-ui-dropdown-list.d.ts +219 -0
- package/types/nanahoshi-mona-ui-dropdowns.d.ts +176 -0
- package/types/nanahoshi-mona-ui-editor.d.ts +113 -0
- package/types/nanahoshi-mona-ui-expansion-panel.d.ts +87 -0
- package/types/nanahoshi-mona-ui-fieldset.d.ts +68 -0
- package/types/nanahoshi-mona-ui-filter.d.ts +115 -0
- package/types/nanahoshi-mona-ui-grid.d.ts +1114 -0
- package/types/nanahoshi-mona-ui-internal-filter-input.d.ts +25 -0
- package/types/nanahoshi-mona-ui-internal-indicator-icon.d.ts +28 -0
- package/types/nanahoshi-mona-ui-internal-list.d.ts +269 -0
- package/types/nanahoshi-mona-ui-internal-tree.d.ts +391 -0
- package/types/nanahoshi-mona-ui-internal.d.ts +136 -0
- package/types/nanahoshi-mona-ui-list-box.d.ts +225 -0
- package/types/nanahoshi-mona-ui-list-view.d.ts +188 -0
- package/types/nanahoshi-mona-ui-list.d.ts +1 -0
- package/types/nanahoshi-mona-ui-menubar.d.ts +198 -0
- package/types/nanahoshi-mona-ui-multi-select.d.ts +247 -0
- package/types/nanahoshi-mona-ui-notification.d.ts +106 -0
- package/types/nanahoshi-mona-ui-numeric-text-box.d.ts +161 -0
- package/types/nanahoshi-mona-ui-pager.d.ts +238 -0
- package/types/nanahoshi-mona-ui-placeholder.d.ts +35 -0
- package/types/nanahoshi-mona-ui-popover.d.ts +130 -0
- package/types/nanahoshi-mona-ui-popup-menu.d.ts +412 -0
- package/types/nanahoshi-mona-ui-popup.d.ts +485 -0
- package/types/nanahoshi-mona-ui-progress-bar.d.ts +139 -0
- package/types/nanahoshi-mona-ui-query.d.ts +89 -0
- package/types/nanahoshi-mona-ui-radio-button.d.ts +128 -0
- package/types/nanahoshi-mona-ui-scroll-view.d.ts +166 -0
- package/types/nanahoshi-mona-ui-slider.d.ts +305 -0
- package/types/nanahoshi-mona-ui-split-button.d.ts +182 -0
- package/types/nanahoshi-mona-ui-splitter.d.ts +70 -0
- package/types/nanahoshi-mona-ui-stepper.d.ts +173 -0
- package/types/nanahoshi-mona-ui-switch.d.ts +125 -0
- package/types/nanahoshi-mona-ui-tabs.d.ts +158 -0
- package/types/nanahoshi-mona-ui-text-area.d.ts +42 -0
- package/types/nanahoshi-mona-ui-text-box.d.ts +164 -0
- package/types/nanahoshi-mona-ui-theme.d.ts +23 -0
- package/types/nanahoshi-mona-ui-time-picker.d.ts +184 -0
- package/types/nanahoshi-mona-ui-time-selector.d.ts +143 -0
- package/types/nanahoshi-mona-ui-tooltip.d.ts +130 -0
- package/types/nanahoshi-mona-ui-tree-view.d.ts +274 -0
- package/types/nanahoshi-mona-ui-window.d.ts +295 -0
- package/types/nanahoshi-mona-ui.d.ts +2 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { computed, input, Component } from '@angular/core';
|
|
3
|
+
|
|
4
|
+
class AvatarComponent {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.avatarLabelStyles = computed(() => {
|
|
7
|
+
return {
|
|
8
|
+
alignItems: "center",
|
|
9
|
+
color: this.labelColor(),
|
|
10
|
+
display: "flex",
|
|
11
|
+
fontSize: this.labelFontSize(),
|
|
12
|
+
fontWeight: this.labelFontWeight(),
|
|
13
|
+
height: "100%",
|
|
14
|
+
justifyContent: "center",
|
|
15
|
+
width: "100%"
|
|
16
|
+
};
|
|
17
|
+
}, /* @ts-ignore */
|
|
18
|
+
...(ngDevMode ? [{ debugName: "avatarLabelStyles" }] : /* istanbul ignore next */ []));
|
|
19
|
+
this.avatarStyles = computed(() => {
|
|
20
|
+
const image = this.image();
|
|
21
|
+
const backgroundColor = image ? "transparent" : this.backgroundColor();
|
|
22
|
+
return {
|
|
23
|
+
borderColor: this.borderColor(),
|
|
24
|
+
borderWidth: this.borderWidth(),
|
|
25
|
+
borderStyle: "solid",
|
|
26
|
+
borderRadius: this.borderRadius(),
|
|
27
|
+
backgroundColor,
|
|
28
|
+
display: "inline-block",
|
|
29
|
+
height: this.height(),
|
|
30
|
+
width: this.width(),
|
|
31
|
+
...this.customStyles()
|
|
32
|
+
};
|
|
33
|
+
}, /* @ts-ignore */
|
|
34
|
+
...(ngDevMode ? [{ debugName: "avatarStyles" }] : /* istanbul ignore next */ []));
|
|
35
|
+
/**
|
|
36
|
+
* @description Alternative text for the avatar image. Provide a meaningful description for non-decorative images;
|
|
37
|
+
* an empty string marks the image as decorative.
|
|
38
|
+
* @default ""
|
|
39
|
+
*/
|
|
40
|
+
this.alt = input("", /* @ts-ignore */
|
|
41
|
+
...(ngDevMode ? [{ debugName: "alt" }] : /* istanbul ignore next */ []));
|
|
42
|
+
/**
|
|
43
|
+
* @description Accessible name for the host element. Describe what the avatar represents.
|
|
44
|
+
* When non-empty, the host receives `role="img"` in label and projected-content modes.
|
|
45
|
+
* @default ""
|
|
46
|
+
*/
|
|
47
|
+
this.ariaLabel = input("", { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: "aria-label" });
|
|
48
|
+
/**
|
|
49
|
+
* @description Background color of the host element.
|
|
50
|
+
* Ignored in image mode — the background is set to transparent automatically.
|
|
51
|
+
* @default "var(--color-primary)"
|
|
52
|
+
*/
|
|
53
|
+
this.backgroundColor = input("var(--color-primary)", /* @ts-ignore */
|
|
54
|
+
...(ngDevMode ? [{ debugName: "backgroundColor" }] : /* istanbul ignore next */ []));
|
|
55
|
+
/**
|
|
56
|
+
* @description Border color of the host element.
|
|
57
|
+
* @default "var(--color-border)"
|
|
58
|
+
*/
|
|
59
|
+
this.borderColor = input("var(--color-border)", /* @ts-ignore */
|
|
60
|
+
...(ngDevMode ? [{ debugName: "borderColor" }] : /* istanbul ignore next */ []));
|
|
61
|
+
/**
|
|
62
|
+
* @description Border radius of the host element. Accepts a CSS string (`'50%'`, `'8px'`) or a number converted to `px`.
|
|
63
|
+
* In image mode, the image is also clipped to this radius.
|
|
64
|
+
* @default "0"
|
|
65
|
+
*/
|
|
66
|
+
this.borderRadius = input("0", { ...(ngDevMode ? { debugName: "borderRadius" } : /* istanbul ignore next */ {}), transform: (value) => {
|
|
67
|
+
if (typeof value === "number") {
|
|
68
|
+
return `${value}px`;
|
|
69
|
+
}
|
|
70
|
+
return value;
|
|
71
|
+
} });
|
|
72
|
+
/**
|
|
73
|
+
* @description Border width of the host element. Accepts a CSS string or a number converted to `px`.
|
|
74
|
+
* @default "1px"
|
|
75
|
+
*/
|
|
76
|
+
this.borderWidth = input("1px", { ...(ngDevMode ? { debugName: "borderWidth" } : /* istanbul ignore next */ {}), transform: (value) => {
|
|
77
|
+
if (typeof value === "number") {
|
|
78
|
+
return `${value}px`;
|
|
79
|
+
}
|
|
80
|
+
return value;
|
|
81
|
+
} });
|
|
82
|
+
/**
|
|
83
|
+
* @description Inline styles applied after all other style inputs,
|
|
84
|
+
* taking precedence over every computed style including `display`, `height`, and `width`.
|
|
85
|
+
* @default {}
|
|
86
|
+
*/
|
|
87
|
+
this.customStyles = input({}, /* @ts-ignore */
|
|
88
|
+
...(ngDevMode ? [{ debugName: "customStyles" }] : /* istanbul ignore next */ []));
|
|
89
|
+
/**
|
|
90
|
+
* @description Height of the host element. A string is used as-is; a number is converted to `px`.
|
|
91
|
+
* @default "64px"
|
|
92
|
+
*/
|
|
93
|
+
this.height = input("64px", { ...(ngDevMode ? { debugName: "height" } : /* istanbul ignore next */ {}), transform: (value) => {
|
|
94
|
+
if (typeof value === "string") {
|
|
95
|
+
return value;
|
|
96
|
+
}
|
|
97
|
+
return `${value}px`;
|
|
98
|
+
} });
|
|
99
|
+
/**
|
|
100
|
+
* @description Image URL. When non-empty, renders an `<img>` and suppresses `label` and projected content.
|
|
101
|
+
* @default ""
|
|
102
|
+
*/
|
|
103
|
+
// TODO(owner-review): migrate to NgOptimizedImage once width/height inputs are changed to number-only
|
|
104
|
+
this.image = input("", /* @ts-ignore */
|
|
105
|
+
...(ngDevMode ? [{ debugName: "image" }] : /* istanbul ignore next */ []));
|
|
106
|
+
/**
|
|
107
|
+
* @description Text label displayed inside the avatar when no image is provided. Ignored when `image` is non-empty.
|
|
108
|
+
* @default ""
|
|
109
|
+
*/
|
|
110
|
+
this.label = input("", /* @ts-ignore */
|
|
111
|
+
...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
112
|
+
/**
|
|
113
|
+
* @description Color of the label text. Ignored in image mode.
|
|
114
|
+
* @default "var(--color-foreground)"
|
|
115
|
+
*/
|
|
116
|
+
this.labelColor = input("var(--color-foreground)", /* @ts-ignore */
|
|
117
|
+
...(ngDevMode ? [{ debugName: "labelColor" }] : /* istanbul ignore next */ []));
|
|
118
|
+
/**
|
|
119
|
+
* @description Font size of the label text. Ignored in image mode.
|
|
120
|
+
* @default "1rem"
|
|
121
|
+
*/
|
|
122
|
+
this.labelFontSize = input("1rem", /* @ts-ignore */
|
|
123
|
+
...(ngDevMode ? [{ debugName: "labelFontSize" }] : /* istanbul ignore next */ []));
|
|
124
|
+
/**
|
|
125
|
+
* @description Font weight of the label text. Ignored in image mode.
|
|
126
|
+
* @default "700"
|
|
127
|
+
*/
|
|
128
|
+
this.labelFontWeight = input("700", /* @ts-ignore */
|
|
129
|
+
...(ngDevMode ? [{ debugName: "labelFontWeight" }] : /* istanbul ignore next */ []));
|
|
130
|
+
/**
|
|
131
|
+
* @description Width of the host element. A string is used as-is; a number is converted to `px`.
|
|
132
|
+
* @default "64px"
|
|
133
|
+
*/
|
|
134
|
+
this.width = input("64px", { ...(ngDevMode ? { debugName: "width" } : /* istanbul ignore next */ {}), transform: (value) => {
|
|
135
|
+
if (typeof value === "string") {
|
|
136
|
+
return value;
|
|
137
|
+
}
|
|
138
|
+
return `${value}px`;
|
|
139
|
+
} });
|
|
140
|
+
/**
|
|
141
|
+
* @description Additional CSS classes applied to the host element.
|
|
142
|
+
* @default ""
|
|
143
|
+
*/
|
|
144
|
+
this.userClass = input("", { ...(ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {}), alias: "class" });
|
|
145
|
+
}
|
|
146
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: AvatarComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
147
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: AvatarComponent, isStandalone: true, selector: "mona-avatar", inputs: { alt: { classPropertyName: "alt", publicName: "alt", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null }, backgroundColor: { classPropertyName: "backgroundColor", publicName: "backgroundColor", isSignal: true, isRequired: false, transformFunction: null }, borderColor: { classPropertyName: "borderColor", publicName: "borderColor", isSignal: true, isRequired: false, transformFunction: null }, borderRadius: { classPropertyName: "borderRadius", publicName: "borderRadius", isSignal: true, isRequired: false, transformFunction: null }, borderWidth: { classPropertyName: "borderWidth", publicName: "borderWidth", isSignal: true, isRequired: false, transformFunction: null }, customStyles: { classPropertyName: "customStyles", publicName: "customStyles", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, image: { classPropertyName: "image", publicName: "image", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, labelColor: { classPropertyName: "labelColor", publicName: "labelColor", isSignal: true, isRequired: false, transformFunction: null }, labelFontSize: { classPropertyName: "labelFontSize", publicName: "labelFontSize", isSignal: true, isRequired: false, transformFunction: null }, labelFontWeight: { classPropertyName: "labelFontWeight", publicName: "labelFontWeight", isSignal: true, isRequired: false, transformFunction: null }, width: { classPropertyName: "width", publicName: "width", isSignal: true, isRequired: false, transformFunction: null }, userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "attr.aria-label": "ariaLabel() || null", "attr.role": "ariaLabel() && !image() ? 'img' : null", "class": "userClass()", "style": "avatarStyles()" } }, ngImport: i0, template: "@if (image()) {\n <img [src]=\"image()\" [style.border-radius]=\"borderRadius()\" [alt]=\"alt()\" />\n} @else if (label()) {\n <div [style]=\"avatarLabelStyles()\">{{ label() }}</div>\n} @else {\n <ng-content></ng-content>\n}\n" }); }
|
|
148
|
+
}
|
|
149
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: AvatarComponent, decorators: [{
|
|
150
|
+
type: Component,
|
|
151
|
+
args: [{ selector: "mona-avatar", host: {
|
|
152
|
+
"[attr.aria-label]": "ariaLabel() || null",
|
|
153
|
+
"[attr.role]": "ariaLabel() && !image() ? 'img' : null",
|
|
154
|
+
"[class]": "userClass()",
|
|
155
|
+
"[style]": "avatarStyles()"
|
|
156
|
+
}, template: "@if (image()) {\n <img [src]=\"image()\" [style.border-radius]=\"borderRadius()\" [alt]=\"alt()\" />\n} @else if (label()) {\n <div [style]=\"avatarLabelStyles()\">{{ label() }}</div>\n} @else {\n <ng-content></ng-content>\n}\n" }]
|
|
157
|
+
}], propDecorators: { alt: [{ type: i0.Input, args: [{ isSignal: true, alias: "alt", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-label", required: false }] }], backgroundColor: [{ type: i0.Input, args: [{ isSignal: true, alias: "backgroundColor", required: false }] }], borderColor: [{ type: i0.Input, args: [{ isSignal: true, alias: "borderColor", required: false }] }], borderRadius: [{ type: i0.Input, args: [{ isSignal: true, alias: "borderRadius", required: false }] }], borderWidth: [{ type: i0.Input, args: [{ isSignal: true, alias: "borderWidth", required: false }] }], customStyles: [{ type: i0.Input, args: [{ isSignal: true, alias: "customStyles", required: false }] }], height: [{ type: i0.Input, args: [{ isSignal: true, alias: "height", required: false }] }], image: [{ type: i0.Input, args: [{ isSignal: true, alias: "image", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], labelColor: [{ type: i0.Input, args: [{ isSignal: true, alias: "labelColor", required: false }] }], labelFontSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "labelFontSize", required: false }] }], labelFontWeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "labelFontWeight", required: false }] }], width: [{ type: i0.Input, args: [{ isSignal: true, alias: "width", required: false }] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
158
|
+
|
|
159
|
+
/*
|
|
160
|
+
* Public API Surface of @nanahoshi/mona-ui/avatar
|
|
161
|
+
*/
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Generated bundle index. Do not edit.
|
|
165
|
+
*/
|
|
166
|
+
|
|
167
|
+
export { AvatarComponent };
|
|
168
|
+
//# sourceMappingURL=nanahoshi-mona-ui-avatar.mjs.map
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { NgTemplateOutlet } from '@angular/common';
|
|
2
|
+
import * as i0 from '@angular/core';
|
|
3
|
+
import { inject, computed, input, Directive, output, viewChild, TemplateRef, Component, contentChildren, contentChild } from '@angular/core';
|
|
4
|
+
import { LucideChevronRight } from '@lucide/angular';
|
|
5
|
+
import { twMerge } from 'tailwind-merge';
|
|
6
|
+
import { ThemeService } from '@nanahoshi/mona-ui/theme';
|
|
7
|
+
import { cva } from 'class-variance-authority';
|
|
8
|
+
|
|
9
|
+
const breadcrumbListVariants = cva(`
|
|
10
|
+
flex items-center
|
|
11
|
+
overflow-hidden gap-1
|
|
12
|
+
list-none select-none py-1 px-2
|
|
13
|
+
`, {
|
|
14
|
+
variants: {
|
|
15
|
+
disabled: {
|
|
16
|
+
true: "cursor-not-allowed pointer-events-none opacity-50",
|
|
17
|
+
false: ""
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
const breadcrumbListItemVariants = cva(`
|
|
22
|
+
flex items-center
|
|
23
|
+
truncate cursor-pointer
|
|
24
|
+
h-full text-primary/70
|
|
25
|
+
bg-transparent border-0
|
|
26
|
+
outline-none rounded-sm px-1
|
|
27
|
+
hover:text-primary
|
|
28
|
+
focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40
|
|
29
|
+
transition-colors duration-100 ease-in-out
|
|
30
|
+
`, {
|
|
31
|
+
variants: {
|
|
32
|
+
disabled: {
|
|
33
|
+
true: "cursor-not-allowed pointer-events-none",
|
|
34
|
+
false: ""
|
|
35
|
+
},
|
|
36
|
+
listDisabled: {
|
|
37
|
+
true: "",
|
|
38
|
+
false: ""
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
compoundVariants: [{ disabled: true, listDisabled: false, class: "opacity-50" }],
|
|
42
|
+
defaultVariants: {
|
|
43
|
+
disabled: false,
|
|
44
|
+
listDisabled: false
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
const breadcrumbCurrentItemVariants = cva(`flex items-center truncate cursor-default font-medium text-primary`);
|
|
48
|
+
|
|
49
|
+
const breadcrumbListThemeVariants = (theme) => {
|
|
50
|
+
switch (theme) {
|
|
51
|
+
case "mona":
|
|
52
|
+
return breadcrumbListVariants;
|
|
53
|
+
default:
|
|
54
|
+
return breadcrumbListVariants;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const breadcrumbListItemThemeVariants = (theme) => {
|
|
58
|
+
switch (theme) {
|
|
59
|
+
case "mona":
|
|
60
|
+
return breadcrumbListItemVariants;
|
|
61
|
+
default:
|
|
62
|
+
return breadcrumbListItemVariants;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
const breadcrumbCurrentItemThemeVariants = (theme) => {
|
|
66
|
+
switch (theme) {
|
|
67
|
+
case "mona":
|
|
68
|
+
return breadcrumbCurrentItemVariants;
|
|
69
|
+
default:
|
|
70
|
+
return breadcrumbCurrentItemVariants;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
class BreadcrumbItemDirective {
|
|
75
|
+
constructor() {
|
|
76
|
+
this.#themeService = inject(ThemeService);
|
|
77
|
+
this.baseClass = computed(() => {
|
|
78
|
+
const theme = this.#themeService.theme();
|
|
79
|
+
const disabled = this.disabled();
|
|
80
|
+
const listDisabled = this.listDisabled();
|
|
81
|
+
const userClass = this.userClass();
|
|
82
|
+
return twMerge(breadcrumbListItemThemeVariants(theme)({ disabled, listDisabled }), userClass);
|
|
83
|
+
}, /* @ts-ignore */
|
|
84
|
+
...(ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []));
|
|
85
|
+
/**
|
|
86
|
+
* @description Renders this item with reduced visual emphasis and removes pointer interaction.
|
|
87
|
+
* @default false
|
|
88
|
+
*/
|
|
89
|
+
this.disabled = input(false, /* @ts-ignore */
|
|
90
|
+
...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
91
|
+
/**
|
|
92
|
+
* @description Reflects whether the parent breadcrumb is disabled. Controls compound disabled styling when only individual items are disabled.
|
|
93
|
+
* @default false
|
|
94
|
+
*/
|
|
95
|
+
this.listDisabled = input(false, /* @ts-ignore */
|
|
96
|
+
...(ngDevMode ? [{ debugName: "listDisabled" }] : /* istanbul ignore next */ []));
|
|
97
|
+
/**
|
|
98
|
+
* @description Additional CSS classes merged onto the breadcrumb item via `tailwind-merge`.
|
|
99
|
+
* @default ""
|
|
100
|
+
*/
|
|
101
|
+
this.userClass = input("", { ...(ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {}), alias: "class" });
|
|
102
|
+
}
|
|
103
|
+
#themeService;
|
|
104
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: BreadcrumbItemDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
105
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: BreadcrumbItemDirective, isStandalone: true, selector: "button[monaBreadcrumbItem]", inputs: { disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, listDisabled: { classPropertyName: "listDisabled", publicName: "listDisabled", isSignal: true, isRequired: false, transformFunction: null }, userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "baseClass()", "disabled": "disabled()" } }, ngImport: i0 }); }
|
|
106
|
+
}
|
|
107
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: BreadcrumbItemDirective, decorators: [{
|
|
108
|
+
type: Directive,
|
|
109
|
+
args: [{
|
|
110
|
+
selector: "button[monaBreadcrumbItem]",
|
|
111
|
+
host: {
|
|
112
|
+
"[class]": "baseClass()",
|
|
113
|
+
"[disabled]": "disabled()"
|
|
114
|
+
}
|
|
115
|
+
}]
|
|
116
|
+
}], propDecorators: { disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], listDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "listDisabled", required: false }] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
117
|
+
|
|
118
|
+
class BreadcrumbSeparatorTemplateDirective {
|
|
119
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: BreadcrumbSeparatorTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
120
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: BreadcrumbSeparatorTemplateDirective, isStandalone: true, selector: "ng-template[monaBreadcrumbSeparatorTemplate]", ngImport: i0 }); }
|
|
121
|
+
}
|
|
122
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: BreadcrumbSeparatorTemplateDirective, decorators: [{
|
|
123
|
+
type: Directive,
|
|
124
|
+
args: [{
|
|
125
|
+
selector: "ng-template[monaBreadcrumbSeparatorTemplate]"
|
|
126
|
+
}]
|
|
127
|
+
}] });
|
|
128
|
+
|
|
129
|
+
class BreadcrumbItemComponent {
|
|
130
|
+
constructor() {
|
|
131
|
+
/**
|
|
132
|
+
* @description Renders this item with reduced visual emphasis and removes pointer interaction.
|
|
133
|
+
* Has no visual effect when the parent breadcrumb is also disabled.
|
|
134
|
+
* @default false
|
|
135
|
+
*/
|
|
136
|
+
this.disabled = input(false, /* @ts-ignore */
|
|
137
|
+
...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
138
|
+
/**
|
|
139
|
+
* @description Emitted when the item is clicked or activated via keyboard.
|
|
140
|
+
* Not emitted when this is the last (current-page) item or when the item is disabled.
|
|
141
|
+
*/
|
|
142
|
+
this.itemClick = output();
|
|
143
|
+
this.templateRef = viewChild.required(TemplateRef, /* @ts-ignore */
|
|
144
|
+
...(ngDevMode ? [{ debugName: "templateRef" }] : /* istanbul ignore next */ []));
|
|
145
|
+
}
|
|
146
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: BreadcrumbItemComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
147
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.0.6", type: BreadcrumbItemComponent, isStandalone: true, selector: "mona-breadcrumb-item", inputs: { disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { itemClick: "itemClick" }, viewQueries: [{ propertyName: "templateRef", first: true, predicate: TemplateRef, descendants: true, isSignal: true }], ngImport: i0, template: "<ng-template>\r\n <ng-content></ng-content>\r\n</ng-template>\r\n" }); }
|
|
148
|
+
}
|
|
149
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: BreadcrumbItemComponent, decorators: [{
|
|
150
|
+
type: Component,
|
|
151
|
+
args: [{ selector: "mona-breadcrumb-item", template: "<ng-template>\r\n <ng-content></ng-content>\r\n</ng-template>\r\n" }]
|
|
152
|
+
}], propDecorators: { disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], itemClick: [{ type: i0.Output, args: ["itemClick"] }], templateRef: [{ type: i0.ViewChild, args: [i0.forwardRef(() => TemplateRef), { isSignal: true }] }] } });
|
|
153
|
+
|
|
154
|
+
class BreadcrumbComponent {
|
|
155
|
+
constructor() {
|
|
156
|
+
this.#themeService = inject(ThemeService);
|
|
157
|
+
this.itemComponents = contentChildren(BreadcrumbItemComponent, /* @ts-ignore */
|
|
158
|
+
...(ngDevMode ? [{ debugName: "itemComponents" }] : /* istanbul ignore next */ []));
|
|
159
|
+
this.currentItemClass = computed(() => {
|
|
160
|
+
const theme = this.#themeService.theme();
|
|
161
|
+
return breadcrumbCurrentItemThemeVariants(theme)();
|
|
162
|
+
}, /* @ts-ignore */
|
|
163
|
+
...(ngDevMode ? [{ debugName: "currentItemClass" }] : /* istanbul ignore next */ []));
|
|
164
|
+
this.listClass = computed(() => {
|
|
165
|
+
const theme = this.#themeService.theme();
|
|
166
|
+
const disabled = this.disabled();
|
|
167
|
+
const userClass = this.userClass();
|
|
168
|
+
const variantClass = breadcrumbListThemeVariants(theme)({ disabled });
|
|
169
|
+
return twMerge(variantClass, userClass);
|
|
170
|
+
}, /* @ts-ignore */
|
|
171
|
+
...(ngDevMode ? [{ debugName: "listClass" }] : /* istanbul ignore next */ []));
|
|
172
|
+
this.separatorTemplate = contentChild(BreadcrumbSeparatorTemplateDirective, { ...(ngDevMode ? { debugName: "separatorTemplate" } : /* istanbul ignore next */ {}), read: TemplateRef });
|
|
173
|
+
/**
|
|
174
|
+
* @description Accessible name for the breadcrumb navigation landmark.
|
|
175
|
+
* Override when multiple breadcrumb components appear on the same page.
|
|
176
|
+
* @default "Breadcrumb"
|
|
177
|
+
*/
|
|
178
|
+
this.ariaLabel = input("Breadcrumb", { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: "aria-label" });
|
|
179
|
+
/**
|
|
180
|
+
* @description Renders the entire breadcrumb with reduced visual emphasis and removes pointer interaction from all items.
|
|
181
|
+
* @default false
|
|
182
|
+
*/
|
|
183
|
+
this.disabled = input(false, /* @ts-ignore */
|
|
184
|
+
...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
185
|
+
/**
|
|
186
|
+
* @description Additional CSS classes merged onto the breadcrumb list via `tailwind-merge`.
|
|
187
|
+
* @default ""
|
|
188
|
+
*/
|
|
189
|
+
this.userClass = input("", { ...(ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {}), alias: "class" });
|
|
190
|
+
}
|
|
191
|
+
#themeService;
|
|
192
|
+
onItemClick(item) {
|
|
193
|
+
if (this.disabled() || item.disabled()) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
item.itemClick.emit();
|
|
197
|
+
}
|
|
198
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: BreadcrumbComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
199
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: BreadcrumbComponent, isStandalone: true, selector: "mona-breadcrumb", inputs: { ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "navigation" }, properties: { "attr.aria-label": "ariaLabel()" } }, queries: [{ propertyName: "itemComponents", predicate: BreadcrumbItemComponent, isSignal: true }, { propertyName: "separatorTemplate", first: true, predicate: BreadcrumbSeparatorTemplateDirective, descendants: true, read: TemplateRef, isSignal: true }], ngImport: i0, template: "<ol role=\"list\" [class]=\"listClass()\">\r\n @for (item of itemComponents(); track item) {\r\n <li>\r\n @if ($last) {\r\n <span aria-current=\"page\" [class]=\"currentItemClass()\">\r\n <ng-container [ngTemplateOutlet]=\"item.templateRef()\"></ng-container>\r\n </span>\r\n } @else {\r\n <button\r\n type=\"button\"\r\n monaBreadcrumbItem\r\n [disabled]=\"disabled() || item.disabled()\"\r\n (click)=\"onItemClick(item)\">\r\n <ng-container [ngTemplateOutlet]=\"item.templateRef()\"></ng-container>\r\n </button>\r\n }\r\n </li>\r\n\r\n @if (!$last) {\r\n <li aria-hidden=\"true\" role=\"presentation\">\r\n @if (separatorTemplate()) {\r\n <ng-container\r\n [ngTemplateOutlet]=\"separatorTemplate()\"\r\n [ngTemplateOutletContext]=\"{ $implicit: $index }\"></ng-container>\r\n } @else {\r\n <svg lucideChevronRight [size]=\"18\"></svg>\r\n }\r\n </li>\r\n }\r\n }\r\n</ol>\r\n", dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: BreadcrumbItemDirective, selector: "button[monaBreadcrumbItem]", inputs: ["disabled", "listDisabled", "class"] }, { kind: "component", type: LucideChevronRight, selector: "svg[lucideChevronRight]" }] }); }
|
|
200
|
+
}
|
|
201
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: BreadcrumbComponent, decorators: [{
|
|
202
|
+
type: Component,
|
|
203
|
+
args: [{ selector: "mona-breadcrumb", imports: [NgTemplateOutlet, BreadcrumbItemDirective, LucideChevronRight], host: {
|
|
204
|
+
role: "navigation",
|
|
205
|
+
"[attr.aria-label]": "ariaLabel()"
|
|
206
|
+
}, template: "<ol role=\"list\" [class]=\"listClass()\">\r\n @for (item of itemComponents(); track item) {\r\n <li>\r\n @if ($last) {\r\n <span aria-current=\"page\" [class]=\"currentItemClass()\">\r\n <ng-container [ngTemplateOutlet]=\"item.templateRef()\"></ng-container>\r\n </span>\r\n } @else {\r\n <button\r\n type=\"button\"\r\n monaBreadcrumbItem\r\n [disabled]=\"disabled() || item.disabled()\"\r\n (click)=\"onItemClick(item)\">\r\n <ng-container [ngTemplateOutlet]=\"item.templateRef()\"></ng-container>\r\n </button>\r\n }\r\n </li>\r\n\r\n @if (!$last) {\r\n <li aria-hidden=\"true\" role=\"presentation\">\r\n @if (separatorTemplate()) {\r\n <ng-container\r\n [ngTemplateOutlet]=\"separatorTemplate()\"\r\n [ngTemplateOutletContext]=\"{ $implicit: $index }\"></ng-container>\r\n } @else {\r\n <svg lucideChevronRight [size]=\"18\"></svg>\r\n }\r\n </li>\r\n }\r\n }\r\n</ol>\r\n" }]
|
|
207
|
+
}], propDecorators: { itemComponents: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => BreadcrumbItemComponent), { isSignal: true }] }], separatorTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => BreadcrumbSeparatorTemplateDirective), { ...{
|
|
208
|
+
read: TemplateRef
|
|
209
|
+
}, isSignal: true }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-label", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
210
|
+
|
|
211
|
+
/*
|
|
212
|
+
* Public API Surface of @nanahoshi/mona-ui/breadcrumb
|
|
213
|
+
*/
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Generated bundle index. Do not edit.
|
|
217
|
+
*/
|
|
218
|
+
|
|
219
|
+
export { BreadcrumbComponent, BreadcrumbItemComponent, BreadcrumbSeparatorTemplateDirective };
|
|
220
|
+
//# sourceMappingURL=nanahoshi-mona-ui-breadcrumb.mjs.map
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { inject, DestroyRef, computed, contentChildren, input, model, effect, untracked, afterNextRender, Component } from '@angular/core';
|
|
3
|
+
import { outputFromObservable, takeUntilDestroyed, toObservable } from '@angular/core/rxjs-interop';
|
|
4
|
+
import { ButtonService, ButtonDirective } from '@nanahoshi/mona-ui/button';
|
|
5
|
+
import { ThemeService } from '@nanahoshi/mona-ui/theme';
|
|
6
|
+
import { map, pairwise } from 'rxjs';
|
|
7
|
+
import { twMerge } from 'tailwind-merge';
|
|
8
|
+
import { cva } from 'class-variance-authority';
|
|
9
|
+
|
|
10
|
+
const buttonGroupVariants = cva(`
|
|
11
|
+
inline-flex items-center justify-center
|
|
12
|
+
border border-border shadow-xs
|
|
13
|
+
[&>button]:border-0
|
|
14
|
+
[&>button]:focus-visible:ring-2
|
|
15
|
+
[&>button]:focus-visible:z-10
|
|
16
|
+
[&>button]:rounded-none
|
|
17
|
+
[&>button]:shadow-none
|
|
18
|
+
`, {
|
|
19
|
+
variants: {
|
|
20
|
+
look: {
|
|
21
|
+
default: "",
|
|
22
|
+
error: "",
|
|
23
|
+
ghost: "border-transparent",
|
|
24
|
+
info: "",
|
|
25
|
+
outline: "[&>button:not(:last-child)]:border-r",
|
|
26
|
+
primary: "",
|
|
27
|
+
secondary: "",
|
|
28
|
+
success: "",
|
|
29
|
+
warning: ""
|
|
30
|
+
},
|
|
31
|
+
rounded: {
|
|
32
|
+
full: `
|
|
33
|
+
rounded-full
|
|
34
|
+
[&>button]:first:rounded-ss-full [&>button]:first:rounded-es-full
|
|
35
|
+
[&>button]:last:rounded-se-full [&>button]:last:rounded-ee-full
|
|
36
|
+
`,
|
|
37
|
+
large: `
|
|
38
|
+
rounded-lg
|
|
39
|
+
[&>button]:first:rounded-ss-lg [&>button]:first:rounded-es-lg
|
|
40
|
+
[&>button]:last:rounded-se-lg [&>button]:last:rounded-ee-lg
|
|
41
|
+
`,
|
|
42
|
+
medium: `
|
|
43
|
+
rounded-md
|
|
44
|
+
[&>button]:first:rounded-ss-md [&>button]:first:rounded-es-md
|
|
45
|
+
[&>button]:last:rounded-se-md [&>button]:last:rounded-ee-md
|
|
46
|
+
`,
|
|
47
|
+
none: `
|
|
48
|
+
rounded-none
|
|
49
|
+
`,
|
|
50
|
+
small: `
|
|
51
|
+
rounded-sm
|
|
52
|
+
[&>button]:first:rounded-ss-sm [&>button]:first:rounded-es-sm
|
|
53
|
+
[&>button]:last:rounded-se-sm [&>button]:last:rounded-ee-sm
|
|
54
|
+
`
|
|
55
|
+
},
|
|
56
|
+
size: {
|
|
57
|
+
large: ``,
|
|
58
|
+
medium: "",
|
|
59
|
+
small: ``
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
defaultVariants: {
|
|
63
|
+
look: "default",
|
|
64
|
+
size: "medium"
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const buttonGroupThemeVariants = (theme) => {
|
|
69
|
+
switch (theme) {
|
|
70
|
+
case "mona":
|
|
71
|
+
return buttonGroupVariants;
|
|
72
|
+
default:
|
|
73
|
+
return buttonGroupVariants;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
class ButtonGroupComponent {
|
|
78
|
+
#buttonService;
|
|
79
|
+
#destroyRef;
|
|
80
|
+
#themeService;
|
|
81
|
+
constructor() {
|
|
82
|
+
this.#buttonService = inject(ButtonService, { self: true });
|
|
83
|
+
this.#destroyRef = inject(DestroyRef);
|
|
84
|
+
this.#themeService = inject(ThemeService);
|
|
85
|
+
this.baseClass = computed(() => {
|
|
86
|
+
const theme = this.#themeService.theme();
|
|
87
|
+
const look = this.look();
|
|
88
|
+
const rounded = this.rounded();
|
|
89
|
+
const size = this.size();
|
|
90
|
+
const variantClasses = buttonGroupThemeVariants(theme)({ look, rounded, size });
|
|
91
|
+
const userClass = this.userClass();
|
|
92
|
+
return twMerge(variantClasses, userClass);
|
|
93
|
+
}, /* @ts-ignore */
|
|
94
|
+
...(ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []));
|
|
95
|
+
this.buttons = contentChildren(ButtonDirective, /* @ts-ignore */
|
|
96
|
+
...(ngDevMode ? [{ debugName: "buttons" }] : /* istanbul ignore next */ []));
|
|
97
|
+
/**
|
|
98
|
+
* @description When `false` and `selection` is `"single"`, at least one button must remain selected;
|
|
99
|
+
* the active button cannot be deselected. Has no effect in `"multiple"` mode.
|
|
100
|
+
* @default true
|
|
101
|
+
*/
|
|
102
|
+
this.allowEmpty = input(true, /* @ts-ignore */
|
|
103
|
+
...(ngDevMode ? [{ debugName: "allowEmpty" }] : /* istanbul ignore next */ []));
|
|
104
|
+
/**
|
|
105
|
+
* @description Accessible name for the host element. Override when multiple button groups appear on the same page
|
|
106
|
+
* so screen reader users can distinguish them.
|
|
107
|
+
* @default "Button group"
|
|
108
|
+
*/
|
|
109
|
+
this.ariaLabel = input("Button group", { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: "aria-label" });
|
|
110
|
+
/**
|
|
111
|
+
* @description Emitted when any child button in the group is clicked.
|
|
112
|
+
* Use `[(selected)]` on child buttons to observe the resulting selection state.
|
|
113
|
+
*/
|
|
114
|
+
this.buttonClick = outputFromObservable(this.#buttonService.buttonClick$.pipe(map(() => undefined), takeUntilDestroyed(this.#destroyRef)));
|
|
115
|
+
/**
|
|
116
|
+
* @description Renders all child buttons with reduced visual emphasis and removes pointer interaction.
|
|
117
|
+
* @default false
|
|
118
|
+
*/
|
|
119
|
+
this.disabled = model(false, /* @ts-ignore */
|
|
120
|
+
...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
121
|
+
/**
|
|
122
|
+
* @description Visual style variant propagated to all child buttons.
|
|
123
|
+
* Also controls container-level divider and border behavior.
|
|
124
|
+
* @default "outline"
|
|
125
|
+
*/
|
|
126
|
+
this.look = input("outline", /* @ts-ignore */
|
|
127
|
+
...(ngDevMode ? [{ debugName: "look" }] : /* istanbul ignore next */ []));
|
|
128
|
+
/**
|
|
129
|
+
* @description Border-radius preset applied to the container and the outer corners of the first and last child button.
|
|
130
|
+
* @default "medium"
|
|
131
|
+
*/
|
|
132
|
+
this.rounded = input("medium", /* @ts-ignore */
|
|
133
|
+
...(ngDevMode ? [{ debugName: "rounded" }] : /* istanbul ignore next */ []));
|
|
134
|
+
/**
|
|
135
|
+
* @description Two-way bindable. Controls whether child buttons behave as a radio group (`"single"`)
|
|
136
|
+
* or toggle independently (`"multiple"`).
|
|
137
|
+
* @default "multiple"
|
|
138
|
+
*/
|
|
139
|
+
this.selection = model("multiple", /* @ts-ignore */
|
|
140
|
+
...(ngDevMode ? [{ debugName: "selection" }] : /* istanbul ignore next */ []));
|
|
141
|
+
/**
|
|
142
|
+
* @description Size preset propagated to all child buttons, overriding their individual `size` inputs.
|
|
143
|
+
* @default "medium"
|
|
144
|
+
*/
|
|
145
|
+
this.size = input("medium", /* @ts-ignore */
|
|
146
|
+
...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
|
|
147
|
+
/**
|
|
148
|
+
* @description Additional CSS classes merged onto the host element via `tailwind-merge`.
|
|
149
|
+
* @default ""
|
|
150
|
+
*/
|
|
151
|
+
this.userClass = input("", { ...(ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {}), alias: "class" });
|
|
152
|
+
effect(() => {
|
|
153
|
+
const disabled = this.disabled();
|
|
154
|
+
untracked(() => this.#buttonService.groupDisabled.set(disabled));
|
|
155
|
+
});
|
|
156
|
+
effect(() => {
|
|
157
|
+
const look = this.look();
|
|
158
|
+
untracked(() => this.#buttonService.groupLook.set(look));
|
|
159
|
+
});
|
|
160
|
+
effect(() => {
|
|
161
|
+
const rounded = this.rounded();
|
|
162
|
+
untracked(() => this.#buttonService.groupRounded.set(rounded));
|
|
163
|
+
});
|
|
164
|
+
effect(() => {
|
|
165
|
+
const size = this.size();
|
|
166
|
+
untracked(() => this.#buttonService.groupSize.set(size));
|
|
167
|
+
});
|
|
168
|
+
toObservable(this.selection)
|
|
169
|
+
.pipe(pairwise(), takeUntilDestroyed(this.#destroyRef))
|
|
170
|
+
.subscribe(([prev, curr]) => {
|
|
171
|
+
if (prev === "multiple" && curr === "single") {
|
|
172
|
+
const selected = this.buttons().filter(b => b.selected());
|
|
173
|
+
selected.slice(1).forEach(b => {
|
|
174
|
+
this.#buttonService.buttonSelect$.next([b, false]);
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
afterNextRender({
|
|
179
|
+
read: () => this.setSubscriptions()
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
setSubscriptions() {
|
|
183
|
+
this.#buttonService.buttonClick$
|
|
184
|
+
.pipe(takeUntilDestroyed(this.#destroyRef))
|
|
185
|
+
.subscribe(([button, wasSelected]) => {
|
|
186
|
+
if (this.selection() === "single") {
|
|
187
|
+
if (wasSelected && !this.allowEmpty()) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
this.buttons().forEach(b => {
|
|
191
|
+
if (b.selected()) {
|
|
192
|
+
this.#buttonService.buttonSelect$.next([b, false]);
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
if (!wasSelected) {
|
|
196
|
+
this.#buttonService.buttonSelect$.next([button, true]);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
this.#buttonService.buttonSelect$.next([button, !wasSelected]);
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ButtonGroupComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
205
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.0.6", type: ButtonGroupComponent, isStandalone: true, selector: "mona-button-group", inputs: { allowEmpty: { classPropertyName: "allowEmpty", publicName: "allowEmpty", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, look: { classPropertyName: "look", publicName: "look", isSignal: true, isRequired: false, transformFunction: null }, rounded: { classPropertyName: "rounded", publicName: "rounded", isSignal: true, isRequired: false, transformFunction: null }, selection: { classPropertyName: "selection", publicName: "selection", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { buttonClick: "buttonClick", disabled: "disabledChange", selection: "selectionChange" }, host: { attributes: { "role": "group" }, properties: { "attr.aria-label": "ariaLabel()", "class": "baseClass()" } }, providers: [ButtonService], queries: [{ propertyName: "buttons", predicate: ButtonDirective, isSignal: true }], ngImport: i0, template: "<ng-content select=\"[monaButton]\"></ng-content>\n" }); }
|
|
206
|
+
}
|
|
207
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ButtonGroupComponent, decorators: [{
|
|
208
|
+
type: Component,
|
|
209
|
+
args: [{ selector: "mona-button-group", providers: [ButtonService], host: {
|
|
210
|
+
"[attr.aria-label]": "ariaLabel()",
|
|
211
|
+
"[class]": "baseClass()",
|
|
212
|
+
role: "group"
|
|
213
|
+
}, template: "<ng-content select=\"[monaButton]\"></ng-content>\n" }]
|
|
214
|
+
}], ctorParameters: () => [], propDecorators: { buttons: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => ButtonDirective), { isSignal: true }] }], allowEmpty: [{ type: i0.Input, args: [{ isSignal: true, alias: "allowEmpty", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-label", required: false }] }], buttonClick: [{ type: i0.Output, args: ["buttonClick"] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }, { type: i0.Output, args: ["disabledChange"] }], look: [{ type: i0.Input, args: [{ isSignal: true, alias: "look", required: false }] }], rounded: [{ type: i0.Input, args: [{ isSignal: true, alias: "rounded", required: false }] }], selection: [{ type: i0.Input, args: [{ isSignal: true, alias: "selection", required: false }] }, { type: i0.Output, args: ["selectionChange"] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
215
|
+
|
|
216
|
+
/*
|
|
217
|
+
* Public API Surface of @nanahoshi/mona-ui/button-group
|
|
218
|
+
*/
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Generated bundle index. Do not edit.
|
|
222
|
+
*/
|
|
223
|
+
|
|
224
|
+
export { ButtonGroupComponent };
|
|
225
|
+
//# sourceMappingURL=nanahoshi-mona-ui-button-group.mjs.map
|