@nanahoshi/mona-ui 0.11.2 → 0.11.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.
@@ -8,26 +8,46 @@ const segmentedContainerThemeVariants = cva(`
8
8
  inline-flex items-center gap-0.5
9
9
  ${themeControlSurfaceClasses}
10
10
  border border-input-border
11
- rounded-lg
12
11
  p-1
13
12
  data-[invalid='true']:border-error
14
13
  data-[invalid='true']:ring-2 data-[invalid='true']:ring-error/35
15
14
  transition-colors duration-(--mona-motion-fast)
16
- `);
15
+ `, {
16
+ variants: {
17
+ rounded: {
18
+ none: "rounded-none",
19
+ small: "rounded-sm",
20
+ medium: "rounded-md",
21
+ large: "rounded-lg",
22
+ full: "rounded-full"
23
+ }
24
+ },
25
+ defaultVariants: {
26
+ rounded: "medium"
27
+ }
28
+ });
17
29
  const segmentedOptionThemeVariants = cva(`
18
30
  relative flex flex-1 cursor-pointer items-center justify-center gap-1
19
31
  whitespace-nowrap
20
- rounded-md
21
32
  transition-colors duration-(--mona-motion-fast)
22
33
  data-[disabled='true']:pointer-events-none
23
34
  data-[disabled='true']:cursor-not-allowed
35
+ data-[disabled='true']:opacity-50
24
36
  data-[disabled='true']:text-disabled-foreground
25
37
  data-[selected='true']:bg-primary data-[selected='true']:text-primary-foreground
26
38
  data-[selected='true']:shadow-sm data-[selected='true']:ring-1 data-[selected='true']:ring-selected-border
27
39
  data-[selected='false']:text-muted-foreground
28
40
  data-[selected='false']:hover:bg-hover data-[selected='false']:hover:text-foreground
41
+ data-[disabled='true']:data-[selected='false']:text-disabled-foreground
29
42
  `, {
30
43
  variants: {
44
+ rounded: {
45
+ none: "rounded-none",
46
+ small: "rounded-xs",
47
+ medium: "rounded-sm",
48
+ large: "rounded-md",
49
+ full: "rounded-full"
50
+ },
31
51
  size: {
32
52
  small: "h-6 px-1.5 text-sm",
33
53
  medium: "h-8 px-2.5 text-sm",
@@ -35,6 +55,7 @@ const segmentedOptionThemeVariants = cva(`
35
55
  }
36
56
  },
37
57
  defaultVariants: {
58
+ rounded: "medium",
38
59
  size: "medium"
39
60
  }
40
61
  });
