@atelier-ui/angular 0.3.15 → 0.4.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 CHANGED
@@ -29,7 +29,7 @@ import { AtlButton } from '@atelier-ui/angular';
29
29
  @Component({
30
30
  standalone: true,
31
31
  imports: [AtlButton],
32
- template: ` <atl-button variant="primary" (click)="save()">Save</atl-button> `,
32
+ template: ` <button atl-button variant="primary" (click)="save()">Save</button> `,
33
33
  })
34
34
  export class MyComponent {}
35
35
  ```
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { input, computed, inject, ElementRef, DestroyRef, afterNextRender, ViewEncapsulation, ChangeDetectionStrategy, Component, model, viewChild, effect, InjectionToken, signal, output, Injector, viewChildren, Directive, Injectable, untracked, contentChildren, booleanAttribute } from '@angular/core';
2
+ import { input, computed, inject, ElementRef, afterNextRender, ViewEncapsulation, ChangeDetectionStrategy, Component, model, viewChild, effect, InjectionToken, signal, output, Injector, viewChildren, Directive, Injectable, DestroyRef, untracked, contentChildren, booleanAttribute } from '@angular/core';
3
3
  import * as i1 from '@angular/cdk/text-field';
4
4
  import { TextFieldModule } from '@angular/cdk/text-field';
5
5
  import * as i1$1 from '@angular/cdk/a11y';
@@ -13,13 +13,15 @@ import { CdkMenuTrigger, CdkMenu, CdkMenuItem } from '@angular/cdk/menu';
13
13
  import { NgTemplateOutlet } from '@angular/common';
14
14
 
15
15
  /**
16
- * Accessible button component with visual variants and sizes.
16
+ * Accessible button component with visual variants and sizes. An attribute
17
+ * component on a native `<button>`: focus, Tab order, Enter/Space activation and
18
+ * form submission are the browser's own.
17
19
  *
18
20
  * Usage:
19
21
  * ```html
20
- * <atl-button variant="primary" size="md" (click)="save()">Save</atl-button>
21
- * <atl-button variant="outline" [disabled]="true">Cancel</atl-button>
22
- * <atl-button [loading]="isSaving">Saving…</atl-button>
22
+ * <button atl-button variant="primary" size="md" (click)="save()">Save</button>
23
+ * <button atl-button variant="outline" [disabled]="true">Cancel</button>
24
+ * <button atl-button type="submit" [loading]="isSaving">Saving…</button>
23
25
  * ```
24
26
  */
25
27
  class AtlButton {
@@ -35,31 +37,16 @@ class AtlButton {
35
37
  /** Shows a loading spinner and disables interaction. */
36
38
  loading = input(false, /* @ts-ignore */
37
39
  ...(ngDevMode ? [{ debugName: "loading" }] : /* istanbul ignore next */ []));
40
+ /** Native `type` attribute of the button. */
41
+ type = input('button', /* @ts-ignore */
42
+ ...(ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []));
38
43
  isDisabled = computed(() => this.disabled() || this.loading(), /* @ts-ignore */
39
44
  ...(ngDevMode ? [{ debugName: "isDisabled" }] : /* istanbul ignore next */ []));
40
45
  hostClasses = computed(() => `variant-${this.variant()} size-${this.size()}${this.isDisabled() ? ' is-disabled' : ''}${this.loading() ? ' is-loading' : ''}`, /* @ts-ignore */
41
46
  ...(ngDevMode ? [{ debugName: "hostClasses" }] : /* istanbul ignore next */ []));
42
47
  /** @internal — host element ref for the dev-mode a11y check. */
43
48
  el = inject(ElementRef);
44
- destroyRef = inject(DestroyRef);
45
49
  constructor() {
46
- // Suppress clicks while disabled/loading. The host is a custom element, so
47
- // — unlike a native `<button disabled>` — neither the `disabled` attribute
48
- // nor `pointer-events: none` reliably blocks click dispatch (the latter only
49
- // affects pointer-driven clicks, not programmatic/keyboard ones). A real
50
- // click lands on projected content (a descendant), so a capture-phase
51
- // listener on the host intercepts it before any consumer `(click)` handler
52
- // bound on the host (which fires in the bubble phase), matching the
53
- // React/Vue native-disabled behavior.
54
- const host = this.el.nativeElement;
55
- const guard = (event) => {
56
- if (this.isDisabled()) {
57
- event.stopImmediatePropagation();
58
- event.preventDefault();
59
- }
60
- };
61
- host.addEventListener('click', guard, true);
62
- this.destroyRef.onDestroy(() => host.removeEventListener('click', guard, true));
63
50
  // Dev-mode warning when a button has no accessible name. Angular's
64
51
  // <ng-content> projection means we can't enforce this at the type
65
52
  // level (unlike the React adapter), so we check after first render.
@@ -77,7 +64,7 @@ class AtlButton {
77
64
  }
78
65
  }
79
66
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: AtlButton, deps: [], target: i0.ɵɵFactoryTarget.Component });
80
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.5", type: AtlButton, isStandalone: true, selector: "atl-button", inputs: { variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, loading: { classPropertyName: "loading", publicName: "loading", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "button" }, properties: { "class": "hostClasses()", "attr.aria-disabled": "isDisabled()", "attr.disabled": "isDisabled() ? true : null" }, classAttribute: "atl-button" }, ngImport: i0, template: `
67
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.5", type: AtlButton, isStandalone: true, selector: "button[atl-button]", inputs: { variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, loading: { classPropertyName: "loading", publicName: "loading", isSignal: true, isRequired: false, transformFunction: null }, type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "hostClasses()", "attr.type": "type()", "disabled": "isDisabled()", "attr.aria-disabled": "isDisabled() || null" }, classAttribute: "atl-button" }, ngImport: i0, template: `
81
68
  @if (loading()) {
82
69
  <span class="spinner" aria-hidden="true"></span>
83
70
  }
