@ojiepermana/angular-component 22.0.27
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 +82 -0
- package/accordion/README.md +193 -0
- package/alert/README.md +180 -0
- package/alert-dialog/README.md +239 -0
- package/aspect-ratio/README.md +112 -0
- package/avatar/README.md +176 -0
- package/badge/README.md +133 -0
- package/breadcrumb/README.md +216 -0
- package/button/README.md +139 -0
- package/button-group/README.md +208 -0
- package/calendar/README.md +135 -0
- package/card/README.md +220 -0
- package/carousel/README.md +276 -0
- package/checkbox/README.md +149 -0
- package/collapsible/README.md +195 -0
- package/combobox/README.md +198 -0
- package/command/README.md +275 -0
- package/composer/README.md +235 -0
- package/context-menu/README.md +267 -0
- package/date-picker/README.md +179 -0
- package/dialog/README.md +235 -0
- package/drawer/README.md +145 -0
- package/dropdown-menu/README.md +311 -0
- package/editor/README.md +136 -0
- package/empty/README.md +183 -0
- package/fesm2022/ojiepermana-angular-component-accordion.mjs +186 -0
- package/fesm2022/ojiepermana-angular-component-accordion.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-alert-dialog.mjs +276 -0
- package/fesm2022/ojiepermana-angular-component-alert-dialog.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-alert.mjs +99 -0
- package/fesm2022/ojiepermana-angular-component-alert.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-aspect-ratio.mjs +37 -0
- package/fesm2022/ojiepermana-angular-component-aspect-ratio.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-avatar.mjs +139 -0
- package/fesm2022/ojiepermana-angular-component-avatar.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-badge.mjs +50 -0
- package/fesm2022/ojiepermana-angular-component-badge.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-breadcrumb.mjs +200 -0
- package/fesm2022/ojiepermana-angular-component-breadcrumb.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-button-group.mjs +103 -0
- package/fesm2022/ojiepermana-angular-component-button-group.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-button.mjs +68 -0
- package/fesm2022/ojiepermana-angular-component-button.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-calendar.mjs +103 -0
- package/fesm2022/ojiepermana-angular-component-calendar.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-card.mjs +152 -0
- package/fesm2022/ojiepermana-angular-component-card.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-carousel.mjs +334 -0
- package/fesm2022/ojiepermana-angular-component-carousel.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-checkbox.mjs +165 -0
- package/fesm2022/ojiepermana-angular-component-checkbox.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-collapsible.mjs +121 -0
- package/fesm2022/ojiepermana-angular-component-collapsible.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-combobox.mjs +274 -0
- package/fesm2022/ojiepermana-angular-component-combobox.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-command.mjs +297 -0
- package/fesm2022/ojiepermana-angular-component-command.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-composer.mjs +352 -0
- package/fesm2022/ojiepermana-angular-component-composer.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-context-menu.mjs +108 -0
- package/fesm2022/ojiepermana-angular-component-context-menu.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-date-picker.mjs +186 -0
- package/fesm2022/ojiepermana-angular-component-date-picker.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-dialog.mjs +283 -0
- package/fesm2022/ojiepermana-angular-component-dialog.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-drawer.mjs +6 -0
- package/fesm2022/ojiepermana-angular-component-drawer.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-dropdown-menu.mjs +494 -0
- package/fesm2022/ojiepermana-angular-component-dropdown-menu.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-editor.mjs +680 -0
- package/fesm2022/ojiepermana-angular-component-editor.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-empty.mjs +145 -0
- package/fesm2022/ojiepermana-angular-component-empty.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-form.mjs +364 -0
- package/fesm2022/ojiepermana-angular-component-form.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-hover-card.mjs +275 -0
- package/fesm2022/ojiepermana-angular-component-hover-card.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-icon.mjs +86 -0
- package/fesm2022/ojiepermana-angular-component-icon.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-input-group.mjs +179 -0
- package/fesm2022/ojiepermana-angular-component-input-group.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-input-otp.mjs +517 -0
- package/fesm2022/ojiepermana-angular-component-input-otp.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-input.mjs +45 -0
- package/fesm2022/ojiepermana-angular-component-input.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-item.mjs +264 -0
- package/fesm2022/ojiepermana-angular-component-item.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-kanban.mjs +314 -0
- package/fesm2022/ojiepermana-angular-component-kanban.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-kbd.mjs +55 -0
- package/fesm2022/ojiepermana-angular-component-kbd.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-label.mjs +33 -0
- package/fesm2022/ojiepermana-angular-component-label.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-menubar.mjs +311 -0
- package/fesm2022/ojiepermana-angular-component-menubar.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-native-select.mjs +67 -0
- package/fesm2022/ojiepermana-angular-component-native-select.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-navigation-menu.mjs +408 -0
- package/fesm2022/ojiepermana-angular-component-navigation-menu.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-pagination.mjs +226 -0
- package/fesm2022/ojiepermana-angular-component-pagination.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-pillbox.mjs +810 -0
- package/fesm2022/ojiepermana-angular-component-pillbox.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-popover.mjs +145 -0
- package/fesm2022/ojiepermana-angular-component-popover.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-progress.mjs +60 -0
- package/fesm2022/ojiepermana-angular-component-progress.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-radio.mjs +173 -0
- package/fesm2022/ojiepermana-angular-component-radio.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-resizable.mjs +478 -0
- package/fesm2022/ojiepermana-angular-component-resizable.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-scroll-area.mjs +54 -0
- package/fesm2022/ojiepermana-angular-component-scroll-area.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-select.mjs +297 -0
- package/fesm2022/ojiepermana-angular-component-select.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-separator.mjs +37 -0
- package/fesm2022/ojiepermana-angular-component-separator.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-sheet.mjs +297 -0
- package/fesm2022/ojiepermana-angular-component-sheet.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-skeleton.mjs +31 -0
- package/fesm2022/ojiepermana-angular-component-skeleton.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-slider.mjs +423 -0
- package/fesm2022/ojiepermana-angular-component-slider.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-spinner.mjs +60 -0
- package/fesm2022/ojiepermana-angular-component-spinner.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-switch.mjs +140 -0
- package/fesm2022/ojiepermana-angular-component-switch.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-table.mjs +155 -0
- package/fesm2022/ojiepermana-angular-component-table.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-tabs.mjs +271 -0
- package/fesm2022/ojiepermana-angular-component-tabs.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-textarea.mjs +39 -0
- package/fesm2022/ojiepermana-angular-component-textarea.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-timeline.mjs +237 -0
- package/fesm2022/ojiepermana-angular-component-timeline.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-toast.mjs +161 -0
- package/fesm2022/ojiepermana-angular-component-toast.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-toggle-group.mjs +289 -0
- package/fesm2022/ojiepermana-angular-component-toggle-group.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-toggle.mjs +82 -0
- package/fesm2022/ojiepermana-angular-component-toggle.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-tooltip.mjs +410 -0
- package/fesm2022/ojiepermana-angular-component-tooltip.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component-utils.mjs +81 -0
- package/fesm2022/ojiepermana-angular-component-utils.mjs.map +1 -0
- package/fesm2022/ojiepermana-angular-component.mjs +11 -0
- package/fesm2022/ojiepermana-angular-component.mjs.map +1 -0
- package/form/README.md +210 -0
- package/hover-card/README.md +142 -0
- package/icon/README.md +25 -0
- package/input/README.md +159 -0
- package/input-group/README.md +237 -0
- package/input-otp/README.md +278 -0
- package/item/README.md +247 -0
- package/kanban/README.md +81 -0
- package/kbd/README.md +139 -0
- package/label/README.md +135 -0
- package/menubar/README.md +269 -0
- package/native-select/README.md +176 -0
- package/navigation-menu/README.md +160 -0
- package/package.json +291 -0
- package/pagination/README.md +144 -0
- package/pillbox/README.md +67 -0
- package/popover/README.md +43 -0
- package/progress/README.md +160 -0
- package/radio/README.md +209 -0
- package/resizable/README.md +168 -0
- package/scroll-area/README.md +143 -0
- package/select/README.md +174 -0
- package/separator/README.md +170 -0
- package/sheet/README.md +183 -0
- package/skeleton/README.md +158 -0
- package/slider/README.md +207 -0
- package/spinner/README.md +160 -0
- package/switch/README.md +166 -0
- package/table/README.md +291 -0
- package/tabs/README.md +214 -0
- package/textarea/README.md +153 -0
- package/timeline/README.md +94 -0
- package/toast/README.md +321 -0
- package/toggle/README.md +131 -0
- package/toggle-group/README.md +206 -0
- package/tooltip/README.md +207 -0
- package/types/ojiepermana-angular-component-accordion.d.ts +51 -0
- package/types/ojiepermana-angular-component-alert-dialog.d.ts +93 -0
- package/types/ojiepermana-angular-component-alert.d.ts +37 -0
- package/types/ojiepermana-angular-component-aspect-ratio.d.ts +12 -0
- package/types/ojiepermana-angular-component-avatar.d.ts +51 -0
- package/types/ojiepermana-angular-component-badge.d.ts +19 -0
- package/types/ojiepermana-angular-component-breadcrumb.d.ts +46 -0
- package/types/ojiepermana-angular-component-button-group.d.ts +26 -0
- package/types/ojiepermana-angular-component-button.d.ts +22 -0
- package/types/ojiepermana-angular-component-calendar.d.ts +39 -0
- package/types/ojiepermana-angular-component-card.d.ts +60 -0
- package/types/ojiepermana-angular-component-carousel.d.ts +86 -0
- package/types/ojiepermana-angular-component-checkbox.d.ts +42 -0
- package/types/ojiepermana-angular-component-collapsible.d.ts +42 -0
- package/types/ojiepermana-angular-component-combobox.d.ts +53 -0
- package/types/ojiepermana-angular-component-command.d.ts +102 -0
- package/types/ojiepermana-angular-component-composer.d.ts +90 -0
- package/types/ojiepermana-angular-component-context-menu.d.ts +36 -0
- package/types/ojiepermana-angular-component-date-picker.d.ts +48 -0
- package/types/ojiepermana-angular-component-dialog.d.ts +87 -0
- package/types/ojiepermana-angular-component-drawer.d.ts +1 -0
- package/types/ojiepermana-angular-component-dropdown-menu.d.ts +140 -0
- package/types/ojiepermana-angular-component-editor.d.ts +126 -0
- package/types/ojiepermana-angular-component-empty.d.ts +50 -0
- package/types/ojiepermana-angular-component-form.d.ts +140 -0
- package/types/ojiepermana-angular-component-hover-card.d.ts +75 -0
- package/types/ojiepermana-angular-component-icon.d.ts +31 -0
- package/types/ojiepermana-angular-component-input-group.d.ts +51 -0
- package/types/ojiepermana-angular-component-input-otp.d.ts +142 -0
- package/types/ojiepermana-angular-component-input.d.ts +16 -0
- package/types/ojiepermana-angular-component-item.d.ts +88 -0
- package/types/ojiepermana-angular-component-kanban.d.ts +70 -0
- package/types/ojiepermana-angular-component-kbd.d.ts +16 -0
- package/types/ojiepermana-angular-component-label.d.ts +11 -0
- package/types/ojiepermana-angular-component-menubar.d.ts +69 -0
- package/types/ojiepermana-angular-component-native-select.d.ts +26 -0
- package/types/ojiepermana-angular-component-navigation-menu.d.ts +98 -0
- package/types/ojiepermana-angular-component-pagination.d.ts +33 -0
- package/types/ojiepermana-angular-component-pillbox.d.ts +156 -0
- package/types/ojiepermana-angular-component-popover.d.ts +50 -0
- package/types/ojiepermana-angular-component-progress.d.ts +17 -0
- package/types/ojiepermana-angular-component-radio.d.ts +57 -0
- package/types/ojiepermana-angular-component-resizable.d.ts +99 -0
- package/types/ojiepermana-angular-component-scroll-area.d.ts +19 -0
- package/types/ojiepermana-angular-component-select.d.ts +56 -0
- package/types/ojiepermana-angular-component-separator.d.ts +14 -0
- package/types/ojiepermana-angular-component-sheet.d.ts +78 -0
- package/types/ojiepermana-angular-component-skeleton.d.ts +10 -0
- package/types/ojiepermana-angular-component-slider.d.ts +74 -0
- package/types/ojiepermana-angular-component-spinner.d.ts +13 -0
- package/types/ojiepermana-angular-component-switch.d.ts +44 -0
- package/types/ojiepermana-angular-component-table.d.ts +52 -0
- package/types/ojiepermana-angular-component-tabs.d.ts +92 -0
- package/types/ojiepermana-angular-component-textarea.d.ts +12 -0
- package/types/ojiepermana-angular-component-timeline.d.ts +63 -0
- package/types/ojiepermana-angular-component-toast.d.ts +51 -0
- package/types/ojiepermana-angular-component-toggle-group.d.ts +89 -0
- package/types/ojiepermana-angular-component-toggle.d.ts +25 -0
- package/types/ojiepermana-angular-component-tooltip.d.ts +101 -0
- package/types/ojiepermana-angular-component-utils.d.ts +30 -0
- package/types/ojiepermana-angular-component.d.ts +2 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# Timeline
|
|
2
|
+
|
|
3
|
+
Display a series of events or steps in a vertical or horizontal timeline.
|
|
4
|
+
|
|
5
|
+
This component is conceptually inspired by Flux Timeline. The Angular API, slot names, styling tokens, and examples are implemented for this library's shadcn-style component system.
|
|
6
|
+
|
|
7
|
+
## Import
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import {
|
|
11
|
+
TimelineBlockComponent,
|
|
12
|
+
TimelineComponent,
|
|
13
|
+
TimelineContentComponent,
|
|
14
|
+
TimelineIndicatorComponent,
|
|
15
|
+
TimelineItemComponent,
|
|
16
|
+
TimelineSubgridComponent,
|
|
17
|
+
} from '@ojiepermana/angular-component/timeline';
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
```html
|
|
23
|
+
<Timeline>
|
|
24
|
+
<TimelineItem status="complete">
|
|
25
|
+
<TimelineIndicator>1</TimelineIndicator>
|
|
26
|
+
<TimelineContent>
|
|
27
|
+
<h3 class="text-sm font-medium">Submit</h3>
|
|
28
|
+
<p class="text-muted-foreground">Complete the form and provide all necessary assets.</p>
|
|
29
|
+
</TimelineContent>
|
|
30
|
+
</TimelineItem>
|
|
31
|
+
</Timeline>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Composition
|
|
35
|
+
|
|
36
|
+
```text
|
|
37
|
+
Timeline
|
|
38
|
+
|-- TimelineItem
|
|
39
|
+
| |-- TimelineIndicator
|
|
40
|
+
| `-- TimelineContent
|
|
41
|
+
|-- TimelineItem
|
|
42
|
+
| `-- TimelineBlock
|
|
43
|
+
| `-- TimelineSubgrid
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Horizontal Status
|
|
47
|
+
|
|
48
|
+
```html
|
|
49
|
+
<Timeline horizontal>
|
|
50
|
+
<TimelineItem status="complete">
|
|
51
|
+
<TimelineIndicator>1</TimelineIndicator>
|
|
52
|
+
<TimelineContent>Order confirmed</TimelineContent>
|
|
53
|
+
</TimelineItem>
|
|
54
|
+
<TimelineItem status="current">
|
|
55
|
+
<TimelineIndicator>2</TimelineIndicator>
|
|
56
|
+
<TimelineContent>On its way</TimelineContent>
|
|
57
|
+
</TimelineItem>
|
|
58
|
+
<TimelineItem status="incomplete">
|
|
59
|
+
<TimelineIndicator>3</TimelineIndicator>
|
|
60
|
+
<TimelineContent>Delivered</TimelineContent>
|
|
61
|
+
</TimelineItem>
|
|
62
|
+
</Timeline>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Inputs
|
|
66
|
+
|
|
67
|
+
| Part | Input | Type | Default |
|
|
68
|
+
| ---------------------------- | ------------ | ------------------------------------ | ---------- |
|
|
69
|
+
| `TimelineComponent` | `horizontal` | `boolean` | `false` |
|
|
70
|
+
| `TimelineComponent` | `align` | `start \| baseline \| center \| end` | `center` |
|
|
71
|
+
| `TimelineComponent` | `size` | `default \| lg` | `default` |
|
|
72
|
+
| `TimelineItemComponent` | `status` | `complete \| current \| incomplete` | `null` |
|
|
73
|
+
| `TimelineItemComponent` | `align` | `start \| baseline \| center \| end` | root value |
|
|
74
|
+
| `TimelineItemComponent` | `size` | `default \| lg` | root value |
|
|
75
|
+
| `TimelineIndicatorComponent` | `variant` | `default \| bare` | `default` |
|
|
76
|
+
| `TimelineIndicatorComponent` | `status` | `complete \| current \| incomplete` | item value |
|
|
77
|
+
| `TimelineIndicatorComponent` | `color` | standard color token | `null` |
|
|
78
|
+
|
|
79
|
+
## Spacing
|
|
80
|
+
|
|
81
|
+
The root exposes CSS variables for spacing and indicator sizing.
|
|
82
|
+
|
|
83
|
+
```html
|
|
84
|
+
<Timeline class="[--timeline-item-gap:3rem] [--timeline-content-gap:1rem]">
|
|
85
|
+
<!-- timeline items -->
|
|
86
|
+
</Timeline>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Accessibility
|
|
90
|
+
|
|
91
|
+
- Use semantic headings and text inside `TimelineContent`.
|
|
92
|
+
- Give icon-only indicators an accessible label when the icon communicates meaning.
|
|
93
|
+
- Keep chronological order in DOM order for screen readers.
|
|
94
|
+
- Do not rely on color alone; pair status indicators with text content.
|
package/toast/README.md
ADDED
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
# Toast
|
|
2
|
+
|
|
3
|
+
Imperative notification service wrapping `MatSnackBar` with shadcn styling and a Sonner-style API surface.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { ToastService } from '@ojiepermana/angular-component/toast';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Application Setup
|
|
12
|
+
|
|
13
|
+
Angular Material snack bars require animations to be configured once at application bootstrap.
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { bootstrapApplication } from '@angular/platform-browser';
|
|
17
|
+
import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';
|
|
18
|
+
|
|
19
|
+
bootstrapApplication(AppComponent, {
|
|
20
|
+
providers: [provideAnimationsAsync()],
|
|
21
|
+
});
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Use `provideNoopAnimations()` instead when the host application intentionally disables animations.
|
|
25
|
+
|
|
26
|
+
## Basic Usage
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import { inject } from '@angular/core';
|
|
30
|
+
import { ToastService } from '@ojiepermana/angular-component/toast';
|
|
31
|
+
|
|
32
|
+
export class SaveButtonComponent {
|
|
33
|
+
private readonly toast = inject(ToastService);
|
|
34
|
+
|
|
35
|
+
save(): void {
|
|
36
|
+
this.toast.success({
|
|
37
|
+
title: 'Saved',
|
|
38
|
+
description: 'Your changes have been saved.',
|
|
39
|
+
action: 'Undo',
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
fail(): void {
|
|
44
|
+
this.toast.error({ title: 'Upload failed', description: 'Check your connection.' });
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Common Patterns
|
|
50
|
+
|
|
51
|
+
### Variants
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
this.toast.show({ title: 'Draft created' });
|
|
55
|
+
this.toast.success({ title: 'Invoice paid' });
|
|
56
|
+
this.toast.info({ title: 'Deploy starts in 10 minutes' });
|
|
57
|
+
this.toast.warning({ title: 'Storage is almost full' });
|
|
58
|
+
this.toast.error({ title: 'Payment failed' });
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Position
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
this.toast.show({
|
|
65
|
+
title: 'Event has been created',
|
|
66
|
+
horizontalPosition: 'start',
|
|
67
|
+
verticalPosition: 'top',
|
|
68
|
+
});
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Promise State
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
void this.toast.promise(() => this.createEvent(), {
|
|
75
|
+
loading: 'Loading...',
|
|
76
|
+
success: (event) => `${event.name} has been created`,
|
|
77
|
+
error: 'Error',
|
|
78
|
+
});
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
The loading toast uses `durationMs: null` internally so it stays visible until the promise settles.
|
|
82
|
+
|
|
83
|
+
## API Reference
|
|
84
|
+
|
|
85
|
+
### `ToastService`
|
|
86
|
+
|
|
87
|
+
| Method | Returns |
|
|
88
|
+
| ---------------------------------- | ------------------------- |
|
|
89
|
+
| `show(options: ToastOptions)` | `MatSnackBarRef<unknown>` |
|
|
90
|
+
| `success(options)` | `MatSnackBarRef<unknown>` |
|
|
91
|
+
| `info(options)` | `MatSnackBarRef<unknown>` |
|
|
92
|
+
| `warning(options)` | `MatSnackBarRef<unknown>` |
|
|
93
|
+
| `error(options)` | `MatSnackBarRef<unknown>` |
|
|
94
|
+
| `promise(taskOrFactory, messages)` | `Promise<T>` |
|
|
95
|
+
| `dismiss()` | `void` |
|
|
96
|
+
|
|
97
|
+
### `ToastOptions`
|
|
98
|
+
|
|
99
|
+
| Field | Type | Default |
|
|
100
|
+
| -------------------- | ---------------------------------------------------------------- | ----------- |
|
|
101
|
+
| `title` | `string` | — |
|
|
102
|
+
| `description` | `string` | — |
|
|
103
|
+
| `action` | `string` | `''` |
|
|
104
|
+
| `variant` | `'default' \| 'destructive' \| 'success' \| 'info' \| 'warning'` | `'default'` |
|
|
105
|
+
| `durationMs` | `number \| null` | `5000` |
|
|
106
|
+
| `horizontalPosition` | `MatSnackBarConfig['horizontalPosition']` | `'end'` |
|
|
107
|
+
| `verticalPosition` | `MatSnackBarConfig['verticalPosition']` | `'bottom'` |
|
|
108
|
+
|
|
109
|
+
Set `durationMs` to `null` when the toast should stay visible until `dismiss()` is called.
|
|
110
|
+
|
|
111
|
+
### `ToastPromiseMessages<T>`
|
|
112
|
+
|
|
113
|
+
| Field | Type | Notes |
|
|
114
|
+
| --------- | ---------------------------------------- | ----------------------------------------- |
|
|
115
|
+
| `loading` | `string` | Title shown while the promise is pending. |
|
|
116
|
+
| `success` | `string \| ((value: T) => string)` | Title shown when the promise resolves. |
|
|
117
|
+
| `error` | `string \| ((error: unknown) => string)` | Title shown when the promise rejects. |
|
|
118
|
+
|
|
119
|
+
## Styling And Theming
|
|
120
|
+
|
|
121
|
+
The service applies `toast-panel` plus `toast-<variant>` panel classes to the Angular Material snack-bar container.
|
|
122
|
+
|
|
123
|
+
- `default` keeps the background and foreground tokens from the active theme.
|
|
124
|
+
- `success` uses the primary theme tokens.
|
|
125
|
+
- `info` uses the shared `info` tokens.
|
|
126
|
+
- `warning` uses the shared `warning` tokens.
|
|
127
|
+
- `error` maps to the destructive tokens.
|
|
128
|
+
|
|
129
|
+
If you need to override a variant, target the container class and set the Material snack-bar CSS custom properties:
|
|
130
|
+
|
|
131
|
+
```css
|
|
132
|
+
.mat-mdc-snack-bar-container.toast-warning {
|
|
133
|
+
--mdc-snackbar-container-color: hsl(var(--warning));
|
|
134
|
+
--mdc-snackbar-supporting-text-color: hsl(var(--warning-foreground));
|
|
135
|
+
--mat-snack-bar-button-color: hsl(var(--warning-foreground));
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Accessibility
|
|
140
|
+
|
|
141
|
+
`MatSnackBar` manages live-region announcements automatically. Keep titles short, use `action` for a single primary follow-up, and avoid moving focus into the toast.
|
|
142
|
+
|
|
143
|
+
## Angular Notes
|
|
144
|
+
|
|
145
|
+
Inject the service where the interaction starts instead of creating a global host component. `MatSnackBar` shows one visible toast at a time, so `promise()` dismisses the loading state before showing its success or error follow-up.
|
|
146
|
+
|
|
147
|
+
## Source Parity
|
|
148
|
+
|
|
149
|
+
This entrypoint is the local Angular mapping for shadcn Sonner as well as the simpler toast examples in the demo. It intentionally preserves the imperative API mental model, variant coverage, and placement controls while staying honest about the implementation boundary: the runtime surface is still a focused `MatSnackBar` wrapper, not Sonner's stacked multi-toast viewport.
|
|
150
|
+
|
|
151
|
+
# Toast
|
|
152
|
+
|
|
153
|
+
Imperative notification service backed by `MatSnackBar`, styled for the local shadcn-inspired theme.
|
|
154
|
+
|
|
155
|
+
The upstream shadcn toast page is deprecated in favor of Sonner. This entrypoint remains useful for lightweight single-message flows in Angular apps, while richer stacked notification workflows can move to a future Sonner-style surface.
|
|
156
|
+
|
|
157
|
+
## Import
|
|
158
|
+
|
|
159
|
+
```ts
|
|
160
|
+
import { ToastService } from '@ojiepermana/angular-component/toast';
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## App setup
|
|
164
|
+
|
|
165
|
+
Enable browser or noop animations so the underlying snackbar overlay can render correctly.
|
|
166
|
+
|
|
167
|
+
```ts
|
|
168
|
+
import type { ApplicationConfig } from '@angular/core';
|
|
169
|
+
import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';
|
|
170
|
+
|
|
171
|
+
export const appConfig: ApplicationConfig = {
|
|
172
|
+
providers: [provideAnimationsAsync()],
|
|
173
|
+
};
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Use `provideNoopAnimations()` instead when the host application deliberately disables animations.
|
|
177
|
+
|
|
178
|
+
## Structure
|
|
179
|
+
|
|
180
|
+
This entrypoint exports a service rather than a component tree. `ToastService` keeps the API at the same event-handling layer as your save, delete, archive, or publish action, while rendering is delegated to Angular Material overlays.
|
|
181
|
+
|
|
182
|
+
## Basic usage
|
|
183
|
+
|
|
184
|
+
```ts
|
|
185
|
+
import { inject } from '@angular/core';
|
|
186
|
+
import { ToastService } from '@ojiepermana/angular-component/toast';
|
|
187
|
+
|
|
188
|
+
export class SaveButton {
|
|
189
|
+
private readonly toast = inject(ToastService);
|
|
190
|
+
|
|
191
|
+
save(): void {
|
|
192
|
+
this.toast.success({
|
|
193
|
+
title: 'Saved',
|
|
194
|
+
description: 'Your changes have been saved.',
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## Common patterns
|
|
201
|
+
|
|
202
|
+
### Status shortcuts
|
|
203
|
+
|
|
204
|
+
```ts
|
|
205
|
+
this.toast.show({
|
|
206
|
+
title: 'Deployment queued',
|
|
207
|
+
description: 'We will notify you when the build is ready.',
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
this.toast.success({
|
|
211
|
+
title: 'Saved',
|
|
212
|
+
description: 'Your changes have been saved.',
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
this.toast.info({
|
|
216
|
+
title: 'Heads up',
|
|
217
|
+
description: 'The deployment window starts in 10 minutes.',
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
this.toast.warning({
|
|
221
|
+
title: 'Storage almost full',
|
|
222
|
+
description: 'Archive older uploads before the next sync.',
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
this.toast.error({
|
|
226
|
+
title: 'Failed to save',
|
|
227
|
+
description: 'Network error. Please retry.',
|
|
228
|
+
});
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### Persistent action
|
|
232
|
+
|
|
233
|
+
For an important action, keep the toast open and handle the snackbar action from the returned reference.
|
|
234
|
+
|
|
235
|
+
```ts
|
|
236
|
+
const ref = this.toast.show({
|
|
237
|
+
title: 'Event archived',
|
|
238
|
+
description: 'Restore it from the calendar within the next minute.',
|
|
239
|
+
action: 'Undo',
|
|
240
|
+
durationMs: null,
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
ref.onAction().subscribe(() => {
|
|
244
|
+
this.toast.info({
|
|
245
|
+
title: 'Archive cancelled',
|
|
246
|
+
description: 'The event is back on the calendar.',
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### Promise helper
|
|
252
|
+
|
|
253
|
+
Use `toast.promise()` when one async task should produce loading, success, and failure feedback in sequence.
|
|
254
|
+
|
|
255
|
+
```ts
|
|
256
|
+
await this.toast.promise(
|
|
257
|
+
() =>
|
|
258
|
+
new Promise<{ name: string }>((resolve) => {
|
|
259
|
+
window.setTimeout(() => resolve({ name: 'Summer launch checklist' }), 900);
|
|
260
|
+
}),
|
|
261
|
+
{
|
|
262
|
+
loading: 'Archiving draft...',
|
|
263
|
+
success: (draft) => `${draft.name} archived`,
|
|
264
|
+
error: 'Unable to archive draft',
|
|
265
|
+
},
|
|
266
|
+
);
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
## API Reference
|
|
270
|
+
|
|
271
|
+
### `ToastService`
|
|
272
|
+
|
|
273
|
+
| Method | Returns | Notes |
|
|
274
|
+
| ---------------------------------- | ------------------------- | ---------------------------------------------------------- |
|
|
275
|
+
| `show(options)` | `MatSnackBarRef<unknown>` | Lowest-level method with full option control. |
|
|
276
|
+
| `success(options)` | `MatSnackBarRef<unknown>` | Shortcut for `variant: 'success'`. |
|
|
277
|
+
| `info(options)` | `MatSnackBarRef<unknown>` | Angular-local semantic shortcut. |
|
|
278
|
+
| `warning(options)` | `MatSnackBarRef<unknown>` | Angular-local semantic shortcut. |
|
|
279
|
+
| `error(options)` | `MatSnackBarRef<unknown>` | Shortcut for `variant: 'destructive'`. |
|
|
280
|
+
| `promise(taskOrFactory, messages)` | `Promise<T>` | Shows loading first, then success or destructive feedback. |
|
|
281
|
+
| `dismiss()` | `void` | Closes the active toast. |
|
|
282
|
+
|
|
283
|
+
### `ToastOptions`
|
|
284
|
+
|
|
285
|
+
| Field | Type | Default | Notes |
|
|
286
|
+
| -------------------- | ---------------------------------------------------------------- | ----------- | ------------------------------------------------------- |
|
|
287
|
+
| `title` | `string` | unset | Primary message line. |
|
|
288
|
+
| `description` | `string` | unset | Optional secondary line. |
|
|
289
|
+
| `action` | `string` | `''` | Single action label shown by the snackbar. |
|
|
290
|
+
| `variant` | `'default' \| 'destructive' \| 'success' \| 'info' \| 'warning'` | `'default'` | Visual variant applied through `toast-*` panel classes. |
|
|
291
|
+
| `durationMs` | `number \| null` | `5000` | Set to `null` to keep the toast open until dismissed. |
|
|
292
|
+
| `horizontalPosition` | `MatSnackBarConfig['horizontalPosition']` | `'end'` | Snackbar x-axis placement. |
|
|
293
|
+
| `verticalPosition` | `MatSnackBarConfig['verticalPosition']` | `'bottom'` | Snackbar y-axis placement. |
|
|
294
|
+
|
|
295
|
+
### `ToastPromiseMessages<T>`
|
|
296
|
+
|
|
297
|
+
| Field | Type | Notes |
|
|
298
|
+
| --------- | ---------------------------------------- | --------------------------------------------------- |
|
|
299
|
+
| `loading` | `string` | Required loading message while the task is pending. |
|
|
300
|
+
| `success` | `string \| ((value: T) => string)` | Static or data-derived success copy. |
|
|
301
|
+
| `error` | `string \| ((error: unknown) => string)` | Static or error-derived destructive copy. |
|
|
302
|
+
|
|
303
|
+
## Styling and theming
|
|
304
|
+
|
|
305
|
+
The service applies `toast-panel` and `toast-<variant>` classes on the snackbar container. The shared Material integration maps those classes to the local semantic tokens for default, destructive, success, info, and warning states, and preserves line breaks between `title` and `description`.
|
|
306
|
+
|
|
307
|
+
## Accessibility
|
|
308
|
+
|
|
309
|
+
`MatSnackBar` manages live-region announcements automatically. Keep toast copy short, reserve it for transient status updates, and prefer `durationMs: null` when the action button must stay available long enough for keyboard and assistive-technology users.
|
|
310
|
+
|
|
311
|
+
## Keyboard interactions
|
|
312
|
+
|
|
313
|
+
The toast body itself is not a roving-focus widget. Keyboard interaction is limited to the optional action button exposed by the snackbar when `action` is present.
|
|
314
|
+
|
|
315
|
+
## Angular notes
|
|
316
|
+
|
|
317
|
+
This API is intentionally Angular-first rather than a one-to-one port of Radix toast composition. You trigger notifications from event handlers or async workflows, not by managing a dedicated toast viewport in every template.
|
|
318
|
+
|
|
319
|
+
## Source parity
|
|
320
|
+
|
|
321
|
+
Default and destructive map most closely to the historical shadcn toast examples. `success`, `info`, and `warning` are Angular-local semantic additions that fit the service-style API better. The upstream shadcn page now points users to Sonner, so this entrypoint deliberately focuses on simple, single-message feedback instead of stacked queue management.
|
package/toggle/README.md
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# Toggle
|
|
2
|
+
|
|
3
|
+
A two-state button that can be either on or off.
|
|
4
|
+
|
|
5
|
+
Use Toggle for persistent formatting, bookmarking, pinning, or filter state where a pressed button is the right semantic pattern.
|
|
6
|
+
|
|
7
|
+
## Import
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { ToggleComponent } from '@ojiepermana/angular-component/toggle';
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Composition
|
|
14
|
+
|
|
15
|
+
The Angular surface keeps the same single-host shape as shadcn and Radix while mapping it to a native button selector.
|
|
16
|
+
|
|
17
|
+
```text
|
|
18
|
+
button[Toggle]
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Basic usage
|
|
22
|
+
|
|
23
|
+
Bind `[(pressed)]` when the parent should observe or control the state. The host always renders as a native button with `aria-pressed`.
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
readonly bookmarked = signal(false);
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
```html
|
|
30
|
+
<button Toggle aria-label="Toggle bookmark" [(pressed)]="bookmarked" variant="outline" size="sm">
|
|
31
|
+
<svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
|
|
32
|
+
<path d="M6 4.75c0-.41.34-.75.75-.75h10.5c.41 0 .75.34.75.75V20l-6-3.5L6 20V4.75Z" />
|
|
33
|
+
</svg>
|
|
34
|
+
Bookmark
|
|
35
|
+
</button>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Common patterns
|
|
39
|
+
|
|
40
|
+
### Outline variant
|
|
41
|
+
|
|
42
|
+
Use `variant="outline"` when the toggle should read like a bordered tool button.
|
|
43
|
+
|
|
44
|
+
```html
|
|
45
|
+
<button Toggle aria-label="Toggle italic" variant="outline">Italic</button>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### With text
|
|
49
|
+
|
|
50
|
+
Project an icon and visible text when the label should stay on screen.
|
|
51
|
+
|
|
52
|
+
```html
|
|
53
|
+
<button Toggle aria-label="Toggle italic">
|
|
54
|
+
<svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
|
|
55
|
+
<path d="M10 4h8" />
|
|
56
|
+
<path d="M6 20h8" />
|
|
57
|
+
<path d="M14 4 10 20" />
|
|
58
|
+
</svg>
|
|
59
|
+
Italic
|
|
60
|
+
</button>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Sizes
|
|
64
|
+
|
|
65
|
+
The toggle supports the shadcn size names `sm`, `default`, and `lg`.
|
|
66
|
+
|
|
67
|
+
```html
|
|
68
|
+
<button Toggle size="sm" variant="outline" aria-label="Toggle small">Small</button>
|
|
69
|
+
<button Toggle size="default" variant="outline" aria-label="Toggle default">Default</button>
|
|
70
|
+
<button Toggle size="lg" variant="outline" aria-label="Toggle large">Large</button>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Disabled state
|
|
74
|
+
|
|
75
|
+
Set `[disabled]="true"` when the control should remain visible but unavailable.
|
|
76
|
+
|
|
77
|
+
```html
|
|
78
|
+
<button Toggle aria-label="Toggle bookmark" [disabled]="true">Bookmark</button>
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### RTL
|
|
82
|
+
|
|
83
|
+
Direction comes from the surrounding layout. The API stays the same.
|
|
84
|
+
|
|
85
|
+
```html
|
|
86
|
+
<div dir="rtl" lang="ar" class="text-right">
|
|
87
|
+
<button Toggle aria-label="تبديل الإشارة المرجعية" variant="outline" size="sm">إشارة مرجعية</button>
|
|
88
|
+
</div>
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## API reference
|
|
92
|
+
|
|
93
|
+
| Input or model | Type | Default |
|
|
94
|
+
| -------------- | --------------------------- | ----------- |
|
|
95
|
+
| `pressed` | `boolean` | `false` |
|
|
96
|
+
| `disabled` | `boolean` | `false` |
|
|
97
|
+
| `variant` | `'default' \| 'outline'` | `'default'` |
|
|
98
|
+
| `size` | `'sm' \| 'default' \| 'lg'` | `'default'` |
|
|
99
|
+
| `class` | `string` | `''` |
|
|
100
|
+
|
|
101
|
+
Host: `button[Toggle]`.
|
|
102
|
+
|
|
103
|
+
The host exposes `aria-pressed`, `data-state="on|off"`, `data-variant`, `data-size`, and `data-disabled` for styling and testing hooks.
|
|
104
|
+
|
|
105
|
+
## Styling and theming
|
|
106
|
+
|
|
107
|
+
The primitive uses the shared library color tokens for `foreground`, `accent`, `muted`, `input`, and `ring`.
|
|
108
|
+
|
|
109
|
+
Use `class` to add width, shape, or layout utilities such as `rounded-full`, `w-full`, or responsive flex helpers.
|
|
110
|
+
|
|
111
|
+
## Accessibility
|
|
112
|
+
|
|
113
|
+
- `button[Toggle]` keeps the native button semantics and adds `aria-pressed` for the two-state pattern.
|
|
114
|
+
- Provide an `aria-label` for icon-only toggles.
|
|
115
|
+
- Use Toggle for persistent on/off state. If the control changes application state like a checkbox field, prefer the dedicated switch or checkbox primitive.
|
|
116
|
+
- Disabled toggles remain visible but non-interactive.
|
|
117
|
+
|
|
118
|
+
## Keyboard interactions
|
|
119
|
+
|
|
120
|
+
- Native button behavior covers Tab focus plus Enter and Space activation.
|
|
121
|
+
- Pressing Enter or Space toggles the `pressed` model through the native click event.
|
|
122
|
+
|
|
123
|
+
## Angular notes
|
|
124
|
+
|
|
125
|
+
- Import `ToggleComponent` into the standalone component that renders the host.
|
|
126
|
+
- `[(pressed)]` is the Angular replacement for React's `pressed` and `onPressedChange` pairing.
|
|
127
|
+
- The host always defaults to `type="button"` so it does not submit ancestor forms accidentally.
|
|
128
|
+
|
|
129
|
+
## Source parity
|
|
130
|
+
|
|
131
|
+
This Angular implementation follows the shadcn Toggle information architecture, variants, sizes, and RTL guidance while translating the runtime API to a native button host with signal-friendly two-way binding.
|