@@ -48,7 +69,7 @@ const segmentedInputThemeVariants = cva(`
48
69
  class SegmentedComponent {
49
70
  constructor() {
50
71
  this.containerClasses = computed(() => {
51
- const classes = segmentedContainerThemeVariants();
72
+ const classes = segmentedContainerThemeVariants({ rounded: this.rounded() });
52
73
  return twMerge(classes, this.userClass());
53
74
  }, /* @ts-ignore */
54
75
  ...(ngDevMode ? [{ debugName: "containerClasses" }] : /* istanbul ignore next */ []));
@@ -58,8 +79,9 @@ class SegmentedComponent {
58
79
  this.invalidState = computed(() => this.touched() && this.invalid(), /* @ts-ignore */
59
80
  ...(ngDevMode ? [{ debugName: "invalidState" }] : /* istanbul ignore next */ []));
60
81
  this.optionClasses = computed(() => {
82
+ const rounded = this.rounded();
61
83
  const size = this.size();
62
- return segmentedOptionThemeVariants({ size });
84
+ return segmentedOptionThemeVariants({ rounded, size });
63
85
  }, /* @ts-ignore */
64
86
  ...(ngDevMode ? [{ debugName: "optionClasses" }] : /* istanbul ignore next */ []));
65
87
  /**
@@ -90,6 +112,12 @@ class SegmentedComponent {
90
112
  */
91
113
  this.options = input.required(/* @ts-ignore */
92
114
  ...(ngDevMode ? [{ debugName: "options" }] : /* istanbul ignore next */ []));
115
+ /**
116
+ * @description Border-radius preset applied to the segmented container and its options.
117
+ * @default "large"
118
+ */
119
+ this.rounded = input("medium", /* @ts-ignore */
120
+ ...(ngDevMode ? [{ debugName: "rounded" }] : /* istanbul ignore next */ []));
93
121
  /**
94
122
  * @description Size preset controlling the height, horizontal padding, text size, and spacing of each option.
95
123
  * @default "medium"
@@ -131,7 +159,7 @@ class SegmentedComponent {
131
159
  this.touch.emit();
132
160
  }
133
161
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SegmentedComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
134
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: SegmentedComponent, isStandalone: true, selector: "mona-segmented", inputs: { ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null }, ariaLabelledBy: { classPropertyName: "ariaLabelledBy", publicName: "aria-labelledby", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: true, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, touched: { classPropertyName: "touched", publicName: "touched", isSignal: true, isRequired: false, transformFunction: null }, userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { touch: "touch", value: "valueChange" }, host: { properties: { "attr.aria-disabled": "disabled() || undefined", "attr.aria-invalid": "invalidState() ? 'true' : null", "attr.aria-label": "ariaLabel()", "attr.aria-labelledby": "ariaLabelledBy()", "attr.data-disabled": "disabled()", "attr.data-invalid": "invalidState() || null", "attr.role": "'radiogroup'", "class": "containerClasses()" } }, ngImport: i0, template: "@for (option of options(); track option.value) {\n @let selected = option.value === value();\n @let optionDisabled = disabled() || option.disabled;\n\n <label [class]=\"optionClasses()\" [attr.data-selected]=\"selected\" [attr.data-disabled]=\"optionDisabled\">\n <input\n type=\"radio\"\n [name]=\"groupName\"\n [value]=\"option.value\"\n [checked]=\"selected\"\n [disabled]=\"optionDisabled\"\n [class]=\"inputClasses()\"\n (change)=\"onOptionChange(option)\"\n (blur)=\"onOptionBlur()\" />\n\n <span\n class=\"pointer-events-none flex flex-1 items-center justify-center gap-1 rounded-md peer-focus-visible:ring-2 peer-focus-visible:ring-focus-indicator/35\">\n {{ option.label }}\n </span>\n </label>\n}\n" }); }
162
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: SegmentedComponent, isStandalone: true, selector: "mona-segmented", inputs: { ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null }, ariaLabelledBy: { classPropertyName: "ariaLabelledBy", publicName: "aria-labelledby", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: true, transformFunction: null }, rounded: { classPropertyName: "rounded", publicName: "rounded", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, touched: { classPropertyName: "touched", publicName: "touched", isSignal: true, isRequired: false, transformFunction: null }, userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { touch: "touch", value: "valueChange" }, host: { properties: { "attr.aria-disabled": "disabled() || undefined", "attr.aria-invalid": "invalidState() ? 'true' : null", "attr.aria-label": "ariaLabel()", "attr.aria-labelledby": "ariaLabelledBy()", "attr.data-disabled": "disabled()", "attr.data-invalid": "invalidState() || null", "attr.role": "'radiogroup'", "class": "containerClasses()" } }, ngImport: i0, template: "@for (option of options(); track option.value) {\n @let selected = option.value === value();\n @let optionDisabled = disabled() || option.disabled;\n\n <label [class]=\"optionClasses()\" [attr.data-selected]=\"selected\" [attr.data-disabled]=\"optionDisabled\">\n <input\n type=\"radio\"\n [name]=\"groupName\"\n [value]=\"option.value\"\n [checked]=\"selected\"\n [disabled]=\"optionDisabled\"\n [class]=\"inputClasses()\"\n (change)=\"onOptionChange(option)\"\n (blur)=\"onOptionBlur()\" />\n\n <span\n class=\"pointer-events-none flex flex-1 items-center justify-center gap-1\n [border-radius:inherit]\n peer-focus-visible:ring-2\n peer-focus-visible:ring-focus-indicator/35\">\n {{ option.label }}\n </span>\n </label>\n}\n" }); }
135
163
  }
136
164
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SegmentedComponent, decorators: [{
137
165
  type: Component,
@@ -144,8 +172,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
144
172
  "[attr.data-invalid]": "invalidState() || null",
145
173
  "[attr.role]": "'radiogroup'",
146
174
  "[class]": "containerClasses()"
147
- }, template: "@for (option of options(); track option.value) {\n @let selected = option.value === value();\n @let optionDisabled = disabled() || option.disabled;\n\n <label [class]=\"optionClasses()\" [attr.data-selected]=\"selected\" [attr.data-disabled]=\"optionDisabled\">\n <input\n type=\"radio\"\n [name]=\"groupName\"\n [value]=\"option.value\"\n [checked]=\"selected\"\n [disabled]=\"optionDisabled\"\n [class]=\"inputClasses()\"\n (change)=\"onOptionChange(option)\"\n (blur)=\"onOptionBlur()\" />\n\n <span\n class=\"pointer-events-none flex flex-1 items-center justify-center gap-1 rounded-md peer-focus-visible:ring-2 peer-focus-visible:ring-focus-indicator/35\">\n {{ option.label }}\n </span>\n </label>\n}\n" }]
148
- }], propDecorators: { ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-label", required: false }] }], ariaLabelledBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-labelledby", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }], options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: true }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], touch: [{ type: i0.Output, args: ["touch"] }], touched: [{ type: i0.Input, args: [{ isSignal: true, alias: "touched", required: false }] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }] } });
175
+ }, template: "@for (option of options(); track option.value) {\n @let selected = option.value === value();\n @let optionDisabled = disabled() || option.disabled;\n\n <label [class]=\"optionClasses()\" [attr.data-selected]=\"selected\" [attr.data-disabled]=\"optionDisabled\">\n <input\n type=\"radio\"\n [name]=\"groupName\"\n [value]=\"option.value\"\n [checked]=\"selected\"\n [disabled]=\"optionDisabled\"\n [class]=\"inputClasses()\"\n (change)=\"onOptionChange(option)\"\n (blur)=\"onOptionBlur()\" />\n\n <span\n class=\"pointer-events-none flex flex-1 items-center justify-center gap-1\n [border-radius:inherit]\n peer-focus-visible:ring-2\n peer-focus-visible:ring-focus-indicator/35\">\n {{ option.label }}\n </span>\n </label>\n}\n" }]
176
+ }], propDecorators: { ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-label", required: false }] }], ariaLabelledBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-labelledby", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }], options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: true }] }], rounded: [{ type: i0.Input, args: [{ isSignal: true, alias: "rounded", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], touch: [{ type: i0.Output, args: ["touch"] }], touched: [{ type: i0.Input, args: [{ isSignal: true, alias: "touched", required: false }] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }] } });
149
177
 
150
178
  /*
151
179
  * Public API Surface of @nanahoshi/mona-ui/segmented
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nanahoshi/mona-ui",
3
- "version": "0.11.2",
3
+ "version": "0.11.3",
4
4
  "description": "A very light Angular UI framework",
5
5
  "author": "Nanahoshi",
6
6
  "repository": {
@@ -12,8 +12,11 @@ interface SegmentedOption<T extends SegmentedValue = SegmentedValue> {
12
12
  readonly disabled?: boolean;
13
13
  }
14
14
 
15
- declare const segmentedContainerThemeVariants: (props?: class_variance_authority_types.ClassProp | undefined) => string;
15
+ declare const segmentedContainerThemeVariants: (props?: ({
16
+ rounded?: "none" | "small" | "medium" | "large" | "full" | null | undefined;
17
+ } & class_variance_authority_types.ClassProp) | undefined) => string;
16
18
  declare const segmentedOptionThemeVariants: (props?: ({
19
+ rounded?: "none" | "small" | "medium" | "large" | "full" | null | undefined;
17
20
  size?: "small" | "medium" | "large" | null | undefined;
18
21
  } & class_variance_authority_types.ClassProp) | undefined) => string;
19
22
  type SegmentedContainerVariantProps = VariantProps<typeof segmentedContainerThemeVariants>;
@@ -54,6 +57,11 @@ declare class SegmentedComponent<T extends SegmentedValue = SegmentedValue> impl
54
57
  * @description The list of selectable options. Exactly one option is selected at a time.
55
58
  */
56
59
  readonly options: _angular_core.InputSignal<readonly SegmentedOption<T>[]>;
60
+ /**
61
+ * @description Border-radius preset applied to the segmented container and its options.
62
+ * @default "large"
63
+ */
64
+ readonly rounded: _angular_core.InputSignal<"none" | "small" | "medium" | "large" | "full" | null | undefined>;
57
65
  /**
58
66
  * @description Size preset controlling the height, horizontal padding, text size, and spacing of each option.
59
67
  * @default "medium"
@@ -83,7 +91,7 @@ declare class SegmentedComponent<T extends SegmentedValue = SegmentedValue> impl
83
91
  protected onOptionBlur(): void;
84
92
  protected onOptionChange(option: SegmentedOption<T>): void;
85
93
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<SegmentedComponent<any>, never>;
86
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<SegmentedComponent<any>, "mona-segmented", never, { "ariaLabel": { "alias": "aria-label"; "required": false; "isSignal": true; }; "ariaLabelledBy": { "alias": "aria-labelledby"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "invalid": { "alias": "invalid"; "required": false; "isSignal": true; }; "options": { "alias": "options"; "required": true; "isSignal": true; }; "size": { "alias": "size"; "required": false; "isSignal": true; }; "touched": { "alias": "touched"; "required": false; "isSignal": true; }; "userClass": { "alias": "class"; "required": false; "isSignal": true; }; "value": { "alias": "value"; "required": false; "isSignal": true; }; }, { "touch": "touch"; "value": "valueChange"; }, never, never, true, never>;
94
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<SegmentedComponent<any>, "mona-segmented", never, { "ariaLabel": { "alias": "aria-label"; "required": false; "isSignal": true; }; "ariaLabelledBy": { "alias": "aria-labelledby"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "invalid": { "alias": "invalid"; "required": false; "isSignal": true; }; "options": { "alias": "options"; "required": true; "isSignal": true; }; "rounded": { "alias": "rounded"; "required": false; "isSignal": true; }; "size": { "alias": "size"; "required": false; "isSignal": true; }; "touched": { "alias": "touched"; "required": false; "isSignal": true; }; "userClass": { "alias": "class"; "required": false; "isSignal": true; }; "value": { "alias": "value"; "required": false; "isSignal": true; }; }, { "touch": "touch"; "value": "valueChange"; }, never, never, true, never>;
87
95
  }
88
96
 
89
97
  export { SegmentedComponent };