@@ -86,19 +73,19 @@ class AtlButton {
86
73
  }
87
74
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: AtlButton, decorators: [{
88
75
  type: Component,
89
- args: [{ selector: 'atl-button', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, template: `
76
+ args: [{ selector: 'button[atl-button]', changeDetection: ChangeDetectionStrategy.OnPush, template: `
90
77
  @if (loading()) {
91
78
  <span class="spinner" aria-hidden="true"></span>
92
79
  }
93
80
  <ng-content />
94
81
  `, encapsulation: ViewEncapsulation.None, host: {
95
82
  class: 'atl-button',
96
- role: 'button',
97
83
  '[class]': 'hostClasses()',
98
- '[attr.aria-disabled]': 'isDisabled()',
99
- '[attr.disabled]': 'isDisabled() ? true : null',
84
+ '[attr.type]': 'type()',
85
+ '[disabled]': 'isDisabled()',
86
+ '[attr.aria-disabled]': 'isDisabled() || null',
100
87
  }, styles: [".atl-button,.atl-button *{box-sizing:border-box}.atl-button{display:inline-flex;align-items:center;justify-content:center;gap:var(--ui-spacing-2);border:var(--ui-border-width) solid transparent;border-radius:var(--ui-radius-md);font-family:var(--ui-font-family);font-size:var(--ui-font-size-md);font-weight:var(--ui-font-weight-semibold);line-height:var(--ui-line-height-tight);letter-spacing:var(--ui-letter-spacing-tight);cursor:pointer;transition:background-color var(--ui-transition-fast),border-color var(--ui-transition-fast),color var(--ui-transition-fast),box-shadow var(--ui-transition-fast);white-space:nowrap;text-decoration:none;-webkit-user-select:none;user-select:none}.atl-button:focus-visible{outline:none;box-shadow:var(--ui-focus-ring)}.atl-button.variant-primary{background-color:var(--ui-color-primary);color:var(--ui-color-text-on-primary);border-color:var(--ui-color-primary)}.atl-button.variant-primary:hover:not(.is-disabled){background-color:var(--ui-color-primary-hover);border-color:var(--ui-color-primary-hover)}.atl-button.variant-primary:active:not(.is-disabled){background-color:var(--ui-color-primary-active);border-color:var(--ui-color-primary-active)}.atl-button.variant-secondary{background-color:var(--ui-color-secondary);color:var(--ui-color-text-on-secondary);border-color:var(--ui-color-secondary)}.atl-button.variant-secondary:hover:not(.is-disabled){background-color:var(--ui-color-secondary-hover);border-color:var(--ui-color-secondary-hover)}.atl-button.variant-secondary:active:not(.is-disabled){background-color:var(--ui-color-secondary-active);border-color:var(--ui-color-secondary-active)}.atl-button.variant-outline{background-color:var(--ui-color-surface-raised);color:var(--ui-color-primary);border-color:var(--ui-color-border-strong)}.atl-button.variant-outline:hover:not(.is-disabled){background-color:var(--ui-color-surface-sunken);border-color:var(--ui-color-primary)}.atl-button.variant-outline:active:not(.is-disabled){background-color:var(--ui-color-surface-sunken);border-color:var(--ui-color-primary-active)}.atl-button.variant-danger{background-color:var(--ui-color-danger);color:var(--ui-color-text-on-danger);border-color:var(--ui-color-danger);box-shadow:inset 0 0 0 1px #0000002e}.atl-button.variant-danger:hover:not(.is-disabled){background-color:var(--ui-color-danger-hover);border-color:var(--ui-color-danger-hover);box-shadow:inset 0 0 0 1px #0000002e}.atl-button.variant-danger:active:not(.is-disabled){background-color:var(--ui-color-danger-active);border-color:var(--ui-color-danger-active);box-shadow:inset 0 0 0 1px #0000002e}.atl-button.size-sm{padding:calc((var(--ui-control-height-sm) - var(--ui-line-height-tight) * var(--ui-font-size-sm)) / 2 - 1px) .875rem;font-size:var(--ui-font-size-sm);min-height:var(--ui-control-height-sm)}.atl-button.size-md{padding:calc((var(--ui-control-height-md) - var(--ui-line-height-tight) * var(--ui-font-size-md)) / 2 - 1px) 1.125rem;font-size:var(--ui-font-size-md);min-height:var(--ui-control-height-md)}.atl-button.size-lg{padding:calc((var(--ui-control-height-lg) - var(--ui-line-height-tight) * var(--ui-font-size-lg)) / 2 - 1px) 1.5rem;font-size:var(--ui-font-size-lg);min-height:var(--ui-control-height-lg)}.atl-button.is-disabled{background-color:var(--ui-color-disabled-bg);border-color:var(--ui-color-disabled-border);color:var(--ui-color-disabled-text);box-shadow:none;cursor:not-allowed;pointer-events:none}.atl-button.variant-outline.is-disabled{background-color:transparent}.atl-button>.spinner{display:inline-block;width:1em;height:1em;border:var(--ui-border-width-thick) solid currentColor;border-top-color:transparent;border-radius:var(--ui-radius-full);animation:atl-spin .7s linear infinite;flex-shrink:0}@keyframes atl-spin{to{transform:rotate(360deg)}}\n"] }]
101
- }], ctorParameters: () => [], propDecorators: { variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], loading: [{ type: i0.Input, args: [{ isSignal: true, alias: "loading", required: false }] }] } });
88
+ }], ctorParameters: () => [], propDecorators: { variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], loading: [{ type: i0.Input, args: [{ isSignal: true, alias: "loading", required: false }] }], type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: false }] }] } });
102
89
 
103
90
  /**
104
91
  * Card container component supporting elevated, outlined, and flat visual variants.
@@ -110,7 +97,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImpor
110
97
  * <atl-card-header>Card Title</atl-card-header>
111
98
  * <atl-card-content>Main content goes here.</atl-card-content>
112
99
  * <atl-card-footer>
113
- * <atl-button variant="primary">Save</atl-button>
100
+ * <button atl-button variant="primary">Save</button>
114
101
  * </atl-card-footer>
115
102
  * </atl-card>
116
103
  * ```
@@ -186,7 +173,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImpor
186
173
  * Usage:
187
174
  * ```html
188
175
  * <atl-card-footer>
189
- * <atl-button variant="primary">Save</atl-button>
176
+ * <button atl-button variant="primary">Save</button>
190
177
  * </atl-card-footer>
191
178
  * ```
192
179
  */
@@ -2473,7 +2460,7 @@ let nextId$5 = 0;
2473
2460
  * <atl-dialog-header>Dialog Title</atl-dialog-header>
2474
2461
  * <atl-dialog-content>Dialog body content.</atl-dialog-content>
2475
2462
  * <atl-dialog-footer>
2476
- * <atl-button variant="primary" (click)="isOpen = false">Confirm</atl-button>
2463
+ * <button atl-button variant="primary" (click)="isOpen = false">Confirm</button>
2477
2464
  * </atl-dialog-footer>
2478
2465
  * </atl-dialog>
2479
2466
  * ```
@@ -3176,11 +3163,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImpor
3176
3163
 
3177
3164
  /**
3178
3165
  * Trigger directive that opens an `<atl-menu>` dropdown.
3179
- * Apply to any element (typically `<atl-button>`) to wire up click + keyboard open/close.
3166
+ * Apply to any element (typically `<button atl-button>`) to wire up click + keyboard open/close.
3180
3167
  *
3181
3168
  * Usage:
3182
3169
  * ```html
3183
- * <atl-button [atlMenuTriggerFor]="myMenu">Open</atl-button>
3170
+ * <button atl-button [atlMenuTriggerFor]="myMenu">Open</button>
3184
3171
  * <ng-template #myMenu>
3185
3172
  * <atl-menu>
3186
3173
  * <atl-menu-item (triggered)="action()">Action</atl-menu-item>
@@ -3211,7 +3198,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImpor
3211
3198
  *
3212
3199
  * Usage:
3213
3200
  * ```html
3214
- * <atl-button [atlMenuTriggerFor]="actions">Actions</atl-button>
3201
+ * <button atl-button [atlMenuTriggerFor]="actions">Actions</button>
3215
3202
  * <ng-template #actions>
3216
3203
  * <atl-menu>
3217
3204
  * <atl-menu-item (triggered)="onCopy()">Copy</atl-menu-item>
@@ -3413,8 +3400,8 @@ const POSITIONS = {
3413
3400
  *
3414
3401
  * Usage:
3415
3402
  * ```html
3416
- * <atl-button atlTooltip="Save your changes">Save</atl-button>
3417
- * <atl-button atlTooltip="Copy to clipboard" atlTooltipPosition="right">Copy</atl-button>
3403
+ * <button atl-button atlTooltip="Save your changes">Save</button>
3404
+ * <button atl-button atlTooltip="Copy to clipboard" atlTooltipPosition="right">Copy</button>
3418
3405
  * ```
3419
3406
  */
3420
3407
  class AtlTooltip {
@@ -4370,12 +4357,12 @@ let nextId$2 = 0;
4370
4357
  *
4371
4358
  * Usage:
4372
4359
  * ```html
4373
- * <atl-button (click)="isOpen = true">Open</atl-button>
4360
+ * <button atl-button (click)="isOpen = true">Open</button>
4374
4361
  * <atl-drawer [(open)]="isOpen" position="right">
4375
4362
  * <atl-drawer-header>Settings</atl-drawer-header>
4376
4363
  * <atl-drawer-content>Content here.</atl-drawer-content>
4377
4364
  * <atl-drawer-footer>
4378
- * <atl-button variant="primary" (click)="isOpen = false">Save</atl-button>
4365
+ * <button atl-button variant="primary" (click)="isOpen = false">Save</button>
4379
4366
  * </atl-drawer-footer>
4380
4367
  * </atl-drawer>
4381
4368
  * ```