@4sh/ui-kit 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/NOTICE +7 -0
- package/README.md +229 -0
- package/fesm2022/4sh-ui-kit-forms.mjs +501 -0
- package/fesm2022/4sh-ui-kit-forms.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-motion.mjs +155 -0
- package/fesm2022/4sh-ui-kit-motion.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-overlay.mjs +61 -0
- package/fesm2022/4sh-ui-kit-overlay.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-theming.mjs +120 -0
- package/fesm2022/4sh-ui-kit-theming.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-types.mjs +12 -0
- package/fesm2022/4sh-ui-kit-types.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-accordion.mjs +244 -0
- package/fesm2022/4sh-ui-kit-ui-accordion.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-alert.mjs +160 -0
- package/fesm2022/4sh-ui-kit-ui-alert.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-autocomplete.mjs +926 -0
- package/fesm2022/4sh-ui-kit-ui-autocomplete.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-avatar-group.mjs +34 -0
- package/fesm2022/4sh-ui-kit-ui-avatar-group.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-avatar.mjs +122 -0
- package/fesm2022/4sh-ui-kit-ui-avatar.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-badge.mjs +95 -0
- package/fesm2022/4sh-ui-kit-ui-badge.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-breadcrumb.mjs +190 -0
- package/fesm2022/4sh-ui-kit-ui-breadcrumb.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-button-split.mjs +151 -0
- package/fesm2022/4sh-ui-kit-ui-button-split.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-button.mjs +222 -0
- package/fesm2022/4sh-ui-kit-ui-button.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-card.mjs +164 -0
- package/fesm2022/4sh-ui-kit-ui-card.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-checkbox.mjs +118 -0
- package/fesm2022/4sh-ui-kit-ui-checkbox.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-chip.mjs +205 -0
- package/fesm2022/4sh-ui-kit-ui-chip.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-context-menu.mjs +219 -0
- package/fesm2022/4sh-ui-kit-ui-context-menu.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-datepicker.mjs +1508 -0
- package/fesm2022/4sh-ui-kit-ui-datepicker.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-drawer.mjs +300 -0
- package/fesm2022/4sh-ui-kit-ui-drawer.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-empty-state.mjs +148 -0
- package/fesm2022/4sh-ui-kit-ui-empty-state.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-field.mjs +102 -0
- package/fesm2022/4sh-ui-kit-ui-field.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-file-upload.mjs +568 -0
- package/fesm2022/4sh-ui-kit-ui-file-upload.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-helper.mjs +85 -0
- package/fesm2022/4sh-ui-kit-ui-helper.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-icon.mjs +98 -0
- package/fesm2022/4sh-ui-kit-ui-icon.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-image.mjs +201 -0
- package/fesm2022/4sh-ui-kit-ui-image.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-input-group.mjs +119 -0
- package/fesm2022/4sh-ui-kit-ui-input-group.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-input-mask.mjs +125 -0
- package/fesm2022/4sh-ui-kit-ui-input-mask.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-input-number.mjs +234 -0
- package/fesm2022/4sh-ui-kit-ui-input-number.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-input-otp.mjs +288 -0
- package/fesm2022/4sh-ui-kit-ui-input-otp.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-input-tags.mjs +679 -0
- package/fesm2022/4sh-ui-kit-ui-input-tags.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-input.mjs +121 -0
- package/fesm2022/4sh-ui-kit-ui-input.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-label.mjs +61 -0
- package/fesm2022/4sh-ui-kit-ui-label.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-link.mjs +147 -0
- package/fesm2022/4sh-ui-kit-ui-link.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-menu.mjs +484 -0
- package/fesm2022/4sh-ui-kit-ui-menu.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-modal.mjs +555 -0
- package/fesm2022/4sh-ui-kit-ui-modal.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-nudger.mjs +168 -0
- package/fesm2022/4sh-ui-kit-ui-nudger.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-paginator.mjs +245 -0
- package/fesm2022/4sh-ui-kit-ui-paginator.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-popover.mjs +296 -0
- package/fesm2022/4sh-ui-kit-ui-popover.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-progress-bar.mjs +124 -0
- package/fesm2022/4sh-ui-kit-ui-progress-bar.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-radio.mjs +92 -0
- package/fesm2022/4sh-ui-kit-ui-radio.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-rating.mjs +185 -0
- package/fesm2022/4sh-ui-kit-ui-rating.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-read-only.mjs +146 -0
- package/fesm2022/4sh-ui-kit-ui-read-only.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-segment-control.mjs +386 -0
- package/fesm2022/4sh-ui-kit-ui-segment-control.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-select.mjs +868 -0
- package/fesm2022/4sh-ui-kit-ui-select.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-separator.mjs +77 -0
- package/fesm2022/4sh-ui-kit-ui-separator.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-sidebar.mjs +577 -0
- package/fesm2022/4sh-ui-kit-ui-sidebar.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-skeleton.mjs +81 -0
- package/fesm2022/4sh-ui-kit-ui-skeleton.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-slider.mjs +340 -0
- package/fesm2022/4sh-ui-kit-ui-slider.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-spinner.mjs +132 -0
- package/fesm2022/4sh-ui-kit-ui-spinner.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-stepper.mjs +389 -0
- package/fesm2022/4sh-ui-kit-ui-stepper.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-table.mjs +1406 -0
- package/fesm2022/4sh-ui-kit-ui-table.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-tabs.mjs +503 -0
- package/fesm2022/4sh-ui-kit-ui-tabs.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-tag.mjs +84 -0
- package/fesm2022/4sh-ui-kit-ui-tag.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-textarea.mjs +119 -0
- package/fesm2022/4sh-ui-kit-ui-textarea.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-toast.mjs +424 -0
- package/fesm2022/4sh-ui-kit-ui-toast.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-toggle.mjs +120 -0
- package/fesm2022/4sh-ui-kit-ui-toggle.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit-ui-tooltip.mjs +445 -0
- package/fesm2022/4sh-ui-kit-ui-tooltip.mjs.map +1 -0
- package/fesm2022/4sh-ui-kit.mjs +16 -0
- package/fesm2022/4sh-ui-kit.mjs.map +1 -0
- package/package.json +287 -0
- package/styles/base/_base.scss +19 -0
- package/styles/base/_motion.scss +144 -0
- package/styles/base/_typography.scss +99 -0
- package/styles/generated/_tokens-breakpoint.scss +8 -0
- package/styles/generated/_tokens-metrics.scss +37 -0
- package/styles/generated/_tokens-primitives.scss +284 -0
- package/styles/generated/_tokens-responsive.scss +99 -0
- package/styles/generated/_tokens-semantics.scss +1274 -0
- package/styles/generated/_tokens-styles.scss +35 -0
- package/styles/generated/_tokens-transitions.scss +11 -0
- package/styles/generated/_tokens-typography.scss +14 -0
- package/styles/generated/_tokens.scss +10 -0
- package/styles/index.scss +25 -0
- package/styles/settings/_ui-config.scss +67 -0
- package/styles/utils/_functions.scss +67 -0
- package/styles/utils/_helpers.scss +129 -0
- package/styles/utils/_mixins.scss +186 -0
- package/styles/utils/_motion.scss +47 -0
- package/styles/utils/_overlay.scss +26 -0
- package/styles/utils.scss +15 -0
- package/styles.css +1 -0
- package/types/4sh-ui-kit-forms.d.ts +259 -0
- package/types/4sh-ui-kit-motion.d.ts +111 -0
- package/types/4sh-ui-kit-overlay.d.ts +31 -0
- package/types/4sh-ui-kit-theming.d.ts +54 -0
- package/types/4sh-ui-kit-types.d.ts +13 -0
- package/types/4sh-ui-kit-ui-accordion.d.ts +140 -0
- package/types/4sh-ui-kit-ui-alert.d.ts +89 -0
- package/types/4sh-ui-kit-ui-autocomplete.d.ts +411 -0
- package/types/4sh-ui-kit-ui-avatar-group.d.ts +17 -0
- package/types/4sh-ui-kit-ui-avatar.d.ts +55 -0
- package/types/4sh-ui-kit-ui-badge.d.ts +38 -0
- package/types/4sh-ui-kit-ui-breadcrumb.d.ts +131 -0
- package/types/4sh-ui-kit-ui-button-split.d.ts +102 -0
- package/types/4sh-ui-kit-ui-button.d.ts +91 -0
- package/types/4sh-ui-kit-ui-card.d.ts +102 -0
- package/types/4sh-ui-kit-ui-checkbox.d.ts +54 -0
- package/types/4sh-ui-kit-ui-chip.d.ts +114 -0
- package/types/4sh-ui-kit-ui-context-menu.d.ts +105 -0
- package/types/4sh-ui-kit-ui-datepicker.d.ts +539 -0
- package/types/4sh-ui-kit-ui-drawer.d.ts +147 -0
- package/types/4sh-ui-kit-ui-empty-state.d.ts +93 -0
- package/types/4sh-ui-kit-ui-field.d.ts +53 -0
- package/types/4sh-ui-kit-ui-file-upload.d.ts +268 -0
- package/types/4sh-ui-kit-ui-helper.d.ts +46 -0
- package/types/4sh-ui-kit-ui-icon.d.ts +69 -0
- package/types/4sh-ui-kit-ui-image.d.ts +88 -0
- package/types/4sh-ui-kit-ui-input-group.d.ts +54 -0
- package/types/4sh-ui-kit-ui-input-mask.d.ts +63 -0
- package/types/4sh-ui-kit-ui-input-number.d.ts +96 -0
- package/types/4sh-ui-kit-ui-input-otp.d.ts +130 -0
- package/types/4sh-ui-kit-ui-input-tags.d.ts +350 -0
- package/types/4sh-ui-kit-ui-input.d.ts +78 -0
- package/types/4sh-ui-kit-ui-label.d.ts +36 -0
- package/types/4sh-ui-kit-ui-link.d.ts +72 -0
- package/types/4sh-ui-kit-ui-menu.d.ts +235 -0
- package/types/4sh-ui-kit-ui-modal.d.ts +241 -0
- package/types/4sh-ui-kit-ui-nudger.d.ts +79 -0
- package/types/4sh-ui-kit-ui-paginator.d.ts +150 -0
- package/types/4sh-ui-kit-ui-popover.d.ts +125 -0
- package/types/4sh-ui-kit-ui-progress-bar.d.ts +82 -0
- package/types/4sh-ui-kit-ui-radio.d.ts +44 -0
- package/types/4sh-ui-kit-ui-rating.d.ts +90 -0
- package/types/4sh-ui-kit-ui-read-only.d.ts +70 -0
- package/types/4sh-ui-kit-ui-segment-control.d.ts +184 -0
- package/types/4sh-ui-kit-ui-select.d.ts +392 -0
- package/types/4sh-ui-kit-ui-separator.d.ts +43 -0
- package/types/4sh-ui-kit-ui-sidebar.d.ts +358 -0
- package/types/4sh-ui-kit-ui-skeleton.d.ts +52 -0
- package/types/4sh-ui-kit-ui-slider.d.ts +127 -0
- package/types/4sh-ui-kit-ui-spinner.d.ts +67 -0
- package/types/4sh-ui-kit-ui-stepper.d.ts +220 -0
- package/types/4sh-ui-kit-ui-table.d.ts +570 -0
- package/types/4sh-ui-kit-ui-tabs.d.ts +225 -0
- package/types/4sh-ui-kit-ui-tag.d.ts +46 -0
- package/types/4sh-ui-kit-ui-textarea.d.ts +61 -0
- package/types/4sh-ui-kit-ui-toast.d.ts +247 -0
- package/types/4sh-ui-kit-ui-toggle.d.ts +67 -0
- package/types/4sh-ui-kit-ui-tooltip.d.ts +167 -0
- package/types/4sh-ui-kit.d.ts +4 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"4sh-ui-kit-ui-image.mjs","sources":["../../../projects/ui-kit/ui-image/src/lib/ui-image.ts","../../../projects/ui-kit/ui-image/src/lib/ui-image.html","../../../projects/ui-kit/ui-image/src/public-api.ts","../../../projects/ui-kit/ui-image/src/4sh-ui-kit-ui-image.ts"],"sourcesContent":["import {\n Component,\n computed,\n effect,\n inject,\n InjectionToken,\n input,\n isDevMode,\n linkedSignal,\n output,\n Provider,\n} from '@angular/core';\nimport { NgOptimizedImage } from '@angular/common';\nimport { httpResource } from '@angular/common/http';\nimport { DomSanitizer, SafeHtml } from '@angular/platform-browser';\nimport { ThemeService } from '@4sh/ui-kit/theming';\nimport { BrandService } from '@4sh/ui-kit/theming';\nimport { UiIcon } from '@4sh/ui-kit/ui-icon';\n\ninterface ModeMap {\n base?: string;\n light?: string;\n dark?: string;\n}\ntype ThemeMap = Record<string, ModeMap>;\n/** filename → { brand|'common' → { base|light|dark → extension } }. */\nexport type UiImageAssetsMap = Record<string, ThemeMap>;\n\n/**\n * Map of the LOCAL assets available to `ui-image` (its `name` input).\n *\n * The kit cannot know a project's assets, so the map is injected rather than\n * bundled: generate it in your app (see `npm run generate:assets` in the\n * starter, which writes `src/assets/assets-map.json`) and provide it with\n * `provideUiImageAssets()`. Without it, `name` resolves to nothing and the\n * component falls back to its placeholder — `src` (remote URLs) still works.\n */\nexport const UI_IMAGE_ASSETS = new InjectionToken<UiImageAssetsMap>('UI_IMAGE_ASSETS');\n\n/**\n * Registers the local asset map consumed by `ui-image`.\n *\n * ```ts\n * import assetsMap from './assets/assets-map.json';\n * providers: [provideUiImageAssets(assetsMap)]\n * ```\n */\nexport function provideUiImageAssets(map: UiImageAssetsMap): Provider {\n return { provide: UI_IMAGE_ASSETS, useValue: map };\n}\n\n/** Cross-instance memoization: the same resolved URL is fetched once (logos repeated across the app). */\nconst SVG_CACHE = new Map<string, string>();\n\n/**\n * ui-image — theme/brand-aware image.\n *\n * Two sources: `name` (local asset key resolved through `assets-map.json`,\n * theme/brand variants) or `src` (remote/absolute URL — takes precedence).\n * Local `.svg` assets are inlined (`innerHTML`) so they can inherit CSS;\n * remote URLs always render through `<img [ngSrc]>` (never inlined).\n * On load failure the `fallback` local asset is shown, then a token-styled\n * placeholder if the fallback also fails (or none is provided).\n */\n@Component({\n selector: 'ui-image',\n templateUrl: './ui-image.html',\n styleUrl: './ui-image.scss',\n imports: [NgOptimizedImage, UiIcon],\n})\nexport class UiImage {\n private readonly sanitizer = inject(DomSanitizer);\n private readonly assetsMap = inject(UI_IMAGE_ASSETS, { optional: true }) ?? {};\n private readonly themeService = inject(ThemeService);\n private readonly brandService = inject(BrandService);\n\n /** Local asset key in `assets-map.json` (theme/brand-aware resolution). */\n name = input<string>();\n /** Remote/absolute URL, rendered via `NgOptimizedImage` — takes precedence over `name`. */\n src = input<string>();\n /** Local asset name (`assets-map.json` key) displayed when the main image fails to load. */\n fallback = input<string>();\n priority = input(false);\n fill = input(false);\n width = input<string | number>();\n widthUnit = input<string>();\n height = input<string | number>();\n heightUnit = input<string>();\n alt = input<string>();\n\n /** Emitted with the failed URL when an image fails to load. */\n loadFailed = output<string>();\n\n protected readonly isRemote = computed(() => !!this.src());\n /** Inline SVG is reserved for LOCAL assets — a remote `.svg` renders through `<img>` (no XSS surface). */\n protected readonly isInlineSvg = computed(() => !this.isRemote() && !!this.name()?.toLowerCase().endsWith('.svg'));\n\n protected readonly localSrc = computed(() => this.resolveLocal(this.name()));\n protected readonly fallbackSrc = computed(() => this.resolveLocal(this.fallback()));\n protected readonly primarySrc = computed(() => this.src() || this.localSrc());\n\n // Failure flags auto-reset when their source URL changes (theme/brand/src swap → automatic retry).\n private readonly primaryImgFailed = linkedSignal({ source: this.primarySrc, computation: () => false });\n private readonly fallbackImgFailed = linkedSignal({ source: this.fallbackSrc, computation: () => false });\n\n private readonly svgResource = httpResource.text(() => {\n if (!this.isInlineSvg()) return undefined;\n const url = this.localSrc();\n return !url || SVG_CACHE.has(url) ? undefined : url;\n });\n\n protected readonly svgContent = computed<SafeHtml | null>(() => {\n if (!this.isInlineSvg()) return null;\n const url = this.localSrc();\n if (!url) return null;\n const raw = SVG_CACHE.get(url) ?? (this.svgResource.hasValue() ? this.svgResource.value() : undefined);\n return raw === undefined ? null : this.sanitizer.bypassSecurityTrustHtml(raw);\n });\n\n protected readonly primaryFailed = computed(() =>\n this.isInlineSvg() ? this.svgResource.status() === 'error' : this.primaryImgFailed(),\n );\n protected readonly showFallback = computed(\n () => this.primaryFailed() && !!this.fallbackSrc() && !this.fallbackImgFailed(),\n );\n protected readonly showPlaceholder = computed(\n () => !this.primarySrc() || (this.primaryFailed() && (!this.fallbackSrc() || this.fallbackImgFailed())),\n );\n protected readonly displayedSrc = computed(() => (this.showFallback() ? this.fallbackSrc() : this.primarySrc()));\n\n protected readonly cssWidth = computed(() =>\n this.width() != null ? `${this.width()}${this.widthUnit() || 'px'}` : null,\n );\n protected readonly cssHeight = computed(() =>\n this.height() != null ? `${this.height()}${this.heightUnit() || 'px'}` : null,\n );\n\n constructor() {\n // Side effect only: populate the module-level SVG cache once a fetch resolves.\n effect(() => {\n if (!this.isInlineSvg()) return;\n const url = this.localSrc();\n if (url && this.svgResource.hasValue()) SVG_CACHE.set(url, this.svgResource.value());\n });\n if (isDevMode()) {\n effect(() => {\n if (this.src() && this.name()) {\n console.warn('[ui-image] `src` and `name` are both set — `src` takes precedence.');\n }\n if (!this.src() && !this.name()) {\n console.warn('[ui-image] Neither `src` nor `name` is set — the placeholder is displayed.');\n }\n });\n }\n }\n\n protected onImgError(): void {\n const failed = this.displayedSrc();\n if (this.showFallback()) this.fallbackImgFailed.set(true);\n else this.primaryImgFailed.set(true);\n if (failed) this.loadFailed.emit(failed);\n }\n\n private resolveLocal(filename: string | undefined): string {\n if (!filename) return '';\n const mode = this.themeService.currentMode();\n const brand = this.brandService.currentBrand();\n\n const fileEntry = this.assetsMap[filename];\n if (!fileEntry) return '';\n\n if (fileEntry[brand]) {\n const path = this.resolvePath(brand, fileEntry[brand], mode, filename);\n if (path) return path;\n }\n\n if (fileEntry['common']) {\n return this.buildPath('common', fileEntry['common'], mode, filename);\n }\n\n return '';\n }\n\n private resolvePath(\n themeFolder: string,\n variants: ModeMap,\n currentMode: 'light' | 'dark',\n filename: string,\n ): string | null {\n if (variants[currentMode]) {\n const type = variants[currentMode]!;\n return `assets/img/${themeFolder}/${type}/${currentMode}/${filename}`;\n }\n\n if (variants.base) {\n const type = variants.base;\n return `assets/img/${themeFolder}/${type}/${filename}`;\n }\n\n return null;\n }\n\n private buildPath(themeName: string, variants: ModeMap, currentMode: 'light' | 'dark', filename: string): string {\n if (variants[currentMode]) {\n const type = variants[currentMode]!;\n return `assets/img/${themeName}/${type}/${currentMode}/${filename}`;\n }\n\n if (variants.base) {\n const type = variants.base;\n return `assets/img/${themeName}/${type}/${filename}`;\n }\n\n return '';\n }\n}\n","@if (showPlaceholder()) {\n <div\n class=\"ui-image-placeholder\"\n [style.width]=\"cssWidth()\"\n [style.height]=\"cssHeight()\"\n [attr.role]=\"alt() ? 'img' : null\"\n [attr.aria-label]=\"alt() || null\"\n [attr.aria-hidden]=\"alt() ? null : true\"\n >\n <ui-icon name=\"image\" />\n </div>\n} @else if (isInlineSvg() && !primaryFailed()) {\n <div class=\"ui-image-svg\" [style.width]=\"cssWidth()\" [style.height]=\"cssHeight()\" [innerHTML]=\"svgContent()\"></div>\n} @else {\n <img\n class=\"ui-image\"\n [ngSrc]=\"displayedSrc()!\"\n [alt]=\"alt() || ''\"\n [width]=\"!fill() ? width() : null\"\n [height]=\"!fill() ? (height() ? height() : width()) : null\"\n [fill]=\"fill()\"\n [priority]=\"priority()\"\n (error)=\"onImgError()\"\n />\n}\n","/*\n * Public API Surface of ui-kit/ui-image\n */\n\nexport * from './lib/ui-image';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;AA4BA;;;;;;;;AAQG;MACU,eAAe,GAAG,IAAI,cAAc,CAAmB,iBAAiB;AAErF;;;;;;;AAOG;AACG,SAAU,oBAAoB,CAAC,GAAqB,EAAA;IACxD,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,GAAG,EAAE;AACpD;AAEA;AACA,MAAM,SAAS,GAAG,IAAI,GAAG,EAAkB;AAE3C;;;;;;;;;AASG;MAOU,OAAO,CAAA;AAmElB,IAAA,WAAA,GAAA;AAlEiB,QAAA,IAAA,CAAA,SAAS,GAAG,MAAM,CAAC,YAAY,CAAC;AAChC,QAAA,IAAA,CAAA,SAAS,GAAG,MAAM,CAAC,eAAe,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE;AAC7D,QAAA,IAAA,CAAA,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC;AACnC,QAAA,IAAA,CAAA,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC;;AAGpD,QAAA,IAAA,CAAA,IAAI,GAAG,KAAK;4FAAU;;AAEtB,QAAA,IAAA,CAAA,G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MAAA,EAAA,CAAA,ybAAA,CAAA,EAAA;;;AEpErC;;AAEG;;ACFH;;AAEG;;;;"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { input, inject, DestroyRef, viewChild, afterNextRender, Component, computed } from '@angular/core';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* ui-input-group — glues a control and its add-ons into a single visual field.
|
|
6
|
+
*
|
|
7
|
+
* Purely presentational: each child keeps its own API and states; the group
|
|
8
|
+
* only lays them out on one row, squares the inner corners and collapses the
|
|
9
|
+
* shared borders. The children are **projected**, so that shaping is applied
|
|
10
|
+
* on the DOM (custom properties + flex), not through scoped selectors which
|
|
11
|
+
* cannot reach projected content.
|
|
12
|
+
*
|
|
13
|
+
* Add-ons (text, icon, checkbox…) go through `ui-input-group-addon`; controls
|
|
14
|
+
* (`ui-input`, `ui-select`, `ui-button`…) are placed directly in the group.
|
|
15
|
+
*/
|
|
16
|
+
class UiInputGroup {
|
|
17
|
+
constructor() {
|
|
18
|
+
/** Size shared with the projected `ui-input-group-addon` (controls keep their own `size`). */
|
|
19
|
+
this.size = input('default', /* @ts-ignore */
|
|
20
|
+
...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
|
|
21
|
+
/** @ignore */
|
|
22
|
+
this.destroyRef = inject(DestroyRef);
|
|
23
|
+
/** @ignore */
|
|
24
|
+
this.row = viewChild.required('row', /* @ts-ignore */
|
|
25
|
+
...(ngDevMode ? [{ debugName: "row" }] : /* istanbul ignore next */ []));
|
|
26
|
+
afterNextRender(() => {
|
|
27
|
+
this.shape();
|
|
28
|
+
// Items are projected: follow the `@if`/`@for` of the consumer template.
|
|
29
|
+
const observer = new MutationObserver(() => this.shape());
|
|
30
|
+
observer.observe(this.row().nativeElement, { childList: true });
|
|
31
|
+
this.destroyRef.onDestroy(() => observer.disconnect());
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
/** @ignore Direct items of the row. */
|
|
35
|
+
items() {
|
|
36
|
+
return Array.from(this.row().nativeElement.children);
|
|
37
|
+
}
|
|
38
|
+
/** @ignore Only the edges keep a rounded corner, and shared borders overlap instead of doubling. */
|
|
39
|
+
shape() {
|
|
40
|
+
const items = this.items();
|
|
41
|
+
const last = items.length - 1;
|
|
42
|
+
items.forEach((el, index) => {
|
|
43
|
+
const start = index === 0 ? 'var(--ui-input-group-radius)' : '0';
|
|
44
|
+
const end = index === last ? 'var(--ui-input-group-radius)' : '0';
|
|
45
|
+
const radius = `${start} ${end} ${end} ${start}`;
|
|
46
|
+
// Radius hooks exposed by the children (custom properties inherit
|
|
47
|
+
// across the component boundary — no ::ng-deep).
|
|
48
|
+
el.style.setProperty('--ui-field-radius', radius);
|
|
49
|
+
el.style.setProperty('--ui-button-radius', radius);
|
|
50
|
+
el.style.setProperty('--ui-input-group-item-radius', radius);
|
|
51
|
+
el.style.position = 'relative'; // lets the focused item paint above its neighbours
|
|
52
|
+
el.style.marginInlineStart = index === 0 ? '' : 'var(--ui-input-group-overlap)';
|
|
53
|
+
// Add-ons and buttons keep their natural width; the controls take the rest.
|
|
54
|
+
const fixed = el.matches('ui-input-group-addon, ui-button');
|
|
55
|
+
el.style.flex = fixed ? '0 0 auto' : '1 1 0';
|
|
56
|
+
el.style.minWidth = fixed ? '' : '0';
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
/** @ignore Raises the focused item so its focus ring is not covered by the overlap. */
|
|
60
|
+
onFocusIn(event) {
|
|
61
|
+
for (const el of this.items()) {
|
|
62
|
+
el.style.zIndex = el.contains(event.target) ? '1' : '';
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/** @ignore */
|
|
66
|
+
onFocusOut() {
|
|
67
|
+
for (const el of this.items())
|
|
68
|
+
el.style.zIndex = '';
|
|
69
|
+
}
|
|
70
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: UiInputGroup, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
71
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.0.8", type: UiInputGroup, isStandalone: true, selector: "ui-input-group", inputs: { size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "focusin": "onFocusIn($event)", "focusout": "onFocusOut()" } }, viewQueries: [{ propertyName: "row", first: true, predicate: ["row"], descendants: true, isSignal: true }], ngImport: i0, template: "<div #row class=\"ui-input-group\">\n <ng-content />\n</div>\n", styles: [":host{display:block}.ui-input-group{--ui-input-group-radius: var(--radius-sm);--ui-input-group-overlap: calc(-1 * var(--stroke-default));display:flex;align-items:stretch;width:100%}\n"] }); }
|
|
72
|
+
}
|
|
73
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: UiInputGroup, decorators: [{
|
|
74
|
+
type: Component,
|
|
75
|
+
args: [{ selector: 'ui-input-group', host: {
|
|
76
|
+
'(focusin)': 'onFocusIn($event)',
|
|
77
|
+
'(focusout)': 'onFocusOut()',
|
|
78
|
+
}, template: "<div #row class=\"ui-input-group\">\n <ng-content />\n</div>\n", styles: [":host{display:block}.ui-input-group{--ui-input-group-radius: var(--radius-sm);--ui-input-group-overlap: calc(-1 * var(--stroke-default));display:flex;align-items:stretch;width:100%}\n"] }]
|
|
79
|
+
}], ctorParameters: () => [], propDecorators: { size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], row: [{ type: i0.ViewChild, args: ['row', { isSignal: true }] }] } });
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* ui-input-group-addon — non-interactive cell of a `ui-input-group`
|
|
83
|
+
* (text, icon, checkbox, radio…).
|
|
84
|
+
*
|
|
85
|
+
* Projects its content in a box aligned on the field height. `size` falls back
|
|
86
|
+
* to the parent group's when it is not set.
|
|
87
|
+
*/
|
|
88
|
+
class UiInputGroupAddon {
|
|
89
|
+
constructor() {
|
|
90
|
+
/** Size (defaults to the parent `ui-input-group` size). */
|
|
91
|
+
this.size = input(/* @ts-ignore */
|
|
92
|
+
...(ngDevMode ? [undefined, { debugName: "size" }] : /* istanbul ignore next */ []));
|
|
93
|
+
/** @ignore */
|
|
94
|
+
this.group = inject(UiInputGroup, { optional: true });
|
|
95
|
+
/** @ignore */
|
|
96
|
+
this.classes = computed(() => {
|
|
97
|
+
const size = this.size() ?? this.group?.size() ?? 'default';
|
|
98
|
+
return size === 'default' ? 'ui-input-group-addon' : `ui-input-group-addon _${size}`;
|
|
99
|
+
}, /* @ts-ignore */
|
|
100
|
+
...(ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []));
|
|
101
|
+
}
|
|
102
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: UiInputGroupAddon, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
103
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.0.8", type: UiInputGroupAddon, isStandalone: true, selector: "ui-input-group-addon", inputs: { size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<div [class]=\"classes()\">\n <ng-content />\n</div>\n", styles: [":host{display:flex}.ui-input-group-addon{display:flex;align-items:center;justify-content:center;gap:var(--units-sm);box-sizing:border-box;min-width:var(--size-components-default);min-height:var(--size-components-default);padding:0 var(--units-md);border:var(--stroke-default) solid var(--form-high-stroke-default);border-radius:var(--ui-input-group-item-radius, var(--radius-sm));background-color:var(--global-background-muted);color:var(--global-text-muted);font-family:var(--fontfamily-base);font-size:var(--size-typography-text-default);line-height:1.2;white-space:nowrap;-webkit-user-select:none;user-select:none}.ui-input-group-addon._small{min-width:var(--size-components-sm);min-height:var(--size-components-sm);font-size:var(--size-typography-text-md)}\n"] }); }
|
|
104
|
+
}
|
|
105
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: UiInputGroupAddon, decorators: [{
|
|
106
|
+
type: Component,
|
|
107
|
+
args: [{ selector: 'ui-input-group-addon', template: "<div [class]=\"classes()\">\n <ng-content />\n</div>\n", styles: [":host{display:flex}.ui-input-group-addon{display:flex;align-items:center;justify-content:center;gap:var(--units-sm);box-sizing:border-box;min-width:var(--size-components-default);min-height:var(--size-components-default);padding:0 var(--units-md);border:var(--stroke-default) solid var(--form-high-stroke-default);border-radius:var(--ui-input-group-item-radius, var(--radius-sm));background-color:var(--global-background-muted);color:var(--global-text-muted);font-family:var(--fontfamily-base);font-size:var(--size-typography-text-default);line-height:1.2;white-space:nowrap;-webkit-user-select:none;user-select:none}.ui-input-group-addon._small{min-width:var(--size-components-sm);min-height:var(--size-components-sm);font-size:var(--size-typography-text-md)}\n"] }]
|
|
108
|
+
}], propDecorators: { size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }] } });
|
|
109
|
+
|
|
110
|
+
/*
|
|
111
|
+
* Public API Surface of ui-kit/ui-input-group
|
|
112
|
+
*/
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Generated bundle index. Do not edit.
|
|
116
|
+
*/
|
|
117
|
+
|
|
118
|
+
export { UiInputGroup, UiInputGroupAddon };
|
|
119
|
+
//# sourceMappingURL=4sh-ui-kit-ui-input-group.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"4sh-ui-kit-ui-input-group.mjs","sources":["../../../projects/ui-kit/ui-input-group/src/lib/ui-input-group.ts","../../../projects/ui-kit/ui-input-group/src/lib/ui-input-group.html","../../../projects/ui-kit/ui-input-group/src/lib/ui-input-group-addon.ts","../../../projects/ui-kit/ui-input-group/src/lib/ui-input-group-addon.html","../../../projects/ui-kit/ui-input-group/src/public-api.ts","../../../projects/ui-kit/ui-input-group/src/4sh-ui-kit-ui-input-group.ts"],"sourcesContent":["import {\n afterNextRender,\n Component,\n DestroyRef,\n ElementRef,\n inject,\n input,\n viewChild,\n} from '@angular/core';\nimport { FieldSize } from '@4sh/ui-kit/forms';\n\n/**\n * ui-input-group — glues a control and its add-ons into a single visual field.\n *\n * Purely presentational: each child keeps its own API and states; the group\n * only lays them out on one row, squares the inner corners and collapses the\n * shared borders. The children are **projected**, so that shaping is applied\n * on the DOM (custom properties + flex), not through scoped selectors which\n * cannot reach projected content.\n *\n * Add-ons (text, icon, checkbox…) go through `ui-input-group-addon`; controls\n * (`ui-input`, `ui-select`, `ui-button`…) are placed directly in the group.\n */\n@Component({\n selector: 'ui-input-group',\n templateUrl: './ui-input-group.html',\n styleUrl: './ui-input-group.scss',\n host: {\n '(focusin)': 'onFocusIn($event)',\n '(focusout)': 'onFocusOut()',\n },\n})\nexport class UiInputGroup {\n /** Size shared with the projected `ui-input-group-addon` (controls keep their own `size`). */\n size = input<FieldSize>('default');\n\n /** @ignore */\n private readonly destroyRef = inject(DestroyRef);\n /** @ignore */\n private readonly row = viewChild.required<ElementRef<HTMLElement>>('row');\n\n constructor() {\n afterNextRender(() => {\n this.shape();\n // Items are projected: follow the `@if`/`@for` of the consumer template.\n const observer = new MutationObserver(() => this.shape());\n observer.observe(this.row().nativeElement, { childList: true });\n this.destroyRef.onDestroy(() => observer.disconnect());\n });\n }\n\n /** @ignore Direct items of the row. */\n private items(): HTMLElement[] {\n return Array.from(this.row().nativeElement.children) as HTMLElement[];\n }\n\n /** @ignore Only the edges keep a rounded corner, and shared borders overlap instead of doubling. */\n private shape(): void {\n const items = this.items();\n const last = items.length - 1;\n items.forEach((el, index) => {\n const start = index === 0 ? 'var(--ui-input-group-radius)' : '0';\n const end = index === last ? 'var(--ui-input-group-radius)' : '0';\n const radius = `${start} ${end} ${end} ${start}`;\n // Radius hooks exposed by the children (custom properties inherit\n // across the component boundary — no ::ng-deep).\n el.style.setProperty('--ui-field-radius', radius);\n el.style.setProperty('--ui-button-radius', radius);\n el.style.setProperty('--ui-input-group-item-radius', radius);\n el.style.position = 'relative'; // lets the focused item paint above its neighbours\n el.style.marginInlineStart = index === 0 ? '' : 'var(--ui-input-group-overlap)';\n // Add-ons and buttons keep their natural width; the controls take the rest.\n const fixed = el.matches('ui-input-group-addon, ui-button');\n el.style.flex = fixed ? '0 0 auto' : '1 1 0';\n el.style.minWidth = fixed ? '' : '0';\n });\n }\n\n /** @ignore Raises the focused item so its focus ring is not covered by the overlap. */\n protected onFocusIn(event: FocusEvent): void {\n for (const el of this.items()) {\n el.style.zIndex = el.contains(event.target as Node) ? '1' : '';\n }\n }\n\n /** @ignore */\n protected onFocusOut(): void {\n for (const el of this.items()) el.style.zIndex = '';\n }\n}\n","<div #row class=\"ui-input-group\">\n <ng-content />\n</div>\n","import { Component, computed, inject, input } from '@angular/core';\nimport { FieldSize } from '@4sh/ui-kit/forms';\nimport { UiInputGroup } from './ui-input-group';\n\n/**\n * ui-input-group-addon — non-interactive cell of a `ui-input-group`\n * (text, icon, checkbox, radio…).\n *\n * Projects its content in a box aligned on the field height. `size` falls back\n * to the parent group's when it is not set.\n */\n@Component({\n selector: 'ui-input-group-addon',\n templateUrl: './ui-input-group-addon.html',\n styleUrl: './ui-input-group-addon.scss',\n})\nexport class UiInputGroupAddon {\n /** Size (defaults to the parent `ui-input-group` size). */\n size = input<FieldSize>();\n\n /** @ignore */\n private readonly group = inject(UiInputGroup, { optional: true });\n\n /** @ignore */\n protected readonly classes = computed(() => {\n const size = this.size() ?? this.group?.size() ?? 'default';\n return size === 'default' ? 'ui-input-group-addon' : `ui-input-group-addon _${size}`;\n });\n}\n","<div [class]=\"classes()\">\n <ng-content />\n</div>\n","/*\n * Public API Surface of ui-kit/ui-input-group\n */\n\nexport * from './lib/ui-input-group-addon';\nexport * from './lib/ui-input-group';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;AAWA;;;;;;;;;;;AAWG;MAUU,YAAY,CAAA;AASvB,IAAA,WAAA,GAAA;;QAPA,IAAA,CAAA,IAAI,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EAAA,QAAA,EAAA,yDAAA,EAAA,MAAA,EAAA,CAAA,4vBAAA,CAAA,EAAA;;;AEZlC;;AAEG;;ACFH;;AAEG;;;;"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { input, booleanAttribute, output, viewChild, signal, computed, forwardRef, Component } from '@angular/core';
|
|
3
|
+
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
4
|
+
import { BaseFormField, parseMaskRanges, buildMaskSlots, applyMaskTemplate, extractMaskData, caretForMask } from '@4sh/ui-kit/forms';
|
|
5
|
+
import { UiField } from '@4sh/ui-kit/ui-field';
|
|
6
|
+
import { UiIcon } from '@4sh/ui-kit/ui-icon';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* ui-input-mask — headless masked field (`ui-field` shell).
|
|
10
|
+
*
|
|
11
|
+
* `mask` describes the template: `9` digit, `a` letter, `*` alphanumeric; any
|
|
12
|
+
* other character is a literal inserted automatically (e.g. `99/99/9999`,
|
|
13
|
+
* `(999) 999-9999`). Empty positions show `slotChar`.
|
|
14
|
+
*
|
|
15
|
+
* Model value = string: masked (`12/09/2024`) by default, or raw (`12092024`)
|
|
16
|
+
* when `unmask`. Standalone, `[(ngModel)]` or reactive forms.
|
|
17
|
+
*/
|
|
18
|
+
class UiInputMask extends BaseFormField {
|
|
19
|
+
constructor() {
|
|
20
|
+
super(...arguments);
|
|
21
|
+
/** Mask template (9 digit · a letter · * alphanumeric · other = literal). */
|
|
22
|
+
this.mask = input.required(/* @ts-ignore */
|
|
23
|
+
...(ngDevMode ? [{ debugName: "mask" }] : /* istanbul ignore next */ []));
|
|
24
|
+
/**
|
|
25
|
+
* Inclusive bounds of each numeric segment (run of consecutive `9` tokens),
|
|
26
|
+
* in mask order and space-separated: `"0-23 0-59"` for `99:99`,
|
|
27
|
+
* `"1-31 1-12 1900-2100"` for `99/99/9999`. `*` leaves a segment unbounded.
|
|
28
|
+
* A character that could not lead to an in-range segment is rejected.
|
|
29
|
+
*/
|
|
30
|
+
this.ranges = input('', /* @ts-ignore */
|
|
31
|
+
...(ngDevMode ? [{ debugName: "ranges" }] : /* istanbul ignore next */ []));
|
|
32
|
+
/** Fill character for empty positions. */
|
|
33
|
+
this.slotChar = input('_', /* @ts-ignore */
|
|
34
|
+
...(ngDevMode ? [{ debugName: "slotChar" }] : /* istanbul ignore next */ []));
|
|
35
|
+
/** Emit the raw value (without literals) instead of the masked value. */
|
|
36
|
+
this.unmask = input(false, { ...(ngDevMode ? { debugName: "unmask" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
37
|
+
/** Native placeholder (shown when the field is empty). */
|
|
38
|
+
this.placeholder = input(/* @ts-ignore */
|
|
39
|
+
...(ngDevMode ? [undefined, { debugName: "placeholder" }] : /* istanbul ignore next */ []));
|
|
40
|
+
/** Left FontAwesome icon name (decorative). */
|
|
41
|
+
this.iconLeft = input(/* @ts-ignore */
|
|
42
|
+
...(ngDevMode ? [undefined, { debugName: "iconLeft" }] : /* istanbul ignore next */ []));
|
|
43
|
+
/** Emitted on each value change. */
|
|
44
|
+
this.valueChange = output();
|
|
45
|
+
/** Emitted when the input loses focus. */
|
|
46
|
+
this.inputBlur = output();
|
|
47
|
+
/** @ignore */
|
|
48
|
+
this.inputEl = viewChild.required('inputEl', /* @ts-ignore */
|
|
49
|
+
...(ngDevMode ? [{ debugName: "inputEl" }] : /* istanbul ignore next */ []));
|
|
50
|
+
/** @ignore Masked displayed text. */
|
|
51
|
+
this.text = signal('', /* @ts-ignore */
|
|
52
|
+
...(ngDevMode ? [{ debugName: "text" }] : /* istanbul ignore next */ []));
|
|
53
|
+
/** @ignore */
|
|
54
|
+
this.iconSize = computed(() => (this.size() === 'small' ? 'sm' : 'md'), /* @ts-ignore */
|
|
55
|
+
...(ngDevMode ? [{ debugName: "iconSize" }] : /* istanbul ignore next */ []));
|
|
56
|
+
/** @ignore Bounds declared by `ranges`, one entry per numeric segment (`null` = unbounded). */
|
|
57
|
+
this.parsedRanges = computed(() => parseMaskRanges(this.ranges()), /* @ts-ignore */
|
|
58
|
+
...(ngDevMode ? [{ debugName: "parsedRanges" }] : /* istanbul ignore next */ []));
|
|
59
|
+
/**
|
|
60
|
+
* @ignore The mask resolved once per template: literals, input slots, and the
|
|
61
|
+
* `ranges` bounds attached to every slot of the numeric segment it belongs to.
|
|
62
|
+
*/
|
|
63
|
+
this.slots = computed(() => buildMaskSlots(this.mask(), this.parsedRanges()), /* @ts-ignore */
|
|
64
|
+
...(ngDevMode ? [{ debugName: "slots" }] : /* istanbul ignore next */ []));
|
|
65
|
+
}
|
|
66
|
+
writeValue(value) {
|
|
67
|
+
const built = applyMaskTemplate(this.slots(), extractMaskData(value ?? ''), this.slotChar());
|
|
68
|
+
this.modelValue.set(this.emitValue(built));
|
|
69
|
+
this.text.set(built.data.length ? built.display : '');
|
|
70
|
+
}
|
|
71
|
+
/** Focuses the input. */
|
|
72
|
+
focus(options) {
|
|
73
|
+
this.inputEl().nativeElement.focus(options);
|
|
74
|
+
}
|
|
75
|
+
/** @ignore Input: apply the mask, update model + display + caret. */
|
|
76
|
+
onInput() {
|
|
77
|
+
const el = this.inputEl().nativeElement;
|
|
78
|
+
const raw = el.value;
|
|
79
|
+
const caret = el.selectionStart ?? raw.length;
|
|
80
|
+
// Number of data characters located BEFORE the caret (stable anchor).
|
|
81
|
+
const dataBeforeCaret = extractMaskData(raw.slice(0, caret)).length;
|
|
82
|
+
const built = applyMaskTemplate(this.slots(), extractMaskData(raw), this.slotChar());
|
|
83
|
+
const value = this.emitValue(built);
|
|
84
|
+
const display = built.data.length ? built.display : '';
|
|
85
|
+
this.text.set(display);
|
|
86
|
+
this.modelValue.set(value);
|
|
87
|
+
this.emitChange(value);
|
|
88
|
+
this.valueChange.emit(value);
|
|
89
|
+
// Apply synchronously + restore the caret after the Nth typed character
|
|
90
|
+
// (auto-inserted literals skipped). The [value] binding becomes a no-op.
|
|
91
|
+
el.value = display;
|
|
92
|
+
const pos = caretForMask(built.tokenIndices, dataBeforeCaret, display.length);
|
|
93
|
+
el.setSelectionRange(pos, pos);
|
|
94
|
+
}
|
|
95
|
+
/** @ignore */
|
|
96
|
+
onBlur(event) {
|
|
97
|
+
this.emitTouch();
|
|
98
|
+
this.inputBlur.emit(event);
|
|
99
|
+
}
|
|
100
|
+
/** @ignore Emitted value depending on `unmask`. */
|
|
101
|
+
emitValue(built) {
|
|
102
|
+
return this.unmask() ? built.data : built.masked;
|
|
103
|
+
}
|
|
104
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: UiInputMask, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
105
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.8", type: UiInputMask, isStandalone: true, selector: "ui-input-mask", inputs: { mask: { classPropertyName: "mask", publicName: "mask", isSignal: true, isRequired: true, transformFunction: null }, ranges: { classPropertyName: "ranges", publicName: "ranges", isSignal: true, isRequired: false, transformFunction: null }, slotChar: { classPropertyName: "slotChar", publicName: "slotChar", isSignal: true, isRequired: false, transformFunction: null }, unmask: { classPropertyName: "unmask", publicName: "unmask", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, iconLeft: { classPropertyName: "iconLeft", publicName: "iconLeft", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { valueChange: "valueChange", inputBlur: "inputBlur" }, providers: [
|
|
106
|
+
{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => UiInputMask), multi: true },
|
|
107
|
+
], viewQueries: [{ propertyName: "inputEl", first: true, predicate: ["inputEl"], descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0, template: "<ui-field\n [label]=\"label()\"\n [for]=\"resolvedId()\"\n [required]=\"required()\"\n [size]=\"size()\"\n [level]=\"effectiveLevel()\"\n [disabled]=\"isDisabled()\"\n [readonly]=\"readonly()\"\n [message]=\"displayMessage()\"\n [messageId]=\"messageId()\"\n>\n @if (iconLeft(); as name) {\n <ui-icon uiFieldPrefix class=\"ui-input-mask-icon\" [class._disabled]=\"isDisabled()\" [name]=\"name\" [size]=\"iconSize()\" />\n }\n\n <input\n #inputEl\n class=\"ui-input-mask-native\"\n [class._small]=\"size() === 'small'\"\n type=\"text\"\n [id]=\"resolvedId()\"\n [value]=\"text()\"\n [placeholder]=\"placeholder() ?? ''\"\n [disabled]=\"isDisabled()\"\n [readOnly]=\"readonly()\"\n [required]=\"required()\"\n [attr.name]=\"name() || null\"\n [attr.tabindex]=\"tabindex()\"\n [attr.aria-label]=\"label() ? null : ariaLabel() || null\"\n [attr.aria-labelledby]=\"ariaLabelledBy() || null\"\n [attr.aria-describedby]=\"displayMessage() ? messageId() : null\"\n [attr.aria-invalid]=\"effectiveLevel() === 'error' ? 'true' : null\"\n (input)=\"onInput()\"\n (blur)=\"onBlur($event)\"\n />\n</ui-field>\n", styles: [".ui-input-mask-native{flex:1 1 auto;align-self:stretch;min-width:0;margin:0;padding:0;border:none;border-radius:inherit;background:transparent;outline:none;font-family:var(--fontfamily-base);font-size:var(--size-typography-text-default);color:var(--form-high-content-default)}.ui-input-mask-native:first-child{padding-inline-start:var(--units-md)}.ui-input-mask-native:last-child{padding-inline-end:var(--units-md)}.ui-input-mask-native::placeholder{color:var(--form-low-content-default);opacity:1}.ui-input-mask-native:disabled{cursor:not-allowed;color:var(--form-high-content-disabled)}.ui-input-mask-native._small{font-size:var(--size-typography-text-md)}.ui-input-mask-icon{flex-shrink:0;color:var(--form-low-content-default)}.ui-input-mask-icon:first-child{margin-inline-start:var(--units-md)}.ui-input-mask-icon:last-child{margin-inline-end:var(--units-md)}.ui-input-mask-icon._disabled{color:var(--form-high-content-disabled)}\n"], dependencies: [{ kind: "component", type: UiField, selector: "ui-field", inputs: ["label", "for", "required", "size", "level", "disabled", "readonly", "multiline", "autoHeight", "message", "messageId", "hasFooter"] }, { kind: "component", type: UiIcon, selector: "ui-icon", inputs: ["name", "size", "type", "family", "decorative", "ariaLabel"] }] }); }
|
|
108
|
+
}
|
|
109
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: UiInputMask, decorators: [{
|
|
110
|
+
type: Component,
|
|
111
|
+
args: [{ selector: 'ui-input-mask', imports: [UiField, UiIcon], providers: [
|
|
112
|
+
{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => UiInputMask), multi: true },
|
|
113
|
+
], template: "<ui-field\n [label]=\"label()\"\n [for]=\"resolvedId()\"\n [required]=\"required()\"\n [size]=\"size()\"\n [level]=\"effectiveLevel()\"\n [disabled]=\"isDisabled()\"\n [readonly]=\"readonly()\"\n [message]=\"displayMessage()\"\n [messageId]=\"messageId()\"\n>\n @if (iconLeft(); as name) {\n <ui-icon uiFieldPrefix class=\"ui-input-mask-icon\" [class._disabled]=\"isDisabled()\" [name]=\"name\" [size]=\"iconSize()\" />\n }\n\n <input\n #inputEl\n class=\"ui-input-mask-native\"\n [class._small]=\"size() === 'small'\"\n type=\"text\"\n [id]=\"resolvedId()\"\n [value]=\"text()\"\n [placeholder]=\"placeholder() ?? ''\"\n [disabled]=\"isDisabled()\"\n [readOnly]=\"readonly()\"\n [required]=\"required()\"\n [attr.name]=\"name() || null\"\n [attr.tabindex]=\"tabindex()\"\n [attr.aria-label]=\"label() ? null : ariaLabel() || null\"\n [attr.aria-labelledby]=\"ariaLabelledBy() || null\"\n [attr.aria-describedby]=\"displayMessage() ? messageId() : null\"\n [attr.aria-invalid]=\"effectiveLevel() === 'error' ? 'true' : null\"\n (input)=\"onInput()\"\n (blur)=\"onBlur($event)\"\n />\n</ui-field>\n", styles: [".ui-input-mask-native{flex:1 1 auto;align-self:stretch;min-width:0;margin:0;padding:0;border:none;border-radius:inherit;background:transparent;outline:none;font-family:var(--fontfamily-base);font-size:var(--size-typography-text-default);color:var(--form-high-content-default)}.ui-input-mask-native:first-child{padding-inline-start:var(--units-md)}.ui-input-mask-native:last-child{padding-inline-end:var(--units-md)}.ui-input-mask-native::placeholder{color:var(--form-low-content-default);opacity:1}.ui-input-mask-native:disabled{cursor:not-allowed;color:var(--form-high-content-disabled)}.ui-input-mask-native._small{font-size:var(--size-typography-text-md)}.ui-input-mask-icon{flex-shrink:0;color:var(--form-low-content-default)}.ui-input-mask-icon:first-child{margin-inline-start:var(--units-md)}.ui-input-mask-icon:last-child{margin-inline-end:var(--units-md)}.ui-input-mask-icon._disabled{color:var(--form-high-content-disabled)}\n"] }]
|
|
114
|
+
}], propDecorators: { mask: [{ type: i0.Input, args: [{ isSignal: true, alias: "mask", required: true }] }], ranges: [{ type: i0.Input, args: [{ isSignal: true, alias: "ranges", required: false }] }], slotChar: [{ type: i0.Input, args: [{ isSignal: true, alias: "slotChar", required: false }] }], unmask: [{ type: i0.Input, args: [{ isSignal: true, alias: "unmask", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], iconLeft: [{ type: i0.Input, args: [{ isSignal: true, alias: "iconLeft", required: false }] }], valueChange: [{ type: i0.Output, args: ["valueChange"] }], inputBlur: [{ type: i0.Output, args: ["inputBlur"] }], inputEl: [{ type: i0.ViewChild, args: ['inputEl', { isSignal: true }] }] } });
|
|
115
|
+
|
|
116
|
+
/*
|
|
117
|
+
* Public API Surface of ui-kit/ui-input-mask
|
|
118
|
+
*/
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Generated bundle index. Do not edit.
|
|
122
|
+
*/
|
|
123
|
+
|
|
124
|
+
export { UiInputMask };
|
|
125
|
+
//# sourceMappingURL=4sh-ui-kit-ui-input-mask.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"4sh-ui-kit-ui-input-mask.mjs","sources":["../../../projects/ui-kit/ui-input-mask/src/lib/ui-input-mask.ts","../../../projects/ui-kit/ui-input-mask/src/lib/ui-input-mask.html","../../../projects/ui-kit/ui-input-mask/src/public-api.ts","../../../projects/ui-kit/ui-input-mask/src/4sh-ui-kit-ui-input-mask.ts"],"sourcesContent":["import {\n booleanAttribute,\n Component,\n computed,\n ElementRef,\n forwardRef,\n input,\n output,\n signal,\n viewChild,\n} from '@angular/core';\nimport { NG_VALUE_ACCESSOR } from '@angular/forms';\nimport { BaseFormField } from '@4sh/ui-kit/forms';\nimport { UiField } from '@4sh/ui-kit/ui-field';\nimport { UiIcon, UiIconSize } from '@4sh/ui-kit/ui-icon';\nimport {\n applyMaskTemplate,\n buildMaskSlots,\n caretForMask,\n extractMaskData,\n MaskBounds,\n MaskSlot,\n parseMaskRanges,\n} from '@4sh/ui-kit/forms';\n\n/**\n * ui-input-mask — headless masked field (`ui-field` shell).\n *\n * `mask` describes the template: `9` digit, `a` letter, `*` alphanumeric; any\n * other character is a literal inserted automatically (e.g. `99/99/9999`,\n * `(999) 999-9999`). Empty positions show `slotChar`.\n *\n * Model value = string: masked (`12/09/2024`) by default, or raw (`12092024`)\n * when `unmask`. Standalone, `[(ngModel)]` or reactive forms.\n */\n@Component({\n selector: 'ui-input-mask',\n imports: [UiField, UiIcon],\n templateUrl: './ui-input-mask.html',\n styleUrl: './ui-input-mask.scss',\n providers: [\n { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => UiInputMask), multi: true },\n ],\n})\nexport class UiInputMask extends BaseFormField<string> {\n /** Mask template (9 digit · a letter · * alphanumeric · other = literal). */\n mask = input.required<string>();\n /**\n * Inclusive bounds of each numeric segment (run of consecutive `9` tokens),\n * in mask order and space-separated: `\"0-23 0-59\"` for `99:99`,\n * `\"1-31 1-12 1900-2100\"` for `99/99/9999`. `*` leaves a segment unbounded.\n * A character that could not lead to an in-range segment is rejected.\n */\n ranges = input('');\n /** Fill character for empty positions. */\n slotChar = input('_');\n /** Emit the raw value (without literals) instead of the masked value. */\n unmask = input(false, { transform: booleanAttribute });\n /** Native placeholder (shown when the field is empty). */\n placeholder = input<string>();\n /** Left FontAwesome icon name (decorative). */\n iconLeft = input<string>();\n\n /** Emitted on each value change. */\n valueChange = output<string>();\n /** Emitted when the input loses focus. */\n inputBlur = output<FocusEvent>();\n\n /** @ignore */\n private readonly inputEl = viewChild.required<ElementRef<HTMLInputElement>>('inputEl');\n /** @ignore Masked displayed text. */\n protected readonly text = signal('');\n\n /** @ignore */\n protected readonly iconSize = computed<UiIconSize>(() => (this.size() === 'small' ? 'sm' : 'md'));\n\n /** @ignore Bounds declared by `ranges`, one entry per numeric segment (`null` = unbounded). */\n private readonly parsedRanges = computed<(MaskBounds | null)[]>(() => parseMaskRanges(this.ranges()));\n\n /**\n * @ignore The mask resolved once per template: literals, input slots, and the\n * `ranges` bounds attached to every slot of the numeric segment it belongs to.\n */\n private readonly slots = computed<MaskSlot[]>(() => buildMaskSlots(this.mask(), this.parsedRanges()));\n\n override writeValue(value: string | null): void {\n const built = applyMaskTemplate(this.slots(), extractMaskData(value ?? ''), this.slotChar());\n this.modelValue.set(this.emitValue(built));\n this.text.set(built.data.length ? built.display : '');\n }\n\n /** Focuses the input. */\n focus(options?: FocusOptions): void {\n this.inputEl().nativeElement.focus(options);\n }\n\n /** @ignore Input: apply the mask, update model + display + caret. */\n protected onInput(): void {\n const el = this.inputEl().nativeElement;\n const raw = el.value;\n const caret = el.selectionStart ?? raw.length;\n // Number of data characters located BEFORE the caret (stable anchor).\n const dataBeforeCaret = extractMaskData(raw.slice(0, caret)).length;\n\n const built = applyMaskTemplate(this.slots(), extractMaskData(raw), this.slotChar());\n const value = this.emitValue(built);\n const display = built.data.length ? built.display : '';\n\n this.text.set(display);\n this.modelValue.set(value);\n this.emitChange(value);\n this.valueChange.emit(value);\n\n // Apply synchronously + restore the caret after the Nth typed character\n // (auto-inserted literals skipped). The [value] binding becomes a no-op.\n el.value = display;\n const pos = caretForMask(built.tokenIndices, dataBeforeCaret, display.length);\n el.setSelectionRange(pos, pos);\n }\n\n /** @ignore */\n protected onBlur(event: FocusEvent): void {\n this.emitTouch();\n this.inputBlur.emit(event);\n }\n\n /** @ignore Emitted value depending on `unmask`. */\n private emitValue(built: { masked: string; data: string }): string {\n return this.unmask() ? built.data : built.masked;\n }\n}\n","<ui-field\n [label]=\"label()\"\n [for]=\"resolvedId()\"\n [required]=\"required()\"\n [size]=\"size()\"\n [level]=\"effectiveLevel()\"\n [disabled]=\"isDisabled()\"\n [readonly]=\"readonly()\"\n [message]=\"displayMessage()\"\n [messageId]=\"messageId()\"\n>\n @if (iconLeft(); as name) {\n <ui-icon uiFieldPrefix class=\"ui-input-mask-icon\" [class._disabled]=\"isDisabled()\" [name]=\"name\" [size]=\"iconSize()\" />\n }\n\n <input\n #inputEl\n class=\"ui-input-mask-native\"\n [class._small]=\"size() === 'small'\"\n type=\"text\"\n [id]=\"resolvedId()\"\n [value]=\"text()\"\n [placeholder]=\"placeholder() ?? ''\"\n [disabled]=\"isDisabled()\"\n [readOnly]=\"readonly()\"\n [required]=\"required()\"\n [attr.name]=\"name() || null\"\n [attr.tabindex]=\"tabindex()\"\n [attr.aria-label]=\"label() ? null : ariaLabel() || null\"\n [attr.aria-labelledby]=\"ariaLabelledBy() || null\"\n [attr.aria-describedby]=\"displayMessage() ? messageId() : null\"\n [attr.aria-invalid]=\"effectiveLevel() === 'error' ? 'true' : null\"\n (input)=\"onInput()\"\n (blur)=\"onBlur($event)\"\n />\n</ui-field>\n","/*\n * Public API Surface of ui-kit/ui-input-mask\n */\n\nexport * from './lib/ui-input-mask';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;AAyBA;;;;;;;;;AASG;AAUG,MAAO,WAAY,SAAQ,aAAqB,CAAA;AATtD,IAAA,WAAA,GAAA;;;QAWE,IAAA,CAAA,IAAI,GAAG,KAAK,CAAC,QAAQ;iFAAU;AAC/B;;;;;AAKG;QACH,IAAA,CAAA,MAAM,GAAG,KAAK,CAAC,EAAE;mFAAC;;QAElB,IAAA,CAAA,QAAQ,GAAG,KAAK,CAA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AA,eAAe,WAChB,CAAC,OAAO,EAAE,MAAM,CAAC,EAAA,SAAA,EAGf;AACT,wBAAA,EAAE,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,UAAU,CAAC,iBAAiB,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE;AACxF,qBAAA,EAAA,QAAA,EAAA,ipCAAA,EAAA,MAAA,EAAA,CAAA,y6BAAA,CAAA,EAAA;4uBA2B2E,SAAS,EAAA,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA;;AErEvF;;AAEG;;ACFH;;AAEG;;;;"}
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { input, numberAttribute, booleanAttribute, output, viewChild, signal, computed, forwardRef, Component } from '@angular/core';
|
|
3
|
+
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
4
|
+
import { BaseFormField } from '@4sh/ui-kit/forms';
|
|
5
|
+
import { UiField } from '@4sh/ui-kit/ui-field';
|
|
6
|
+
import { UiIcon } from '@4sh/ui-kit/ui-icon';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* ui-input-number — headless numeric field (`ui-field` shell).
|
|
10
|
+
*
|
|
11
|
+
* Model value = `number | null`. Lenient input: the text is **not** reformatted
|
|
12
|
+
* while typing (no caret jump) — the field shows an editable form on focus, and
|
|
13
|
+
* the **rich format** (thousands grouping, currency, decimals via
|
|
14
|
+
* `Intl.NumberFormat`) is applied **on blur**. `min`/`max`/`step`, ± spinner,
|
|
15
|
+
* ↑/↓ arrow keys, clamp on blur.
|
|
16
|
+
*
|
|
17
|
+
* Formatting is driven by `locale`/`currency`/`useGrouping`/`*FractionDigits`;
|
|
18
|
+
* for a very specific case, override the protected `format()` method.
|
|
19
|
+
*/
|
|
20
|
+
class UiInputNumber extends BaseFormField {
|
|
21
|
+
constructor() {
|
|
22
|
+
super(...arguments);
|
|
23
|
+
/** Native placeholder. */
|
|
24
|
+
this.placeholder = input(/* @ts-ignore */
|
|
25
|
+
...(ngDevMode ? [undefined, { debugName: "placeholder" }] : /* istanbul ignore next */ []));
|
|
26
|
+
/** Minimum value (clamp on blur + disables "−" at the bound). */
|
|
27
|
+
this.min = input(undefined, { ...(ngDevMode ? { debugName: "min" } : /* istanbul ignore next */ {}), transform: numberAttribute });
|
|
28
|
+
/** Maximum value (clamp on blur + disables "+" at the bound). */
|
|
29
|
+
this.max = input(undefined, { ...(ngDevMode ? { debugName: "max" } : /* istanbul ignore next */ {}), transform: numberAttribute });
|
|
30
|
+
/** Increment step (spinner + arrow keys). */
|
|
31
|
+
this.step = input(1, { ...(ngDevMode ? { debugName: "step" } : /* istanbul ignore next */ {}), transform: numberAttribute });
|
|
32
|
+
/** Allow decimals. */
|
|
33
|
+
this.allowDecimals = input(true, { ...(ngDevMode ? { debugName: "allowDecimals" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
34
|
+
/** Suffix unit (e.g. "kg"). Ignored when `currency` is set. */
|
|
35
|
+
this.unit = input(/* @ts-ignore */
|
|
36
|
+
...(ngDevMode ? [undefined, { debugName: "unit" }] : /* istanbul ignore next */ []));
|
|
37
|
+
/** Show the ± spinner. */
|
|
38
|
+
this.showButtons = input(true, { ...(ngDevMode ? { debugName: "showButtons" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
39
|
+
/** Accessible label of the increment spinner button. */
|
|
40
|
+
this.incrementAriaLabel = input('Augmenter', /* @ts-ignore */
|
|
41
|
+
...(ngDevMode ? [{ debugName: "incrementAriaLabel" }] : /* istanbul ignore next */ []));
|
|
42
|
+
/** Accessible label of the decrement spinner button. */
|
|
43
|
+
this.decrementAriaLabel = input('Diminuer', /* @ts-ignore */
|
|
44
|
+
...(ngDevMode ? [{ debugName: "decrementAriaLabel" }] : /* istanbul ignore next */ []));
|
|
45
|
+
// --- Formatting (Intl.NumberFormat) --------------------------------
|
|
46
|
+
/** BCP-47 locale (e.g. `fr-FR`). Defaults to the browser locale. */
|
|
47
|
+
this.locale = input(/* @ts-ignore */
|
|
48
|
+
...(ngDevMode ? [undefined, { debugName: "locale" }] : /* istanbul ignore next */ []));
|
|
49
|
+
/** ISO currency code (e.g. `EUR`) → currency formatting on blur. */
|
|
50
|
+
this.currency = input(/* @ts-ignore */
|
|
51
|
+
...(ngDevMode ? [undefined, { debugName: "currency" }] : /* istanbul ignore next */ []));
|
|
52
|
+
/** Thousands separators on blur. */
|
|
53
|
+
this.useGrouping = input(true, { ...(ngDevMode ? { debugName: "useGrouping" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
54
|
+
/** Minimum fraction digits shown on blur. */
|
|
55
|
+
this.minFractionDigits = input(undefined, { ...(ngDevMode ? { debugName: "minFractionDigits" } : /* istanbul ignore next */ {}), transform: numberAttribute });
|
|
56
|
+
/** Maximum fraction digits shown on blur. */
|
|
57
|
+
this.maxFractionDigits = input(undefined, { ...(ngDevMode ? { debugName: "maxFractionDigits" } : /* istanbul ignore next */ {}), transform: numberAttribute });
|
|
58
|
+
/** Emitted on each numeric value change. */
|
|
59
|
+
this.valueChange = output();
|
|
60
|
+
/** Emitted when the input receives focus. */
|
|
61
|
+
this.inputFocus = output();
|
|
62
|
+
/** Emitted when the input loses focus. */
|
|
63
|
+
this.inputBlur = output();
|
|
64
|
+
/** @ignore */
|
|
65
|
+
this.inputEl = viewChild.required('inputEl', /* @ts-ignore */
|
|
66
|
+
...(ngDevMode ? [{ debugName: "inputEl" }] : /* istanbul ignore next */ []));
|
|
67
|
+
/** @ignore Raw displayed text (independent from the model while typing). */
|
|
68
|
+
this.text = signal('', /* @ts-ignore */
|
|
69
|
+
...(ngDevMode ? [{ debugName: "text" }] : /* istanbul ignore next */ []));
|
|
70
|
+
/** @ignore Suffix unit, ignored when `currency` is set (the formatted value already carries it). */
|
|
71
|
+
this.displayUnit = computed(() => (this.currency() ? null : (this.unit() ?? null)), /* @ts-ignore */
|
|
72
|
+
...(ngDevMode ? [{ debugName: "displayUnit" }] : /* istanbul ignore next */ []));
|
|
73
|
+
/** @ignore */
|
|
74
|
+
this.unitSmall = computed(() => this.size() === 'small', /* @ts-ignore */
|
|
75
|
+
...(ngDevMode ? [{ debugName: "unitSmall" }] : /* istanbul ignore next */ []));
|
|
76
|
+
/** @ignore Bounds reached (disable the spinner buttons). */
|
|
77
|
+
this.atMax = computed(() => {
|
|
78
|
+
const v = this.modelValue();
|
|
79
|
+
const max = this.max();
|
|
80
|
+
return v != null && max != null && v >= max;
|
|
81
|
+
}, /* @ts-ignore */
|
|
82
|
+
...(ngDevMode ? [{ debugName: "atMax" }] : /* istanbul ignore next */ []));
|
|
83
|
+
this.atMin = computed(() => {
|
|
84
|
+
const v = this.modelValue();
|
|
85
|
+
const min = this.min();
|
|
86
|
+
return v != null && min != null && v <= min;
|
|
87
|
+
}, /* @ts-ignore */
|
|
88
|
+
...(ngDevMode ? [{ debugName: "atMin" }] : /* istanbul ignore next */ []));
|
|
89
|
+
/** @ignore Group/decimal separators of the current locale. */
|
|
90
|
+
this.separators = computed(() => {
|
|
91
|
+
const parts = new Intl.NumberFormat(this.locale()).formatToParts(11111.1);
|
|
92
|
+
return {
|
|
93
|
+
group: parts.find((p) => p.type === 'group')?.value ?? '',
|
|
94
|
+
decimal: parts.find((p) => p.type === 'decimal')?.value ?? '.',
|
|
95
|
+
};
|
|
96
|
+
}, /* @ts-ignore */
|
|
97
|
+
...(ngDevMode ? [{ debugName: "separators" }] : /* istanbul ignore next */ []));
|
|
98
|
+
}
|
|
99
|
+
writeValue(value) {
|
|
100
|
+
this.modelValue.set(value ?? undefined);
|
|
101
|
+
this.text.set(value === null || value === undefined ? '' : this.format(value));
|
|
102
|
+
}
|
|
103
|
+
/** Focuses the input. */
|
|
104
|
+
focus(options) {
|
|
105
|
+
this.inputEl().nativeElement.focus(options);
|
|
106
|
+
}
|
|
107
|
+
/** @ignore Focus: switch to an editable form (no grouping/currency). */
|
|
108
|
+
onFocus(event) {
|
|
109
|
+
const v = this.modelValue();
|
|
110
|
+
if (v != null)
|
|
111
|
+
this.text.set(this.editable(v));
|
|
112
|
+
this.inputFocus.emit(event);
|
|
113
|
+
}
|
|
114
|
+
/** @ignore Input: parse without reformatting the text (caret preserved). */
|
|
115
|
+
onInput() {
|
|
116
|
+
const raw = this.inputEl().nativeElement.value;
|
|
117
|
+
this.text.set(raw);
|
|
118
|
+
this.commit(this.parse(raw), { reformat: false });
|
|
119
|
+
}
|
|
120
|
+
/** @ignore Blur: clamp + rich reformatting. */
|
|
121
|
+
onBlur(event) {
|
|
122
|
+
this.commit(this.clamp(this.modelValue() ?? null), { reformat: true });
|
|
123
|
+
this.emitTouch();
|
|
124
|
+
this.inputBlur.emit(event);
|
|
125
|
+
}
|
|
126
|
+
/** @ignore ↑/↓ arrow keys. */
|
|
127
|
+
onKeydown(event) {
|
|
128
|
+
if (event.key === 'ArrowUp') {
|
|
129
|
+
event.preventDefault();
|
|
130
|
+
this.stepBy(1);
|
|
131
|
+
}
|
|
132
|
+
else if (event.key === 'ArrowDown') {
|
|
133
|
+
event.preventDefault();
|
|
134
|
+
this.stepBy(-1);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/** @ignore ± spinner. */
|
|
138
|
+
stepBy(direction) {
|
|
139
|
+
if (this.isDisabled() || this.readonly())
|
|
140
|
+
return;
|
|
141
|
+
const base = this.modelValue() ?? 0;
|
|
142
|
+
const next = this.clamp(base + direction * this.step());
|
|
143
|
+
this.commit(next, { reformat: !this.isFocused() });
|
|
144
|
+
if (this.isFocused())
|
|
145
|
+
this.text.set(next === null ? '' : this.editable(next));
|
|
146
|
+
this.inputEl().nativeElement.focus();
|
|
147
|
+
}
|
|
148
|
+
/** @ignore Does the input currently have focus? */
|
|
149
|
+
isFocused() {
|
|
150
|
+
return typeof document !== 'undefined' && document.activeElement === this.inputEl().nativeElement;
|
|
151
|
+
}
|
|
152
|
+
/** @ignore Update model + emit; reformat the text when requested. */
|
|
153
|
+
commit(value, opts) {
|
|
154
|
+
this.modelValue.set(value ?? undefined);
|
|
155
|
+
if (opts.reformat)
|
|
156
|
+
this.text.set(value === null ? '' : this.format(value));
|
|
157
|
+
this.emitChange(value);
|
|
158
|
+
this.valueChange.emit(value);
|
|
159
|
+
}
|
|
160
|
+
/** @ignore Parse a lenient (locale-aware) input → number or null. */
|
|
161
|
+
parse(raw) {
|
|
162
|
+
const { group, decimal } = this.separators();
|
|
163
|
+
let s = raw.trim();
|
|
164
|
+
if (group)
|
|
165
|
+
s = s.split(group).join('');
|
|
166
|
+
s = s
|
|
167
|
+
.replace(/\s/g, '') // spaces (incl. U+202F/U+00A0 grouping separators)
|
|
168
|
+
.replace(decimal, '.')
|
|
169
|
+
.replace(/[^0-9.-]/g, ''); // strip currency/symbols
|
|
170
|
+
if (s === '' || s === '-' || s === '.' || s === '-.')
|
|
171
|
+
return null;
|
|
172
|
+
const n = Number(s);
|
|
173
|
+
if (Number.isNaN(n))
|
|
174
|
+
return null;
|
|
175
|
+
return this.allowDecimals() ? n : Math.trunc(n);
|
|
176
|
+
}
|
|
177
|
+
/** @ignore Clamp the value into [min, max]. */
|
|
178
|
+
clamp(value) {
|
|
179
|
+
if (value === null)
|
|
180
|
+
return null;
|
|
181
|
+
const min = this.min();
|
|
182
|
+
const max = this.max();
|
|
183
|
+
let v = value;
|
|
184
|
+
if (min != null && v < min)
|
|
185
|
+
v = min;
|
|
186
|
+
if (max != null && v > max)
|
|
187
|
+
v = max;
|
|
188
|
+
return v;
|
|
189
|
+
}
|
|
190
|
+
/** @ignore Editable form on focus: locale decimals, no grouping or currency. */
|
|
191
|
+
editable(value) {
|
|
192
|
+
return new Intl.NumberFormat(this.locale(), {
|
|
193
|
+
useGrouping: false,
|
|
194
|
+
maximumFractionDigits: 20,
|
|
195
|
+
}).format(value);
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Display formatting on blur (overridable). Defaults to `Intl.NumberFormat`
|
|
199
|
+
* with `locale`/`currency`/`useGrouping`/`*FractionDigits`.
|
|
200
|
+
*/
|
|
201
|
+
format(value) {
|
|
202
|
+
const options = { useGrouping: this.useGrouping() };
|
|
203
|
+
if (this.currency()) {
|
|
204
|
+
options.style = 'currency';
|
|
205
|
+
options.currency = this.currency();
|
|
206
|
+
}
|
|
207
|
+
if (this.minFractionDigits() != null)
|
|
208
|
+
options.minimumFractionDigits = this.minFractionDigits();
|
|
209
|
+
if (this.maxFractionDigits() != null)
|
|
210
|
+
options.maximumFractionDigits = this.maxFractionDigits();
|
|
211
|
+
return new Intl.NumberFormat(this.locale(), options).format(value);
|
|
212
|
+
}
|
|
213
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: UiInputNumber, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
214
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.8", type: UiInputNumber, isStandalone: true, selector: "ui-input-number", inputs: { placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, step: { classPropertyName: "step", publicName: "step", isSignal: true, isRequired: false, transformFunction: null }, allowDecimals: { classPropertyName: "allowDecimals", publicName: "allowDecimals", isSignal: true, isRequired: false, transformFunction: null }, unit: { classPropertyName: "unit", publicName: "unit", isSignal: true, isRequired: false, transformFunction: null }, showButtons: { classPropertyName: "showButtons", publicName: "showButtons", isSignal: true, isRequired: false, transformFunction: null }, incrementAriaLabel: { classPropertyName: "incrementAriaLabel", publicName: "incrementAriaLabel", isSignal: true, isRequired: false, transformFunction: null }, decrementAriaLabel: { classPropertyName: "decrementAriaLabel", publicName: "decrementAriaLabel", isSignal: true, isRequired: false, transformFunction: null }, locale: { classPropertyName: "locale", publicName: "locale", isSignal: true, isRequired: false, transformFunction: null }, currency: { classPropertyName: "currency", publicName: "currency", isSignal: true, isRequired: false, transformFunction: null }, useGrouping: { classPropertyName: "useGrouping", publicName: "useGrouping", isSignal: true, isRequired: false, transformFunction: null }, minFractionDigits: { classPropertyName: "minFractionDigits", publicName: "minFractionDigits", isSignal: true, isRequired: false, transformFunction: null }, maxFractionDigits: { classPropertyName: "maxFractionDigits", publicName: "maxFractionDigits", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { valueChange: "valueChange", inputFocus: "inputFocus", inputBlur: "inputBlur" }, providers: [
|
|
215
|
+
{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => UiInputNumber), multi: true },
|
|
216
|
+
], viewQueries: [{ propertyName: "inputEl", first: true, predicate: ["inputEl"], descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0, template: "<ui-field\n [label]=\"label()\"\n [for]=\"resolvedId()\"\n [required]=\"required()\"\n [size]=\"size()\"\n [level]=\"effectiveLevel()\"\n [disabled]=\"isDisabled()\"\n [readonly]=\"readonly()\"\n [message]=\"displayMessage()\"\n [messageId]=\"messageId()\"\n>\n <input\n #inputEl\n class=\"ui-input-number-native\"\n [class._small]=\"size() === 'small'\"\n type=\"text\"\n inputmode=\"decimal\"\n [id]=\"resolvedId()\"\n [value]=\"text()\"\n [placeholder]=\"placeholder() ?? ''\"\n [disabled]=\"isDisabled()\"\n [readOnly]=\"readonly()\"\n [required]=\"required()\"\n [attr.name]=\"name() || null\"\n [attr.tabindex]=\"tabindex()\"\n [attr.aria-label]=\"label() ? null : ariaLabel() || null\"\n [attr.aria-labelledby]=\"ariaLabelledBy() || null\"\n [attr.aria-describedby]=\"displayMessage() ? messageId() : null\"\n [attr.aria-invalid]=\"effectiveLevel() === 'error' ? 'true' : null\"\n role=\"spinbutton\"\n [attr.aria-valuenow]=\"modelValue() ?? null\"\n [attr.aria-valuemin]=\"min() ?? null\"\n [attr.aria-valuemax]=\"max() ?? null\"\n (input)=\"onInput()\"\n (keydown)=\"onKeydown($event)\"\n (focus)=\"onFocus($event)\"\n (blur)=\"onBlur($event)\"\n />\n\n @if (displayUnit(); as u) {\n <span uiFieldSuffix class=\"ui-input-number-unit\" [class._small]=\"unitSmall()\" [class._disabled]=\"isDisabled()\">{{ u }}</span>\n }\n\n @if (showButtons()) {\n <span uiFieldSuffix class=\"ui-input-number-spinner\">\n <button\n type=\"button\"\n tabindex=\"-1\"\n [attr.aria-label]=\"incrementAriaLabel()\"\n [disabled]=\"isDisabled() || readonly() || atMax()\"\n (click)=\"stepBy(1)\"\n >\n <ui-icon name=\"angle-up\" size=\"sm\" />\n </button>\n <button\n type=\"button\"\n tabindex=\"-1\"\n [attr.aria-label]=\"decrementAriaLabel()\"\n [disabled]=\"isDisabled() || readonly() || atMin()\"\n (click)=\"stepBy(-1)\"\n >\n <ui-icon name=\"angle-down\" size=\"sm\" />\n </button>\n </span>\n }\n</ui-field>\n", styles: [".ui-input-number-native{flex:1 1 auto;align-self:stretch;min-width:0;margin:0;padding:0;border:none;border-radius:inherit;background:transparent;outline:none;font-family:var(--fontfamily-base);font-size:var(--size-typography-text-default);color:var(--form-high-content-default)}.ui-input-number-native:first-child{padding-inline-start:var(--units-md)}.ui-input-number-native:last-child{padding-inline-end:var(--units-md)}.ui-input-number-native::placeholder{color:var(--form-low-content-default);opacity:1}.ui-input-number-native:disabled{cursor:not-allowed;color:var(--form-high-content-disabled)}.ui-input-number-native._small{font-size:var(--size-typography-text-md)}.ui-input-number-unit{flex-shrink:0;color:var(--form-low-content-default)}.ui-input-number-unit:first-child{margin-inline-start:var(--units-md)}.ui-input-number-unit:last-child{margin-inline-end:var(--units-md)}.ui-input-number-unit._disabled{color:var(--form-high-content-disabled)}.ui-input-number-unit{font-family:var(--fontfamily-base);font-size:var(--size-typography-text-default);white-space:nowrap;-webkit-user-select:none;user-select:none}.ui-input-number-unit._small{font-size:var(--size-typography-text-md)}.ui-input-number-spinner{display:flex;flex-direction:column;align-self:stretch;flex-shrink:0;width:1.875rem;border-left:var(--stroke-default) solid var(--form-high-stroke-default);border-radius:0 var(--radius-sm) var(--radius-sm) 0;overflow:hidden}.ui-input-number-spinner button{display:flex;flex:1 1 50%;align-items:center;justify-content:center;min-height:0;padding:0;border:none;background:none;line-height:0;color:var(--form-low-content-default);cursor:pointer;transition:color var(--transition-default) var(--transition-easeinout),background-color var(--transition-default) var(--transition-easeinout)}.ui-input-number-spinner button:hover:not(:disabled){color:var(--form-high-content-hover);background-color:var(--form-high-surface-hover)}.ui-input-number-spinner button:disabled{cursor:not-allowed;color:var(--form-high-content-disabled)}.ui-input-number-spinner button+button{border-top:var(--stroke-default) solid var(--form-high-stroke-default)}\n"], dependencies: [{ kind: "component", type: UiField, selector: "ui-field", inputs: ["label", "for", "required", "size", "level", "disabled", "readonly", "multiline", "autoHeight", "message", "messageId", "hasFooter"] }, { kind: "component", type: UiIcon, selector: "ui-icon", inputs: ["name", "size", "type", "family", "decorative", "ariaLabel"] }] }); }
|
|
217
|
+
}
|
|
218
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: UiInputNumber, decorators: [{
|
|
219
|
+
type: Component,
|
|
220
|
+
args: [{ selector: 'ui-input-number', imports: [UiField, UiIcon], providers: [
|
|
221
|
+
{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => UiInputNumber), multi: true },
|
|
222
|
+
], template: "<ui-field\n [label]=\"label()\"\n [for]=\"resolvedId()\"\n [required]=\"required()\"\n [size]=\"size()\"\n [level]=\"effectiveLevel()\"\n [disabled]=\"isDisabled()\"\n [readonly]=\"readonly()\"\n [message]=\"displayMessage()\"\n [messageId]=\"messageId()\"\n>\n <input\n #inputEl\n class=\"ui-input-number-native\"\n [class._small]=\"size() === 'small'\"\n type=\"text\"\n inputmode=\"decimal\"\n [id]=\"resolvedId()\"\n [value]=\"text()\"\n [placeholder]=\"placeholder() ?? ''\"\n [disabled]=\"isDisabled()\"\n [readOnly]=\"readonly()\"\n [required]=\"required()\"\n [attr.name]=\"name() || null\"\n [attr.tabindex]=\"tabindex()\"\n [attr.aria-label]=\"label() ? null : ariaLabel() || null\"\n [attr.aria-labelledby]=\"ariaLabelledBy() || null\"\n [attr.aria-describedby]=\"displayMessage() ? messageId() : null\"\n [attr.aria-invalid]=\"effectiveLevel() === 'error' ? 'true' : null\"\n role=\"spinbutton\"\n [attr.aria-valuenow]=\"modelValue() ?? null\"\n [attr.aria-valuemin]=\"min() ?? null\"\n [attr.aria-valuemax]=\"max() ?? null\"\n (input)=\"onInput()\"\n (keydown)=\"onKeydown($event)\"\n (focus)=\"onFocus($event)\"\n (blur)=\"onBlur($event)\"\n />\n\n @if (displayUnit(); as u) {\n <span uiFieldSuffix class=\"ui-input-number-unit\" [class._small]=\"unitSmall()\" [class._disabled]=\"isDisabled()\">{{ u }}</span>\n }\n\n @if (showButtons()) {\n <span uiFieldSuffix class=\"ui-input-number-spinner\">\n <button\n type=\"button\"\n tabindex=\"-1\"\n [attr.aria-label]=\"incrementAriaLabel()\"\n [disabled]=\"isDisabled() || readonly() || atMax()\"\n (click)=\"stepBy(1)\"\n >\n <ui-icon name=\"angle-up\" size=\"sm\" />\n </button>\n <button\n type=\"button\"\n tabindex=\"-1\"\n [attr.aria-label]=\"decrementAriaLabel()\"\n [disabled]=\"isDisabled() || readonly() || atMin()\"\n (click)=\"stepBy(-1)\"\n >\n <ui-icon name=\"angle-down\" size=\"sm\" />\n </button>\n </span>\n }\n</ui-field>\n", styles: [".ui-input-number-native{flex:1 1 auto;align-self:stretch;min-width:0;margin:0;padding:0;border:none;border-radius:inherit;background:transparent;outline:none;font-family:var(--fontfamily-base);font-size:var(--size-typography-text-default);color:var(--form-high-content-default)}.ui-input-number-native:first-child{padding-inline-start:var(--units-md)}.ui-input-number-native:last-child{padding-inline-end:var(--units-md)}.ui-input-number-native::placeholder{color:var(--form-low-content-default);opacity:1}.ui-input-number-native:disabled{cursor:not-allowed;color:var(--form-high-content-disabled)}.ui-input-number-native._small{font-size:var(--size-typography-text-md)}.ui-input-number-unit{flex-shrink:0;color:var(--form-low-content-default)}.ui-input-number-unit:first-child{margin-inline-start:var(--units-md)}.ui-input-number-unit:last-child{margin-inline-end:var(--units-md)}.ui-input-number-unit._disabled{color:var(--form-high-content-disabled)}.ui-input-number-unit{font-family:var(--fontfamily-base);font-size:var(--size-typography-text-default);white-space:nowrap;-webkit-user-select:none;user-select:none}.ui-input-number-unit._small{font-size:var(--size-typography-text-md)}.ui-input-number-spinner{display:flex;flex-direction:column;align-self:stretch;flex-shrink:0;width:1.875rem;border-left:var(--stroke-default) solid var(--form-high-stroke-default);border-radius:0 var(--radius-sm) var(--radius-sm) 0;overflow:hidden}.ui-input-number-spinner button{display:flex;flex:1 1 50%;align-items:center;justify-content:center;min-height:0;padding:0;border:none;background:none;line-height:0;color:var(--form-low-content-default);cursor:pointer;transition:color var(--transition-default) var(--transition-easeinout),background-color var(--transition-default) var(--transition-easeinout)}.ui-input-number-spinner button:hover:not(:disabled){color:var(--form-high-content-hover);background-color:var(--form-high-surface-hover)}.ui-input-number-spinner button:disabled{cursor:not-allowed;color:var(--form-high-content-disabled)}.ui-input-number-spinner button+button{border-top:var(--stroke-default) solid var(--form-high-stroke-default)}\n"] }]
|
|
223
|
+
}], propDecorators: { placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], min: [{ type: i0.Input, args: [{ isSignal: true, alias: "min", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], step: [{ type: i0.Input, args: [{ isSignal: true, alias: "step", required: false }] }], allowDecimals: [{ type: i0.Input, args: [{ isSignal: true, alias: "allowDecimals", required: false }] }], unit: [{ type: i0.Input, args: [{ isSignal: true, alias: "unit", required: false }] }], showButtons: [{ type: i0.Input, args: [{ isSignal: true, alias: "showButtons", required: false }] }], incrementAriaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "incrementAriaLabel", required: false }] }], decrementAriaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "decrementAriaLabel", required: false }] }], locale: [{ type: i0.Input, args: [{ isSignal: true, alias: "locale", required: false }] }], currency: [{ type: i0.Input, args: [{ isSignal: true, alias: "currency", required: false }] }], useGrouping: [{ type: i0.Input, args: [{ isSignal: true, alias: "useGrouping", required: false }] }], minFractionDigits: [{ type: i0.Input, args: [{ isSignal: true, alias: "minFractionDigits", required: false }] }], maxFractionDigits: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxFractionDigits", required: false }] }], valueChange: [{ type: i0.Output, args: ["valueChange"] }], inputFocus: [{ type: i0.Output, args: ["inputFocus"] }], inputBlur: [{ type: i0.Output, args: ["inputBlur"] }], inputEl: [{ type: i0.ViewChild, args: ['inputEl', { isSignal: true }] }] } });
|
|
224
|
+
|
|
225
|
+
/*
|
|
226
|
+
* Public API Surface of ui-kit/ui-input-number
|
|
227
|
+
*/
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Generated bundle index. Do not edit.
|
|
231
|
+
*/
|
|
232
|
+
|
|
233
|
+
export { UiInputNumber };
|
|
234
|
+
//# sourceMappingURL=4sh-ui-kit-ui-input-number.mjs.map
|