@ojiepermana/angular 22.1.10 → 22.1.12
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 +32 -26
- package/chart/README.md +272 -0
- package/component/README.md +89 -0
- package/component/accordion/README.md +195 -0
- package/component/alert/README.md +184 -0
- package/component/alert-dialog/README.md +255 -0
- package/component/aspect-ratio/README.md +116 -0
- package/component/avatar/README.md +182 -0
- package/component/badge/README.md +143 -0
- package/component/breadcrumb/README.md +223 -0
- package/component/button/README.md +141 -0
- package/component/button-group/README.md +214 -0
- package/component/calendar/README.md +137 -0
- package/component/card/README.md +232 -0
- package/component/carousel/README.md +276 -0
- package/component/checkbox/README.md +153 -0
- package/component/collapsible/README.md +216 -0
- package/component/combobox/README.md +202 -0
- package/component/command/README.md +287 -0
- package/component/composer/README.md +241 -0
- package/component/context-menu/README.md +268 -0
- package/component/date-picker/README.md +202 -0
- package/component/dialog/README.md +276 -0
- package/component/drawer/README.md +147 -0
- package/component/dropdown-menu/README.md +336 -0
- package/component/editor/README.md +152 -0
- package/component/empty/README.md +193 -0
- package/component/form/README.md +216 -0
- package/component/hover-card/README.md +150 -0
- package/component/icon/README.md +25 -0
- package/component/input/README.md +160 -0
- package/component/input-group/README.md +245 -0
- package/component/input-otp/README.md +331 -0
- package/component/item/README.md +254 -0
- package/component/kanban/README.md +81 -0
- package/component/kbd/README.md +141 -0
- package/component/label/README.md +137 -0
- package/component/menubar/README.md +270 -0
- package/component/native-select/README.md +176 -0
- package/component/navigation-menu/README.md +165 -0
- package/component/pagination/README.md +151 -0
- package/component/pillbox/README.md +68 -0
- package/component/popover/README.md +54 -0
- package/component/progress/README.md +160 -0
- package/component/radio/README.md +212 -0
- package/component/resizable/README.md +178 -0
- package/component/scroll-area/README.md +150 -0
- package/component/select/README.md +228 -0
- package/component/separator/README.md +175 -0
- package/component/sheet/README.md +190 -0
- package/component/skeleton/README.md +158 -0
- package/component/slider/README.md +207 -0
- package/component/spinner/README.md +160 -0
- package/component/switch/README.md +170 -0
- package/component/table/README.md +292 -0
- package/component/tabs/README.md +220 -0
- package/component/textarea/README.md +169 -0
- package/component/timeline/README.md +94 -0
- package/component/toast/README.md +173 -0
- package/component/toggle/README.md +133 -0
- package/component/toggle-group/README.md +234 -0
- package/component/tooltip/README.md +230 -0
- package/fesm2022/ojiepermana-angular-chart-area.mjs +289 -3
- package/fesm2022/ojiepermana-angular-chart-bar.mjs +722 -3
- package/fesm2022/ojiepermana-angular-chart-core.mjs +1482 -3
- package/fesm2022/ojiepermana-angular-chart-line.mjs +294 -3
- package/fesm2022/ojiepermana-angular-chart-pie.mjs +291 -3
- package/fesm2022/ojiepermana-angular-chart-primitives.mjs +1301 -3
- package/fesm2022/ojiepermana-angular-chart-radar.mjs +421 -3
- package/fesm2022/ojiepermana-angular-chart-radial.mjs +295 -3
- package/fesm2022/ojiepermana-angular-chart-scatter.mjs +306 -3
- package/fesm2022/ojiepermana-angular-chart.mjs +12 -3
- package/fesm2022/ojiepermana-angular-component-accordion.mjs +267 -3
- package/fesm2022/ojiepermana-angular-component-alert-dialog.mjs +359 -3
- package/fesm2022/ojiepermana-angular-component-alert.mjs +101 -3
- package/fesm2022/ojiepermana-angular-component-aspect-ratio.mjs +31 -3
- package/fesm2022/ojiepermana-angular-component-avatar.mjs +139 -3
- package/fesm2022/ojiepermana-angular-component-badge.mjs +57 -3
- package/fesm2022/ojiepermana-angular-component-breadcrumb.mjs +192 -3
- package/fesm2022/ojiepermana-angular-component-button-group.mjs +95 -3
- package/fesm2022/ojiepermana-angular-component-button.mjs +73 -3
- package/fesm2022/ojiepermana-angular-component-calendar.mjs +718 -3
- package/fesm2022/ojiepermana-angular-component-card.mjs +167 -3
- package/fesm2022/ojiepermana-angular-component-carousel.mjs +326 -3
- package/fesm2022/ojiepermana-angular-component-checkbox.mjs +190 -3
- package/fesm2022/ojiepermana-angular-component-collapsible.mjs +117 -3
- package/fesm2022/ojiepermana-angular-component-combobox.mjs +327 -3
- package/fesm2022/ojiepermana-angular-component-command.mjs +351 -3
- package/fesm2022/ojiepermana-angular-component-composer.mjs +359 -3
- package/fesm2022/ojiepermana-angular-component-context-menu.mjs +158 -3
- package/fesm2022/ojiepermana-angular-component-date-picker.mjs +482 -3
- package/fesm2022/ojiepermana-angular-component-dialog.mjs +400 -3
- package/fesm2022/ojiepermana-angular-component-drawer.mjs +1 -3
- package/fesm2022/ojiepermana-angular-component-dropdown-menu.mjs +689 -3
- package/fesm2022/ojiepermana-angular-component-editor.mjs +511 -3
- package/fesm2022/ojiepermana-angular-component-empty.mjs +134 -3
- package/fesm2022/ojiepermana-angular-component-form.mjs +438 -3
- package/fesm2022/ojiepermana-angular-component-hover-card.mjs +273 -3
- package/fesm2022/ojiepermana-angular-component-icon.mjs +139 -3
- package/fesm2022/ojiepermana-angular-component-input-group.mjs +176 -3
- package/fesm2022/ojiepermana-angular-component-input-otp.mjs +550 -3
- package/fesm2022/ojiepermana-angular-component-input.mjs +52 -3
- package/fesm2022/ojiepermana-angular-component-item.mjs +264 -3
- package/fesm2022/ojiepermana-angular-component-kanban.mjs +310 -3
- package/fesm2022/ojiepermana-angular-component-kbd.mjs +48 -3
- package/fesm2022/ojiepermana-angular-component-label.mjs +27 -3
- package/fesm2022/ojiepermana-angular-component-menubar.mjs +327 -3
- package/fesm2022/ojiepermana-angular-component-native-select.mjs +62 -3
- package/fesm2022/ojiepermana-angular-component-navigation-menu.mjs +378 -3
- package/fesm2022/ojiepermana-angular-component-pagination.mjs +238 -3
- package/fesm2022/ojiepermana-angular-component-pillbox.mjs +999 -3
- package/fesm2022/ojiepermana-angular-component-popover.mjs +201 -3
- package/fesm2022/ojiepermana-angular-component-progress.mjs +57 -3
- package/fesm2022/ojiepermana-angular-component-radio.mjs +180 -3
- package/fesm2022/ojiepermana-angular-component-resizable.mjs +493 -3
- package/fesm2022/ojiepermana-angular-component-scroll-area.mjs +51 -3
- package/fesm2022/ojiepermana-angular-component-segmented-control.mjs +227 -3
- package/fesm2022/ojiepermana-angular-component-select.mjs +609 -3
- package/fesm2022/ojiepermana-angular-component-separator.mjs +31 -3
- package/fesm2022/ojiepermana-angular-component-sheet.mjs +407 -3
- package/fesm2022/ojiepermana-angular-component-skeleton.mjs +25 -3
- package/fesm2022/ojiepermana-angular-component-slider.mjs +456 -3
- package/fesm2022/ojiepermana-angular-component-spinner.mjs +56 -3
- package/fesm2022/ojiepermana-angular-component-switch.mjs +145 -3
- package/fesm2022/ojiepermana-angular-component-table.mjs +155 -3
- package/fesm2022/ojiepermana-angular-component-tabs.mjs +315 -3
- package/fesm2022/ojiepermana-angular-component-textarea.mjs +46 -3
- package/fesm2022/ojiepermana-angular-component-timeline.mjs +237 -3
- package/fesm2022/ojiepermana-angular-component-toast.mjs +241 -3
- package/fesm2022/ojiepermana-angular-component-toggle-group.mjs +290 -3
- package/fesm2022/ojiepermana-angular-component-toggle.mjs +76 -3
- package/fesm2022/ojiepermana-angular-component-tooltip.mjs +519 -3
- package/fesm2022/ojiepermana-angular-component-utils-core.mjs +310 -3
- package/fesm2022/ojiepermana-angular-component-utils-overlay.mjs +62 -3
- package/fesm2022/ojiepermana-angular-component-utils-scale.mjs +34 -3
- package/fesm2022/ojiepermana-angular-component-utils.mjs +3 -2
- package/fesm2022/ojiepermana-angular-component.mjs +4 -4
- package/fesm2022/ojiepermana-angular-navigation-core.mjs +21 -3
- package/fesm2022/ojiepermana-angular-navigation-icon.mjs +20 -3
- package/fesm2022/ojiepermana-angular-navigation-navigation-badge-count.component-CDBxQ8rk.mjs +91 -0
- package/fesm2022/ojiepermana-angular-navigation-navigation-dockbar-menu.component-DBQHdvGa.mjs +512 -0
- package/fesm2022/ojiepermana-angular-navigation-navigation-entry-grid.component-Cd-jh6tg.mjs +623 -0
- package/fesm2022/ojiepermana-angular-navigation-navigation-flyout-menu.component-BCGvhoYj.mjs +404 -0
- package/fesm2022/ojiepermana-angular-navigation-navigation-horizontal.component-Dk_03e-6.mjs +466 -0
- package/fesm2022/ojiepermana-angular-navigation-ojiepermana-angular-navigation-DNKU6viC.mjs +2642 -0
- package/fesm2022/ojiepermana-angular-navigation-service.mjs +725 -3
- package/fesm2022/ojiepermana-angular-navigation-types.mjs +65 -4
- package/fesm2022/ojiepermana-angular-navigation.mjs +4 -10
- package/fesm2022/ojiepermana-angular-sdk.mjs +204 -4
- package/fesm2022/ojiepermana-angular-theme-component-settings.mjs +1387 -3
- package/fesm2022/ojiepermana-angular-theme-layout-services.mjs +331 -3
- package/fesm2022/ojiepermana-angular-theme-layout-types.mjs +45 -4
- package/fesm2022/ojiepermana-angular-theme-layout-wrapper.mjs +1044 -3
- package/fesm2022/ojiepermana-angular-theme-layout.mjs +729 -3
- package/fesm2022/ojiepermana-angular-theme-page-core.mjs +381 -3
- package/fesm2022/ojiepermana-angular-theme-page-filter.mjs +267 -3
- package/fesm2022/ojiepermana-angular-theme-page-root.mjs +361 -3
- package/fesm2022/ojiepermana-angular-theme-page-side.mjs +198 -3
- package/fesm2022/ojiepermana-angular-theme-page-slots.mjs +110 -3
- package/fesm2022/ojiepermana-angular-theme-page.mjs +7 -2
- package/fesm2022/ojiepermana-angular-theme-shell-services.mjs +338 -3
- package/fesm2022/ojiepermana-angular-theme-shell-types.mjs +160 -4
- package/fesm2022/ojiepermana-angular-theme-shell.mjs +811 -3
- package/fesm2022/ojiepermana-angular-theme-styles.mjs +783 -3
- package/fesm2022/ojiepermana-angular-theme.mjs +4 -4
- package/fesm2022/ojiepermana-angular.mjs +6 -11
- package/navigation/README.md +374 -0
- package/package.json +81 -20
- package/sdk/README.md +212 -0
- package/sdk/schematics/collection.json +20 -0
- package/sdk/schematics/init/index.js +83 -0
- package/sdk/schematics/init/schema.json +19 -0
- package/sdk/schematics/ng-add/index.js +147 -0
- package/sdk/schematics/ng-add/schema.json +14 -0
- package/sdk/schematics/package.json +3 -0
- package/sdk/schematics/sdk/index.js +175 -0
- package/sdk/schematics/sdk/schema.json +19 -0
- package/sdk/sdk.config.example.json +24 -0
- package/sdk/src/config/loader.js +43 -0
- package/sdk/src/config/schema.js +59 -0
- package/sdk/src/emit/client.js +251 -0
- package/sdk/src/emit/metadata.js +310 -0
- package/sdk/src/emit/models.js +104 -0
- package/sdk/src/emit/navigation.js +56 -0
- package/sdk/src/emit/operations.js +118 -0
- package/sdk/src/emit/public-api.js +54 -0
- package/sdk/src/emit/services.js +110 -0
- package/sdk/src/engine.js +67 -0
- package/sdk/src/layout/per-domain.js +360 -0
- package/sdk/src/package.json +3 -0
- package/sdk/src/parser/bundle.js +25 -0
- package/sdk/src/parser/ir.js +429 -0
- package/sdk/src/parser/types.js +7 -0
- package/sdk/src/render/template.js +152 -0
- package/sdk/src/writer/index.js +286 -0
- package/theme/README.md +126 -0
- package/theme/component/settings/README.md +135 -0
- package/theme/layout/README.md +539 -0
- package/theme/page/README.md +453 -0
- package/theme/shell/README.md +340 -0
- package/theme/styles/README.md +178 -0
- package/theme/styles/css/base/components.css +553 -0
- package/theme/styles/css/base/index.css +14 -0
- package/theme/styles/css/base/package.css +9 -0
- package/theme/styles/css/base/prefers-dark.css +86 -0
- package/theme/styles/css/base/print.css +62 -0
- package/theme/styles/css/base/status.css +38 -0
- package/theme/styles/css/base/tailwind.css +165 -0
- package/theme/styles/css/base/theme.css +373 -0
- package/theme/styles/css/base/tokens.css +361 -0
- package/theme/styles/css/color/amber.css +72 -0
- package/theme/styles/css/color/blue.css +72 -0
- package/theme/styles/css/color/brand.css +38 -0
- package/theme/styles/css/color/cyan.css +72 -0
- package/theme/styles/css/color/emerald.css +72 -0
- package/theme/styles/css/color/fuchsia.css +72 -0
- package/theme/styles/css/color/green.css +72 -0
- package/theme/styles/css/color/index.css +19 -0
- package/theme/styles/css/color/indigo.css +72 -0
- package/theme/styles/css/color/lime.css +72 -0
- package/theme/styles/css/color/orange.css +72 -0
- package/theme/styles/css/color/pink.css +72 -0
- package/theme/styles/css/color/purple.css +72 -0
- package/theme/styles/css/color/red.css +72 -0
- package/theme/styles/css/color/rose.css +72 -0
- package/theme/styles/css/color/sky.css +72 -0
- package/theme/styles/css/color/teal.css +72 -0
- package/theme/styles/css/color/violet.css +72 -0
- package/theme/styles/css/color/yellow.css +72 -0
- package/theme/styles/css/index.css +18 -0
- package/theme/styles/css/neutral/gray.css +63 -0
- package/theme/styles/css/neutral/index.css +11 -0
- package/theme/styles/css/neutral/mauve.css +63 -0
- package/theme/styles/css/neutral/mist.css +63 -0
- package/theme/styles/css/neutral/neutral.css +63 -0
- package/theme/styles/css/neutral/olive.css +63 -0
- package/theme/styles/css/neutral/slate.css +63 -0
- package/theme/styles/css/neutral/stone.css +63 -0
- package/theme/styles/css/neutral/taupe.css +63 -0
- package/theme/styles/css/neutral/zinc.css +63 -0
- package/theme/styles/css/radius/index.css +30 -0
- package/theme/styles/css/space/index.css +20 -0
- package/types/ojiepermana-angular-chart-area.d.ts +76 -1
- package/types/ojiepermana-angular-chart-bar.d.ts +201 -1
- package/types/ojiepermana-angular-chart-core.d.ts +811 -1
- package/types/ojiepermana-angular-chart-line.d.ts +75 -1
- package/types/ojiepermana-angular-chart-pie.d.ts +131 -1
- package/types/ojiepermana-angular-chart-primitives.d.ts +291 -1
- package/types/ojiepermana-angular-chart-radar.d.ts +116 -1
- package/types/ojiepermana-angular-chart-radial.d.ts +116 -1
- package/types/ojiepermana-angular-chart-scatter.d.ts +125 -1
- package/types/ojiepermana-angular-chart.d.ts +2 -1
- package/types/ojiepermana-angular-component-accordion.d.ts +85 -1
- package/types/ojiepermana-angular-component-alert-dialog.d.ts +140 -1
- package/types/ojiepermana-angular-component-alert.d.ts +42 -1
- package/types/ojiepermana-angular-component-aspect-ratio.d.ts +12 -1
- package/types/ojiepermana-angular-component-avatar.d.ts +56 -1
- package/types/ojiepermana-angular-component-badge.d.ts +24 -1
- package/types/ojiepermana-angular-component-breadcrumb.d.ts +46 -1
- package/types/ojiepermana-angular-component-button-group.d.ts +26 -1
- package/types/ojiepermana-angular-component-button.d.ts +27 -1
- package/types/ojiepermana-angular-component-calendar.d.ts +111 -1
- package/types/ojiepermana-angular-component-card.d.ts +69 -1
- package/types/ojiepermana-angular-component-carousel.d.ts +86 -1
- package/types/ojiepermana-angular-component-checkbox.d.ts +42 -1
- package/types/ojiepermana-angular-component-collapsible.d.ts +42 -1
- package/types/ojiepermana-angular-component-combobox.d.ts +60 -1
- package/types/ojiepermana-angular-component-command.d.ts +130 -1
- package/types/ojiepermana-angular-component-composer.d.ts +90 -1
- package/types/ojiepermana-angular-component-context-menu.d.ts +54 -1
- package/types/ojiepermana-angular-component-date-picker.d.ts +109 -1
- package/types/ojiepermana-angular-component-dialog.d.ts +136 -1
- package/types/ojiepermana-angular-component-drawer.d.ts +1 -1
- package/types/ojiepermana-angular-component-dropdown-menu.d.ts +248 -1
- package/types/ojiepermana-angular-component-editor.d.ts +135 -1
- package/types/ojiepermana-angular-component-empty.d.ts +50 -1
- package/types/ojiepermana-angular-component-form.d.ts +159 -1
- package/types/ojiepermana-angular-component-hover-card.d.ts +75 -1
- package/types/ojiepermana-angular-component-icon.d.ts +89 -1
- package/types/ojiepermana-angular-component-input-group.d.ts +51 -1
- package/types/ojiepermana-angular-component-input-otp.d.ts +155 -1
- package/types/ojiepermana-angular-component-input.d.ts +21 -1
- package/types/ojiepermana-angular-component-item.d.ts +93 -1
- package/types/ojiepermana-angular-component-kanban.d.ts +70 -1
- package/types/ojiepermana-angular-component-kbd.d.ts +16 -1
- package/types/ojiepermana-angular-component-label.d.ts +11 -1
- package/types/ojiepermana-angular-component-menubar.d.ts +93 -1
- package/types/ojiepermana-angular-component-native-select.d.ts +26 -1
- package/types/ojiepermana-angular-component-navigation-menu.d.ts +104 -1
- package/types/ojiepermana-angular-component-pagination.d.ts +33 -1
- package/types/ojiepermana-angular-component-pillbox.d.ts +222 -1
- package/types/ojiepermana-angular-component-popover.d.ts +66 -1
- package/types/ojiepermana-angular-component-progress.d.ts +17 -1
- package/types/ojiepermana-angular-component-radio.d.ts +60 -1
- package/types/ojiepermana-angular-component-resizable.d.ts +117 -1
- package/types/ojiepermana-angular-component-scroll-area.d.ts +19 -1
- package/types/ojiepermana-angular-component-segmented-control.d.ts +58 -1
- package/types/ojiepermana-angular-component-select.d.ts +122 -1
- package/types/ojiepermana-angular-component-separator.d.ts +14 -1
- package/types/ojiepermana-angular-component-sheet.d.ts +130 -1
- package/types/ojiepermana-angular-component-skeleton.d.ts +10 -1
- package/types/ojiepermana-angular-component-slider.d.ts +83 -1
- package/types/ojiepermana-angular-component-spinner.d.ts +13 -1
- package/types/ojiepermana-angular-component-switch.d.ts +44 -1
- package/types/ojiepermana-angular-component-table.d.ts +57 -1
- package/types/ojiepermana-angular-component-tabs.d.ts +124 -1
- package/types/ojiepermana-angular-component-textarea.d.ts +17 -1
- package/types/ojiepermana-angular-component-timeline.d.ts +64 -1
- package/types/ojiepermana-angular-component-toast.d.ts +64 -1
- package/types/ojiepermana-angular-component-toggle-group.d.ts +90 -1
- package/types/ojiepermana-angular-component-toggle.d.ts +25 -1
- package/types/ojiepermana-angular-component-tooltip.d.ts +143 -1
- package/types/ojiepermana-angular-component-utils-core.d.ts +184 -1
- package/types/ojiepermana-angular-component-utils-overlay.d.ts +21 -1
- package/types/ojiepermana-angular-component-utils-scale.d.ts +19 -1
- package/types/ojiepermana-angular-component-utils.d.ts +2 -1
- package/types/ojiepermana-angular-component.d.ts +2 -1
- package/types/ojiepermana-angular-navigation-core.d.ts +59 -1
- package/types/ojiepermana-angular-navigation-icon.d.ts +12 -1
- package/types/ojiepermana-angular-navigation-service.d.ts +116 -1
- package/types/ojiepermana-angular-navigation-types.d.ts +144 -1
- package/types/ojiepermana-angular-navigation.d.ts +507 -1
- package/types/ojiepermana-angular-sdk.d.ts +89 -1
- package/types/ojiepermana-angular-theme-component-settings.d.ts +154 -1
- package/types/ojiepermana-angular-theme-layout-services.d.ts +147 -1
- package/types/ojiepermana-angular-theme-layout-types.d.ts +40 -1
- package/types/ojiepermana-angular-theme-layout-wrapper.d.ts +299 -1
- package/types/ojiepermana-angular-theme-layout.d.ts +129 -1
- package/types/ojiepermana-angular-theme-page-core.d.ts +157 -1
- package/types/ojiepermana-angular-theme-page-filter.d.ts +77 -1
- package/types/ojiepermana-angular-theme-page-root.d.ts +88 -1
- package/types/ojiepermana-angular-theme-page-side.d.ts +50 -1
- package/types/ojiepermana-angular-theme-page-slots.d.ts +40 -1
- package/types/ojiepermana-angular-theme-page.d.ts +5 -1
- package/types/ojiepermana-angular-theme-shell-services.d.ts +193 -1
- package/types/ojiepermana-angular-theme-shell-types.d.ts +105 -1
- package/types/ojiepermana-angular-theme-shell.d.ts +100 -1
- package/types/ojiepermana-angular-theme-styles.d.ts +319 -1
- package/types/ojiepermana-angular-theme.d.ts +2 -1
- package/types/ojiepermana-angular.d.ts +5 -5
|
@@ -1,7 +1,245 @@
|
|
|
1
|
-
|
|
1
|
+
import { DOCUMENT } from '@angular/common';
|
|
2
|
+
import * as i0 from '@angular/core';
|
|
3
|
+
import { inject, DestroyRef, Service } from '@angular/core';
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
const DEFAULT_TOAST_DURATION_MS = 5000;
|
|
6
|
+
const VARIANT_CLASSES = {
|
|
7
|
+
default: 'border-border bg-background text-foreground',
|
|
8
|
+
destructive: 'border-destructive/50 bg-destructive text-destructive-foreground',
|
|
9
|
+
success: 'border-success/50 bg-success text-success-foreground',
|
|
10
|
+
info: 'border-info/50 bg-info text-info-foreground',
|
|
11
|
+
warning: 'border-warning/50 bg-warning text-warning-foreground',
|
|
12
|
+
};
|
|
13
|
+
const resolveToastMessage = (message, value) => typeof message === 'function' ? message(value) : message;
|
|
14
|
+
/**
|
|
15
|
+
* Signal-era toast tanpa dependensi Material: stack dirender ke sebuah live
|
|
16
|
+
* region (`role="status"`, `aria-live="polite"`) sehingga screen reader
|
|
17
|
+
* mengumumkan setiap toast.
|
|
18
|
+
*/
|
|
19
|
+
class ToastService {
|
|
20
|
+
documentRef = inject(DOCUMENT, { optional: true });
|
|
21
|
+
container = null;
|
|
22
|
+
active = new Map();
|
|
23
|
+
constructor() {
|
|
24
|
+
// The live region is created as soon as the service is injected, and it is
|
|
25
|
+
// never taken away again.
|
|
26
|
+
//
|
|
27
|
+
// A screen reader only announces content that appears INSIDE a live region
|
|
28
|
+
// that was already there. Creating the region together with the first toast
|
|
29
|
+
// meant the first message was silently missed, and removing the region when
|
|
30
|
+
// the stack emptied made the next first message miss too. An empty region
|
|
31
|
+
// costs nothing: it is fixed, has no background, and ignores the pointer.
|
|
32
|
+
const doc = this.documentRef;
|
|
33
|
+
if (doc) {
|
|
34
|
+
this.ensureContainer(doc);
|
|
35
|
+
inject(DestroyRef).onDestroy(() => {
|
|
36
|
+
this.container?.remove();
|
|
37
|
+
this.container = null;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
show(options) {
|
|
42
|
+
const doc = this.documentRef;
|
|
43
|
+
if (!doc) {
|
|
44
|
+
return { dismiss: () => { }, afterDismissed: Promise.resolve({ dismissedByAction: false }) };
|
|
45
|
+
}
|
|
46
|
+
const variant = options.variant ?? 'default';
|
|
47
|
+
const container = this.ensureContainer(doc);
|
|
48
|
+
// Only move the container while it is empty. The container outlives its
|
|
49
|
+
// toasts now, so repositioning it for a later toast would teleport the ones
|
|
50
|
+
// already on screen out from under the reader.
|
|
51
|
+
if (this.active.size === 0) {
|
|
52
|
+
this.applyPosition(container, options);
|
|
53
|
+
}
|
|
54
|
+
const toast = doc.createElement('div');
|
|
55
|
+
toast.className = [
|
|
56
|
+
'toast-panel pointer-events-auto flex w-80 items-start gap-3 rounded-md border p-4 shadow-lg',
|
|
57
|
+
`toast-${variant}`,
|
|
58
|
+
VARIANT_CLASSES[variant],
|
|
59
|
+
].join(' ');
|
|
60
|
+
toast.setAttribute('data-variant', variant);
|
|
61
|
+
const body = doc.createElement('div');
|
|
62
|
+
body.className = 'flex min-w-0 flex-1 flex-col gap-1';
|
|
63
|
+
if (options.title) {
|
|
64
|
+
const title = doc.createElement('p');
|
|
65
|
+
title.className = 'text-sm font-semibold leading-tight';
|
|
66
|
+
title.textContent = options.title;
|
|
67
|
+
body.appendChild(title);
|
|
68
|
+
}
|
|
69
|
+
if (options.description) {
|
|
70
|
+
const description = doc.createElement('p');
|
|
71
|
+
description.className = 'text-sm leading-snug opacity-90';
|
|
72
|
+
description.textContent = options.description;
|
|
73
|
+
body.appendChild(description);
|
|
74
|
+
}
|
|
75
|
+
toast.appendChild(body);
|
|
76
|
+
let resolveDismiss = () => { };
|
|
77
|
+
const afterDismissed = new Promise((resolve) => {
|
|
78
|
+
resolveDismiss = resolve;
|
|
79
|
+
});
|
|
80
|
+
let timeoutId = null;
|
|
81
|
+
const duration = options.durationMs === null ? null : (options.durationMs ?? DEFAULT_TOAST_DURATION_MS);
|
|
82
|
+
let remainingMs = duration;
|
|
83
|
+
let timerStartedAt = 0;
|
|
84
|
+
const clearTimer = () => {
|
|
85
|
+
if (timeoutId !== null) {
|
|
86
|
+
(doc.defaultView ?? globalThis).clearTimeout(timeoutId);
|
|
87
|
+
timeoutId = null;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
const dismiss = (dismissedByAction = false) => {
|
|
91
|
+
clearTimer();
|
|
92
|
+
if (!this.active.delete(toast)) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
toast.remove();
|
|
96
|
+
// The container stays: see the constructor. Removing it here is what made
|
|
97
|
+
// the next first toast go unannounced.
|
|
98
|
+
resolveDismiss({ dismissedByAction });
|
|
99
|
+
};
|
|
100
|
+
const resumeTimer = () => {
|
|
101
|
+
if (remainingMs === null || timeoutId !== null) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (remainingMs <= 0) {
|
|
105
|
+
dismiss(false);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
timerStartedAt = Date.now();
|
|
109
|
+
timeoutId = (doc.defaultView ?? globalThis).setTimeout(() => {
|
|
110
|
+
timeoutId = null;
|
|
111
|
+
remainingMs = 0;
|
|
112
|
+
dismiss(false);
|
|
113
|
+
}, remainingMs);
|
|
114
|
+
};
|
|
115
|
+
const pauseTimer = () => {
|
|
116
|
+
if (remainingMs === null || timeoutId === null) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
remainingMs = Math.max(0, remainingMs - (Date.now() - timerStartedAt));
|
|
120
|
+
clearTimer();
|
|
121
|
+
};
|
|
122
|
+
if (options.action) {
|
|
123
|
+
const action = doc.createElement('button');
|
|
124
|
+
action.type = 'button';
|
|
125
|
+
action.className =
|
|
126
|
+
'shrink-0 rounded-md border border-current/30 px-2 py-1 text-xs font-medium transition-opacity hover:opacity-80';
|
|
127
|
+
action.textContent = options.action;
|
|
128
|
+
action.addEventListener('click', () => dismiss(true), { once: true });
|
|
129
|
+
toast.appendChild(action);
|
|
130
|
+
}
|
|
131
|
+
const dismissButton = doc.createElement('button');
|
|
132
|
+
dismissButton.type = 'button';
|
|
133
|
+
dismissButton.className =
|
|
134
|
+
'toast-dismiss shrink-0 rounded-md p-1 text-current/80 transition-opacity hover:opacity-100';
|
|
135
|
+
dismissButton.setAttribute('aria-label', options.dismissLabel ?? 'Dismiss notification');
|
|
136
|
+
const dismissIcon = doc.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
137
|
+
dismissIcon.setAttribute('aria-hidden', 'true');
|
|
138
|
+
dismissIcon.setAttribute('viewBox', '0 0 24 24');
|
|
139
|
+
dismissIcon.setAttribute('width', '16');
|
|
140
|
+
dismissIcon.setAttribute('height', '16');
|
|
141
|
+
dismissIcon.setAttribute('fill', 'none');
|
|
142
|
+
dismissIcon.setAttribute('stroke', 'currentColor');
|
|
143
|
+
dismissIcon.setAttribute('stroke-width', '2');
|
|
144
|
+
const dismissPath = doc.createElementNS('http://www.w3.org/2000/svg', 'path');
|
|
145
|
+
dismissPath.setAttribute('d', 'M6 6l12 12M18 6 6 18');
|
|
146
|
+
dismissIcon.appendChild(dismissPath);
|
|
147
|
+
dismissButton.appendChild(dismissIcon);
|
|
148
|
+
dismissButton.addEventListener('click', () => dismiss(false), { once: true });
|
|
149
|
+
toast.appendChild(dismissButton);
|
|
150
|
+
container.appendChild(toast);
|
|
151
|
+
this.active.set(toast, dismiss);
|
|
152
|
+
if (duration !== null && (options.pauseOnInteraction ?? true)) {
|
|
153
|
+
toast.addEventListener('pointerenter', pauseTimer);
|
|
154
|
+
toast.addEventListener('pointerleave', resumeTimer);
|
|
155
|
+
toast.addEventListener('focusin', pauseTimer);
|
|
156
|
+
toast.addEventListener('focusout', (event) => {
|
|
157
|
+
if (!toast.contains(event.relatedTarget)) {
|
|
158
|
+
resumeTimer();
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
resumeTimer();
|
|
163
|
+
return { dismiss: () => dismiss(false), afterDismissed };
|
|
164
|
+
}
|
|
165
|
+
success(opts) {
|
|
166
|
+
return this.show({ ...opts, variant: 'success' });
|
|
167
|
+
}
|
|
168
|
+
info(opts) {
|
|
169
|
+
return this.show({ ...opts, variant: 'info' });
|
|
170
|
+
}
|
|
171
|
+
warning(opts) {
|
|
172
|
+
return this.show({ ...opts, variant: 'warning' });
|
|
173
|
+
}
|
|
174
|
+
error(opts) {
|
|
175
|
+
return this.show({ ...opts, variant: 'destructive' });
|
|
176
|
+
}
|
|
177
|
+
async promise(taskOrFactory, messages) {
|
|
178
|
+
const loading = this.show({ title: messages.loading, durationMs: null });
|
|
179
|
+
try {
|
|
180
|
+
const task = typeof taskOrFactory === 'function' ? taskOrFactory() : taskOrFactory;
|
|
181
|
+
const value = await task;
|
|
182
|
+
loading.dismiss();
|
|
183
|
+
this.success({ title: resolveToastMessage(messages.success, value) });
|
|
184
|
+
return value;
|
|
185
|
+
}
|
|
186
|
+
catch (error) {
|
|
187
|
+
loading.dismiss();
|
|
188
|
+
this.error({ title: resolveToastMessage(messages.error, error) });
|
|
189
|
+
throw error;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
dismiss() {
|
|
193
|
+
for (const dismiss of [...this.active.values()]) {
|
|
194
|
+
dismiss(false);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
ensureContainer(doc) {
|
|
198
|
+
if (this.container?.isConnected) {
|
|
199
|
+
return this.container;
|
|
200
|
+
}
|
|
201
|
+
const container = doc.createElement('div');
|
|
202
|
+
container.className = 'toast-container pointer-events-none fixed z-50 flex flex-col gap-2 p-4';
|
|
203
|
+
container.setAttribute('role', 'status');
|
|
204
|
+
container.setAttribute('aria-live', 'polite');
|
|
205
|
+
doc.body.appendChild(container);
|
|
206
|
+
this.container = container;
|
|
207
|
+
return container;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Position the persistent container for the toast being shown.
|
|
211
|
+
*
|
|
212
|
+
* Applied only when the stack is empty (see {@link show}), so a run of toasts
|
|
213
|
+
* shares one corner and nothing already visible jumps. The previous corner is
|
|
214
|
+
* cleared first, so switching corners between runs works.
|
|
215
|
+
*/
|
|
216
|
+
applyPosition(container, options) {
|
|
217
|
+
for (const property of ['top', 'bottom', 'left', 'right', 'transform']) {
|
|
218
|
+
container.style.removeProperty(property);
|
|
219
|
+
}
|
|
220
|
+
const vertical = options.verticalPosition ?? 'bottom';
|
|
221
|
+
const horizontal = options.horizontalPosition ?? 'end';
|
|
222
|
+
container.style.setProperty(vertical === 'top' ? 'top' : 'bottom', '0');
|
|
223
|
+
if (horizontal === 'center') {
|
|
224
|
+
container.style.setProperty('left', '50%');
|
|
225
|
+
container.style.setProperty('transform', 'translateX(-50%)');
|
|
226
|
+
}
|
|
227
|
+
else if (horizontal === 'start' || horizontal === 'left') {
|
|
228
|
+
container.style.setProperty('left', '0');
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
container.style.setProperty('right', '0');
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.4", ngImport: i0, type: ToastService, deps: [], target: i0.ɵɵFactoryTarget.Service });
|
|
235
|
+
static ɵprov = i0.ɵɵngDeclareService({ minVersion: "22.0.0", version: "22.1.4", ngImport: i0, type: ToastService });
|
|
236
|
+
}
|
|
237
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.4", ngImport: i0, type: ToastService, decorators: [{
|
|
238
|
+
type: Service
|
|
239
|
+
}], ctorParameters: () => [] });
|
|
4
240
|
|
|
5
241
|
/**
|
|
6
242
|
* Generated bundle index. Do not edit.
|
|
7
|
-
*/
|
|
243
|
+
*/
|
|
244
|
+
|
|
245
|
+
export { ToastService };
|
|
@@ -1,7 +1,294 @@
|
|
|
1
|
-
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Directive, input, model, numberAttribute, inject, ElementRef, signal, computed, forwardRef, Component } from '@angular/core';
|
|
3
|
+
import { toggleVariants } from '@ojiepermana/angular/component/toggle';
|
|
4
|
+
import { cn } from '@ojiepermana/angular/component/utils/core';
|
|
2
5
|
|
|
3
|
-
|
|
6
|
+
const spacingClasses = {
|
|
7
|
+
0: '',
|
|
8
|
+
1: 'gap-1',
|
|
9
|
+
2: 'gap-2',
|
|
10
|
+
3: 'gap-3',
|
|
11
|
+
4: 'gap-4',
|
|
12
|
+
};
|
|
13
|
+
const connectedItemClasses = {
|
|
14
|
+
horizontal: [
|
|
15
|
+
'[&>[data-slot=toggle-group-item]:not(:first-child)]:rounded-s-none',
|
|
16
|
+
'[&>[data-slot=toggle-group-item]:not(:first-child)]:[border-inline-start-width:0]',
|
|
17
|
+
'[&>[data-slot=toggle-group-item]:not(:last-child)]:rounded-e-none',
|
|
18
|
+
].join(' '),
|
|
19
|
+
vertical: [
|
|
20
|
+
'[&>[data-slot=toggle-group-item]:not(:first-child)]:rounded-t-none',
|
|
21
|
+
'[&>[data-slot=toggle-group-item]:not(:first-child)]:border-t-0',
|
|
22
|
+
'[&>[data-slot=toggle-group-item]:not(:last-child)]:rounded-b-none',
|
|
23
|
+
].join(' '),
|
|
24
|
+
};
|
|
25
|
+
class ToggleGroupContextBase {
|
|
26
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.4", ngImport: i0, type: ToggleGroupContextBase, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
27
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.1.4", type: ToggleGroupContextBase, isStandalone: true, ngImport: i0 });
|
|
28
|
+
}
|
|
29
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.4", ngImport: i0, type: ToggleGroupContextBase, decorators: [{
|
|
30
|
+
type: Directive
|
|
31
|
+
}] });
|
|
32
|
+
class ToggleGroupComponent extends ToggleGroupContextBase {
|
|
33
|
+
type = input.required(/* @ts-ignore */
|
|
34
|
+
...(ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []));
|
|
35
|
+
value = model(null, /* @ts-ignore */
|
|
36
|
+
...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
37
|
+
values = model([], /* @ts-ignore */
|
|
38
|
+
...(ngDevMode ? [{ debugName: "values" }] : /* istanbul ignore next */ []));
|
|
39
|
+
orientation = input('horizontal', /* @ts-ignore */
|
|
40
|
+
...(ngDevMode ? [{ debugName: "orientation" }] : /* istanbul ignore next */ []));
|
|
41
|
+
variant = input('default', /* @ts-ignore */
|
|
42
|
+
...(ngDevMode ? [{ debugName: "variant" }] : /* istanbul ignore next */ []));
|
|
43
|
+
size = input('default', /* @ts-ignore */
|
|
44
|
+
...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
|
|
45
|
+
spacing = input(2, { ...(ngDevMode ? { debugName: "spacing" } : /* istanbul ignore next */ {}), transform: numberAttribute });
|
|
46
|
+
loop = input(true, /* @ts-ignore */
|
|
47
|
+
...(ngDevMode ? [{ debugName: "loop" }] : /* istanbul ignore next */ []));
|
|
48
|
+
disabled = input(false, /* @ts-ignore */
|
|
49
|
+
...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
50
|
+
dir = input(null, /* @ts-ignore */
|
|
51
|
+
...(ngDevMode ? [{ debugName: "dir" }] : /* istanbul ignore next */ []));
|
|
52
|
+
class = input('', /* @ts-ignore */
|
|
53
|
+
...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
54
|
+
host = inject(ElementRef);
|
|
55
|
+
focusedValue = signal(null, /* @ts-ignore */
|
|
56
|
+
...(ngDevMode ? [{ debugName: "focusedValue" }] : /* istanbul ignore next */ []));
|
|
57
|
+
registrationVersion = signal(0, /* @ts-ignore */
|
|
58
|
+
...(ngDevMode ? [{ debugName: "registrationVersion" }] : /* istanbul ignore next */ []));
|
|
59
|
+
items = new Map();
|
|
60
|
+
resolvedSpacing = computed(() => normalizeSpacing(this.spacing()), /* @ts-ignore */
|
|
61
|
+
...(ngDevMode ? [{ debugName: "resolvedSpacing" }] : /* istanbul ignore next */ []));
|
|
62
|
+
tabStopValue = computed(() => {
|
|
63
|
+
this.registrationVersion();
|
|
64
|
+
const enabledItems = this.enabledItems();
|
|
65
|
+
if (enabledItems.length === 0)
|
|
66
|
+
return null;
|
|
67
|
+
const current = this.focusedValue();
|
|
68
|
+
if (current && enabledItems.some((item) => item.value() === current)) {
|
|
69
|
+
return current;
|
|
70
|
+
}
|
|
71
|
+
const selected = enabledItems.find((item) => this.isSelected(item.value()));
|
|
72
|
+
return selected?.value() ?? enabledItems[0].value();
|
|
73
|
+
}, /* @ts-ignore */
|
|
74
|
+
...(ngDevMode ? [{ debugName: "tabStopValue" }] : /* istanbul ignore next */ []));
|
|
75
|
+
classes = computed(() => cn('inline-flex w-fit', this.orientation() === 'vertical' ? 'flex-col items-stretch' : 'items-center', spacingClasses[this.resolvedSpacing()], this.resolvedSpacing() === 0 && connectedItemClasses[this.orientation()], this.class()), /* @ts-ignore */
|
|
76
|
+
...(ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []));
|
|
77
|
+
groupType() {
|
|
78
|
+
return this.type();
|
|
79
|
+
}
|
|
80
|
+
groupOrientation() {
|
|
81
|
+
return this.orientation();
|
|
82
|
+
}
|
|
83
|
+
groupVariant() {
|
|
84
|
+
return this.variant();
|
|
85
|
+
}
|
|
86
|
+
groupSize() {
|
|
87
|
+
return this.size();
|
|
88
|
+
}
|
|
89
|
+
groupDisabled() {
|
|
90
|
+
return this.disabled();
|
|
91
|
+
}
|
|
92
|
+
isRtl() {
|
|
93
|
+
const explicitDir = this.dir();
|
|
94
|
+
if (explicitDir)
|
|
95
|
+
return explicitDir === 'rtl';
|
|
96
|
+
const host = this.host.nativeElement;
|
|
97
|
+
const nearestDir = host.closest('[dir]')?.getAttribute('dir');
|
|
98
|
+
if (nearestDir === 'rtl' || nearestDir === 'ltr') {
|
|
99
|
+
return nearestDir === 'rtl';
|
|
100
|
+
}
|
|
101
|
+
return getComputedStyle(host).direction === 'rtl';
|
|
102
|
+
}
|
|
103
|
+
register(element, value, disabled) {
|
|
104
|
+
this.items.set(element, { element, value, disabled });
|
|
105
|
+
this.bumpRegistrationVersion();
|
|
106
|
+
}
|
|
107
|
+
unregister(element) {
|
|
108
|
+
this.items.delete(element);
|
|
109
|
+
this.bumpRegistrationVersion();
|
|
110
|
+
}
|
|
111
|
+
isSelected(value) {
|
|
112
|
+
return this.type() === 'multiple' ? this.values().includes(value) : this.value() === value;
|
|
113
|
+
}
|
|
114
|
+
toggle(value) {
|
|
115
|
+
const item = this.itemForValue(value);
|
|
116
|
+
if (!item || this.disabled() || item.disabled())
|
|
117
|
+
return;
|
|
118
|
+
this.focusedValue.set(value);
|
|
119
|
+
if (this.type() === 'multiple') {
|
|
120
|
+
this.values.update((current) => current.includes(value)
|
|
121
|
+
? current.filter((itemValue) => itemValue !== value)
|
|
122
|
+
: [...current, value]);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
this.value.set(this.value() === value ? null : value);
|
|
126
|
+
}
|
|
127
|
+
tabindexFor(value, disabled) {
|
|
128
|
+
if (this.disabled() || disabled)
|
|
129
|
+
return -1;
|
|
130
|
+
return this.tabStopValue() === value ? 0 : -1;
|
|
131
|
+
}
|
|
132
|
+
markFocused(value) {
|
|
133
|
+
const item = this.itemForValue(value);
|
|
134
|
+
if (!item || this.disabled() || item.disabled())
|
|
135
|
+
return;
|
|
136
|
+
this.focusedValue.set(value);
|
|
137
|
+
}
|
|
138
|
+
focusNext(from, offset) {
|
|
139
|
+
const enabledItems = this.enabledItems();
|
|
140
|
+
const currentIndex = enabledItems.findIndex((item) => item.element === from);
|
|
141
|
+
if (currentIndex < 0 || enabledItems.length === 0)
|
|
142
|
+
return;
|
|
143
|
+
let nextIndex = currentIndex + offset;
|
|
144
|
+
if (this.loop()) {
|
|
145
|
+
nextIndex = (nextIndex + enabledItems.length) % enabledItems.length;
|
|
146
|
+
}
|
|
147
|
+
else if (nextIndex < 0 || nextIndex >= enabledItems.length) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
const next = enabledItems[nextIndex];
|
|
151
|
+
this.focusedValue.set(next.value());
|
|
152
|
+
next.element.focus();
|
|
153
|
+
}
|
|
154
|
+
focusFirst() {
|
|
155
|
+
const first = this.enabledItems()[0];
|
|
156
|
+
if (!first)
|
|
157
|
+
return;
|
|
158
|
+
this.focusedValue.set(first.value());
|
|
159
|
+
first.element.focus();
|
|
160
|
+
}
|
|
161
|
+
focusLast() {
|
|
162
|
+
const enabledItems = this.enabledItems();
|
|
163
|
+
const last = enabledItems[enabledItems.length - 1];
|
|
164
|
+
if (!last)
|
|
165
|
+
return;
|
|
166
|
+
this.focusedValue.set(last.value());
|
|
167
|
+
last.element.focus();
|
|
168
|
+
}
|
|
169
|
+
enabledItems() {
|
|
170
|
+
return [...this.items.values()].filter((item) => !item.disabled());
|
|
171
|
+
}
|
|
172
|
+
itemForValue(value) {
|
|
173
|
+
return [...this.items.values()].find((item) => item.value() === value);
|
|
174
|
+
}
|
|
175
|
+
bumpRegistrationVersion() {
|
|
176
|
+
this.registrationVersion.update((version) => version + 1);
|
|
177
|
+
}
|
|
178
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.4", ngImport: i0, type: ToggleGroupComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
179
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.1.4", type: ToggleGroupComponent, isStandalone: true, selector: "ToggleGroup", inputs: { type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: true, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, values: { classPropertyName: "values", publicName: "values", isSignal: true, isRequired: false, transformFunction: null }, orientation: { classPropertyName: "orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null }, variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, spacing: { classPropertyName: "spacing", publicName: "spacing", isSignal: true, isRequired: false, transformFunction: null }, loop: { classPropertyName: "loop", publicName: "loop", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, dir: { classPropertyName: "dir", publicName: "dir", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange", values: "valuesChange" }, host: { properties: { "class": "classes()", "attr.role": "\"group\"", "attr.dir": "dir() ?? null", "attr.data-disabled": "disabled() ? \"\" : null", "attr.data-orientation": "orientation()", "attr.data-slot": "\"toggle-group\"", "attr.data-type": "type()" } }, providers: [
|
|
180
|
+
{ provide: ToggleGroupContextBase, useExisting: forwardRef(() => ToggleGroupComponent) },
|
|
181
|
+
], usesInheritance: true, ngImport: i0, template: `<ng-content />`, isInline: true });
|
|
182
|
+
}
|
|
183
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.4", ngImport: i0, type: ToggleGroupComponent, decorators: [{
|
|
184
|
+
type: Component,
|
|
185
|
+
args: [{
|
|
186
|
+
selector: 'ToggleGroup',
|
|
187
|
+
providers: [
|
|
188
|
+
{ provide: ToggleGroupContextBase, useExisting: forwardRef(() => ToggleGroupComponent) },
|
|
189
|
+
],
|
|
190
|
+
host: {
|
|
191
|
+
'[class]': 'classes()',
|
|
192
|
+
'[attr.role]': '"group"',
|
|
193
|
+
'[attr.dir]': 'dir() ?? null',
|
|
194
|
+
// aria-orientation is not allowed on role="group" (axe aria-allowed-attr);
|
|
195
|
+
// data-orientation below drives the visual layout instead.
|
|
196
|
+
'[attr.data-disabled]': 'disabled() ? "" : null',
|
|
197
|
+
'[attr.data-orientation]': 'orientation()',
|
|
198
|
+
'[attr.data-slot]': '"toggle-group"',
|
|
199
|
+
'[attr.data-type]': 'type()',
|
|
200
|
+
},
|
|
201
|
+
template: `<ng-content />`,
|
|
202
|
+
}]
|
|
203
|
+
}], propDecorators: { type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: true }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], values: [{ type: i0.Input, args: [{ isSignal: true, alias: "values", required: false }] }, { type: i0.Output, args: ["valuesChange"] }], orientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "orientation", required: false }] }], variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], spacing: [{ type: i0.Input, args: [{ isSignal: true, alias: "spacing", required: false }] }], loop: [{ type: i0.Input, args: [{ isSignal: true, alias: "loop", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], dir: [{ type: i0.Input, args: [{ isSignal: true, alias: "dir", required: false }] }], class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
204
|
+
class ToggleGroupItemDirective {
|
|
205
|
+
ctx = inject(ToggleGroupContextBase);
|
|
206
|
+
element = inject(ElementRef);
|
|
207
|
+
value = input.required(/* @ts-ignore */
|
|
208
|
+
...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
209
|
+
disabled = input(false, /* @ts-ignore */
|
|
210
|
+
...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
211
|
+
class = input('', /* @ts-ignore */
|
|
212
|
+
...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
213
|
+
selected = computed(() => this.ctx.isSelected(this.value()), /* @ts-ignore */
|
|
214
|
+
...(ngDevMode ? [{ debugName: "selected" }] : /* istanbul ignore next */ []));
|
|
215
|
+
classes = computed(() => cn(toggleVariants({ variant: this.ctx.groupVariant(), size: this.ctx.groupSize() }), this.class()), /* @ts-ignore */
|
|
216
|
+
...(ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []));
|
|
217
|
+
ngOnInit() {
|
|
218
|
+
this.ctx.register(this.element.nativeElement, this.value, this.disabled);
|
|
219
|
+
}
|
|
220
|
+
ngOnDestroy() {
|
|
221
|
+
this.ctx.unregister(this.element.nativeElement);
|
|
222
|
+
}
|
|
223
|
+
isDisabled() {
|
|
224
|
+
return this.ctx.groupDisabled() || this.disabled();
|
|
225
|
+
}
|
|
226
|
+
onClick() {
|
|
227
|
+
if (this.isDisabled())
|
|
228
|
+
return;
|
|
229
|
+
this.ctx.toggle(this.value());
|
|
230
|
+
}
|
|
231
|
+
onFocus() {
|
|
232
|
+
if (this.isDisabled())
|
|
233
|
+
return;
|
|
234
|
+
this.ctx.markFocused(this.value());
|
|
235
|
+
}
|
|
236
|
+
onArrow(event, offset) {
|
|
237
|
+
event.preventDefault();
|
|
238
|
+
this.ctx.focusNext(this.element.nativeElement, offset);
|
|
239
|
+
}
|
|
240
|
+
onHorizontalArrow(event, offset) {
|
|
241
|
+
event.preventDefault();
|
|
242
|
+
this.ctx.focusNext(this.element.nativeElement, this.ctx.isRtl() ? offset * -1 : offset);
|
|
243
|
+
}
|
|
244
|
+
onHome(event) {
|
|
245
|
+
event.preventDefault();
|
|
246
|
+
this.ctx.focusFirst();
|
|
247
|
+
}
|
|
248
|
+
onEnd(event) {
|
|
249
|
+
event.preventDefault();
|
|
250
|
+
this.ctx.focusLast();
|
|
251
|
+
}
|
|
252
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.4", ngImport: i0, type: ToggleGroupItemDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
253
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.1.4", type: ToggleGroupItemDirective, isStandalone: true, selector: "button[ToggleGroupItem]", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: true, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "type": "button" }, listeners: { "click": "onClick()", "focus": "onFocus()", "keydown.arrowDown": "onArrow($any($event), 1)", "keydown.arrowLeft": "onHorizontalArrow($any($event), -1)", "keydown.arrowRight": "onHorizontalArrow($any($event), 1)", "keydown.arrowUp": "onArrow($any($event), -1)", "keydown.end": "onEnd($any($event))", "keydown.home": "onHome($any($event))" }, properties: { "class": "classes()", "attr.aria-disabled": "isDisabled() ? \"true\" : null", "attr.aria-pressed": "selected()", "attr.data-disabled": "isDisabled() ? \"\" : null", "attr.data-orientation": "ctx.groupOrientation()", "attr.data-size": "ctx.groupSize()", "attr.data-slot": "\"toggle-group-item\"", "attr.data-state": "selected() ? \"on\" : \"off\"", "attr.data-variant": "ctx.groupVariant()", "attr.tabindex": "ctx.tabindexFor(value(), isDisabled())", "disabled": "isDisabled() || null" } }, ngImport: i0 });
|
|
254
|
+
}
|
|
255
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.4", ngImport: i0, type: ToggleGroupItemDirective, decorators: [{
|
|
256
|
+
type: Directive,
|
|
257
|
+
args: [{
|
|
258
|
+
selector: 'button[ToggleGroupItem]',
|
|
259
|
+
host: {
|
|
260
|
+
'[class]': 'classes()',
|
|
261
|
+
type: 'button',
|
|
262
|
+
'[attr.aria-disabled]': 'isDisabled() ? "true" : null',
|
|
263
|
+
'[attr.aria-pressed]': 'selected()',
|
|
264
|
+
'[attr.data-disabled]': 'isDisabled() ? "" : null',
|
|
265
|
+
'[attr.data-orientation]': 'ctx.groupOrientation()',
|
|
266
|
+
'[attr.data-size]': 'ctx.groupSize()',
|
|
267
|
+
'[attr.data-slot]': '"toggle-group-item"',
|
|
268
|
+
'[attr.data-state]': 'selected() ? "on" : "off"',
|
|
269
|
+
'[attr.data-variant]': 'ctx.groupVariant()',
|
|
270
|
+
'[attr.tabindex]': 'ctx.tabindexFor(value(), isDisabled())',
|
|
271
|
+
'[disabled]': 'isDisabled() || null',
|
|
272
|
+
'(click)': 'onClick()',
|
|
273
|
+
'(focus)': 'onFocus()',
|
|
274
|
+
'(keydown.arrowDown)': 'onArrow($any($event), 1)',
|
|
275
|
+
'(keydown.arrowLeft)': 'onHorizontalArrow($any($event), -1)',
|
|
276
|
+
'(keydown.arrowRight)': 'onHorizontalArrow($any($event), 1)',
|
|
277
|
+
'(keydown.arrowUp)': 'onArrow($any($event), -1)',
|
|
278
|
+
'(keydown.end)': 'onEnd($any($event))',
|
|
279
|
+
'(keydown.home)': 'onHome($any($event))',
|
|
280
|
+
},
|
|
281
|
+
}]
|
|
282
|
+
}], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: true }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
283
|
+
function normalizeSpacing(value) {
|
|
284
|
+
if (value in spacingClasses) {
|
|
285
|
+
return value;
|
|
286
|
+
}
|
|
287
|
+
return 2;
|
|
288
|
+
}
|
|
4
289
|
|
|
5
290
|
/**
|
|
6
291
|
* Generated bundle index. Do not edit.
|
|
7
|
-
*/
|
|
292
|
+
*/
|
|
293
|
+
|
|
294
|
+
export { ToggleGroupComponent, ToggleGroupContextBase, ToggleGroupItemDirective };
|
|
@@ -1,7 +1,80 @@
|
|
|
1
|
-
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { model, input, computed, Component } from '@angular/core';
|
|
3
|
+
import { cn } from '@ojiepermana/angular/component/utils/core';
|
|
4
|
+
import { cva } from 'class-variance-authority';
|
|
2
5
|
|
|
3
|
-
|
|
6
|
+
const toggleVariants = cva([
|
|
7
|
+
'group/toggle inline-flex cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-md',
|
|
8
|
+
'text-sm font-medium transition-colors',
|
|
9
|
+
'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',
|
|
10
|
+
'disabled:pointer-events-none disabled:opacity-50',
|
|
11
|
+
'[&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0',
|
|
12
|
+
].join(' '), {
|
|
13
|
+
variants: {
|
|
14
|
+
variant: {
|
|
15
|
+
default: [
|
|
16
|
+
'bg-transparent text-foreground',
|
|
17
|
+
'hover:bg-muted hover:text-muted-foreground',
|
|
18
|
+
'data-[state=on]:bg-accent data-[state=on]:text-accent-foreground',
|
|
19
|
+
].join(' '),
|
|
20
|
+
outline: [
|
|
21
|
+
'border border-input bg-transparent text-foreground shadow-sm',
|
|
22
|
+
'hover:bg-accent hover:text-accent-foreground',
|
|
23
|
+
'data-[state=on]:bg-accent data-[state=on]:text-accent-foreground',
|
|
24
|
+
].join(' '),
|
|
25
|
+
},
|
|
26
|
+
size: {
|
|
27
|
+
sm: 'h-control-sm min-w-control-sm px-2.5 text-xs',
|
|
28
|
+
default: 'h-control-md min-w-control-md px-3',
|
|
29
|
+
lg: 'h-control-10 min-w-control-10 px-3.5',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
defaultVariants: { variant: 'default', size: 'default' },
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
class ToggleComponent {
|
|
36
|
+
pressed = model(false, /* @ts-ignore */
|
|
37
|
+
...(ngDevMode ? [{ debugName: "pressed" }] : /* istanbul ignore next */ []));
|
|
38
|
+
disabled = input(false, /* @ts-ignore */
|
|
39
|
+
...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
40
|
+
variant = input('default', /* @ts-ignore */
|
|
41
|
+
...(ngDevMode ? [{ debugName: "variant" }] : /* istanbul ignore next */ []));
|
|
42
|
+
size = input('default', /* @ts-ignore */
|
|
43
|
+
...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
|
|
44
|
+
class = input('', /* @ts-ignore */
|
|
45
|
+
...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
46
|
+
classes = computed(() => cn(toggleVariants({ variant: this.variant(), size: this.size() }), this.class()), /* @ts-ignore */
|
|
47
|
+
...(ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []));
|
|
48
|
+
toggle() {
|
|
49
|
+
if (this.disabled()) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
this.pressed.update((pressed) => !pressed);
|
|
53
|
+
}
|
|
54
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.4", ngImport: i0, type: ToggleComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
55
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.1.4", type: ToggleComponent, isStandalone: true, selector: "button[Toggle]", inputs: { pressed: { classPropertyName: "pressed", publicName: "pressed", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { pressed: "pressedChange" }, host: { attributes: { "type": "button" }, listeners: { "click": "toggle()" }, properties: { "class": "classes()", "attr.aria-pressed": "pressed()", "attr.data-disabled": "disabled() ? \"\" : null", "attr.data-size": "size()", "attr.data-state": "pressed() ? \"on\" : \"off\"", "attr.data-variant": "variant()", "disabled": "disabled() || null" } }, ngImport: i0, template: `<ng-content />`, isInline: true });
|
|
56
|
+
}
|
|
57
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.4", ngImport: i0, type: ToggleComponent, decorators: [{
|
|
58
|
+
type: Component,
|
|
59
|
+
args: [{
|
|
60
|
+
selector: 'button[Toggle]',
|
|
61
|
+
host: {
|
|
62
|
+
'[class]': 'classes()',
|
|
63
|
+
type: 'button',
|
|
64
|
+
'[attr.aria-pressed]': 'pressed()',
|
|
65
|
+
'[attr.data-disabled]': 'disabled() ? "" : null',
|
|
66
|
+
'[attr.data-size]': 'size()',
|
|
67
|
+
'[attr.data-state]': 'pressed() ? "on" : "off"',
|
|
68
|
+
'[attr.data-variant]': 'variant()',
|
|
69
|
+
'[disabled]': 'disabled() || null',
|
|
70
|
+
'(click)': 'toggle()',
|
|
71
|
+
},
|
|
72
|
+
template: `<ng-content />`,
|
|
73
|
+
}]
|
|
74
|
+
}], propDecorators: { pressed: [{ type: i0.Input, args: [{ isSignal: true, alias: "pressed", required: false }] }, { type: i0.Output, args: ["pressedChange"] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
4
75
|
|
|
5
76
|
/**
|
|
6
77
|
* Generated bundle index. Do not edit.
|
|
7
|
-
*/
|
|
78
|
+
*/
|
|
79
|
+
|
|
80
|
+
export { ToggleComponent, toggleVariants };
|