@liquid-js/lyr-extras 22.0.0-alpha.0 → 22.0.0-alpha.1
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/fesm2022/liquid-js-lyr-extras-color-picker.mjs +5 -3
- package/fesm2022/liquid-js-lyr-extras-color-picker.mjs.map +1 -1
- package/fesm2022/liquid-js-lyr-extras-markdown-editor.mjs +12 -10
- package/fesm2022/liquid-js-lyr-extras-markdown-editor.mjs.map +1 -1
- package/fesm2022/liquid-js-lyr-extras-mask.mjs +6 -4
- package/fesm2022/liquid-js-lyr-extras-mask.mjs.map +1 -1
- package/fesm2022/liquid-js-lyr-extras-phone-input.mjs +8 -6
- package/fesm2022/liquid-js-lyr-extras-phone-input.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -224,9 +224,11 @@ var NbColorPickerComponent = class NbColorPickerComponent {
|
|
|
224
224
|
this.overlayHandler.destroy();
|
|
225
225
|
}
|
|
226
226
|
writeValue(value) {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
227
|
+
untracked(() => {
|
|
228
|
+
this.value.set(value || null);
|
|
229
|
+
this.setParseError(false);
|
|
230
|
+
this.show(value || "");
|
|
231
|
+
});
|
|
230
232
|
}
|
|
231
233
|
registerOnChange(fn) {
|
|
232
234
|
this.onChange = fn;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"liquid-js-lyr-extras-color-picker.mjs","names":[],"sources":["../../../packages/extras/color-picker/src/color-picker-dialog.component.ts","../../../packages/extras/color-picker/src/texts.ts","../../../packages/extras/color-picker/src/color-picker.component.ts","../../../packages/extras/color-picker/src/color-picker.component.html"],"sourcesContent":["import { ChangeDetectionStrategy, Component, input, TemplateRef, viewChild } from '@angular/core'\nimport {\n NbOverlayContainerComponent,\n NbOverlayContent,\n NbPositionedContainerComponent,\n NbRenderableContainer,\n NbTemplatePortal\n} from '@liquid-js/lyr-core'\n\n/**\n * The colour picker's overlay: the dialog of `nb-color-picker`, framed as the date picker's is. The dialog is\n * nxt-color-picker's, shown inline in it, so it opens, and is positioned and closed, as Lyra's pickers are.\n *\n * @internal\n */\n@Component({\n selector: 'nb-color-picker-dialog',\n template: '<nb-overlay-container />',\n // Hosted content may not use signals, so it's checked on every change detection.\n changeDetection: ChangeDetectionStrategy.Eager,\n imports: [NbOverlayContainerComponent]\n})\nexport class NbColorPickerDialogComponent extends NbPositionedContainerComponent implements NbRenderableContainer {\n readonly overlayContainer = viewChild.required(NbOverlayContainerComponent)\n\n readonly content = input<NbOverlayContent>()\n readonly context = input<object>()\n\n renderContent() {\n const container = this.overlayContainer()\n container.detach()\n const content = this.content()\n if (content instanceof TemplateRef) {\n container.attachTemplatePortal(new NbTemplatePortal(content, undefined, this.context()))\n }\n }\n}\n","import { injectNbTexts, NbLocalize } from '@liquid-js/lyr-core'\nimport type { ColorPickerTexts } from 'nxt-color-picker'\n\n/** @internal */\ndeclare const $localize: NbLocalize\n\n/**\n * The texts of the colour picker. `provideNbTexts({ colorPicker: { ... } })` changes them, and they're translated with\n * Angular's i18n, as `$localize` messages with ids like `@@nb.colorPicker.invalid`.\n *\n * The dialog's texts, e.g. `ok` or `presetColors`, are `nxt-color-picker`'s, with ids like\n * `@@nxt-color-picker.button.ok`; set them here too to change them.\n */\nexport interface NbColorPickerTexts extends Partial<ColorPickerTexts> {\n /** Names the field when it has no `aria-label` or `aria-labelledby`. */\n color: string\n /** Label of the button that clears the colour. */\n clear: string\n /** The message of the `nbColorPicker` error for text that isn't a colour. */\n invalid: string\n}\n\ndeclare module '@liquid-js/lyr-core' {\n interface NbTexts {\n colorPicker: NbColorPickerTexts\n }\n}\n\n/** The default texts, in the app's language. @internal */\nexport function nbColorPickerTexts(): NbColorPickerTexts {\n return {\n color: $localize`:@@nb.colorPicker.color:Color`,\n clear: $localize`:@@nb.colorPicker.clear:Clear color`,\n invalid: $localize`:@@nb.colorPicker.invalid:Enter a valid color`\n }\n}\n\n/** @internal */\nexport function injectNbColorPickerTexts() {\n return injectNbTexts('colorPicker', nbColorPickerTexts)\n}\n","import {\n afterNextRender,\n AfterViewInit,\n booleanAttribute,\n Component,\n computed,\n DestroyRef,\n effect,\n ElementRef,\n forwardRef,\n inject,\n Injector,\n input,\n linkedSignal,\n OnDestroy,\n signal,\n TemplateRef,\n untracked,\n viewChild,\n ViewEncapsulation\n} from '@angular/core'\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop'\nimport { ControlValueAccessor, NG_VALIDATORS, NG_VALUE_ACCESSOR, ValidationErrors, Validator } from '@angular/forms'\nimport {\n injectNbDefaults,\n injectNbValidationMessage,\n NbAdjustment,\n NbButtonComponent,\n NbComponentOrCustomStatus,\n NbComponentShape,\n NbComponentSize,\n nbCreateDynamicOverlayHandler,\n NbDynamicOverlay,\n NbFormFieldModule,\n NbIconComponent,\n NbInputDirective,\n NbPosition,\n NbTrigger,\n NbValidationDirective\n} from '@liquid-js/lyr-core'\nimport {\n AlphaChannel,\n cmykToRgb,\n ColorPickerDirective,\n formatCmyk,\n formatOutput,\n hsvaToRgba,\n NXT_COLOR_PICKER_TEXTS,\n OutputFormat,\n rgbaToCmyk,\n rgbaToHsva,\n stringToCmyk,\n stringToHsva\n} from 'nxt-color-picker'\nimport { skip } from 'rxjs'\n\nimport { NbColorPickerDialogComponent } from './color-picker-dialog.component'\nimport { injectNbColorPickerTexts } from './texts'\n\nlet nextDialogId = 0\n\n/** What the dialog's buttons, sliders, presets and inputs match, to move focus into it. */\nconst DIALOG_FOCUSABLE = '[tabindex=\"0\"], input, button'\n\n/** The error kind of text that isn't a colour. */\nexport const NB_COLOR_PICKER_ERROR = 'nbColorPicker' as const\n\n/** The `nbColorPicker` error, as Angular gives parse errors: its kind and its message. */\nexport interface NbColorPickerError {\n kind: typeof NB_COLOR_PICKER_ERROR\n message: string\n}\n\n/** The colour of a text as CSS, e.g. for the swatch: from a CSS colour or a `cmyk()` one, if it's one. */\nfunction cssColor(text: string | null): string | undefined {\n if (!text) {\n return undefined\n }\n const cmyk = stringToCmyk(text, true)\n const hsva = stringToHsva(text, true) ?? (cmyk ? rgbaToHsva(cmykToRgb(cmyk)) : undefined)\n return hsva ? formatOutput(hsva, 'rgba', 'enabled') : undefined\n}\n\n/**\n * A field for a colour, with a swatch and a picker dialog:\n *\n * ```html\n * <nb-color-picker [formControl]=\"color\" [presets]=\"['#3366ff', '#00d68f']\" clearable />\n * ```\n *\n * @stacked-example(Showcase, color-picker/color-picker-showcase.component)\n *\n * ### Installation\n *\n * Install [`nxt-color-picker`](https://www.npmjs.com/package/nxt-color-picker), which draws the dialog, and import\n * `NbColorPickerComponent` from `@liquid-js/lyr-extras/color-picker`:\n *\n * ```bash\n * npm install nxt-color-picker\n * ```\n *\n * ### Usage\n *\n * It's a form control whose value is the colour as text, e.g. `#3366ff`, or `null` without one. The user picks it in\n * the dialog or types it, and with `clearable` the field has a button that clears it, as does emptying the text. It\n * has the sizes, statuses, shapes and `ghost` look of `nbInput`, and its `readonly`, without the dialog; its swatch\n * shows the colour over a checkerboard, so transparency shows:\n * @stacked-example(Sizes and statuses, color-picker/color-picker-sizes.component)\n *\n * The dialog opens below the field when it has focus, as the date picker's does, and closes when focus or a click\n * goes elsewhere. Arrow Down moves focus into it, where the sliders move with the arrow keys, Page Up and Down, Home\n * and End; Enter and Escape close it, keeping the colour, and return to the field.\n *\n * `outputFormat` picks the text the value has, `hex`, `rgba`, `hsla` or `auto`, `alphaChannel` whether it can be\n * transparent, and `cmyk` adds a CMYK input and makes the value a `cmyk()` colour. The dialog has the theme's\n * colours, with its own `color-picker-*` variables, which follow the date picker's values.\n *\n * ### Validation\n *\n * While the text isn't a colour, e.g. `#12345`, the value stays the last colour, and the field has the\n * `nbColorPicker` parse error, `{ kind, message }`, as Angular's controls report text they can't parse; so does\n * empty text in a field that isn't `clearable`. It works with `formControl`, `formControlName`, `ngModel` and signal\n * forms' `[formField]`, and with `nbValidation`:\n * @stacked-example(Validation, color-picker/color-picker-validation.component)\n *\n * ### Texts\n *\n * Its texts, and the dialog's, are in the `colorPicker` section of Lyra's texts:\n *\n * ```ts\n * provideNbTexts({ colorPicker: { clear: 'Remove the color', ok: 'Apply' } })\n * ```\n * @styles\n *\n * color-picker-background-color:\n * color-picker-border-color:\n * color-picker-border-style:\n * color-picker-border-width:\n * color-picker-border-radius:\n * color-picker-shadow:\n * color-picker-text-color:\n * color-picker-text-font-family:\n * color-picker-text-font-size:\n * color-picker-divider-color:\n * color-picker-format-arrow-color:\n */\n@Component({\n selector: 'nb-color-picker',\n templateUrl: './color-picker.component.html',\n // The dialog is in the overlay container, outside the component, so its styles are global.\n encapsulation: ViewEncapsulation.None,\n styles: `\n nb-color-picker {\n display: inline-block;\n /* Lines up with fields and buttons of its size by its middle, as they do. */\n vertical-align: middle;\n }\n\n nb-color-picker.full-width {\n display: block;\n }\n\n nb-color-picker .swatch {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 100%;\n height: 100%;\n }\n\n nb-color-picker .swatch > span {\n width: 100%;\n aspect-ratio: 1;\n border-radius: 50%;\n }\n\n /* The colour over a 2×2 checkerboard, as in the dialog, so transparency shows. */\n nb-color-picker .swatch > span[style*='--nb-color-picker-swatch'] {\n background-image:\n linear-gradient(var(--nb-color-picker-swatch), var(--nb-color-picker-swatch)),\n conic-gradient(#fff 0 25%, #ccc 0 50%, #fff 0 75%, #ccc 0);\n }\n\n nb-color-picker-dialog {\n display: block;\n border: var(--color-picker-border-width) var(--color-picker-border-style) var(--color-picker-border-color);\n border-radius: var(--color-picker-border-radius);\n background: var(--color-picker-background-color);\n box-shadow: var(--color-picker-shadow);\n }\n\n nb-color-picker-dialog nxt-color-picker {\n display: block;\n --nxt-color-picker-background: transparent;\n --nxt-color-picker-border: none;\n /* The colours reach the frame, inside its rounded corners; the colour's mark can go past them. */\n --nxt-color-picker-border-radius: max(\n 0px,\n calc(var(--color-picker-border-radius) - var(--color-picker-border-width))\n );\n --nxt-color-picker-shadow: none;\n --nxt-color-picker-text-color: var(--color-picker-text-color);\n --nxt-color-picker-font-family: var(--color-picker-text-font-family);\n --nxt-color-picker-font-size: var(--color-picker-text-font-size);\n --nxt-color-picker-border-color: var(--color-picker-divider-color);\n --nxt-color-picker-focus-outline: var(--outline-width) solid var(--outline-color);\n --nxt-color-picker-focus-outline-width: var(--outline-width);\n --nxt-color-picker-arrow-color: var(--color-picker-format-arrow-color);\n --nxt-color-picker-input-background: var(--input-basic-background-color);\n --nxt-color-picker-input-border-color: var(--input-basic-border-color);\n --nxt-color-picker-input-border-width: var(--input-border-width);\n --nxt-color-picker-input-text-color: var(--input-basic-text-color);\n --nxt-color-picker-input-placeholder-color: var(--input-basic-placeholder-text-color);\n --nxt-color-picker-input-border-radius: var(--input-rectangle-border-radius);\n --nxt-color-picker-input-hover-background: var(--input-basic-hover-background-color);\n --nxt-color-picker-input-hover-border-color: var(--input-basic-hover-border-color);\n --nxt-color-picker-input-focus-background: var(--input-basic-focus-background-color);\n --nxt-color-picker-input-focus-border-color: var(--input-basic-focus-border-color);\n --nxt-color-picker-input-disabled-background: var(--input-basic-disabled-background-color);\n --nxt-color-picker-input-disabled-border-color: var(--input-basic-disabled-border-color);\n --nxt-color-picker-input-disabled-text-color: var(--input-basic-disabled-text-color);\n --nxt-color-picker-button-color: var(--button-filled-basic-text-color);\n --nxt-color-picker-button-background: var(--button-filled-basic-background-color);\n --nxt-color-picker-button-border: var(--button-filled-border-width) var(--button-filled-border-style)\n var(--button-filled-basic-border-color);\n --nxt-color-picker-button-border-radius: var(--button-rectangle-border-radius);\n --nxt-color-picker-button-font-size: var(--button-small-text-font-size);\n --nxt-color-picker-button-font-weight: var(--button-text-font-weight);\n }\n `,\n imports: [ColorPickerDirective, NbButtonComponent, NbFormFieldModule, NbIconComponent, NbInputDirective],\n providers: [\n { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => NbColorPickerComponent), multi: true },\n { provide: NG_VALIDATORS, useExisting: forwardRef(() => NbColorPickerComponent), multi: true },\n // The dialog's texts follow Lyra's.\n { provide: NXT_COLOR_PICKER_TEXTS, useFactory: injectNbColorPickerTexts }\n ],\n host: {\n '[class.full-width]': 'fullWidth()'\n }\n})\nexport class NbColorPickerComponent implements ControlValueAccessor, Validator, AfterViewInit, OnDestroy {\n // The app's defaults for fields, which the inputs below start from.\n protected readonly nbDefaults = injectNbDefaults('input')\n\n protected readonly texts = injectNbColorPickerTexts()\n protected readonly message = injectNbValidationMessage()\n protected readonly validation = inject(NbValidationDirective, { self: true, optional: true })\n\n /** Field size: `tiny`, `small`, `medium` (default), `large` or `giant`. */\n readonly sizeInput = input<NbComponentSize | undefined>(undefined, { alias: 'size' })\n /** The size in use: the input's, the app's default, or 'medium'. */\n readonly size = linkedSignal<NbComponentSize>(() => this.sizeInput() ?? this.nbDefaults().size ?? 'medium')\n /** Field status: `basic` (default), `primary`, `info`, `success`, `warning`, `danger` or `control`. */\n readonly status = input<NbComponentOrCustomStatus>('basic')\n /** Field shape: `rectangle` (default), `semi-round` or `round`. */\n readonly shapeInput = input<NbComponentShape | undefined>(undefined, { alias: 'shape' })\n /** The shape in use: the input's, the app's default, or 'rectangle'. */\n readonly shape = linkedSignal<NbComponentShape>(() => this.shapeInput() ?? this.nbDefaults().shape ?? 'rectangle')\n /** Makes the field as wide as its container. */\n readonly fullWidth = input(false, { transform: booleanAttribute })\n /** Shows the field without its background and border, as `nbInput`'s `ghost` does. */\n readonly ghost = input(false, { transform: booleanAttribute })\n readonly placeholder = input('')\n /** Lets the user read and select the colour, but not change it, as a read-only field; its dialog doesn't open. */\n readonly readonly = input(false, { transform: booleanAttribute })\n /** Names the field when there's no `aria-labelledby`; \"Color\" by default. */\n readonly ariaLabel = input<string | undefined>(undefined, { alias: 'aria-label' })\n /** The id of the element that names the field, e.g. a `label`. */\n readonly ariaLabelledBy = input<string | undefined>(undefined, { alias: 'aria-labelledby' })\n\n /** What labels the field: its own `aria-labelledby` and an `nbLabel` of its `nbValidation`. */\n protected readonly fieldLabelledBy = computed(\n () => [this.ariaLabelledBy(), this.validation?.labelledBy()].filter(Boolean).join(' ') || null\n )\n\n /** The text of the value: `hex`, `rgba`, `hsla` or `auto`, which keeps the format a colour is typed in. */\n readonly outputFormat = input<OutputFormat>('auto')\n /** Whether the colour can be transparent. */\n readonly alphaChannel = input<AlphaChannel>('enabled')\n /** Adds a CMYK input to the dialog and makes the value a `cmyk()` colour. */\n readonly cmyk = input(false, { transform: booleanAttribute })\n /** Colours to pick from in the dialog. */\n readonly presets = input<string[]>()\n /** The dialog's distance from the field, in pixels. */\n readonly overlayOffset = input(8)\n /** Shows a button that clears the colour, and lets emptying the text clear it. */\n readonly clearable = input(false, { transform: booleanAttribute })\n readonly disabled = input(false, { transform: booleanAttribute })\n\n /** The colour, as text: the form value, `null` without one. */\n protected readonly value = signal<string | null>(null)\n /** The text the field shows; typing doesn't change it, so it doesn't replace what's typed. */\n protected readonly text = signal('')\n protected readonly swatch = computed(() => cssColor(this.value()))\n protected readonly isDisabled = linkedSignal(() => this.disabled())\n protected readonly resolvedStatus = computed(() => this.validation?.status() ?? this.status())\n /** The field's buttons are white on colour, with the `control` status, and grey otherwise. */\n protected readonly buttonStatus = computed(() => (this.resolvedStatus() === 'control' ? 'control' : 'basic'))\n /** Whether the text isn't a colour. */\n protected readonly parseError = signal(false)\n protected readonly open = signal(false)\n\n protected readonly field = viewChild<ElementRef<HTMLInputElement>>('field')\n protected readonly dialog = viewChild.required<TemplateRef<unknown>>('dialog')\n\n // The dialog opens in an overlay by the field, on focus, and closes when focus and clicks go elsewhere, as the date\n // picker's does.\n private readonly overlayHandler = nbCreateDynamicOverlayHandler()\n private overlay?: NbDynamicOverlay\n private readonly injector = inject(Injector)\n private readonly destroyRef = inject(DestroyRef)\n /** The id of the dialog, which the field controls while it's open. */\n protected readonly dialogId = `nb-color-picker-dialog-${nextDialogId++}`\n /** Whether Enter went down in the dialog, so it closes the dialog when it comes up there. */\n private enterInDialog = false\n\n protected onChange: (value: string | null) => void = () => {}\n protected onTouched: () => void = () => {}\n protected onValidatorChange: () => void = () => {}\n\n constructor() {\n // The field is the control: it gets the validation's ARIA, not the host.\n this.validation?.delegateAria()\n\n // Before the overlay is built, rebuilding it does nothing.\n effect(() => {\n this.overlayHandler.offset(this.overlayOffset()).disabled(this.isDisabled() || this.readonly())\n untracked(() => this.overlayHandler.rebuild())\n })\n }\n\n ngAfterViewInit() {\n const field = this.field()\n if (!field) {\n return\n }\n const overlay = this.overlayHandler\n .host(field)\n .componentType(NbColorPickerDialogComponent)\n .trigger(NbTrigger.FOCUS)\n // Below the field, or where there's room, as the pickers' overlays are.\n .position(NbPosition.BOTTOM)\n .adjustment(NbAdjustment.COUNTERCLOCKWISE)\n .offset(this.overlayOffset())\n .content(this.dialog())\n .disabled(this.isDisabled() || this.readonly())\n .build()\n this.overlay = overlay\n overlay.isShown.pipe(skip(1), takeUntilDestroyed(this.destroyRef)).subscribe((shown) => {\n if (shown) {\n this.open.set(true)\n } else {\n this.onClose()\n }\n })\n }\n\n ngOnDestroy() {\n this.overlayHandler.destroy()\n }\n\n writeValue(value?: string | null) {\n this.value.set(value || null)\n this.setParseError(false)\n this.show(value || '')\n }\n\n registerOnChange(fn: (value: string | null) => void) {\n this.onChange = fn\n }\n\n registerOnTouched(fn: () => void) {\n this.onTouched = fn\n }\n\n registerOnValidatorChange(fn: () => void) {\n this.onValidatorChange = fn\n }\n\n setDisabledState(disabled: boolean) {\n this.isDisabled.set(disabled)\n }\n\n /** The parse error of text that isn't a colour. */\n validate(): ValidationErrors | null {\n if (!this.parseError()) {\n return null\n }\n // The app's message for the kind, or the colour picker's text.\n const error: NbColorPickerError = { kind: NB_COLOR_PICKER_ERROR, message: this.texts().invalid }\n const message = this.message({ kind: NB_COLOR_PICKER_ERROR, params: error })\n return { [NB_COLOR_PICKER_ERROR]: { ...error, message } }\n }\n\n /**\n * Clears the colour. The button goes away with it, so focus goes from the button to the field when it was there by\n * keyboard.\n */\n clear(event?: Event) {\n this.setParseError(false)\n this.update(null)\n this.show('')\n this.onTouched()\n if ((event?.currentTarget as HTMLElement | undefined)?.matches(':focus-visible')) {\n this.field()?.nativeElement.focus()\n }\n }\n\n /** @internal */\n onColorChange(color: string) {\n if (!this.cmyk()) {\n this.changed(color)\n }\n }\n\n /** @internal */\n onCmykChange(color: string) {\n if (this.cmyk()) {\n this.changed(color)\n }\n }\n\n /** @internal */\n onInput(event: Event) {\n const text = (event.target as HTMLInputElement).value.trim()\n if (!text && this.clearable()) {\n this.setParseError(false)\n this.update(null)\n } else {\n // Text that is a colour is the value, in the value's format; the field keeps the text while it's typed in.\n const color = this.typedColor(text)\n this.setParseError(!color)\n if (color) {\n this.update(color)\n }\n }\n // Signal forms only check a value accessor's validators again when they're told to.\n this.onValidatorChange()\n }\n\n /**\n * Arrow Down moves into the dialog, opening it if needed, and Escape closes it.\n *\n * @internal\n */\n onFieldKeydown(event: KeyboardEvent) {\n if (event.ctrlKey || event.metaKey || event.altKey || event.shiftKey) {\n return\n }\n if (event.key === 'ArrowDown' && !this.isDisabled() && !this.readonly()) {\n event.preventDefault()\n this.focusDialog()\n } else if (event.key === 'Escape' && this.open()) {\n // Only the colour picker closes, not a dialog or window the field is in.\n event.preventDefault()\n event.stopPropagation()\n this.overlay?.hide()\n }\n }\n\n /**\n * Enter and Escape close the dialog, keeping the colour, and return to the field.\n *\n * @internal\n */\n onDialogKeydown(event: KeyboardEvent) {\n if (event.key === 'Escape') {\n // Only the colour picker closes, not a dialog or window the field is in.\n event.preventDefault()\n event.stopPropagation()\n this.closeDialog()\n } else if (event.key === 'Enter') {\n this.enterInDialog = true\n }\n }\n\n /**\n * Enter closes the dialog when it comes up, once the dialog's inputs have taken what was typed in them.\n *\n * @internal\n */\n onDialogKeyup(event: KeyboardEvent) {\n if (event.key === 'Enter' && this.enterInDialog) {\n this.enterInDialog = false\n event.preventDefault()\n this.closeDialog()\n }\n }\n\n /** @internal */\n onBlur() {\n if (!this.open()) {\n this.leave()\n }\n }\n\n /** The dialog closed: the field is touched once focus is elsewhere. */\n protected onClose() {\n this.open.set(false)\n this.enterInDialog = false\n if (!this.focused()) {\n this.leave()\n }\n }\n\n /** Opens the dialog if needed, and moves focus to its first control. */\n protected focusDialog() {\n if (!this.open()) {\n this.overlay?.show()\n }\n afterNextRender(() => this.overlay?.containerElement?.querySelector<HTMLElement>(DIALOG_FOCUSABLE)?.focus(), {\n injector: this.injector\n })\n }\n\n /** Closes the dialog, with focus back in the field. */\n protected closeDialog() {\n // Focus first: the field opens the dialog on focus, unless it's open.\n this.field()?.nativeElement.focus()\n this.overlay?.hide()\n }\n\n /**\n * The value for typed text that is a colour, in the value's format, as the dialog gives it for a colour picked in\n * it: without transparency where the format has none, and as `cmyk()` with `cmyk`.\n */\n protected typedColor(text: string): string | undefined {\n const hsva = stringToHsva(text, true)\n const cmyk = stringToCmyk(text, true)\n const format = this.outputFormat()\n const alpha = this.alphaChannel()\n const alphaChannel = format === 'hex' && alpha !== 'always' && alpha !== 'forced' ? 'disabled' : alpha\n if (alphaChannel === 'disabled') {\n if (hsva) {\n hsva.a = 1\n }\n if (cmyk) {\n cmyk.a = 1\n }\n }\n if (this.cmyk()) {\n const value = cmyk ?? (hsva && rgbaToCmyk(hsvaToRgba(hsva)))\n return value ? formatCmyk(value, alphaChannel) : undefined\n }\n const color = hsva ?? (cmyk && rgbaToHsva(cmykToRgb(cmyk)))\n return color ? formatOutput(color, format, alphaChannel) : undefined\n }\n\n /** The field shows the colour, as the value has it, unless the text isn't one, and the field is touched. */\n protected leave() {\n if (!this.parseError()) {\n this.show(this.value() ?? '')\n }\n this.onTouched()\n }\n\n /** A colour picked in the dialog, which the field shows, also while it has focus, e.g. as the colours are dragged. */\n protected changed(color: string) {\n this.setParseError(false)\n this.update(color)\n this.show(color)\n }\n\n protected update(color: string | null) {\n const value = color || null\n if (value !== this.value()) {\n this.value.set(value)\n this.onChange(value)\n }\n }\n\n /** Whether the field has focus, e.g. while the user types. */\n protected focused() {\n const field = this.field()?.nativeElement\n return !!field && field.ownerDocument.activeElement === field\n }\n\n /** Shows a text in the field. */\n protected show(text: string) {\n this.text.set(text)\n const field = this.field()?.nativeElement\n if (field && field.value !== text) {\n field.value = text\n }\n }\n\n protected setParseError(parseError: boolean) {\n if (parseError !== this.parseError()) {\n this.parseError.set(parseError)\n this.onValidatorChange()\n }\n }\n}\n","<nb-form-field>\n <span nbPrefix\n class=\"swatch\"\n aria-hidden=\"true\">\n <span [style.--nb-color-picker-swatch]=\"swatch()\"></span>\n </span>\n <input #field\n nbInput\n autocomplete=\"off\"\n aria-haspopup=\"dialog\"\n [attr.aria-expanded]=\"open()\"\n [attr.aria-controls]=\"open() ? dialogId : null\"\n [fieldSize]=\"size()\"\n [status]=\"resolvedStatus()\"\n [shape]=\"shape()\"\n [fullWidth]=\"fullWidth()\"\n [ghost]=\"ghost()\"\n [placeholder]=\"placeholder()\"\n [attr.aria-label]=\"fieldLabelledBy() ? null : (ariaLabel() ?? texts().color)\"\n [attr.aria-labelledby]=\"fieldLabelledBy()\"\n [attr.aria-required]=\"validation?.ariaRequired()\"\n [attr.aria-invalid]=\"validation?.ariaInvalid()\"\n [attr.aria-describedby]=\"validation?.describedBy()\"\n [attr.disabled]=\"isDisabled() || null\"\n [readOnly]=\"readonly()\"\n [value]=\"text()\"\n (input)=\"onInput($event)\"\n (keydown)=\"onFieldKeydown($event)\"\n (blur)=\"onBlur()\" />\n @if (clearable() && value() && !isDisabled() && !readonly()) {\n <button nbSuffix\n nbButton\n ghost\n type=\"button\"\n [size]=\"size()\"\n [status]=\"buttonStatus()\"\n [attr.aria-label]=\"texts().clear\"\n (click)=\"clear($event)\">\n <nb-icon icon=\"close-outline\"\n pack=\"essentials\" />\n </button>\n }\n</nb-form-field>\n\n<!-- The dialog, shown in the overlay while it's open. -->\n<ng-template #dialog>\n <!-- eslint-disable-next-line @angular-eslint/template/interactive-supports-focus -- Keys bubble up from the controls inside. -->\n <div [id]=\"dialogId\"\n (keydown)=\"onDialogKeydown($event)\"\n (keyup)=\"onDialogKeyup($event)\">\n <ng-container nxtColor\n dialogDisplay=\"inline\"\n [nxtColor]=\"value() ?? ''\"\n [outputFormat]=\"outputFormat()\"\n [alphaChannel]=\"alphaChannel()\"\n [cmykEnabled]=\"cmyk()\"\n [presetColors]=\"presets()\"\n [presetLabel]=\"!!presets()?.length\"\n (nxtColorChange)=\"onColorChange($event)\"\n (cmykColorChange)=\"onCmykChange($event)\" />\n </div>\n</ng-template>\n"],"mappings":";;;;;;;;AAsBA,IAAa,+BAAb,MAAa,qCAAqC,+BAA8B;CAPhF,cAAA;;EAQa,KAAA,mBAAmB,UAAU,SAAS,6BAA4B,GAAA,YAAA,CAAA,EAAA,WAAA,mBAAA,CAAA,+BAAA,CAAA,CAAA;EAElE,KAAA,UAAU,MAAyB,GAAA,YAAA,CAAA,QAAA,EAAA,WAAA,UAAA,CAAA,+BAAA,CAAA,CAAA;EACnC,KAAA,UAAU,MAAe,GAAA,YAAA,CAAA,QAAA,EAAA,WAAA,UAAA,CAAA,+BAAA,CAAA,CAAA;CAUrC;CARG,gBAAa;EACT,MAAM,YAAY,KAAK,iBAAgB;EACvC,UAAU,OAAM;EAChB,MAAM,UAAU,KAAK,QAAO;EAC5B,IAAI,mBAAmB,aACnB,UAAU,qBAAqB,IAAI,iBAAiB,SAAS,QAAW,KAAK,QAAO,CAAE,CAAC;CAE/F;CAbS;EAAA,KAAA,OAAA,GAAA,mBAAA;GAAA,YAAA;GAAA,SAAA;GAAA,UAAA;GAAA,MAAA;GAA4B,MAAA;GAAA,QAAA,GAAA,gBAAA;EAAA,CAAA;CAAA;CAA5B;EAAA,KAAA,OAAA,GAAA,qBAAA;GAAA,YAAA;GAAA,SAAA;GAAA,MAAA;GAA4B,cAAA;GAAA,UAAA;GAAA,QAAA;IAAA,SAAA;KAAA,mBAAA;KAAA,YAAA;KAAA,UAAA;KAAA,YAAA;KAAA,mBAAA;IAAA;IAAA,SAAA;KAAA,mBAAA;KAAA,YAAA;KAAA,UAAA;KAAA,YAAA;KAAA,mBAAA;IAAA;GAAA;G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version":3,"file":"liquid-js-lyr-extras-color-picker.mjs","names":[],"sources":["../../../packages/extras/color-picker/src/color-picker-dialog.component.ts","../../../packages/extras/color-picker/src/texts.ts","../../../packages/extras/color-picker/src/color-picker.component.ts","../../../packages/extras/color-picker/src/color-picker.component.html"],"sourcesContent":["import { ChangeDetectionStrategy, Component, input, TemplateRef, viewChild } from '@angular/core'\nimport {\n NbOverlayContainerComponent,\n NbOverlayContent,\n NbPositionedContainerComponent,\n NbRenderableContainer,\n NbTemplatePortal\n} from '@liquid-js/lyr-core'\n\n/**\n * The colour picker's overlay: the dialog of `nb-color-picker`, framed as the date picker's is. The dialog is\n * nxt-color-picker's, shown inline in it, so it opens, and is positioned and closed, as Lyra's pickers are.\n *\n * @internal\n */\n@Component({\n selector: 'nb-color-picker-dialog',\n template: '<nb-overlay-container />',\n // Hosted content may not use signals, so it's checked on every change detection.\n changeDetection: ChangeDetectionStrategy.Eager,\n imports: [NbOverlayContainerComponent]\n})\nexport class NbColorPickerDialogComponent extends NbPositionedContainerComponent implements NbRenderableContainer {\n readonly overlayContainer = viewChild.required(NbOverlayContainerComponent)\n\n readonly content = input<NbOverlayContent>()\n readonly context = input<object>()\n\n renderContent() {\n const container = this.overlayContainer()\n container.detach()\n const content = this.content()\n if (content instanceof TemplateRef) {\n container.attachTemplatePortal(new NbTemplatePortal(content, undefined, this.context()))\n }\n }\n}\n","import { injectNbTexts, NbLocalize } from '@liquid-js/lyr-core'\nimport type { ColorPickerTexts } from 'nxt-color-picker'\n\n/** @internal */\ndeclare const $localize: NbLocalize\n\n/**\n * The texts of the colour picker. `provideNbTexts({ colorPicker: { ... } })` changes them, and they're translated with\n * Angular's i18n, as `$localize` messages with ids like `@@nb.colorPicker.invalid`.\n *\n * The dialog's texts, e.g. `ok` or `presetColors`, are `nxt-color-picker`'s, with ids like\n * `@@nxt-color-picker.button.ok`; set them here too to change them.\n */\nexport interface NbColorPickerTexts extends Partial<ColorPickerTexts> {\n /** Names the field when it has no `aria-label` or `aria-labelledby`. */\n color: string\n /** Label of the button that clears the colour. */\n clear: string\n /** The message of the `nbColorPicker` error for text that isn't a colour. */\n invalid: string\n}\n\ndeclare module '@liquid-js/lyr-core' {\n interface NbTexts {\n colorPicker: NbColorPickerTexts\n }\n}\n\n/** The default texts, in the app's language. @internal */\nexport function nbColorPickerTexts(): NbColorPickerTexts {\n return {\n color: $localize`:@@nb.colorPicker.color:Color`,\n clear: $localize`:@@nb.colorPicker.clear:Clear color`,\n invalid: $localize`:@@nb.colorPicker.invalid:Enter a valid color`\n }\n}\n\n/** @internal */\nexport function injectNbColorPickerTexts() {\n return injectNbTexts('colorPicker', nbColorPickerTexts)\n}\n","import {\n afterNextRender,\n AfterViewInit,\n booleanAttribute,\n Component,\n computed,\n DestroyRef,\n effect,\n ElementRef,\n forwardRef,\n inject,\n Injector,\n input,\n linkedSignal,\n OnDestroy,\n signal,\n TemplateRef,\n untracked,\n viewChild,\n ViewEncapsulation\n} from '@angular/core'\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop'\nimport { ControlValueAccessor, NG_VALIDATORS, NG_VALUE_ACCESSOR, ValidationErrors, Validator } from '@angular/forms'\nimport {\n injectNbDefaults,\n injectNbValidationMessage,\n NbAdjustment,\n NbButtonComponent,\n NbComponentOrCustomStatus,\n NbComponentShape,\n NbComponentSize,\n nbCreateDynamicOverlayHandler,\n NbDynamicOverlay,\n NbFormFieldModule,\n NbIconComponent,\n NbInputDirective,\n NbPosition,\n NbTrigger,\n NbValidationDirective\n} from '@liquid-js/lyr-core'\nimport {\n AlphaChannel,\n cmykToRgb,\n ColorPickerDirective,\n formatCmyk,\n formatOutput,\n hsvaToRgba,\n NXT_COLOR_PICKER_TEXTS,\n OutputFormat,\n rgbaToCmyk,\n rgbaToHsva,\n stringToCmyk,\n stringToHsva\n} from 'nxt-color-picker'\nimport { skip } from 'rxjs'\n\nimport { NbColorPickerDialogComponent } from './color-picker-dialog.component'\nimport { injectNbColorPickerTexts } from './texts'\n\nlet nextDialogId = 0\n\n/** What the dialog's buttons, sliders, presets and inputs match, to move focus into it. */\nconst DIALOG_FOCUSABLE = '[tabindex=\"0\"], input, button'\n\n/** The error kind of text that isn't a colour. */\nexport const NB_COLOR_PICKER_ERROR = 'nbColorPicker' as const\n\n/** The `nbColorPicker` error, as Angular gives parse errors: its kind and its message. */\nexport interface NbColorPickerError {\n kind: typeof NB_COLOR_PICKER_ERROR\n message: string\n}\n\n/** The colour of a text as CSS, e.g. for the swatch: from a CSS colour or a `cmyk()` one, if it's one. */\nfunction cssColor(text: string | null): string | undefined {\n if (!text) {\n return undefined\n }\n const cmyk = stringToCmyk(text, true)\n const hsva = stringToHsva(text, true) ?? (cmyk ? rgbaToHsva(cmykToRgb(cmyk)) : undefined)\n return hsva ? formatOutput(hsva, 'rgba', 'enabled') : undefined\n}\n\n/**\n * A field for a colour, with a swatch and a picker dialog:\n *\n * ```html\n * <nb-color-picker [formControl]=\"color\" [presets]=\"['#3366ff', '#00d68f']\" clearable />\n * ```\n *\n * @stacked-example(Showcase, color-picker/color-picker-showcase.component)\n *\n * ### Installation\n *\n * Install [`nxt-color-picker`](https://www.npmjs.com/package/nxt-color-picker), which draws the dialog, and import\n * `NbColorPickerComponent` from `@liquid-js/lyr-extras/color-picker`:\n *\n * ```bash\n * npm install nxt-color-picker\n * ```\n *\n * ### Usage\n *\n * It's a form control whose value is the colour as text, e.g. `#3366ff`, or `null` without one. The user picks it in\n * the dialog or types it, and with `clearable` the field has a button that clears it, as does emptying the text. It\n * has the sizes, statuses, shapes and `ghost` look of `nbInput`, and its `readonly`, without the dialog; its swatch\n * shows the colour over a checkerboard, so transparency shows:\n * @stacked-example(Sizes and statuses, color-picker/color-picker-sizes.component)\n *\n * The dialog opens below the field when it has focus, as the date picker's does, and closes when focus or a click\n * goes elsewhere. Arrow Down moves focus into it, where the sliders move with the arrow keys, Page Up and Down, Home\n * and End; Enter and Escape close it, keeping the colour, and return to the field.\n *\n * `outputFormat` picks the text the value has, `hex`, `rgba`, `hsla` or `auto`, `alphaChannel` whether it can be\n * transparent, and `cmyk` adds a CMYK input and makes the value a `cmyk()` colour. The dialog has the theme's\n * colours, with its own `color-picker-*` variables, which follow the date picker's values.\n *\n * ### Validation\n *\n * While the text isn't a colour, e.g. `#12345`, the value stays the last colour, and the field has the\n * `nbColorPicker` parse error, `{ kind, message }`, as Angular's controls report text they can't parse; so does\n * empty text in a field that isn't `clearable`. It works with `formControl`, `formControlName`, `ngModel` and signal\n * forms' `[formField]`, and with `nbValidation`:\n * @stacked-example(Validation, color-picker/color-picker-validation.component)\n *\n * ### Texts\n *\n * Its texts, and the dialog's, are in the `colorPicker` section of Lyra's texts:\n *\n * ```ts\n * provideNbTexts({ colorPicker: { clear: 'Remove the color', ok: 'Apply' } })\n * ```\n * @styles\n *\n * color-picker-background-color:\n * color-picker-border-color:\n * color-picker-border-style:\n * color-picker-border-width:\n * color-picker-border-radius:\n * color-picker-shadow:\n * color-picker-text-color:\n * color-picker-text-font-family:\n * color-picker-text-font-size:\n * color-picker-divider-color:\n * color-picker-format-arrow-color:\n */\n@Component({\n selector: 'nb-color-picker',\n templateUrl: './color-picker.component.html',\n // The dialog is in the overlay container, outside the component, so its styles are global.\n encapsulation: ViewEncapsulation.None,\n styles: `\n nb-color-picker {\n display: inline-block;\n /* Lines up with fields and buttons of its size by its middle, as they do. */\n vertical-align: middle;\n }\n\n nb-color-picker.full-width {\n display: block;\n }\n\n nb-color-picker .swatch {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 100%;\n height: 100%;\n }\n\n nb-color-picker .swatch > span {\n width: 100%;\n aspect-ratio: 1;\n border-radius: 50%;\n }\n\n /* The colour over a 2×2 checkerboard, as in the dialog, so transparency shows. */\n nb-color-picker .swatch > span[style*='--nb-color-picker-swatch'] {\n background-image:\n linear-gradient(var(--nb-color-picker-swatch), var(--nb-color-picker-swatch)),\n conic-gradient(#fff 0 25%, #ccc 0 50%, #fff 0 75%, #ccc 0);\n }\n\n nb-color-picker-dialog {\n display: block;\n border: var(--color-picker-border-width) var(--color-picker-border-style) var(--color-picker-border-color);\n border-radius: var(--color-picker-border-radius);\n background: var(--color-picker-background-color);\n box-shadow: var(--color-picker-shadow);\n }\n\n nb-color-picker-dialog nxt-color-picker {\n display: block;\n --nxt-color-picker-background: transparent;\n --nxt-color-picker-border: none;\n /* The colours reach the frame, inside its rounded corners; the colour's mark can go past them. */\n --nxt-color-picker-border-radius: max(\n 0px,\n calc(var(--color-picker-border-radius) - var(--color-picker-border-width))\n );\n --nxt-color-picker-shadow: none;\n --nxt-color-picker-text-color: var(--color-picker-text-color);\n --nxt-color-picker-font-family: var(--color-picker-text-font-family);\n --nxt-color-picker-font-size: var(--color-picker-text-font-size);\n --nxt-color-picker-border-color: var(--color-picker-divider-color);\n --nxt-color-picker-focus-outline: var(--outline-width) solid var(--outline-color);\n --nxt-color-picker-focus-outline-width: var(--outline-width);\n --nxt-color-picker-arrow-color: var(--color-picker-format-arrow-color);\n --nxt-color-picker-input-background: var(--input-basic-background-color);\n --nxt-color-picker-input-border-color: var(--input-basic-border-color);\n --nxt-color-picker-input-border-width: var(--input-border-width);\n --nxt-color-picker-input-text-color: var(--input-basic-text-color);\n --nxt-color-picker-input-placeholder-color: var(--input-basic-placeholder-text-color);\n --nxt-color-picker-input-border-radius: var(--input-rectangle-border-radius);\n --nxt-color-picker-input-hover-background: var(--input-basic-hover-background-color);\n --nxt-color-picker-input-hover-border-color: var(--input-basic-hover-border-color);\n --nxt-color-picker-input-focus-background: var(--input-basic-focus-background-color);\n --nxt-color-picker-input-focus-border-color: var(--input-basic-focus-border-color);\n --nxt-color-picker-input-disabled-background: var(--input-basic-disabled-background-color);\n --nxt-color-picker-input-disabled-border-color: var(--input-basic-disabled-border-color);\n --nxt-color-picker-input-disabled-text-color: var(--input-basic-disabled-text-color);\n --nxt-color-picker-button-color: var(--button-filled-basic-text-color);\n --nxt-color-picker-button-background: var(--button-filled-basic-background-color);\n --nxt-color-picker-button-border: var(--button-filled-border-width) var(--button-filled-border-style)\n var(--button-filled-basic-border-color);\n --nxt-color-picker-button-border-radius: var(--button-rectangle-border-radius);\n --nxt-color-picker-button-font-size: var(--button-small-text-font-size);\n --nxt-color-picker-button-font-weight: var(--button-text-font-weight);\n }\n `,\n imports: [ColorPickerDirective, NbButtonComponent, NbFormFieldModule, NbIconComponent, NbInputDirective],\n providers: [\n { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => NbColorPickerComponent), multi: true },\n { provide: NG_VALIDATORS, useExisting: forwardRef(() => NbColorPickerComponent), multi: true },\n // The dialog's texts follow Lyra's.\n { provide: NXT_COLOR_PICKER_TEXTS, useFactory: injectNbColorPickerTexts }\n ],\n host: {\n '[class.full-width]': 'fullWidth()'\n }\n})\nexport class NbColorPickerComponent implements ControlValueAccessor, Validator, AfterViewInit, OnDestroy {\n // The app's defaults for fields, which the inputs below start from.\n protected readonly nbDefaults = injectNbDefaults('input')\n\n protected readonly texts = injectNbColorPickerTexts()\n protected readonly message = injectNbValidationMessage()\n protected readonly validation = inject(NbValidationDirective, { self: true, optional: true })\n\n /** Field size: `tiny`, `small`, `medium` (default), `large` or `giant`. */\n readonly sizeInput = input<NbComponentSize | undefined>(undefined, { alias: 'size' })\n /** The size in use: the input's, the app's default, or 'medium'. */\n readonly size = linkedSignal<NbComponentSize>(() => this.sizeInput() ?? this.nbDefaults().size ?? 'medium')\n /** Field status: `basic` (default), `primary`, `info`, `success`, `warning`, `danger` or `control`. */\n readonly status = input<NbComponentOrCustomStatus>('basic')\n /** Field shape: `rectangle` (default), `semi-round` or `round`. */\n readonly shapeInput = input<NbComponentShape | undefined>(undefined, { alias: 'shape' })\n /** The shape in use: the input's, the app's default, or 'rectangle'. */\n readonly shape = linkedSignal<NbComponentShape>(() => this.shapeInput() ?? this.nbDefaults().shape ?? 'rectangle')\n /** Makes the field as wide as its container. */\n readonly fullWidth = input(false, { transform: booleanAttribute })\n /** Shows the field without its background and border, as `nbInput`'s `ghost` does. */\n readonly ghost = input(false, { transform: booleanAttribute })\n readonly placeholder = input('')\n /** Lets the user read and select the colour, but not change it, as a read-only field; its dialog doesn't open. */\n readonly readonly = input(false, { transform: booleanAttribute })\n /** Names the field when there's no `aria-labelledby`; \"Color\" by default. */\n readonly ariaLabel = input<string | undefined>(undefined, { alias: 'aria-label' })\n /** The id of the element that names the field, e.g. a `label`. */\n readonly ariaLabelledBy = input<string | undefined>(undefined, { alias: 'aria-labelledby' })\n\n /** What labels the field: its own `aria-labelledby` and an `nbLabel` of its `nbValidation`. */\n protected readonly fieldLabelledBy = computed(\n () => [this.ariaLabelledBy(), this.validation?.labelledBy()].filter(Boolean).join(' ') || null\n )\n\n /** The text of the value: `hex`, `rgba`, `hsla` or `auto`, which keeps the format a colour is typed in. */\n readonly outputFormat = input<OutputFormat>('auto')\n /** Whether the colour can be transparent. */\n readonly alphaChannel = input<AlphaChannel>('enabled')\n /** Adds a CMYK input to the dialog and makes the value a `cmyk()` colour. */\n readonly cmyk = input(false, { transform: booleanAttribute })\n /** Colours to pick from in the dialog. */\n readonly presets = input<string[]>()\n /** The dialog's distance from the field, in pixels. */\n readonly overlayOffset = input(8)\n /** Shows a button that clears the colour, and lets emptying the text clear it. */\n readonly clearable = input(false, { transform: booleanAttribute })\n readonly disabled = input(false, { transform: booleanAttribute })\n\n /** The colour, as text: the form value, `null` without one. */\n protected readonly value = signal<string | null>(null)\n /** The text the field shows; typing doesn't change it, so it doesn't replace what's typed. */\n protected readonly text = signal('')\n protected readonly swatch = computed(() => cssColor(this.value()))\n protected readonly isDisabled = linkedSignal(() => this.disabled())\n protected readonly resolvedStatus = computed(() => this.validation?.status() ?? this.status())\n /** The field's buttons are white on colour, with the `control` status, and grey otherwise. */\n protected readonly buttonStatus = computed(() => (this.resolvedStatus() === 'control' ? 'control' : 'basic'))\n /** Whether the text isn't a colour. */\n protected readonly parseError = signal(false)\n protected readonly open = signal(false)\n\n protected readonly field = viewChild<ElementRef<HTMLInputElement>>('field')\n protected readonly dialog = viewChild.required<TemplateRef<unknown>>('dialog')\n\n // The dialog opens in an overlay by the field, on focus, and closes when focus and clicks go elsewhere, as the date\n // picker's does.\n private readonly overlayHandler = nbCreateDynamicOverlayHandler()\n private overlay?: NbDynamicOverlay\n private readonly injector = inject(Injector)\n private readonly destroyRef = inject(DestroyRef)\n /** The id of the dialog, which the field controls while it's open. */\n protected readonly dialogId = `nb-color-picker-dialog-${nextDialogId++}`\n /** Whether Enter went down in the dialog, so it closes the dialog when it comes up there. */\n private enterInDialog = false\n\n protected onChange: (value: string | null) => void = () => {}\n protected onTouched: () => void = () => {}\n protected onValidatorChange: () => void = () => {}\n\n constructor() {\n // The field is the control: it gets the validation's ARIA, not the host.\n this.validation?.delegateAria()\n\n // Before the overlay is built, rebuilding it does nothing.\n effect(() => {\n this.overlayHandler.offset(this.overlayOffset()).disabled(this.isDisabled() || this.readonly())\n untracked(() => this.overlayHandler.rebuild())\n })\n }\n\n ngAfterViewInit() {\n const field = this.field()\n if (!field) {\n return\n }\n const overlay = this.overlayHandler\n .host(field)\n .componentType(NbColorPickerDialogComponent)\n .trigger(NbTrigger.FOCUS)\n // Below the field, or where there's room, as the pickers' overlays are.\n .position(NbPosition.BOTTOM)\n .adjustment(NbAdjustment.COUNTERCLOCKWISE)\n .offset(this.overlayOffset())\n .content(this.dialog())\n .disabled(this.isDisabled() || this.readonly())\n .build()\n this.overlay = overlay\n overlay.isShown.pipe(skip(1), takeUntilDestroyed(this.destroyRef)).subscribe((shown) => {\n if (shown) {\n this.open.set(true)\n } else {\n this.onClose()\n }\n })\n }\n\n ngOnDestroy() {\n this.overlayHandler.destroy()\n }\n\n // Untracked, as forms write values from wherever the app sets them, e.g. an effect that mustn't come to depend\n // on the control.\n writeValue(value?: string | null) {\n untracked(() => {\n this.value.set(value || null)\n this.setParseError(false)\n this.show(value || '')\n })\n }\n\n registerOnChange(fn: (value: string | null) => void) {\n this.onChange = fn\n }\n\n registerOnTouched(fn: () => void) {\n this.onTouched = fn\n }\n\n registerOnValidatorChange(fn: () => void) {\n this.onValidatorChange = fn\n }\n\n setDisabledState(disabled: boolean) {\n this.isDisabled.set(disabled)\n }\n\n /** The parse error of text that isn't a colour. */\n validate(): ValidationErrors | null {\n if (!this.parseError()) {\n return null\n }\n // The app's message for the kind, or the colour picker's text.\n const error: NbColorPickerError = { kind: NB_COLOR_PICKER_ERROR, message: this.texts().invalid }\n const message = this.message({ kind: NB_COLOR_PICKER_ERROR, params: error })\n return { [NB_COLOR_PICKER_ERROR]: { ...error, message } }\n }\n\n /**\n * Clears the colour. The button goes away with it, so focus goes from the button to the field when it was there by\n * keyboard.\n */\n clear(event?: Event) {\n this.setParseError(false)\n this.update(null)\n this.show('')\n this.onTouched()\n if ((event?.currentTarget as HTMLElement | undefined)?.matches(':focus-visible')) {\n this.field()?.nativeElement.focus()\n }\n }\n\n /** @internal */\n onColorChange(color: string) {\n if (!this.cmyk()) {\n this.changed(color)\n }\n }\n\n /** @internal */\n onCmykChange(color: string) {\n if (this.cmyk()) {\n this.changed(color)\n }\n }\n\n /** @internal */\n onInput(event: Event) {\n const text = (event.target as HTMLInputElement).value.trim()\n if (!text && this.clearable()) {\n this.setParseError(false)\n this.update(null)\n } else {\n // Text that is a colour is the value, in the value's format; the field keeps the text while it's typed in.\n const color = this.typedColor(text)\n this.setParseError(!color)\n if (color) {\n this.update(color)\n }\n }\n // Signal forms only check a value accessor's validators again when they're told to.\n this.onValidatorChange()\n }\n\n /**\n * Arrow Down moves into the dialog, opening it if needed, and Escape closes it.\n *\n * @internal\n */\n onFieldKeydown(event: KeyboardEvent) {\n if (event.ctrlKey || event.metaKey || event.altKey || event.shiftKey) {\n return\n }\n if (event.key === 'ArrowDown' && !this.isDisabled() && !this.readonly()) {\n event.preventDefault()\n this.focusDialog()\n } else if (event.key === 'Escape' && this.open()) {\n // Only the colour picker closes, not a dialog or window the field is in.\n event.preventDefault()\n event.stopPropagation()\n this.overlay?.hide()\n }\n }\n\n /**\n * Enter and Escape close the dialog, keeping the colour, and return to the field.\n *\n * @internal\n */\n onDialogKeydown(event: KeyboardEvent) {\n if (event.key === 'Escape') {\n // Only the colour picker closes, not a dialog or window the field is in.\n event.preventDefault()\n event.stopPropagation()\n this.closeDialog()\n } else if (event.key === 'Enter') {\n this.enterInDialog = true\n }\n }\n\n /**\n * Enter closes the dialog when it comes up, once the dialog's inputs have taken what was typed in them.\n *\n * @internal\n */\n onDialogKeyup(event: KeyboardEvent) {\n if (event.key === 'Enter' && this.enterInDialog) {\n this.enterInDialog = false\n event.preventDefault()\n this.closeDialog()\n }\n }\n\n /** @internal */\n onBlur() {\n if (!this.open()) {\n this.leave()\n }\n }\n\n /** The dialog closed: the field is touched once focus is elsewhere. */\n protected onClose() {\n this.open.set(false)\n this.enterInDialog = false\n if (!this.focused()) {\n this.leave()\n }\n }\n\n /** Opens the dialog if needed, and moves focus to its first control. */\n protected focusDialog() {\n if (!this.open()) {\n this.overlay?.show()\n }\n afterNextRender(() => this.overlay?.containerElement?.querySelector<HTMLElement>(DIALOG_FOCUSABLE)?.focus(), {\n injector: this.injector\n })\n }\n\n /** Closes the dialog, with focus back in the field. */\n protected closeDialog() {\n // Focus first: the field opens the dialog on focus, unless it's open.\n this.field()?.nativeElement.focus()\n this.overlay?.hide()\n }\n\n /**\n * The value for typed text that is a colour, in the value's format, as the dialog gives it for a colour picked in\n * it: without transparency where the format has none, and as `cmyk()` with `cmyk`.\n */\n protected typedColor(text: string): string | undefined {\n const hsva = stringToHsva(text, true)\n const cmyk = stringToCmyk(text, true)\n const format = this.outputFormat()\n const alpha = this.alphaChannel()\n const alphaChannel = format === 'hex' && alpha !== 'always' && alpha !== 'forced' ? 'disabled' : alpha\n if (alphaChannel === 'disabled') {\n if (hsva) {\n hsva.a = 1\n }\n if (cmyk) {\n cmyk.a = 1\n }\n }\n if (this.cmyk()) {\n const value = cmyk ?? (hsva && rgbaToCmyk(hsvaToRgba(hsva)))\n return value ? formatCmyk(value, alphaChannel) : undefined\n }\n const color = hsva ?? (cmyk && rgbaToHsva(cmykToRgb(cmyk)))\n return color ? formatOutput(color, format, alphaChannel) : undefined\n }\n\n /** The field shows the colour, as the value has it, unless the text isn't one, and the field is touched. */\n protected leave() {\n if (!this.parseError()) {\n this.show(this.value() ?? '')\n }\n this.onTouched()\n }\n\n /** A colour picked in the dialog, which the field shows, also while it has focus, e.g. as the colours are dragged. */\n protected changed(color: string) {\n this.setParseError(false)\n this.update(color)\n this.show(color)\n }\n\n protected update(color: string | null) {\n const value = color || null\n if (value !== this.value()) {\n this.value.set(value)\n this.onChange(value)\n }\n }\n\n /** Whether the field has focus, e.g. while the user types. */\n protected focused() {\n const field = this.field()?.nativeElement\n return !!field && field.ownerDocument.activeElement === field\n }\n\n /** Shows a text in the field. */\n protected show(text: string) {\n this.text.set(text)\n const field = this.field()?.nativeElement\n if (field && field.value !== text) {\n field.value = text\n }\n }\n\n protected setParseError(parseError: boolean) {\n if (parseError !== this.parseError()) {\n this.parseError.set(parseError)\n this.onValidatorChange()\n }\n }\n}\n","<nb-form-field>\n <span nbPrefix\n class=\"swatch\"\n aria-hidden=\"true\">\n <span [style.--nb-color-picker-swatch]=\"swatch()\"></span>\n </span>\n <input #field\n nbInput\n autocomplete=\"off\"\n aria-haspopup=\"dialog\"\n [attr.aria-expanded]=\"open()\"\n [attr.aria-controls]=\"open() ? dialogId : null\"\n [fieldSize]=\"size()\"\n [status]=\"resolvedStatus()\"\n [shape]=\"shape()\"\n [fullWidth]=\"fullWidth()\"\n [ghost]=\"ghost()\"\n [placeholder]=\"placeholder()\"\n [attr.aria-label]=\"fieldLabelledBy() ? null : (ariaLabel() ?? texts().color)\"\n [attr.aria-labelledby]=\"fieldLabelledBy()\"\n [attr.aria-required]=\"validation?.ariaRequired()\"\n [attr.aria-invalid]=\"validation?.ariaInvalid()\"\n [attr.aria-describedby]=\"validation?.describedBy()\"\n [attr.disabled]=\"isDisabled() || null\"\n [readOnly]=\"readonly()\"\n [value]=\"text()\"\n (input)=\"onInput($event)\"\n (keydown)=\"onFieldKeydown($event)\"\n (blur)=\"onBlur()\" />\n @if (clearable() && value() && !isDisabled() && !readonly()) {\n <button nbSuffix\n nbButton\n ghost\n type=\"button\"\n [size]=\"size()\"\n [status]=\"buttonStatus()\"\n [attr.aria-label]=\"texts().clear\"\n (click)=\"clear($event)\">\n <nb-icon icon=\"close-outline\"\n pack=\"essentials\" />\n </button>\n }\n</nb-form-field>\n\n<!-- The dialog, shown in the overlay while it's open. -->\n<ng-template #dialog>\n <!-- eslint-disable-next-line @angular-eslint/template/interactive-supports-focus -- Keys bubble up from the controls inside. -->\n <div [id]=\"dialogId\"\n (keydown)=\"onDialogKeydown($event)\"\n (keyup)=\"onDialogKeyup($event)\">\n <ng-container nxtColor\n dialogDisplay=\"inline\"\n [nxtColor]=\"value() ?? ''\"\n [outputFormat]=\"outputFormat()\"\n [alphaChannel]=\"alphaChannel()\"\n [cmykEnabled]=\"cmyk()\"\n [presetColors]=\"presets()\"\n [presetLabel]=\"!!presets()?.length\"\n (nxtColorChange)=\"onColorChange($event)\"\n (cmykColorChange)=\"onCmykChange($event)\" />\n </div>\n</ng-template>\n"],"mappings":";;;;;;;;AAsBA,IAAa,+BAAb,MAAa,qCAAqC,+BAA8B;CAPhF,cAAA;;EAQa,KAAA,mBAAmB,UAAU,SAAS,6BAA4B,GAAA,YAAA,CAAA,EAAA,WAAA,mBAAA,CAAA,+BAAA,CAAA,CAAA;EAElE,KAAA,UAAU,MAAyB,GAAA,YAAA,CAAA,QAAA,EAAA,WAAA,UAAA,CAAA,+BAAA,CAAA,CAAA;EACnC,KAAA,UAAU,MAAe,GAAA,YAAA,CAAA,QAAA,EAAA,WAAA,UAAA,CAAA,+BAAA,CAAA,CAAA;CAUrC;CARG,gBAAa;EACT,MAAM,YAAY,KAAK,iBAAgB;EACvC,UAAU,OAAM;EAChB,MAAM,UAAU,KAAK,QAAO;EAC5B,IAAI,mBAAmB,aACnB,UAAU,qBAAqB,IAAI,iBAAiB,SAAS,QAAW,KAAK,QAAO,CAAE,C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;EAAA,WAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,UAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,OAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,SAAO,EAAA,UAAA,KAAA,CAAA;EAAA,CAAA;EAAA,QAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CACL,UAAQ,EAAA,UAAA,KAAA,CAAA;EAAA,CAAA;CAAA;AAAA,CAAA"}
|
|
@@ -494,17 +494,19 @@ var NbMarkdownEditorComponent = class NbMarkdownEditorComponent {
|
|
|
494
494
|
});
|
|
495
495
|
}
|
|
496
496
|
writeValue(value) {
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
497
|
+
untracked(() => {
|
|
498
|
+
const markdown = value ?? "";
|
|
499
|
+
this.value.set(markdown);
|
|
500
|
+
const editor = this.editor();
|
|
501
|
+
if (editor && editor.getMarkdown() !== markdown) {
|
|
502
|
+
this.writing = true;
|
|
503
|
+
try {
|
|
504
|
+
editor.setMarkdown(markdown, false, false);
|
|
505
|
+
} finally {
|
|
506
|
+
this.writing = false;
|
|
507
|
+
}
|
|
506
508
|
}
|
|
507
|
-
}
|
|
509
|
+
});
|
|
508
510
|
}
|
|
509
511
|
registerOnChange(fn) {
|
|
510
512
|
this.onChange = fn;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"liquid-js-lyr-extras-markdown-editor.mjs","names":[],"sources":["../../../packages/extras/markdown-editor/src/format-style.ts","../../../packages/extras/markdown-editor/src/format.ts","../../../packages/extras/markdown-editor/src/texts.ts","../../../packages/extras/markdown-editor/src/markdown-editor.component.ts"],"sourcesContent":["// The formatter's style and plugin, which `scripts/remark-config.ts` uses too, for `yarn format:md` and VS Code's\n// remark extension: this module only has type imports, so Node runs it as it is.\nimport type { Nodes, Root } from 'mdast'\nimport type { Options } from 'remark-stringify'\n\n/**\n * How formatted markdown is written: `-` bullets, `1.` numbers, `_emphasis_`, `**strong**`, fenced code with\n * backticks, `#` headings, `---` rules, and tables with their columns lined up.\n */\nexport const NB_MARKDOWN_STYLE: Options = {\n bullet: '-',\n bulletOrdered: '.',\n emphasis: '_',\n strong: '*',\n fence: '`',\n fences: true,\n rule: '-',\n setext: false,\n closeAtx: false,\n listItemIndent: 'one',\n incrementListMarker: true,\n quote: '\"'\n}\n\n/** Typographic characters and the plain ones they're written as: the renderer decides how to show them. */\nconst PLAIN: Array<[RegExp, string]> = [\n [/[‘’′]/g, \"'\"],\n [/[“”″]/g, '\"'],\n [/—/g, '---'],\n [/–/g, '--'],\n [/…/g, '...']\n]\n\nfunction plain(value: string): string {\n return PLAIN.reduce((text, [pattern, replacement]) => text.replace(pattern, replacement), value)\n}\n\n/** A rule written as HTML, `<hr>`, on a line of its own; the formatter writes it as markdown's. */\nconst HR = /^<hr\\s*\\/?>$/i\n\n/** The nodes whose children are blocks, where an `<hr>` is a rule rather than a tag in the text. */\nconst BLOCKS = new Set(['root', 'blockquote', 'listItem'])\n\n/** An HTML block as markdown's rule where it is, or ends with, an `<hr>`: e.g. one right after a `</div>`. */\nfunction rules(node: Nodes): Nodes[] {\n if (node.type !== 'html') {\n return [node]\n }\n const lines = node.value.trimEnd().split('\\n')\n if (!HR.test(lines[lines.length - 1].trim())) {\n return [node]\n }\n const html = lines.slice(0, -1).join('\\n')\n return [...(html.trim() ? [{ ...node, value: html }] : []), { type: 'thematicBreak' }]\n}\n\n/**\n * Writes prose in plain characters, text and the titles and alt text of links and images, and rules as markdown's;\n * code and other HTML stay.\n */\nfunction normalise(node: Nodes): void {\n if (node.type === 'text') {\n node.value = plain(node.value)\n }\n if ((node.type === 'link' || node.type === 'image' || node.type === 'definition') && node.title) {\n node.title = plain(node.title)\n }\n if ((node.type === 'image' || node.type === 'imageReference') && node.alt) {\n node.alt = plain(node.alt)\n }\n if ('children' in node) {\n node.children.forEach(normalise)\n if (BLOCKS.has(node.type)) {\n node.children = node.children.flatMap(rules) as typeof node.children\n }\n }\n}\n\n/**\n * A remark plugin that writes prose in plain characters and rules written as `<hr>` as markdown's, as the formatter\n * does.\n */\nexport function nbRemarkNormalise() {\n return (tree: Root) => normalise(tree)\n}\n","import { NB_MARKDOWN_STYLE, nbRemarkNormalise } from './format-style'\n\n/**\n * Formats markdown, CommonMark with GitHub's extensions, in one style, as `nb-markdown-editor`'s Format button does:\n * the same document, written the same way wherever it came from. Prose is written in plain characters, quotes,\n * dashes and ellipses as `'`, `\"`, `--`, `---` and `...`, leaving how they look to the renderer, and a rule written\n * as `<hr>` as `---`. Code stays as it is, and so does front matter, YAML between `---` lines or TOML between `+++`\n * lines. It loads `remark`, `remark-gfm` and `remark-frontmatter` when first called.\n *\n * ```ts\n * import { nbFormatMarkdown } from '@liquid-js/lyr-extras/markdown-editor';\n *\n * const formatted = await nbFormatMarkdown('* one\\n* two\\n\\n__it’s bold__');\n * // \"- one\\n- two\\n\\n**it's bold**\\n\"\n * ```\n */\nexport async function nbFormatMarkdown(markdown: string): Promise<string> {\n const [{ remark }, { default: remarkGfm }, { default: remarkFrontmatter }] = await Promise.all([\n import('remark'),\n import('remark-gfm'),\n import('remark-frontmatter')\n ])\n const file = await remark()\n .use(remarkFrontmatter, ['yaml', 'toml'])\n .use(remarkGfm)\n .use(nbRemarkNormalise)\n .data('settings', NB_MARKDOWN_STYLE)\n .process(markdown)\n return String(file)\n}\n","import { injectNbTexts, NbLocalize } from '@liquid-js/lyr-core'\n\n/** @internal */\ndeclare const $localize: NbLocalize\n\n/**\n * The texts of the markdown editor's toolbar, tabs and popups. `provideNbTexts({ markdownEditor: { ... } })` changes\n * them, and they're translated with Angular's i18n, as `$localize` messages with ids like\n * `@@nb.markdownEditor.bold`.\n */\nexport interface NbMarkdownEditorTexts {\n /** The markdown mode's tab. */\n markdown: string\n /** The WYSIWYG mode's tab. */\n wysiwyg: string\n /** The tab with the markdown, when the preview is a tab. */\n write: string\n preview: string\n /** The toolbar button that opens the headings. */\n headings: string\n /** A level in the list of headings, given the level, e.g. \"Heading 2\". */\n headingLevel: (level: string) => string\n paragraph: string\n bold: string\n italic: string\n strike: string\n code: string\n line: string\n blockquote: string\n unorderedList: string\n orderedList: string\n task: string\n indent: string\n outdent: string\n insertLink: string\n insertCodeBlock: string\n insertTable: string\n insertImage: string\n /** The toolbar button that writes the markdown in one style, with its shortcut. */\n format: string\n /** The toolbar button that shows the items that don't fit. */\n more: string\n /** Names the toolbar. */\n textFormatting: string\n /** Describes the toolbar button whose format the text at the cursor has. */\n activeButton: string\n autoScrollEnabled: string\n autoScrollDisabled: string\n\n imageUrl: string\n selectImageFile: string\n chooseFile: string\n noFile: string\n description: string\n file: string\n url: string\n linkText: string\n linkTextRequired: string\n urlRequired: string\n ok: string\n cancel: string\n edit: string\n editLink: string\n removeLink: string\n editImage: string\n removeImage: string\n /** Asked when tabular text is pasted. */\n pasteAsTable: string\n textColor: string\n /** Edits the language of a code block. */\n chooseLanguage: string\n\n addRowAbove: string\n addRowBelow: string\n addColumnLeft: string\n addColumnRight: string\n removeRow: string\n removeColumn: string\n alignColumnLeft: string\n alignColumnCenter: string\n alignColumnRight: string\n removeTable: string\n}\n\ndeclare module '@liquid-js/lyr-core' {\n interface NbTexts {\n markdownEditor: NbMarkdownEditorTexts\n }\n}\n\n/** The editor's names of its texts; the Format button is the component's. */\nconst keys: Record<Exclude<keyof NbMarkdownEditorTexts, 'format'>, string> = {\n markdown: 'Markdown',\n wysiwyg: 'WYSIWYG',\n write: 'Write',\n preview: 'Preview',\n headings: 'Headings',\n headingLevel: 'Heading {level}',\n paragraph: 'Paragraph',\n bold: 'Bold',\n italic: 'Italic',\n strike: 'Strike',\n code: 'Code',\n line: 'Line',\n blockquote: 'Blockquote',\n unorderedList: 'Unordered list',\n orderedList: 'Ordered list',\n task: 'Task',\n indent: 'Indent',\n outdent: 'Outdent',\n insertLink: 'Insert link',\n insertCodeBlock: 'Insert CodeBlock',\n insertTable: 'Insert table',\n insertImage: 'Insert image',\n more: 'More',\n textFormatting: 'Text Formatting',\n activeButton: 'Active Button',\n autoScrollEnabled: 'Auto scroll enabled',\n autoScrollDisabled: 'Auto scroll disabled',\n imageUrl: 'Image URL',\n selectImageFile: 'Select image file',\n chooseFile: 'Choose a file',\n noFile: 'No file',\n description: 'Description',\n file: 'File',\n url: 'URL',\n linkText: 'Link text',\n linkTextRequired: 'Link text required',\n urlRequired: 'URL required',\n ok: 'OK',\n cancel: 'Cancel',\n edit: 'Edit',\n editLink: 'Edit link',\n removeLink: 'Remove link',\n editImage: 'Edit image',\n removeImage: 'Remove image',\n pasteAsTable: 'Would you like to paste as table?',\n textColor: 'Text color',\n chooseLanguage: 'Choose language',\n addRowAbove: 'Add row to up',\n addRowBelow: 'Add row to down',\n addColumnLeft: 'Add column to left',\n addColumnRight: 'Add column to right',\n removeRow: 'Remove row',\n removeColumn: 'Remove column',\n alignColumnLeft: 'Align column to left',\n alignColumnCenter: 'Align column to center',\n alignColumnRight: 'Align column to right',\n removeTable: 'Remove table'\n}\n\n/** The texts under the editor's names, to register as its language. @internal */\nexport function nbMarkdownEditorLanguage(texts: NbMarkdownEditorTexts): Record<string, string> {\n return Object.fromEntries(\n Object.entries(keys).map(([key, name]) => {\n const text = texts[key as keyof typeof keys]\n // The editor puts the level where `{level}` is.\n return [name, typeof text === 'function' ? text('{level}') : text]\n })\n )\n}\n\n/** @internal */\nexport function injectNbMarkdownEditorTexts() {\n return injectNbTexts('markdownEditor', () => ({\n markdown: $localize`:@@nb.markdownEditor.markdown:Markdown`,\n wysiwyg: $localize`:@@nb.markdownEditor.wysiwyg:WYSIWYG`,\n write: $localize`:@@nb.markdownEditor.write:Write`,\n preview: $localize`:@@nb.markdownEditor.preview:Preview`,\n headings: $localize`:@@nb.markdownEditor.headings:Headings`,\n headingLevel: (level: string) => $localize`:@@nb.markdownEditor.headingLevel:Heading ${level}:level:`,\n paragraph: $localize`:@@nb.markdownEditor.paragraph:Paragraph`,\n bold: $localize`:@@nb.markdownEditor.bold:Bold`,\n italic: $localize`:@@nb.markdownEditor.italic:Italic`,\n strike: $localize`:@@nb.markdownEditor.strike:Strikethrough`,\n code: $localize`:@@nb.markdownEditor.code:Inline code`,\n line: $localize`:@@nb.markdownEditor.line:Horizontal line`,\n blockquote: $localize`:@@nb.markdownEditor.blockquote:Blockquote`,\n unorderedList: $localize`:@@nb.markdownEditor.unorderedList:Unordered list`,\n orderedList: $localize`:@@nb.markdownEditor.orderedList:Ordered list`,\n task: $localize`:@@nb.markdownEditor.task:Task list`,\n indent: $localize`:@@nb.markdownEditor.indent:Indent`,\n outdent: $localize`:@@nb.markdownEditor.outdent:Outdent`,\n insertLink: $localize`:@@nb.markdownEditor.insertLink:Insert link`,\n insertCodeBlock: $localize`:@@nb.markdownEditor.insertCodeBlock:Insert code block`,\n insertTable: $localize`:@@nb.markdownEditor.insertTable:Insert table`,\n insertImage: $localize`:@@nb.markdownEditor.insertImage:Insert image`,\n format: $localize`:@@nb.markdownEditor.format:Format (Shift+Alt+F)`,\n more: $localize`:@@nb.markdownEditor.more:More`,\n textFormatting: $localize`:@@nb.markdownEditor.textFormatting:Text formatting`,\n activeButton: $localize`:@@nb.markdownEditor.activeButton:Active`,\n autoScrollEnabled: $localize`:@@nb.markdownEditor.autoScrollEnabled:Auto scroll enabled`,\n autoScrollDisabled: $localize`:@@nb.markdownEditor.autoScrollDisabled:Auto scroll disabled`,\n\n imageUrl: $localize`:@@nb.markdownEditor.imageUrl:Image URL`,\n selectImageFile: $localize`:@@nb.markdownEditor.selectImageFile:Select image file`,\n chooseFile: $localize`:@@nb.markdownEditor.chooseFile:Choose a file`,\n noFile: $localize`:@@nb.markdownEditor.noFile:No file`,\n description: $localize`:@@nb.markdownEditor.description:Description`,\n file: $localize`:@@nb.markdownEditor.file:File`,\n url: $localize`:@@nb.markdownEditor.url:URL`,\n linkText: $localize`:@@nb.markdownEditor.linkText:Link text`,\n linkTextRequired: $localize`:@@nb.markdownEditor.linkTextRequired:The field \"Link text\" is required`,\n urlRequired: $localize`:@@nb.markdownEditor.urlRequired:The field \"URL\" is required`,\n ok: $localize`:@@nb.markdownEditor.ok:OK`,\n cancel: $localize`:@@nb.markdownEditor.cancel:Cancel`,\n edit: $localize`:@@nb.markdownEditor.edit:Edit`,\n editLink: $localize`:@@nb.markdownEditor.editLink:Edit link`,\n removeLink: $localize`:@@nb.markdownEditor.removeLink:Remove link`,\n editImage: $localize`:@@nb.markdownEditor.editImage:Edit image`,\n removeImage: $localize`:@@nb.markdownEditor.removeImage:Remove image`,\n pasteAsTable: $localize`:@@nb.markdownEditor.pasteAsTable:Paste as a table?`,\n textColor: $localize`:@@nb.markdownEditor.textColor:Text color`,\n chooseLanguage: $localize`:@@nb.markdownEditor.chooseLanguage:Choose language`,\n\n addRowAbove: $localize`:@@nb.markdownEditor.addRowAbove:Add row above`,\n addRowBelow: $localize`:@@nb.markdownEditor.addRowBelow:Add row below`,\n addColumnLeft: $localize`:@@nb.markdownEditor.addColumnLeft:Add column left`,\n addColumnRight: $localize`:@@nb.markdownEditor.addColumnRight:Add column right`,\n removeRow: $localize`:@@nb.markdownEditor.removeRow:Remove row`,\n removeColumn: $localize`:@@nb.markdownEditor.removeColumn:Remove column`,\n alignColumnLeft: $localize`:@@nb.markdownEditor.alignColumnLeft:Align column left`,\n alignColumnCenter: $localize`:@@nb.markdownEditor.alignColumnCenter:Align column center`,\n alignColumnRight: $localize`:@@nb.markdownEditor.alignColumnRight:Align column right`,\n removeTable: $localize`:@@nb.markdownEditor.removeTable:Remove table`\n }))\n}\n","import { isPlatformBrowser } from '@angular/common'\nimport {\n afterRenderEffect,\n booleanAttribute,\n Component,\n computed,\n DestroyRef,\n ElementRef,\n forwardRef,\n inject,\n input,\n linkedSignal,\n model,\n PLATFORM_ID,\n signal,\n untracked,\n viewChild,\n ViewEncapsulation\n} from '@angular/core'\nimport { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'\nimport {\n injectNbDefaults,\n NbComponentOrCustomStatus,\n NbComponentShape,\n NbIconConfig,\n NbIconLibraries,\n NbValidationDirective\n} from '@liquid-js/lyr-core'\nimport type {\n Editor,\n EditorOptions,\n EditorPlugin,\n EditorType,\n IconName,\n PreviewStyle,\n ToolbarItemOptions\n} from '@liquid-js/underflow'\nimport type { HLJSApi } from 'highlight.js'\nimport { HighlightLoader, NXT_HIGHLIGHT_OPTIONS } from 'nxt-highlightjs'\nimport { nbFormatMarkdown } from './format'\nimport { injectNbMarkdownEditorTexts, nbMarkdownEditorLanguage, NbMarkdownEditorTexts } from './texts'\n\n/** Options of `@liquid-js/underflow`'s editor that the component's inputs don't set. */\nexport type NbMarkdownEditorOptions = Omit<\n EditorOptions,\n | 'el'\n | 'initialValue'\n | 'initialEditType'\n | 'height'\n | 'minHeight'\n | 'previewStyle'\n | 'placeholder'\n | 'toolbarItems'\n | 'hideModeSwitch'\n | 'toolbarStyle'\n | 'language'\n | 'theme'\n | 'autofocus'\n | 'viewer'\n | 'readonly'\n | 'disabled'\n | 'autoDirection'\n>\n\n/** Groups of toolbar items: the names of the editor's items, e.g. `bold`, `format`, or items of your own. */\nexport type NbMarkdownEditorToolbar = Array<Array<string | ToolbarItemOptions>>\n\n/** What the editor is made with. */\ninterface Setup {\n texts: NbMarkdownEditorTexts\n toolbarItems?: NbMarkdownEditorToolbar\n hideModeSwitch: boolean\n autoDirection: boolean\n options: NbMarkdownEditorOptions\n /** Highlights code, once it's loaded. */\n highlighter?: HLJSApi\n}\n\n/**\n * The editor's icons, by UnderFlow's names: Lyra's, from the `essentials` pack, written out whole so the pack has them.\n * Every name is here, so a name UnderFlow adds doesn't compile until it has one of Lyra's.\n */\nconst ICONS: Record<IconName, NbIconConfig> = {\n 'heading': { icon: 'heading-outline', pack: 'essentials' },\n 'bold': { icon: 'bold-outline', pack: 'essentials' },\n 'italic': { icon: 'italic-outline', pack: 'essentials' },\n 'strike': { icon: 'strikethrough-outline', pack: 'essentials' },\n 'hrline': { icon: 'minus-outline', pack: 'essentials' },\n 'quote': { icon: 'quote-outline', pack: 'essentials' },\n 'bullet-list': { icon: 'list-outline', pack: 'essentials' },\n 'ordered-list': { icon: 'list-numbered-outline', pack: 'essentials' },\n 'task-list': { icon: 'list-checked-outline', pack: 'essentials' },\n 'indent': { icon: 'indent-outline', pack: 'essentials' },\n 'outdent': { icon: 'outdent-outline', pack: 'essentials' },\n 'table': { icon: 'table-outline', pack: 'essentials' },\n 'image': { icon: 'image-outline', pack: 'essentials' },\n 'link': { icon: 'link-outline', pack: 'essentials' },\n 'code': { icon: 'code-outline', pack: 'essentials' },\n 'codeblock': { icon: 'code-block-outline', pack: 'essentials' },\n 'more': { icon: 'more-horizontal-outline', pack: 'essentials' },\n 'add-row-up': { icon: 'table-row-add-above-outline', pack: 'essentials' },\n 'add-row-down': { icon: 'table-row-add-below-outline', pack: 'essentials' },\n 'add-column-left': { icon: 'table-column-add-left-outline', pack: 'essentials' },\n 'add-column-right': { icon: 'table-column-add-right-outline', pack: 'essentials' },\n 'remove-row': { icon: 'table-row-remove-outline', pack: 'essentials' },\n 'remove-column': { icon: 'table-column-remove-outline', pack: 'essentials' },\n 'align-column-left': { icon: 'align-left-outline', pack: 'essentials' },\n 'align-column-center': { icon: 'align-center-outline', pack: 'essentials' },\n 'align-column-right': { icon: 'align-right-outline', pack: 'essentials' },\n 'remove-table': { icon: 'table-remove-outline', pack: 'essentials' },\n 'chevron-down': { icon: 'chevron-down-outline', pack: 'essentials' },\n 'pencil': { icon: 'edit-outline', pack: 'essentials' }\n}\n\n/** The Format button's icon. */\nconst FORMAT_ICON: NbIconConfig = { icon: 'brush-outline', pack: 'essentials' }\n\n/** The command the Format button runs, in either mode. */\nconst FORMAT_COMMAND = 'nbFormat'\n\n/** UnderFlow's toolbar, with the Format button before the scroll sync switch. */\nconst TOOLBAR: NbMarkdownEditorToolbar = [\n ['heading', 'bold', 'italic', 'strike'],\n ['hr', 'quote'],\n ['ul', 'ol', 'task', 'indent', 'outdent'],\n ['table', 'image', 'link'],\n ['code', 'codeblock'],\n ['format'],\n ['scrollSync']\n]\n\n/** The checkmark of the scroll sync switch, which looks like Lyra's toggle. */\nconst SWITCH_CHECKMARK: NbIconConfig = { icon: 'checkmark-bold-outline', pack: 'essentials' }\n\n// The editor's texts are registered by language code for all editors, so editors with the same texts share a code.\nconst languages = new Map<string, string>()\n\nfunction languageCode(library: typeof Editor, texts: NbMarkdownEditorTexts) {\n const language = nbMarkdownEditorLanguage(texts)\n const key = JSON.stringify(language)\n let code = languages.get(key)\n if (!code) {\n code = `x-nb-markdown-${languages.size}`\n languages.set(key, code)\n library.setLanguage(code, language)\n }\n return code\n}\n\n/**\n * A markdown editor, with a toolbar, a preview and a WYSIWYG mode:\n *\n * ```html\n * <nb-markdown-editor [formControl]=\"text\" aria-label=\"Description\" />\n * ```\n *\n * @stacked-example(Showcase, markdown/markdown-editor-showcase.component)\n *\n * ### Installation\n *\n * Install [`@liquid-js/underflow`](https://www.npmjs.com/package/@liquid-js/underflow), which is the editor, with the\n * ProseMirror and DOMPurify packages it uses, and import `NbMarkdownEditorComponent` from\n * `@liquid-js/lyr-extras/markdown-editor`:\n *\n * ```bash\n * npm install @liquid-js/underflow prosemirror-commands prosemirror-history prosemirror-inputrules \\\n * prosemirror-keymap prosemirror-model prosemirror-state prosemirror-transform prosemirror-view dompurify\n * ```\n *\n * The Format button formats with [`remark`](https://remark.js.org), which it loads when it's first used, with\n * `remark-gfm` and `remark-frontmatter`:\n *\n * ```bash\n * npm install remark remark-gfm remark-frontmatter\n * ```\n *\n * The editor loads when the first one shows; its styles come with the component. It highlights code with the\n * highlight.js that [`nxt-highlightjs`](https://www.npmjs.com/package/nxt-highlightjs) loads, when the app sets it up\n * as in `nb-markdown-viewer`, so install them too:\n *\n * ```bash\n * npm install nxt-highlightjs highlight.js\n * ```\n *\n * ### Usage\n *\n * It's a form control whose value is the markdown, CommonMark with GitHub's extensions, e.g. tables and task lists.\n * Its frame has the colours of a field and its `status`, and the text the theme's styles:\n * @stacked-example(States, markdown/markdown-editor-status.component)\n *\n * The preview shows the text's straight quotes, `--`, `---` and `...` as typographic quotes, en and em dashes and\n * ellipses, as `nb-markdown-viewer` does, while the markdown and the WYSIWYG mode keep them as written.\n *\n * In the markdown mode the preview is a tab, or next to the markdown with `previewStyle=\"vertical\"`; the WYSIWYG mode\n * edits the formatted text, and `mode` is the one that shows. The toolbar wraps onto more lines when it doesn't fit,\n * so all of its buttons can be reached with Tab; `toolbarItems` picks them.\n *\n * The Format button, and Shift+Alt+F in the text, writes the markdown in one style with `nbFormatMarkdown`, which\n * also writes typographic quotes, dashes and ellipses as plain characters; Undo brings the text back. It's `format` in\n * `toolbarItems`.\n *\n * In the text, Tab indents list items and moves between table cells, so Escape and then Tab or Shift+Tab moves focus\n * out of it, as in code editors. Name the text with `aria-label`, `aria-labelledby` for a `label`, or an `nbLabel` with\n * `nbValidation`, which also gives it the field's status and errors, as it does an input.\n *\n * With `readonly` the text can be read, selected and copied, but not changed, as in a read-only field: the toolbar\n * and the mode switch are disabled, while the Write and Preview tabs still switch. Disabled, the editor is read-only\n * too, in the colours of a disabled field, and Tab skips it.\n *\n * Text that mixes right-to-left and left-to-right languages, e.g. Arabic or Hebrew quoted in English, reads right\n * with `autoDirection`: each paragraph, heading, list, quote and table takes the direction of its own text, as\n * `dir=\"auto\"` does, in the preview and the WYSIWYG mode, and so does each line of the markdown. Code blocks read left\n * to right. The markdown itself doesn't change.\n *\n * `options` takes the [editor's other options](https://liquid-js.github.io/underflow/docs/), e.g. plugins, widgets\n * or `hooks.addImageBlobHook` to upload pasted images, and `editor()` is the editor, for its methods. It's made again\n * when the options, the toolbar, the texts or `autoDirection` change, keeping the markdown.\n */\n@Component({\n selector: 'nb-markdown-editor',\n template: '<div #container></div>',\n styleUrl: './markdown-editor.component.scss',\n encapsulation: ViewEncapsulation.None,\n providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => NbMarkdownEditorComponent), multi: true }],\n host: {\n 'class': 'nb-markdown',\n '(keydown)': 'onKeydown($event)',\n '[attr.aria-disabled]': 'isDisabled() || null',\n '[style]': 'statusStyles()',\n // Keeps the editor's place until it loads.\n '[style.min-height]': \"editor() ? null : height() === 'auto' ? minHeight() : height()\"\n }\n})\nexport class NbMarkdownEditorComponent implements ControlValueAccessor {\n protected readonly texts = injectNbMarkdownEditorTexts()\n protected readonly iconLibraries = inject(NbIconLibraries)\n\n /** The editor's height with the toolbar, e.g. `300px` (default) or `auto`, which grows with the text. */\n readonly height = input('300px')\n /** `200px` by default. */\n readonly minHeight = input('200px')\n /** The preview in a `tab` (default), or `vertical`, next to the markdown. */\n readonly previewStyle = input<PreviewStyle>('tab')\n /** `markdown` (default) or `wysiwyg`, and the mode the user picks. */\n readonly mode = model<EditorType>('markdown')\n readonly placeholder = input('')\n /** Field status: `basic` (default), `primary`, `info`, `success`, `warning`, `danger` or `control`. */\n readonly status = input<NbComponentOrCustomStatus>('basic')\n\n // The app's defaults for fields, which the shape starts from, as a textarea's does.\n protected readonly nbDefaults = injectNbDefaults('input')\n /** Field shape: `rectangle` (default), `semi-round` or `round`, only as round as a textarea gets. */\n readonly shapeInput = input<NbComponentShape | undefined>(undefined, { alias: 'shape' })\n /** The shape in use: the input's, the app's default, or 'rectangle'. */\n readonly shape = linkedSignal<NbComponentShape>(() => this.shapeInput() ?? this.nbDefaults().shape ?? 'rectangle')\n /** Groups of toolbar items, e.g. `[['heading', 'bold', 'italic'], ['link']]`. */\n readonly toolbarItems = input<NbMarkdownEditorToolbar>()\n /** Hides the Markdown and WYSIWYG tabs. */\n readonly hideModeSwitch = input(false, { transform: booleanAttribute })\n /**\n * Gives each paragraph, heading, list, quote and table the direction of its own text (`dir=\"auto\"`), for text in\n * more than one direction; `false` by default.\n */\n readonly autoDirection = input(false, { transform: booleanAttribute })\n /** Options of `@liquid-js/underflow`'s editor, e.g. plugins. */\n readonly options = input<NbMarkdownEditorOptions>({})\n /** Names the text area when there's no `aria-labelledby`. */\n readonly ariaLabel = input<string | undefined>(undefined, { alias: 'aria-label' })\n /** The id of the element that names the text area, e.g. a `label`. */\n readonly ariaLabelledBy = input<string | undefined>(undefined, { alias: 'aria-labelledby' })\n readonly disabled = input(false, { transform: booleanAttribute })\n /** Lets the user read the text, but not change it. */\n readonly readonly = input(false, { transform: booleanAttribute })\n\n /** The editor, once it's loaded. */\n readonly editor = signal<Editor | undefined>(undefined)\n\n protected readonly validation = inject(NbValidationDirective, { self: true, optional: true })\n // With `nbValidation`, the status it gives while the control shows errors or success.\n protected readonly resolvedStatus = computed(() => this.validation?.status() ?? this.status())\n\n protected readonly value = signal('')\n protected readonly isDisabled = linkedSignal(() => this.disabled())\n protected readonly container = viewChild.required<ElementRef<HTMLElement>>('container')\n /** Loads highlight.js, when the app highlights code. */\n protected readonly highlightLoader = inject(NXT_HIGHLIGHT_OPTIONS, { optional: true })\n ? inject(HighlightLoader)\n : undefined\n\n protected readonly statusStyles = computed(() => {\n const status = this.resolvedStatus()\n const shape = this.shape()\n return {\n '--nb-markdown-border-radius': `min(var(--input-${shape}-border-radius), var(--input-textarea-max-border-radius))`,\n '--nb-markdown-field-border-radius': `var(--input-${shape}-border-radius)`,\n // At rest; the styles pick the background by state, which an inline value would override.\n '--nb-markdown-rest-background': `var(--input-${status}-background-color)`,\n '--nb-markdown-border-color': `var(--input-${status}-border-color)`,\n '--nb-markdown-hover-background': `var(--input-${status}-hover-background-color)`,\n '--nb-markdown-hover-border-color': `var(--input-${status}-hover-border-color)`,\n '--nb-markdown-focus-background': `var(--input-${status}-focus-background-color)`,\n '--nb-markdown-focus-border-color': `var(--input-${status}-focus-border-color)`,\n '--nb-markdown-focus-and-hover-background': `var(--input-${status}-focus-and-hover-background-color)`,\n '--nb-markdown-focus-and-hover-border-color': `var(--input-${status}-focus-and-hover-border-color)`,\n '--nb-markdown-disabled-background': `var(--input-${status}-disabled-background-color)`,\n '--nb-markdown-disabled-border-color': `var(--input-${status}-disabled-border-color)`\n }\n })\n\n /** What the editor is made with; it's made again when this changes. */\n protected readonly setup = computed<Setup | undefined>(() => {\n const highlight = this.highlightLoader?.hljs\n // The editor waits for highlight.js rather than being made again when it loads.\n if (highlight?.isLoading()) {\n return undefined\n }\n return {\n texts: this.texts(),\n toolbarItems: this.toolbarItems(),\n hideModeSwitch: this.hideModeSwitch(),\n autoDirection: this.autoDirection(),\n options: this.options(),\n highlighter: highlight?.hasValue() ? highlight.value() : undefined\n }\n })\n\n protected creating = 0\n protected destroyed = false\n /** Set while the form's value is written, which isn't a change to report. */\n protected writing = false\n\n protected onChange: (value: string) => void = () => {}\n /** @internal */\n onTouched: () => void = () => {}\n\n constructor() {\n // The text is the control: it gets the validation's ARIA, and the focus from an `nbLabel`, not the host.\n this.validation?.delegateAria(() => this.editor()?.focus())\n if (!isPlatformBrowser(inject(PLATFORM_ID))) {\n return\n }\n afterRenderEffect(() => {\n const setup = this.setup()\n if (setup) {\n untracked(() => void this.create(setup))\n }\n })\n afterRenderEffect(() => {\n const editor = this.editor()\n const [height, minHeight, previewStyle, placeholder, mode] = [\n this.height(),\n this.minHeight(),\n this.previewStyle(),\n this.placeholder(),\n this.mode()\n ]\n if (!editor) {\n return\n }\n if (editor.getHeight() !== height) {\n editor.setHeight(height)\n }\n if (editor.getMinHeight() !== minHeight) {\n editor.setMinHeight(minHeight)\n }\n if (editor.getCurrentPreviewStyle() !== previewStyle) {\n editor.changePreviewStyle(previewStyle)\n // The vertical preview brings the scroll sync switch.\n this.markSwitch()\n }\n editor.setPlaceholder(placeholder)\n if (editor.isWysiwygMode() !== (mode === 'wysiwyg')) {\n editor.changeMode(mode, true)\n }\n })\n afterRenderEffect(() => {\n const editor = this.editor()\n const [disabled, readonly] = [this.isDisabled(), this.readonly()]\n if (editor) {\n editor.setDisabled(disabled)\n editor.setReadonly(readonly)\n }\n })\n afterRenderEffect(() => {\n const editor = this.editor()\n const validation = this.validation\n const labelledBy = [this.ariaLabelledBy(), validation?.labelledBy()].filter(Boolean).join(' ') || undefined\n const attributes = {\n 'aria-label': labelledBy ? undefined : this.ariaLabel(),\n 'aria-labelledby': labelledBy,\n 'aria-invalid': validation?.ariaInvalid() ?? undefined,\n 'aria-describedby': validation?.describedBy() ?? undefined,\n 'aria-required': validation?.ariaRequired() ?? undefined\n }\n if (editor) {\n this.label(editor, attributes)\n }\n })\n inject(DestroyRef).onDestroy(() => {\n this.destroyed = true\n this.editor()?.destroy()\n })\n }\n\n writeValue(value?: string | null) {\n const markdown = value ?? ''\n this.value.set(markdown)\n const editor = this.editor()\n if (editor && editor.getMarkdown() !== markdown) {\n this.writing = true\n try {\n editor.setMarkdown(markdown, false, false)\n } finally {\n this.writing = false\n }\n }\n }\n\n registerOnChange(fn: (value: string) => void) {\n this.onChange = fn\n }\n\n registerOnTouched(fn: () => void) {\n this.onTouched = fn\n }\n\n setDisabledState(disabled: boolean) {\n this.isDisabled.set(disabled)\n }\n\n /** Moves focus to the text. */\n focus() {\n this.editor()?.focus()\n }\n\n protected async create(setup: Setup) {\n const creating = ++this.creating\n const [{ Editor }, highlight] = await Promise.all([\n import('@liquid-js/underflow'),\n setup.highlighter ? import('@liquid-js/underflow/plugins/code-syntax-highlight') : undefined\n ])\n if (creating !== this.creating || this.destroyed) {\n return\n }\n const plugins: EditorPlugin[] = [...(setup.options.plugins ?? [])]\n if (highlight && setup.highlighter) {\n plugins.push([highlight.codeSyntaxHighlightPlugin, { highlighter: setup.highlighter }])\n }\n\n const previous = this.editor()\n previous?.destroy()\n Editor.setIcons(this.icons())\n const editor = new Editor({\n // The preview shows quotes, dashes and ellipses as nb-markdown-viewer does.\n smartPunctuation: true,\n ...setup.options,\n plugins,\n el: this.container().nativeElement,\n initialValue: this.value(),\n initialEditType: this.mode(),\n height: this.height(),\n minHeight: this.minHeight(),\n previewStyle: this.previewStyle(),\n placeholder: this.placeholder(),\n language: languageCode(Editor, setup.texts),\n autofocus: false,\n disabled: this.isDisabled(),\n readonly: this.readonly(),\n // Every button stays in the toolbar, where Tab reaches it, instead of a menu that opens on hover.\n toolbarStyle: 'wrap',\n toolbarItems: this.toolbar(setup),\n hideModeSwitch: setup.hideModeSwitch,\n autoDirection: setup.autoDirection\n })\n editor.on('change', () => this.changed(editor))\n editor.on('blur', () => this.onTouched())\n editor.on('changeMode', (mode: EditorType) => this.mode.set(mode))\n for (const type of ['markdown', 'wysiwyg'] as const) {\n editor.addCommand(type, FORMAT_COMMAND, () => {\n void this.format(editor)\n return true\n })\n }\n this.markSwitch()\n this.editor.set(editor)\n }\n\n /** The toolbar's groups, with the Format button for `format`. */\n protected toolbar(setup: Setup): NbMarkdownEditorToolbar {\n const button = {\n name: 'format',\n // UnderFlow's class for a toolbar button with an icon, which its own buttons have.\n className: 'nb-markdown-format uf-toolbar-icons',\n tooltip: setup.texts.format,\n icon: this.iconLibraries.getSvgIcon(FORMAT_ICON.icon, FORMAT_ICON.pack)?.icon.getContent(),\n command: FORMAT_COMMAND\n }\n return (setup.toolbarItems ?? TOOLBAR).map((group) => group.map((item) => (item === 'format' ? button : item)))\n }\n\n /** Formats the markdown, with Shift+Alt+F too, unless the user can't change it. */\n protected onKeydown(event: KeyboardEvent) {\n const editor = this.editor()\n if (event.code === 'KeyF' && event.shiftKey && event.altKey && !event.ctrlKey && !event.metaKey && editor) {\n // The key would type a character, e.g. Ï on a Mac.\n event.preventDefault()\n void this.format(editor)\n }\n }\n\n /**\n * Writes the markdown in one style, as an edit Undo takes back, keeping the cursor's line; the text stays if the\n * user changes it while the formatter loads.\n */\n protected async format(editor: Editor) {\n if (editor.isReadonly() || editor.isDisabled()) {\n return\n }\n const markdown = editor.getMarkdown()\n const formatted = await nbFormatMarkdown(markdown)\n if (formatted === markdown || editor !== this.editor() || editor.getMarkdown() !== markdown) {\n return\n }\n const line = editor.getCursorLine()\n editor.setMarkdown(formatted, false, false)\n editor.moveCursorTo(Math.min(line, formatted.split('\\n').length), true)\n }\n\n protected changed(editor: Editor) {\n const markdown = editor.getMarkdown()\n if (markdown === this.value()) {\n return\n }\n this.value.set(markdown)\n if (!this.writing) {\n this.onChange(markdown)\n }\n }\n\n /**\n * The editor's icons as the `essentials` pack has them, so an app that replaces one there replaces it here too; one\n * the pack doesn't have keeps UnderFlow's own.\n */\n protected icons(): Partial<Record<IconName, string>> {\n return Object.fromEntries(\n Object.entries(ICONS).map(([name, { icon, pack }]) => [\n name,\n this.iconLibraries.getSvgIcon(icon, pack)?.icon.getContent() || undefined\n ])\n )\n }\n\n /** Gives the scroll sync switch the checkmark of Lyra's toggle, which shows when it's on. */\n protected markSwitch() {\n const toggle = this.container().nativeElement.querySelector('.scroll-sync .switch')\n if (!toggle || toggle.querySelector('.nb-markdown-switch-checkmark')) {\n return\n }\n const checkmark = toggle.ownerDocument.createElement('span')\n checkmark.className = 'nb-markdown-switch-checkmark'\n checkmark.setAttribute('aria-hidden', 'true')\n checkmark.innerHTML =\n this.iconLibraries.getSvgIcon(SWITCH_CHECKMARK.icon, SWITCH_CHECKMARK.pack)?.icon.getContent() ?? ''\n toggle.append(checkmark)\n }\n\n /** Names the texts, the markdown and the WYSIWYG one, leaving out the attributes without a value. */\n protected label(editor: Editor, attributes: Record<string, string | undefined>) {\n const { mdEditor, wwEditor } = editor.getEditorElements()\n for (const text of [mdEditor, wwEditor].map((element) => element.querySelector('.ProseMirror'))) {\n for (const [name, value] of Object.entries(attributes)) {\n if (value) {\n text?.setAttribute(name, value)\n } else {\n text?.removeAttribute(name)\n }\n }\n }\n }\n}\n"],"mappings":";;;;;;AASA,MAAa,oBAA6B;CACtC,QAAQ;CACR,eAAe;CACf,UAAU;CACV,QAAQ;CACR,OAAO;CACP,QAAQ;CACR,MAAM;CACN,QAAQ;CACR,UAAU;CACV,gBAAgB;CAChB,qBAAqB;CACrB,OAAO;AACV;AAGD,MAAM,Q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":["../../../packages/extras/markdown-editor/src/format-style.ts","../../../packages/extras/markdown-editor/src/format.ts","../../../packages/extras/markdown-editor/src/texts.ts","../../../packages/extras/markdown-editor/src/markdown-editor.component.ts"],"sourcesContent":["// The formatter's style and plugin, which `scripts/remark-config.ts` uses too, for `yarn format:md` and VS Code's\n// remark extension: this module only has type imports, so Node runs it as it is.\nimport type { Nodes, Root } from 'mdast'\nimport type { Options } from 'remark-stringify'\n\n/**\n * How formatted markdown is written: `-` bullets, `1.` numbers, `_emphasis_`, `**strong**`, fenced code with\n * backticks, `#` headings, `---` rules, and tables with their columns lined up.\n */\nexport const NB_MARKDOWN_STYLE: Options = {\n bullet: '-',\n bulletOrdered: '.',\n emphasis: '_',\n strong: '*',\n fence: '`',\n fences: true,\n rule: '-',\n setext: false,\n closeAtx: false,\n listItemIndent: 'one',\n incrementListMarker: true,\n quote: '\"'\n}\n\n/** Typographic characters and the plain ones they're written as: the renderer decides how to show them. */\nconst PLAIN: Array<[RegExp, string]> = [\n [/[‘’′]/g, \"'\"],\n [/[“”″]/g, '\"'],\n [/—/g, '---'],\n [/–/g, '--'],\n [/…/g, '...']\n]\n\nfunction plain(value: string): string {\n return PLAIN.reduce((text, [pattern, replacement]) => text.replace(pattern, replacement), value)\n}\n\n/** A rule written as HTML, `<hr>`, on a line of its own; the formatter writes it as markdown's. */\nconst HR = /^<hr\\s*\\/?>$/i\n\n/** The nodes whose children are blocks, where an `<hr>` is a rule rather than a tag in the text. */\nconst BLOCKS = new Set(['root', 'blockquote', 'listItem'])\n\n/** An HTML block as markdown's rule where it is, or ends with, an `<hr>`: e.g. one right after a `</div>`. */\nfunction rules(node: Nodes): Nodes[] {\n if (node.type !== 'html') {\n return [node]\n }\n const lines = node.value.trimEnd().split('\\n')\n if (!HR.test(lines[lines.length - 1].trim())) {\n return [node]\n }\n const html = lines.slice(0, -1).join('\\n')\n return [...(html.trim() ? [{ ...node, value: html }] : []), { type: 'thematicBreak' }]\n}\n\n/**\n * Writes prose in plain characters, text and the titles and alt text of links and images, and rules as markdown's;\n * code and other HTML stay.\n */\nfunction normalise(node: Nodes): void {\n if (node.type === 'text') {\n node.value = plain(node.value)\n }\n if ((node.type === 'link' || node.type === 'image' || node.type === 'definition') && node.title) {\n node.title = plain(node.title)\n }\n if ((node.type === 'image' || node.type === 'imageReference') && node.alt) {\n node.alt = plain(node.alt)\n }\n if ('children' in node) {\n node.children.forEach(normalise)\n if (BLOCKS.has(node.type)) {\n node.children = node.children.flatMap(rules) as typeof node.children\n }\n }\n}\n\n/**\n * A remark plugin that writes prose in plain characters and rules written as `<hr>` as markdown's, as the formatter\n * does.\n */\nexport function nbRemarkNormalise() {\n return (tree: Root) => normalise(tree)\n}\n","import { NB_MARKDOWN_STYLE, nbRemarkNormalise } from './format-style'\n\n/**\n * Formats markdown, CommonMark with GitHub's extensions, in one style, as `nb-markdown-editor`'s Format button does:\n * the same document, written the same way wherever it came from. Prose is written in plain characters, quotes,\n * dashes and ellipses as `'`, `\"`, `--`, `---` and `...`, leaving how they look to the renderer, and a rule written\n * as `<hr>` as `---`. Code stays as it is, and so does front matter, YAML between `---` lines or TOML between `+++`\n * lines. It loads `remark`, `remark-gfm` and `remark-frontmatter` when first called.\n *\n * ```ts\n * import { nbFormatMarkdown } from '@liquid-js/lyr-extras/markdown-editor';\n *\n * const formatted = await nbFormatMarkdown('* one\\n* two\\n\\n__it’s bold__');\n * // \"- one\\n- two\\n\\n**it's bold**\\n\"\n * ```\n */\nexport async function nbFormatMarkdown(markdown: string): Promise<string> {\n const [{ remark }, { default: remarkGfm }, { default: remarkFrontmatter }] = await Promise.all([\n import('remark'),\n import('remark-gfm'),\n import('remark-frontmatter')\n ])\n const file = await remark()\n .use(remarkFrontmatter, ['yaml', 'toml'])\n .use(remarkGfm)\n .use(nbRemarkNormalise)\n .data('settings', NB_MARKDOWN_STYLE)\n .process(markdown)\n return String(file)\n}\n","import { injectNbTexts, NbLocalize } from '@liquid-js/lyr-core'\n\n/** @internal */\ndeclare const $localize: NbLocalize\n\n/**\n * The texts of the markdown editor's toolbar, tabs and popups. `provideNbTexts({ markdownEditor: { ... } })` changes\n * them, and they're translated with Angular's i18n, as `$localize` messages with ids like\n * `@@nb.markdownEditor.bold`.\n */\nexport interface NbMarkdownEditorTexts {\n /** The markdown mode's tab. */\n markdown: string\n /** The WYSIWYG mode's tab. */\n wysiwyg: string\n /** The tab with the markdown, when the preview is a tab. */\n write: string\n preview: string\n /** The toolbar button that opens the headings. */\n headings: string\n /** A level in the list of headings, given the level, e.g. \"Heading 2\". */\n headingLevel: (level: string) => string\n paragraph: string\n bold: string\n italic: string\n strike: string\n code: string\n line: string\n blockquote: string\n unorderedList: string\n orderedList: string\n task: string\n indent: string\n outdent: string\n insertLink: string\n insertCodeBlock: string\n insertTable: string\n insertImage: string\n /** The toolbar button that writes the markdown in one style, with its shortcut. */\n format: string\n /** The toolbar button that shows the items that don't fit. */\n more: string\n /** Names the toolbar. */\n textFormatting: string\n /** Describes the toolbar button whose format the text at the cursor has. */\n activeButton: string\n autoScrollEnabled: string\n autoScrollDisabled: string\n\n imageUrl: string\n selectImageFile: string\n chooseFile: string\n noFile: string\n description: string\n file: string\n url: string\n linkText: string\n linkTextRequired: string\n urlRequired: string\n ok: string\n cancel: string\n edit: string\n editLink: string\n removeLink: string\n editImage: string\n removeImage: string\n /** Asked when tabular text is pasted. */\n pasteAsTable: string\n textColor: string\n /** Edits the language of a code block. */\n chooseLanguage: string\n\n addRowAbove: string\n addRowBelow: string\n addColumnLeft: string\n addColumnRight: string\n removeRow: string\n removeColumn: string\n alignColumnLeft: string\n alignColumnCenter: string\n alignColumnRight: string\n removeTable: string\n}\n\ndeclare module '@liquid-js/lyr-core' {\n interface NbTexts {\n markdownEditor: NbMarkdownEditorTexts\n }\n}\n\n/** The editor's names of its texts; the Format button is the component's. */\nconst keys: Record<Exclude<keyof NbMarkdownEditorTexts, 'format'>, string> = {\n markdown: 'Markdown',\n wysiwyg: 'WYSIWYG',\n write: 'Write',\n preview: 'Preview',\n headings: 'Headings',\n headingLevel: 'Heading {level}',\n paragraph: 'Paragraph',\n bold: 'Bold',\n italic: 'Italic',\n strike: 'Strike',\n code: 'Code',\n line: 'Line',\n blockquote: 'Blockquote',\n unorderedList: 'Unordered list',\n orderedList: 'Ordered list',\n task: 'Task',\n indent: 'Indent',\n outdent: 'Outdent',\n insertLink: 'Insert link',\n insertCodeBlock: 'Insert CodeBlock',\n insertTable: 'Insert table',\n insertImage: 'Insert image',\n more: 'More',\n textFormatting: 'Text Formatting',\n activeButton: 'Active Button',\n autoScrollEnabled: 'Auto scroll enabled',\n autoScrollDisabled: 'Auto scroll disabled',\n imageUrl: 'Image URL',\n selectImageFile: 'Select image file',\n chooseFile: 'Choose a file',\n noFile: 'No file',\n description: 'Description',\n file: 'File',\n url: 'URL',\n linkText: 'Link text',\n linkTextRequired: 'Link text required',\n urlRequired: 'URL required',\n ok: 'OK',\n cancel: 'Cancel',\n edit: 'Edit',\n editLink: 'Edit link',\n removeLink: 'Remove link',\n editImage: 'Edit image',\n removeImage: 'Remove image',\n pasteAsTable: 'Would you like to paste as table?',\n textColor: 'Text color',\n chooseLanguage: 'Choose language',\n addRowAbove: 'Add row to up',\n addRowBelow: 'Add row to down',\n addColumnLeft: 'Add column to left',\n addColumnRight: 'Add column to right',\n removeRow: 'Remove row',\n removeColumn: 'Remove column',\n alignColumnLeft: 'Align column to left',\n alignColumnCenter: 'Align column to center',\n alignColumnRight: 'Align column to right',\n removeTable: 'Remove table'\n}\n\n/** The texts under the editor's names, to register as its language. @internal */\nexport function nbMarkdownEditorLanguage(texts: NbMarkdownEditorTexts): Record<string, string> {\n return Object.fromEntries(\n Object.entries(keys).map(([key, name]) => {\n const text = texts[key as keyof typeof keys]\n // The editor puts the level where `{level}` is.\n return [name, typeof text === 'function' ? text('{level}') : text]\n })\n )\n}\n\n/** @internal */\nexport function injectNbMarkdownEditorTexts() {\n return injectNbTexts('markdownEditor', () => ({\n markdown: $localize`:@@nb.markdownEditor.markdown:Markdown`,\n wysiwyg: $localize`:@@nb.markdownEditor.wysiwyg:WYSIWYG`,\n write: $localize`:@@nb.markdownEditor.write:Write`,\n preview: $localize`:@@nb.markdownEditor.preview:Preview`,\n headings: $localize`:@@nb.markdownEditor.headings:Headings`,\n headingLevel: (level: string) => $localize`:@@nb.markdownEditor.headingLevel:Heading ${level}:level:`,\n paragraph: $localize`:@@nb.markdownEditor.paragraph:Paragraph`,\n bold: $localize`:@@nb.markdownEditor.bold:Bold`,\n italic: $localize`:@@nb.markdownEditor.italic:Italic`,\n strike: $localize`:@@nb.markdownEditor.strike:Strikethrough`,\n code: $localize`:@@nb.markdownEditor.code:Inline code`,\n line: $localize`:@@nb.markdownEditor.line:Horizontal line`,\n blockquote: $localize`:@@nb.markdownEditor.blockquote:Blockquote`,\n unorderedList: $localize`:@@nb.markdownEditor.unorderedList:Unordered list`,\n orderedList: $localize`:@@nb.markdownEditor.orderedList:Ordered list`,\n task: $localize`:@@nb.markdownEditor.task:Task list`,\n indent: $localize`:@@nb.markdownEditor.indent:Indent`,\n outdent: $localize`:@@nb.markdownEditor.outdent:Outdent`,\n insertLink: $localize`:@@nb.markdownEditor.insertLink:Insert link`,\n insertCodeBlock: $localize`:@@nb.markdownEditor.insertCodeBlock:Insert code block`,\n insertTable: $localize`:@@nb.markdownEditor.insertTable:Insert table`,\n insertImage: $localize`:@@nb.markdownEditor.insertImage:Insert image`,\n format: $localize`:@@nb.markdownEditor.format:Format (Shift+Alt+F)`,\n more: $localize`:@@nb.markdownEditor.more:More`,\n textFormatting: $localize`:@@nb.markdownEditor.textFormatting:Text formatting`,\n activeButton: $localize`:@@nb.markdownEditor.activeButton:Active`,\n autoScrollEnabled: $localize`:@@nb.markdownEditor.autoScrollEnabled:Auto scroll enabled`,\n autoScrollDisabled: $localize`:@@nb.markdownEditor.autoScrollDisabled:Auto scroll disabled`,\n\n imageUrl: $localize`:@@nb.markdownEditor.imageUrl:Image URL`,\n selectImageFile: $localize`:@@nb.markdownEditor.selectImageFile:Select image file`,\n chooseFile: $localize`:@@nb.markdownEditor.chooseFile:Choose a file`,\n noFile: $localize`:@@nb.markdownEditor.noFile:No file`,\n description: $localize`:@@nb.markdownEditor.description:Description`,\n file: $localize`:@@nb.markdownEditor.file:File`,\n url: $localize`:@@nb.markdownEditor.url:URL`,\n linkText: $localize`:@@nb.markdownEditor.linkText:Link text`,\n linkTextRequired: $localize`:@@nb.markdownEditor.linkTextRequired:The field \"Link text\" is required`,\n urlRequired: $localize`:@@nb.markdownEditor.urlRequired:The field \"URL\" is required`,\n ok: $localize`:@@nb.markdownEditor.ok:OK`,\n cancel: $localize`:@@nb.markdownEditor.cancel:Cancel`,\n edit: $localize`:@@nb.markdownEditor.edit:Edit`,\n editLink: $localize`:@@nb.markdownEditor.editLink:Edit link`,\n removeLink: $localize`:@@nb.markdownEditor.removeLink:Remove link`,\n editImage: $localize`:@@nb.markdownEditor.editImage:Edit image`,\n removeImage: $localize`:@@nb.markdownEditor.removeImage:Remove image`,\n pasteAsTable: $localize`:@@nb.markdownEditor.pasteAsTable:Paste as a table?`,\n textColor: $localize`:@@nb.markdownEditor.textColor:Text color`,\n chooseLanguage: $localize`:@@nb.markdownEditor.chooseLanguage:Choose language`,\n\n addRowAbove: $localize`:@@nb.markdownEditor.addRowAbove:Add row above`,\n addRowBelow: $localize`:@@nb.markdownEditor.addRowBelow:Add row below`,\n addColumnLeft: $localize`:@@nb.markdownEditor.addColumnLeft:Add column left`,\n addColumnRight: $localize`:@@nb.markdownEditor.addColumnRight:Add column right`,\n removeRow: $localize`:@@nb.markdownEditor.removeRow:Remove row`,\n removeColumn: $localize`:@@nb.markdownEditor.removeColumn:Remove column`,\n alignColumnLeft: $localize`:@@nb.markdownEditor.alignColumnLeft:Align column left`,\n alignColumnCenter: $localize`:@@nb.markdownEditor.alignColumnCenter:Align column center`,\n alignColumnRight: $localize`:@@nb.markdownEditor.alignColumnRight:Align column right`,\n removeTable: $localize`:@@nb.markdownEditor.removeTable:Remove table`\n }))\n}\n","import { isPlatformBrowser } from '@angular/common'\nimport {\n afterRenderEffect,\n booleanAttribute,\n Component,\n computed,\n DestroyRef,\n ElementRef,\n forwardRef,\n inject,\n input,\n linkedSignal,\n model,\n PLATFORM_ID,\n signal,\n untracked,\n viewChild,\n ViewEncapsulation\n} from '@angular/core'\nimport { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'\nimport {\n injectNbDefaults,\n NbComponentOrCustomStatus,\n NbComponentShape,\n NbIconConfig,\n NbIconLibraries,\n NbValidationDirective\n} from '@liquid-js/lyr-core'\nimport type {\n Editor,\n EditorOptions,\n EditorPlugin,\n EditorType,\n IconName,\n PreviewStyle,\n ToolbarItemOptions\n} from '@liquid-js/underflow'\nimport type { HLJSApi } from 'highlight.js'\nimport { HighlightLoader, NXT_HIGHLIGHT_OPTIONS } from 'nxt-highlightjs'\nimport { nbFormatMarkdown } from './format'\nimport { injectNbMarkdownEditorTexts, nbMarkdownEditorLanguage, NbMarkdownEditorTexts } from './texts'\n\n/** Options of `@liquid-js/underflow`'s editor that the component's inputs don't set. */\nexport type NbMarkdownEditorOptions = Omit<\n EditorOptions,\n | 'el'\n | 'initialValue'\n | 'initialEditType'\n | 'height'\n | 'minHeight'\n | 'previewStyle'\n | 'placeholder'\n | 'toolbarItems'\n | 'hideModeSwitch'\n | 'toolbarStyle'\n | 'language'\n | 'theme'\n | 'autofocus'\n | 'viewer'\n | 'readonly'\n | 'disabled'\n | 'autoDirection'\n>\n\n/** Groups of toolbar items: the names of the editor's items, e.g. `bold`, `format`, or items of your own. */\nexport type NbMarkdownEditorToolbar = Array<Array<string | ToolbarItemOptions>>\n\n/** What the editor is made with. */\ninterface Setup {\n texts: NbMarkdownEditorTexts\n toolbarItems?: NbMarkdownEditorToolbar\n hideModeSwitch: boolean\n autoDirection: boolean\n options: NbMarkdownEditorOptions\n /** Highlights code, once it's loaded. */\n highlighter?: HLJSApi\n}\n\n/**\n * The editor's icons, by UnderFlow's names: Lyra's, from the `essentials` pack, written out whole so the pack has them.\n * Every name is here, so a name UnderFlow adds doesn't compile until it has one of Lyra's.\n */\nconst ICONS: Record<IconName, NbIconConfig> = {\n 'heading': { icon: 'heading-outline', pack: 'essentials' },\n 'bold': { icon: 'bold-outline', pack: 'essentials' },\n 'italic': { icon: 'italic-outline', pack: 'essentials' },\n 'strike': { icon: 'strikethrough-outline', pack: 'essentials' },\n 'hrline': { icon: 'minus-outline', pack: 'essentials' },\n 'quote': { icon: 'quote-outline', pack: 'essentials' },\n 'bullet-list': { icon: 'list-outline', pack: 'essentials' },\n 'ordered-list': { icon: 'list-numbered-outline', pack: 'essentials' },\n 'task-list': { icon: 'list-checked-outline', pack: 'essentials' },\n 'indent': { icon: 'indent-outline', pack: 'essentials' },\n 'outdent': { icon: 'outdent-outline', pack: 'essentials' },\n 'table': { icon: 'table-outline', pack: 'essentials' },\n 'image': { icon: 'image-outline', pack: 'essentials' },\n 'link': { icon: 'link-outline', pack: 'essentials' },\n 'code': { icon: 'code-outline', pack: 'essentials' },\n 'codeblock': { icon: 'code-block-outline', pack: 'essentials' },\n 'more': { icon: 'more-horizontal-outline', pack: 'essentials' },\n 'add-row-up': { icon: 'table-row-add-above-outline', pack: 'essentials' },\n 'add-row-down': { icon: 'table-row-add-below-outline', pack: 'essentials' },\n 'add-column-left': { icon: 'table-column-add-left-outline', pack: 'essentials' },\n 'add-column-right': { icon: 'table-column-add-right-outline', pack: 'essentials' },\n 'remove-row': { icon: 'table-row-remove-outline', pack: 'essentials' },\n 'remove-column': { icon: 'table-column-remove-outline', pack: 'essentials' },\n 'align-column-left': { icon: 'align-left-outline', pack: 'essentials' },\n 'align-column-center': { icon: 'align-center-outline', pack: 'essentials' },\n 'align-column-right': { icon: 'align-right-outline', pack: 'essentials' },\n 'remove-table': { icon: 'table-remove-outline', pack: 'essentials' },\n 'chevron-down': { icon: 'chevron-down-outline', pack: 'essentials' },\n 'pencil': { icon: 'edit-outline', pack: 'essentials' }\n}\n\n/** The Format button's icon. */\nconst FORMAT_ICON: NbIconConfig = { icon: 'brush-outline', pack: 'essentials' }\n\n/** The command the Format button runs, in either mode. */\nconst FORMAT_COMMAND = 'nbFormat'\n\n/** UnderFlow's toolbar, with the Format button before the scroll sync switch. */\nconst TOOLBAR: NbMarkdownEditorToolbar = [\n ['heading', 'bold', 'italic', 'strike'],\n ['hr', 'quote'],\n ['ul', 'ol', 'task', 'indent', 'outdent'],\n ['table', 'image', 'link'],\n ['code', 'codeblock'],\n ['format'],\n ['scrollSync']\n]\n\n/** The checkmark of the scroll sync switch, which looks like Lyra's toggle. */\nconst SWITCH_CHECKMARK: NbIconConfig = { icon: 'checkmark-bold-outline', pack: 'essentials' }\n\n// The editor's texts are registered by language code for all editors, so editors with the same texts share a code.\nconst languages = new Map<string, string>()\n\nfunction languageCode(library: typeof Editor, texts: NbMarkdownEditorTexts) {\n const language = nbMarkdownEditorLanguage(texts)\n const key = JSON.stringify(language)\n let code = languages.get(key)\n if (!code) {\n code = `x-nb-markdown-${languages.size}`\n languages.set(key, code)\n library.setLanguage(code, language)\n }\n return code\n}\n\n/**\n * A markdown editor, with a toolbar, a preview and a WYSIWYG mode:\n *\n * ```html\n * <nb-markdown-editor [formControl]=\"text\" aria-label=\"Description\" />\n * ```\n *\n * @stacked-example(Showcase, markdown/markdown-editor-showcase.component)\n *\n * ### Installation\n *\n * Install [`@liquid-js/underflow`](https://www.npmjs.com/package/@liquid-js/underflow), which is the editor, with the\n * ProseMirror and DOMPurify packages it uses, and import `NbMarkdownEditorComponent` from\n * `@liquid-js/lyr-extras/markdown-editor`:\n *\n * ```bash\n * npm install @liquid-js/underflow prosemirror-commands prosemirror-history prosemirror-inputrules \\\n * prosemirror-keymap prosemirror-model prosemirror-state prosemirror-transform prosemirror-view dompurify\n * ```\n *\n * The Format button formats with [`remark`](https://remark.js.org), which it loads when it's first used, with\n * `remark-gfm` and `remark-frontmatter`:\n *\n * ```bash\n * npm install remark remark-gfm remark-frontmatter\n * ```\n *\n * The editor loads when the first one shows; its styles come with the component. It highlights code with the\n * highlight.js that [`nxt-highlightjs`](https://www.npmjs.com/package/nxt-highlightjs) loads, when the app sets it up\n * as in `nb-markdown-viewer`, so install them too:\n *\n * ```bash\n * npm install nxt-highlightjs highlight.js\n * ```\n *\n * ### Usage\n *\n * It's a form control whose value is the markdown, CommonMark with GitHub's extensions, e.g. tables and task lists.\n * Its frame has the colours of a field and its `status`, and the text the theme's styles:\n * @stacked-example(States, markdown/markdown-editor-status.component)\n *\n * The preview shows the text's straight quotes, `--`, `---` and `...` as typographic quotes, en and em dashes and\n * ellipses, as `nb-markdown-viewer` does, while the markdown and the WYSIWYG mode keep them as written.\n *\n * In the markdown mode the preview is a tab, or next to the markdown with `previewStyle=\"vertical\"`; the WYSIWYG mode\n * edits the formatted text, and `mode` is the one that shows. The toolbar wraps onto more lines when it doesn't fit,\n * so all of its buttons can be reached with Tab; `toolbarItems` picks them.\n *\n * The Format button, and Shift+Alt+F in the text, writes the markdown in one style with `nbFormatMarkdown`, which\n * also writes typographic quotes, dashes and ellipses as plain characters; Undo brings the text back. It's `format` in\n * `toolbarItems`.\n *\n * In the text, Tab indents list items and moves between table cells, so Escape and then Tab or Shift+Tab moves focus\n * out of it, as in code editors. Name the text with `aria-label`, `aria-labelledby` for a `label`, or an `nbLabel` with\n * `nbValidation`, which also gives it the field's status and errors, as it does an input.\n *\n * With `readonly` the text can be read, selected and copied, but not changed, as in a read-only field: the toolbar\n * and the mode switch are disabled, while the Write and Preview tabs still switch. Disabled, the editor is read-only\n * too, in the colours of a disabled field, and Tab skips it.\n *\n * Text that mixes right-to-left and left-to-right languages, e.g. Arabic or Hebrew quoted in English, reads right\n * with `autoDirection`: each paragraph, heading, list, quote and table takes the direction of its own text, as\n * `dir=\"auto\"` does, in the preview and the WYSIWYG mode, and so does each line of the markdown. Code blocks read left\n * to right. The markdown itself doesn't change.\n *\n * `options` takes the [editor's other options](https://liquid-js.github.io/underflow/docs/), e.g. plugins, widgets\n * or `hooks.addImageBlobHook` to upload pasted images, and `editor()` is the editor, for its methods. It's made again\n * when the options, the toolbar, the texts or `autoDirection` change, keeping the markdown.\n */\n@Component({\n selector: 'nb-markdown-editor',\n template: '<div #container></div>',\n styleUrl: './markdown-editor.component.scss',\n encapsulation: ViewEncapsulation.None,\n providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => NbMarkdownEditorComponent), multi: true }],\n host: {\n 'class': 'nb-markdown',\n '(keydown)': 'onKeydown($event)',\n '[attr.aria-disabled]': 'isDisabled() || null',\n '[style]': 'statusStyles()',\n // Keeps the editor's place until it loads.\n '[style.min-height]': \"editor() ? null : height() === 'auto' ? minHeight() : height()\"\n }\n})\nexport class NbMarkdownEditorComponent implements ControlValueAccessor {\n protected readonly texts = injectNbMarkdownEditorTexts()\n protected readonly iconLibraries = inject(NbIconLibraries)\n\n /** The editor's height with the toolbar, e.g. `300px` (default) or `auto`, which grows with the text. */\n readonly height = input('300px')\n /** `200px` by default. */\n readonly minHeight = input('200px')\n /** The preview in a `tab` (default), or `vertical`, next to the markdown. */\n readonly previewStyle = input<PreviewStyle>('tab')\n /** `markdown` (default) or `wysiwyg`, and the mode the user picks. */\n readonly mode = model<EditorType>('markdown')\n readonly placeholder = input('')\n /** Field status: `basic` (default), `primary`, `info`, `success`, `warning`, `danger` or `control`. */\n readonly status = input<NbComponentOrCustomStatus>('basic')\n\n // The app's defaults for fields, which the shape starts from, as a textarea's does.\n protected readonly nbDefaults = injectNbDefaults('input')\n /** Field shape: `rectangle` (default), `semi-round` or `round`, only as round as a textarea gets. */\n readonly shapeInput = input<NbComponentShape | undefined>(undefined, { alias: 'shape' })\n /** The shape in use: the input's, the app's default, or 'rectangle'. */\n readonly shape = linkedSignal<NbComponentShape>(() => this.shapeInput() ?? this.nbDefaults().shape ?? 'rectangle')\n /** Groups of toolbar items, e.g. `[['heading', 'bold', 'italic'], ['link']]`. */\n readonly toolbarItems = input<NbMarkdownEditorToolbar>()\n /** Hides the Markdown and WYSIWYG tabs. */\n readonly hideModeSwitch = input(false, { transform: booleanAttribute })\n /**\n * Gives each paragraph, heading, list, quote and table the direction of its own text (`dir=\"auto\"`), for text in\n * more than one direction; `false` by default.\n */\n readonly autoDirection = input(false, { transform: booleanAttribute })\n /** Options of `@liquid-js/underflow`'s editor, e.g. plugins. */\n readonly options = input<NbMarkdownEditorOptions>({})\n /** Names the text area when there's no `aria-labelledby`. */\n readonly ariaLabel = input<string | undefined>(undefined, { alias: 'aria-label' })\n /** The id of the element that names the text area, e.g. a `label`. */\n readonly ariaLabelledBy = input<string | undefined>(undefined, { alias: 'aria-labelledby' })\n readonly disabled = input(false, { transform: booleanAttribute })\n /** Lets the user read the text, but not change it. */\n readonly readonly = input(false, { transform: booleanAttribute })\n\n /** The editor, once it's loaded. */\n readonly editor = signal<Editor | undefined>(undefined)\n\n protected readonly validation = inject(NbValidationDirective, { self: true, optional: true })\n // With `nbValidation`, the status it gives while the control shows errors or success.\n protected readonly resolvedStatus = computed(() => this.validation?.status() ?? this.status())\n\n protected readonly value = signal('')\n protected readonly isDisabled = linkedSignal(() => this.disabled())\n protected readonly container = viewChild.required<ElementRef<HTMLElement>>('container')\n /** Loads highlight.js, when the app highlights code. */\n protected readonly highlightLoader = inject(NXT_HIGHLIGHT_OPTIONS, { optional: true })\n ? inject(HighlightLoader)\n : undefined\n\n protected readonly statusStyles = computed(() => {\n const status = this.resolvedStatus()\n const shape = this.shape()\n return {\n '--nb-markdown-border-radius': `min(var(--input-${shape}-border-radius), var(--input-textarea-max-border-radius))`,\n '--nb-markdown-field-border-radius': `var(--input-${shape}-border-radius)`,\n // At rest; the styles pick the background by state, which an inline value would override.\n '--nb-markdown-rest-background': `var(--input-${status}-background-color)`,\n '--nb-markdown-border-color': `var(--input-${status}-border-color)`,\n '--nb-markdown-hover-background': `var(--input-${status}-hover-background-color)`,\n '--nb-markdown-hover-border-color': `var(--input-${status}-hover-border-color)`,\n '--nb-markdown-focus-background': `var(--input-${status}-focus-background-color)`,\n '--nb-markdown-focus-border-color': `var(--input-${status}-focus-border-color)`,\n '--nb-markdown-focus-and-hover-background': `var(--input-${status}-focus-and-hover-background-color)`,\n '--nb-markdown-focus-and-hover-border-color': `var(--input-${status}-focus-and-hover-border-color)`,\n '--nb-markdown-disabled-background': `var(--input-${status}-disabled-background-color)`,\n '--nb-markdown-disabled-border-color': `var(--input-${status}-disabled-border-color)`\n }\n })\n\n /** What the editor is made with; it's made again when this changes. */\n protected readonly setup = computed<Setup | undefined>(() => {\n const highlight = this.highlightLoader?.hljs\n // The editor waits for highlight.js rather than being made again when it loads.\n if (highlight?.isLoading()) {\n return undefined\n }\n return {\n texts: this.texts(),\n toolbarItems: this.toolbarItems(),\n hideModeSwitch: this.hideModeSwitch(),\n autoDirection: this.autoDirection(),\n options: this.options(),\n highlighter: highlight?.hasValue() ? highlight.value() : undefined\n }\n })\n\n protected creating = 0\n protected destroyed = false\n /** Set while the form's value is written, which isn't a change to report. */\n protected writing = false\n\n protected onChange: (value: string) => void = () => {}\n /** @internal */\n onTouched: () => void = () => {}\n\n constructor() {\n // The text is the control: it gets the validation's ARIA, and the focus from an `nbLabel`, not the host.\n this.validation?.delegateAria(() => this.editor()?.focus())\n if (!isPlatformBrowser(inject(PLATFORM_ID))) {\n return\n }\n afterRenderEffect(() => {\n const setup = this.setup()\n if (setup) {\n untracked(() => void this.create(setup))\n }\n })\n afterRenderEffect(() => {\n const editor = this.editor()\n const [height, minHeight, previewStyle, placeholder, mode] = [\n this.height(),\n this.minHeight(),\n this.previewStyle(),\n this.placeholder(),\n this.mode()\n ]\n if (!editor) {\n return\n }\n if (editor.getHeight() !== height) {\n editor.setHeight(height)\n }\n if (editor.getMinHeight() !== minHeight) {\n editor.setMinHeight(minHeight)\n }\n if (editor.getCurrentPreviewStyle() !== previewStyle) {\n editor.changePreviewStyle(previewStyle)\n // The vertical preview brings the scroll sync switch.\n this.markSwitch()\n }\n editor.setPlaceholder(placeholder)\n if (editor.isWysiwygMode() !== (mode === 'wysiwyg')) {\n editor.changeMode(mode, true)\n }\n })\n afterRenderEffect(() => {\n const editor = this.editor()\n const [disabled, readonly] = [this.isDisabled(), this.readonly()]\n if (editor) {\n editor.setDisabled(disabled)\n editor.setReadonly(readonly)\n }\n })\n afterRenderEffect(() => {\n const editor = this.editor()\n const validation = this.validation\n const labelledBy = [this.ariaLabelledBy(), validation?.labelledBy()].filter(Boolean).join(' ') || undefined\n const attributes = {\n 'aria-label': labelledBy ? undefined : this.ariaLabel(),\n 'aria-labelledby': labelledBy,\n 'aria-invalid': validation?.ariaInvalid() ?? undefined,\n 'aria-describedby': validation?.describedBy() ?? undefined,\n 'aria-required': validation?.ariaRequired() ?? undefined\n }\n if (editor) {\n this.label(editor, attributes)\n }\n })\n inject(DestroyRef).onDestroy(() => {\n this.destroyed = true\n this.editor()?.destroy()\n })\n }\n\n // Untracked, as forms write values from wherever the app sets them, e.g. an effect that mustn't come to depend\n // on the control.\n writeValue(value?: string | null) {\n untracked(() => {\n const markdown = value ?? ''\n this.value.set(markdown)\n const editor = this.editor()\n if (editor && editor.getMarkdown() !== markdown) {\n this.writing = true\n try {\n editor.setMarkdown(markdown, false, false)\n } finally {\n this.writing = false\n }\n }\n })\n }\n\n registerOnChange(fn: (value: string) => void) {\n this.onChange = fn\n }\n\n registerOnTouched(fn: () => void) {\n this.onTouched = fn\n }\n\n setDisabledState(disabled: boolean) {\n this.isDisabled.set(disabled)\n }\n\n /** Moves focus to the text. */\n focus() {\n this.editor()?.focus()\n }\n\n protected async create(setup: Setup) {\n const creating = ++this.creating\n const [{ Editor }, highlight] = await Promise.all([\n import('@liquid-js/underflow'),\n setup.highlighter ? import('@liquid-js/underflow/plugins/code-syntax-highlight') : undefined\n ])\n if (creating !== this.creating || this.destroyed) {\n return\n }\n const plugins: EditorPlugin[] = [...(setup.options.plugins ?? [])]\n if (highlight && setup.highlighter) {\n plugins.push([highlight.codeSyntaxHighlightPlugin, { highlighter: setup.highlighter }])\n }\n\n const previous = this.editor()\n previous?.destroy()\n Editor.setIcons(this.icons())\n const editor = new Editor({\n // The preview shows quotes, dashes and ellipses as nb-markdown-viewer does.\n smartPunctuation: true,\n ...setup.options,\n plugins,\n el: this.container().nativeElement,\n initialValue: this.value(),\n initialEditType: this.mode(),\n height: this.height(),\n minHeight: this.minHeight(),\n previewStyle: this.previewStyle(),\n placeholder: this.placeholder(),\n language: languageCode(Editor, setup.texts),\n autofocus: false,\n disabled: this.isDisabled(),\n readonly: this.readonly(),\n // Every button stays in the toolbar, where Tab reaches it, instead of a menu that opens on hover.\n toolbarStyle: 'wrap',\n toolbarItems: this.toolbar(setup),\n hideModeSwitch: setup.hideModeSwitch,\n autoDirection: setup.autoDirection\n })\n editor.on('change', () => this.changed(editor))\n editor.on('blur', () => this.onTouched())\n editor.on('changeMode', (mode: EditorType) => this.mode.set(mode))\n for (const type of ['markdown', 'wysiwyg'] as const) {\n editor.addCommand(type, FORMAT_COMMAND, () => {\n void this.format(editor)\n return true\n })\n }\n this.markSwitch()\n this.editor.set(editor)\n }\n\n /** The toolbar's groups, with the Format button for `format`. */\n protected toolbar(setup: Setup): NbMarkdownEditorToolbar {\n const button = {\n name: 'format',\n // UnderFlow's class for a toolbar button with an icon, which its own buttons have.\n className: 'nb-markdown-format uf-toolbar-icons',\n tooltip: setup.texts.format,\n icon: this.iconLibraries.getSvgIcon(FORMAT_ICON.icon, FORMAT_ICON.pack)?.icon.getContent(),\n command: FORMAT_COMMAND\n }\n return (setup.toolbarItems ?? TOOLBAR).map((group) => group.map((item) => (item === 'format' ? button : item)))\n }\n\n /** Formats the markdown, with Shift+Alt+F too, unless the user can't change it. */\n protected onKeydown(event: KeyboardEvent) {\n const editor = this.editor()\n if (event.code === 'KeyF' && event.shiftKey && event.altKey && !event.ctrlKey && !event.metaKey && editor) {\n // The key would type a character, e.g. Ï on a Mac.\n event.preventDefault()\n void this.format(editor)\n }\n }\n\n /**\n * Writes the markdown in one style, as an edit Undo takes back, keeping the cursor's line; the text stays if the\n * user changes it while the formatter loads.\n */\n protected async format(editor: Editor) {\n if (editor.isReadonly() || editor.isDisabled()) {\n return\n }\n const markdown = editor.getMarkdown()\n const formatted = await nbFormatMarkdown(markdown)\n if (formatted === markdown || editor !== this.editor() || editor.getMarkdown() !== markdown) {\n return\n }\n const line = editor.getCursorLine()\n editor.setMarkdown(formatted, false, false)\n editor.moveCursorTo(Math.min(line, formatted.split('\\n').length), true)\n }\n\n protected changed(editor: Editor) {\n const markdown = editor.getMarkdown()\n if (markdown === this.value()) {\n return\n }\n this.value.set(markdown)\n if (!this.writing) {\n this.onChange(markdown)\n }\n }\n\n /**\n * The editor's icons as the `essentials` pack has them, so an app that replaces one there replaces it here too; one\n * the pack doesn't have keeps UnderFlow's own.\n */\n protected icons(): Partial<Record<IconName, string>> {\n return Object.fromEntries(\n Object.entries(ICONS).map(([name, { icon, pack }]) => [\n name,\n this.iconLibraries.getSvgIcon(icon, pack)?.icon.getContent() || undefined\n ])\n )\n }\n\n /** Gives the scroll sync switch the checkmark of Lyra's toggle, which shows when it's on. */\n protected markSwitch() {\n const toggle = this.container().nativeElement.querySelector('.scroll-sync .switch')\n if (!toggle || toggle.querySelector('.nb-markdown-switch-checkmark')) {\n return\n }\n const checkmark = toggle.ownerDocument.createElement('span')\n checkmark.className = 'nb-markdown-switch-checkmark'\n checkmark.setAttribute('aria-hidden', 'true')\n checkmark.innerHTML =\n this.iconLibraries.getSvgIcon(SWITCH_CHECKMARK.icon, SWITCH_CHECKMARK.pack)?.icon.getContent() ?? ''\n toggle.append(checkmark)\n }\n\n /** Names the texts, the markdown and the WYSIWYG one, leaving out the attributes without a value. */\n protected label(editor: Editor, attributes: Record<string, string | undefined>) {\n const { mdEditor, wwEditor } = editor.getEditorElements()\n for (const text of [mdEditor, wwEditor].map((element) => element.querySelector('.ProseMirror'))) {\n for (const [name, value] of Object.entries(attributes)) {\n if (value) {\n text?.setAttribute(name, value)\n } else {\n text?.removeAttribute(name)\n }\n }\n }\n }\n}\n"],"mappings":";;;;;;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;GAAA,CAAA;EAAA,CAAA;EAAA,WAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,aAAW,EAAA,UAAA,KAAA,CAAA;EAAA,CAAA;CAAA;AAAA,CAAA"}
|
|
@@ -69,10 +69,12 @@ var NbMaskDirective = class NbMaskDirective {
|
|
|
69
69
|
inject(DestroyRef).onDestroy(() => this.maskInput?.destroy());
|
|
70
70
|
}
|
|
71
71
|
writeValue(value) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
untracked(() => {
|
|
73
|
+
const text = String(value ?? "");
|
|
74
|
+
this.value = text;
|
|
75
|
+
this.show(text);
|
|
76
|
+
this.setParseError(false);
|
|
77
|
+
});
|
|
76
78
|
}
|
|
77
79
|
registerOnChange(fn) {
|
|
78
80
|
this.onChange = fn;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"liquid-js-lyr-extras-mask.mjs","names":[],"sources":["../../../packages/extras/mask/src/texts.ts","../../../packages/extras/mask/src/mask.directive.ts"],"sourcesContent":["import { injectNbTexts, NbLocalize } from '@liquid-js/lyr-core'\n\n/** @internal */\ndeclare const $localize: NbLocalize\n\n/**\n * The texts of masked fields. `provideNbTexts({ mask: { ... } })` changes them, and they're translated with Angular's\n * i18n, as `$localize` messages with ids like `@@nb.mask.incomplete`.\n */\nexport interface NbMaskTexts {\n /** The message of the `nbMask` error for a value that doesn't fill the mask. */\n incomplete: string\n}\n\ndeclare module '@liquid-js/lyr-core' {\n interface NbTexts {\n mask: NbMaskTexts\n }\n}\n\n/** @internal */\nexport function injectNbMaskTexts() {\n return injectNbTexts('mask', () => ({\n incomplete: $localize`:@@nb.mask.incomplete:Complete the value`\n }))\n}\n","import {\n computed,\n DestroyRef,\n Directive,\n effect,\n ElementRef,\n forwardRef,\n inject,\n input,\n PLATFORM_ID,\n signal,\n untracked\n} from '@angular/core'\nimport { isPlatformBrowser } from '@angular/common'\nimport {\n ControlValueAccessor,\n NG_VALIDATORS,\n NG_VALUE_ACCESSOR,\n ValidationErrors,\n Validator\n} from '@angular/forms'\nimport { injectNbValidationMessage } from '@liquid-js/lyr-core'\nimport { Mask, MaskaDetail, MaskInput, MaskInputOptions, MaskType } from 'maska'\n\nimport { injectNbMaskTexts } from './texts'\n\n/** The form value of a masked field: the characters typed (`unmasked`, default), or the text as shown (`masked`). */\nexport type NbMaskValue = 'unmasked' | 'masked'\n\n/** The error kind of a value that doesn't fill the mask. */\nexport const NB_MASK_ERROR = 'nbMask' as const\n\n/** The `nbMask` error, as Angular gives parse errors: its kind and its message. */\nexport interface NbMaskError {\n kind: typeof NB_MASK_ERROR\n message: string\n}\n\n/** maska's options besides the mask: `tokens`, `eager`, `reversed`, `number`, `preProcess` and `postProcess`. */\nexport type NbMaskOptions = Omit<MaskInputOptions, 'mask' | 'onMaska'>\n\n/**\n * Formats what the user types in a field with a mask, e.g. a phone number or a card number:\n *\n * ```html\n * <input nbInput type=\"tel\" [nbMask]=\"'(###) ###-####'\" formControlName=\"phone\" />\n * ```\n *\n * @stacked-example(Showcase, mask/mask-showcase.component)\n *\n * ### Installation\n *\n * It formats with [`maska`](https://www.npmjs.com/package/maska); install it and import `NbMaskDirective` from\n * `@liquid-js/lyr-extras/mask`.\n *\n * ```sh\n * npm install maska\n * ```\n *\n * ### Usage\n *\n * In the mask, `#` is a digit, `@` a letter and `*` either; other characters are shown as they are. A list of masks\n * picks the one that fits the length of what's typed, e.g. `['#### ####', '#### #### ####']`, and a function gives\n * the mask for what's typed. `nbMaskOptions` takes maska's other options, e.g. `eager` to show the mask's next\n * characters before they're typed, `tokens` of your own, or `number` for numbers in the app's format.\n *\n * The form value is what the user typed, without the mask's characters, e.g. `2015550123`, or with\n * `nbMaskValue=\"masked\"`, the text as shown, `(201) 555-0123`. While the text doesn't fill the mask, the value stays\n * the last complete one, or empty, and the field has the `nbMask` parse error, `{ kind, message }`, as Angular's\n * controls report text they can't parse; an empty field passes. It works with `formControl`, `formControlName`,\n * `ngModel` and signal forms' `[formField]`.\n * @stacked-example(Validation, mask/mask-validation.component)\n *\n * It works on text, search, URL, phone and password inputs.\n */\n@Directive({\n selector: 'input[nbMask]',\n exportAs: 'nbMask',\n providers: [\n { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => NbMaskDirective), multi: true },\n { provide: NG_VALIDATORS, useExisting: forwardRef(() => NbMaskDirective), multi: true }\n ],\n host: {\n '(blur)': 'onTouched()'\n }\n})\nexport class NbMaskDirective implements ControlValueAccessor, Validator {\n protected readonly texts = injectNbMaskTexts()\n /** The message of an error, as `nb-validation-errors` shows it. */\n protected readonly message = injectNbValidationMessage()\n protected readonly element = inject<ElementRef<HTMLInputElement>>(ElementRef).nativeElement\n\n /** The mask, e.g. `(###) ###-####`, a list of masks, or a function that gives the mask for what's typed. */\n readonly mask = input.required<MaskType>({ alias: 'nbMask' })\n /** maska's other options, e.g. `{ eager: true }`. */\n readonly options = input<NbMaskOptions>({}, { alias: 'nbMaskOptions' })\n /** The form value: `unmasked` (default), what was typed, or `masked`, the text as shown. */\n readonly valueType = input<NbMaskValue>('unmasked', { alias: 'nbMaskValue' })\n\n /** Whether the text fills the mask. */\n readonly completed = signal(false)\n /** Whether the text doesn't fill the mask, which the form gets as a parse error. */\n protected readonly parseError = signal(false)\n\n /** Formats values the way the field does. */\n protected readonly formatter = computed(() => {\n const { preProcess, postProcess, ...options } = this.options()\n const mask = new Mask({ ...options, mask: this.mask() })\n return {\n mask,\n masked: (value: string) => {\n const text = mask.masked(preProcess ? preProcess(value) : value)\n return postProcess ? postProcess(text) : text\n },\n unmasked: (value: string) => mask.unmasked(preProcess ? preProcess(value) : value),\n // A number, or no mask, has no length to fill.\n completed: (value: string) =>\n options.number || this.mask() === null ? true : mask.completed(preProcess ? preProcess(value) : value)\n }\n })\n\n protected maskInput?: MaskInput\n /** The value last given to the form. */\n protected value = ''\n\n protected onChange: (value: string) => void = () => {}\n /** @internal */\n onTouched: () => void = () => {}\n protected onValidatorChange: () => void = () => {}\n\n constructor() {\n const browser = isPlatformBrowser(inject(PLATFORM_ID))\n let started = false\n effect(() => {\n const options: MaskInputOptions = {\n ...this.options(),\n mask: this.mask(),\n onMaska: (detail) => this.changed(detail)\n }\n // Read for the mask's options, which change what the value is.\n this.valueType()\n untracked(() => {\n if (browser) {\n if (this.maskInput) {\n this.maskInput.update(options)\n } else {\n this.maskInput = new MaskInput(this.element, options)\n }\n }\n this.show(this.value)\n // A new mask or kind of value changes the value, which the first run only shows.\n if (started) {\n this.take(this.element.value)\n }\n started = true\n })\n })\n inject(DestroyRef).onDestroy(() => this.maskInput?.destroy())\n }\n\n writeValue(value?: string | number | null) {\n const text = String(value ?? '')\n this.value = text\n this.show(text)\n this.setParseError(false)\n }\n\n registerOnChange(fn: (value: string) => void) {\n this.onChange = fn\n }\n\n registerOnTouched(fn: () => void) {\n this.onTouched = fn\n }\n\n registerOnValidatorChange(fn: () => void) {\n this.onValidatorChange = fn\n }\n\n setDisabledState(disabled: boolean) {\n this.element.disabled = disabled\n }\n\n /** The parse error of text that doesn't fill the mask. */\n validate(): ValidationErrors | null {\n if (!this.parseError()) {\n return null\n }\n // The app's message for the kind, or the mask's text.\n const error: NbMaskError = { kind: NB_MASK_ERROR, message: this.texts().incomplete }\n return { [NB_MASK_ERROR]: { ...error, message: this.message({ kind: NB_MASK_ERROR, params: error }) } }\n }\n\n /** Shows a form value in the field, formatted. */\n protected show(value: string) {\n const formatter = this.formatter()\n const masked = value ? formatter.masked(value) : ''\n this.element.value = masked\n this.completed.set(!!masked && formatter.completed(masked))\n }\n\n protected changed(detail: MaskaDetail) {\n this.take(detail.masked)\n }\n\n /**\n * Gives the form the value of the text in the field, when it's another; while the text doesn't fill the mask, the\n * value stays and the field has the parse error.\n */\n protected take(masked: string) {\n const formatter = this.formatter()\n const unmasked = formatter.unmasked(masked)\n const completed = !!unmasked && formatter.completed(masked)\n this.completed.set(completed)\n this.setParseError(!!unmasked && !completed)\n if (unmasked && !completed) {\n return\n }\n const value = !unmasked ? '' : this.valueType() === 'masked' ? masked : unmasked\n if (value !== this.value) {\n this.value = value\n this.onChange(value)\n }\n }\n\n protected setParseError(parseError: boolean) {\n if (parseError !== this.parseError()) {\n this.parseError.set(parseError)\n this.onValidatorChange()\n }\n }\n}\n"],"mappings":";;;;;;AAqBA,SAAgB,oBAAiB;CAC7B,OAAO,cAAc,eAAe,EAChC,YAAY,SAAS,2CACxB,EAAC;AACN;ACKA,MAAa,gBAAgB;AAwD7B,IAAa,kBAAb,MAAa,gBAAe;CA4CxB,cAAA;EA3CmB,KAAA,QAAQ,kBAAiB;EAEzB,KAAA,UAAU,0BAAyB;EACnC,KAAA,UAAU,OAAqC,UAAU,CAAC,CAAC;EAGrE,KAAA,OAAO,MAAM,SAAQ;GAAA,GAAA,YAAA,EAAA,WAAA,OAAA,+BAAA,CAAA;GAAa,OAAO;EAAQ,CAAA;EAEjD,KAAA,UAAU,MAAqB,CAAA,GAAE;GAAA,GAAA,YAAA,EAAA,WAAA,UAAA,+BAAA,CAAA;GAAI,OAAO;EAAe,CAAA;EAE3D,KAAA,YAAY,MAAmB,YAAU;GAAA,GAAA,YAAA,EAAA,WAAA,YAAA,+BAAA,CAAA;GAAI,OAAO;EAAa,CAAA;EAGjE,KAAA,YAAY,OAAO,OAAM,GAAA,YAAA,CAAA,EAAA,WAAA,YAAA,CAAA,+BAAA,CAAA,CAAA;EAEf,KAAA,aAAa,OAAO,OAAM,GAAA,YAAA,CAAA,EAAA,WAAA,aAAA,CAAA,+BAAA,CAAA,CAAA;EAG1B,KAAA,YAAY,eAAc;GACzC,MAAM,EAAE,YAAY,aAAa,GAAG,YAAY,KAAK,QAAO;GAC5D,MAAM,OAAO,IAAI,KAAK;IAAE,GAAG;IAAS,MAAM,KAAK,KAAI;GAAE,CAAE;GACvD,OAAO;IACH;IACA,SAAS,UAAiB;KACtB,MAAM,OAAO,KAAK,OAAO,aAAa,WAAW,KAAK,IAAI,KAAK;KAC/D,OAAO,cAAc,YAAY,IA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A;GAAA,QAAA;IAAA,MAAA;KAAA,mBAAA;KAAA,YAAA;KAAA,UAAA;KAAA,YAAA;KAAA,mBAAA;IAAA;IAAA,SAAA;KAAA,mBAAA;KAAA,YAAA;KAAA,UAAA;KAAA,YAAA;KAAA,mBAAA;IAAA;IAAA,WAAA;KAAA,mBAAA;KAAA,YAAA;KAAA,UAAA;KAAA,YAAA;KAAA,mBAAA;IAAA;GAAA;GAAA,MAAA,EAAA,WAAA,EAAA,QAAA,cAAA,EAAA;GAAA,WARb,CACP;IAAE,SAAS;IAAmB,aAAa,iBAAiB,eAAe;IAAG,OAAO;GAAI,GACzF;IAAE,SAAS;IAAe,aAAa,iBAAiB,eAAe;IAAG,OAAO;GAAI,CACxF;GAAA,UAAA,CAAA,QAAA;GAAA,UAAA;EAAA,CAAA;CAAA;;AAKQ,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAe,YAAA,CAAA;EAX3B,MAAA;EAAU,MAAA,CAAA;GACP,UAAU;GACV,UAAU;GACV,WAAW,CACP;IAAE,SAAS;IAAmB,aAAa,iBAAgB,eAAgB;IAAG,OAAO;GAAI,GACzF;IAAE,SAAS;IAAe,aAAa,iBAAgB,eAAgB;IAAG,OAAO;GAAI,CACxF;GACD,MAAM,EACF,UAAU,cACb;EACJ,CAAA"}
|
|
1
|
+
{"version":3,"file":"liquid-js-lyr-extras-mask.mjs","names":[],"sources":["../../../packages/extras/mask/src/texts.ts","../../../packages/extras/mask/src/mask.directive.ts"],"sourcesContent":["import { injectNbTexts, NbLocalize } from '@liquid-js/lyr-core'\n\n/** @internal */\ndeclare const $localize: NbLocalize\n\n/**\n * The texts of masked fields. `provideNbTexts({ mask: { ... } })` changes them, and they're translated with Angular's\n * i18n, as `$localize` messages with ids like `@@nb.mask.incomplete`.\n */\nexport interface NbMaskTexts {\n /** The message of the `nbMask` error for a value that doesn't fill the mask. */\n incomplete: string\n}\n\ndeclare module '@liquid-js/lyr-core' {\n interface NbTexts {\n mask: NbMaskTexts\n }\n}\n\n/** @internal */\nexport function injectNbMaskTexts() {\n return injectNbTexts('mask', () => ({\n incomplete: $localize`:@@nb.mask.incomplete:Complete the value`\n }))\n}\n","import {\n computed,\n DestroyRef,\n Directive,\n effect,\n ElementRef,\n forwardRef,\n inject,\n input,\n PLATFORM_ID,\n signal,\n untracked\n} from '@angular/core'\nimport { isPlatformBrowser } from '@angular/common'\nimport {\n ControlValueAccessor,\n NG_VALIDATORS,\n NG_VALUE_ACCESSOR,\n ValidationErrors,\n Validator\n} from '@angular/forms'\nimport { injectNbValidationMessage } from '@liquid-js/lyr-core'\nimport { Mask, MaskaDetail, MaskInput, MaskInputOptions, MaskType } from 'maska'\n\nimport { injectNbMaskTexts } from './texts'\n\n/** The form value of a masked field: the characters typed (`unmasked`, default), or the text as shown (`masked`). */\nexport type NbMaskValue = 'unmasked' | 'masked'\n\n/** The error kind of a value that doesn't fill the mask. */\nexport const NB_MASK_ERROR = 'nbMask' as const\n\n/** The `nbMask` error, as Angular gives parse errors: its kind and its message. */\nexport interface NbMaskError {\n kind: typeof NB_MASK_ERROR\n message: string\n}\n\n/** maska's options besides the mask: `tokens`, `eager`, `reversed`, `number`, `preProcess` and `postProcess`. */\nexport type NbMaskOptions = Omit<MaskInputOptions, 'mask' | 'onMaska'>\n\n/**\n * Formats what the user types in a field with a mask, e.g. a phone number or a card number:\n *\n * ```html\n * <input nbInput type=\"tel\" [nbMask]=\"'(###) ###-####'\" formControlName=\"phone\" />\n * ```\n *\n * @stacked-example(Showcase, mask/mask-showcase.component)\n *\n * ### Installation\n *\n * It formats with [`maska`](https://www.npmjs.com/package/maska); install it and import `NbMaskDirective` from\n * `@liquid-js/lyr-extras/mask`.\n *\n * ```sh\n * npm install maska\n * ```\n *\n * ### Usage\n *\n * In the mask, `#` is a digit, `@` a letter and `*` either; other characters are shown as they are. A list of masks\n * picks the one that fits the length of what's typed, e.g. `['#### ####', '#### #### ####']`, and a function gives\n * the mask for what's typed. `nbMaskOptions` takes maska's other options, e.g. `eager` to show the mask's next\n * characters before they're typed, `tokens` of your own, or `number` for numbers in the app's format.\n *\n * The form value is what the user typed, without the mask's characters, e.g. `2015550123`, or with\n * `nbMaskValue=\"masked\"`, the text as shown, `(201) 555-0123`. While the text doesn't fill the mask, the value stays\n * the last complete one, or empty, and the field has the `nbMask` parse error, `{ kind, message }`, as Angular's\n * controls report text they can't parse; an empty field passes. It works with `formControl`, `formControlName`,\n * `ngModel` and signal forms' `[formField]`.\n * @stacked-example(Validation, mask/mask-validation.component)\n *\n * It works on text, search, URL, phone and password inputs.\n */\n@Directive({\n selector: 'input[nbMask]',\n exportAs: 'nbMask',\n providers: [\n { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => NbMaskDirective), multi: true },\n { provide: NG_VALIDATORS, useExisting: forwardRef(() => NbMaskDirective), multi: true }\n ],\n host: {\n '(blur)': 'onTouched()'\n }\n})\nexport class NbMaskDirective implements ControlValueAccessor, Validator {\n protected readonly texts = injectNbMaskTexts()\n /** The message of an error, as `nb-validation-errors` shows it. */\n protected readonly message = injectNbValidationMessage()\n protected readonly element = inject<ElementRef<HTMLInputElement>>(ElementRef).nativeElement\n\n /** The mask, e.g. `(###) ###-####`, a list of masks, or a function that gives the mask for what's typed. */\n readonly mask = input.required<MaskType>({ alias: 'nbMask' })\n /** maska's other options, e.g. `{ eager: true }`. */\n readonly options = input<NbMaskOptions>({}, { alias: 'nbMaskOptions' })\n /** The form value: `unmasked` (default), what was typed, or `masked`, the text as shown. */\n readonly valueType = input<NbMaskValue>('unmasked', { alias: 'nbMaskValue' })\n\n /** Whether the text fills the mask. */\n readonly completed = signal(false)\n /** Whether the text doesn't fill the mask, which the form gets as a parse error. */\n protected readonly parseError = signal(false)\n\n /** Formats values the way the field does. */\n protected readonly formatter = computed(() => {\n const { preProcess, postProcess, ...options } = this.options()\n const mask = new Mask({ ...options, mask: this.mask() })\n return {\n mask,\n masked: (value: string) => {\n const text = mask.masked(preProcess ? preProcess(value) : value)\n return postProcess ? postProcess(text) : text\n },\n unmasked: (value: string) => mask.unmasked(preProcess ? preProcess(value) : value),\n // A number, or no mask, has no length to fill.\n completed: (value: string) =>\n options.number || this.mask() === null ? true : mask.completed(preProcess ? preProcess(value) : value)\n }\n })\n\n protected maskInput?: MaskInput\n /** The value last given to the form. */\n protected value = ''\n\n protected onChange: (value: string) => void = () => {}\n /** @internal */\n onTouched: () => void = () => {}\n protected onValidatorChange: () => void = () => {}\n\n constructor() {\n const browser = isPlatformBrowser(inject(PLATFORM_ID))\n let started = false\n effect(() => {\n const options: MaskInputOptions = {\n ...this.options(),\n mask: this.mask(),\n onMaska: (detail) => this.changed(detail)\n }\n // Read for the mask's options, which change what the value is.\n this.valueType()\n untracked(() => {\n if (browser) {\n if (this.maskInput) {\n this.maskInput.update(options)\n } else {\n this.maskInput = new MaskInput(this.element, options)\n }\n }\n this.show(this.value)\n // A new mask or kind of value changes the value, which the first run only shows.\n if (started) {\n this.take(this.element.value)\n }\n started = true\n })\n })\n inject(DestroyRef).onDestroy(() => this.maskInput?.destroy())\n }\n\n // Untracked, as forms write values from wherever the app sets them, e.g. an effect that mustn't come to depend\n // on the control.\n writeValue(value?: string | number | null) {\n untracked(() => {\n const text = String(value ?? '')\n this.value = text\n this.show(text)\n this.setParseError(false)\n })\n }\n\n registerOnChange(fn: (value: string) => void) {\n this.onChange = fn\n }\n\n registerOnTouched(fn: () => void) {\n this.onTouched = fn\n }\n\n registerOnValidatorChange(fn: () => void) {\n this.onValidatorChange = fn\n }\n\n setDisabledState(disabled: boolean) {\n this.element.disabled = disabled\n }\n\n /** The parse error of text that doesn't fill the mask. */\n validate(): ValidationErrors | null {\n if (!this.parseError()) {\n return null\n }\n // The app's message for the kind, or the mask's text.\n const error: NbMaskError = { kind: NB_MASK_ERROR, message: this.texts().incomplete }\n return { [NB_MASK_ERROR]: { ...error, message: this.message({ kind: NB_MASK_ERROR, params: error }) } }\n }\n\n /** Shows a form value in the field, formatted. */\n protected show(value: string) {\n const formatter = this.formatter()\n const masked = value ? formatter.masked(value) : ''\n this.element.value = masked\n this.completed.set(!!masked && formatter.completed(masked))\n }\n\n protected changed(detail: MaskaDetail) {\n this.take(detail.masked)\n }\n\n /**\n * Gives the form the value of the text in the field, when it's another; while the text doesn't fill the mask, the\n * value stays and the field has the parse error.\n */\n protected take(masked: string) {\n const formatter = this.formatter()\n const unmasked = formatter.unmasked(masked)\n const completed = !!unmasked && formatter.completed(masked)\n this.completed.set(completed)\n this.setParseError(!!unmasked && !completed)\n if (unmasked && !completed) {\n return\n }\n const value = !unmasked ? '' : this.valueType() === 'masked' ? masked : unmasked\n if (value !== this.value) {\n this.value = value\n this.onChange(value)\n }\n }\n\n protected setParseError(parseError: boolean) {\n if (parseError !== this.parseError()) {\n this.parseError.set(parseError)\n this.onValidatorChange()\n }\n }\n}\n"],"mappings":";;;;;;AAqBA,SAAgB,oBAAiB;CAC7B,OAAO,cAAc,eAAe,EAChC,YAAY,SAAS,2CACxB,EAAC;AACN;ACKA,MAAa,gBAAgB;AAwD7B,IAAa,kBAAb,MAAa,gBAAe;CA4CxB,cAAA;EA3CmB,KAAA,QAAQ,kBAAiB;EAEzB,KAAA,UAAU,0BAAyB;EACnC,KAAA,UAAU,OAAqC,UAAU,CAAC,CAAC;EAGrE,KAAA,OAAO,MAAM,SAAQ;GAAA,GAAA,YAAA,EAAA,WAAA,OAAA,+BAAA,CAAA;GAAa,OAAO;EAAQ,CAAA;EAEjD,KAAA,UAAU,MAAqB,CAAA,GAAE;GAAA,GAAA,YAAA,EAAA,WAAA,UAAA,+BAAA,CAAA;GAAI,OAAO;EAAe,CAAA;EAE3D,KAAA,YAAY,MAAmB,YAAU;GAAA,GAAA,YAAA,EAAA,WAAA,YAAA,+BAAA,CAAA;GAAI,OAAO;EAAa,CAAA;EAGjE,KAAA,YAAY,OAAO,OAAM,GAAA,YAAA,CAAA,EAAA,WAAA,YAAA,CAAA,+BAAA,CAAA,CAAA;EAEf,KAAA,a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14 @@ var NbPhoneInputComponent = class NbPhoneInputComponent {
|
|
|
232
232
|
if (!this.country()) this.pickCountry(localeCountry(this.locale));
|
|
233
233
|
}
|
|
234
234
|
writeValue(value) {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
235
|
+
untracked(() => {
|
|
236
|
+
const text = value ?? "";
|
|
237
|
+
const number = this.parse(text);
|
|
238
|
+
this.pickCountry(number?.country);
|
|
239
|
+
this.text.set(number ? this.display(number) : text);
|
|
240
|
+
this.value = value ?? null;
|
|
241
|
+
this.setParseError(false);
|
|
242
|
+
});
|
|
241
243
|
}
|
|
242
244
|
registerOnChange(fn) {
|
|
243
245
|
this.onChange = fn;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"liquid-js-lyr-extras-phone-input.mjs","names":["allCountries"],"sources":["../../../packages/extras/phone-input/src/country-names.ts","../../../packages/extras/phone-input/src/texts.ts","../../../packages/extras/phone-input/src/phone-number.validator.ts","../../../packages/extras/phone-input/src/phone-input.component.ts","../../../packages/extras/phone-input/src/phone-input.component.html","../../../packages/extras/phone-input/src/phone-number.directive.ts"],"sourcesContent":["import { InjectionToken, Provider } from '@angular/core'\n\n/**\n * Country names in a language, as the language files of\n * [`i18n-iso-countries`](https://www.npmjs.com/package/i18n-iso-countries) have them, e.g. its `langs/de.json`: the\n * language and the names by ISO 3166-1 code, each a name or a list of names, the first of which is shown.\n */\nexport interface NbCountryNames {\n locale: string\n countries: Record<string, string | string[]>\n}\n\n/** Country names, or a function that loads them, e.g. `() => import('i18n-iso-countries/langs/de.json')`. */\nexport type NbCountryNamesSource = NbCountryNames | (() => Promise<NbCountryNames | { default: NbCountryNames }>)\n\n/** @internal */\nexport const NB_COUNTRY_NAMES = new InjectionToken<NbCountryNamesSource>('Lyra Country Names', {\n factory: () => () => import('i18n-iso-countries/langs/en.json', { with: { type: 'json' } })\n})\n\n/**\n * Sets the language of the country names in the phone input, English by default, for the app or for the components\n * inside the one that provides it:\n *\n * ```ts\n * providers: [provideNbCountryNames(() => import('i18n-iso-countries/langs/de.json'))]\n * ```\n */\nexport function provideNbCountryNames(names: NbCountryNamesSource): Provider[] {\n return [{ provide: NB_COUNTRY_NAMES, useValue: names }]\n}\n\n/** @internal */\nexport async function loadCountryNames(source: NbCountryNamesSource): Promise<NbCountryNames> {\n if (typeof source !== 'function') {\n return source\n }\n const loaded = await source()\n return 'default' in loaded ? loaded.default : loaded\n}\n","import { injectNbTexts, NbLocalize } from '@liquid-js/lyr-core'\n\n/** @internal */\ndeclare const $localize: NbLocalize\n\n/**\n * The texts of the phone input. `provideNbTexts({ phoneInput: { ... } })` changes them, and they're translated with\n * Angular's i18n, as `$localize` messages with ids like `@@nb.phoneInput.invalid`.\n */\nexport interface NbPhoneInputTexts {\n /** Names the number field when it has no `aria-label` or `aria-labelledby`. */\n number: string\n /** Label of the button that picks the country, given the country's name. */\n country: (name: string) => string\n /** Label of the button that picks the country while there's none. */\n noCountry: string\n /** Label and placeholder of the field that searches the countries. */\n search: string\n /** The message of the `nbPhoneNumber` error for a number that isn't valid. */\n invalid: string\n /** The message of the `nbPhoneNumber` error for a number from a country that isn't allowed. */\n otherCountry: string\n}\n\ndeclare module '@liquid-js/lyr-core' {\n interface NbTexts {\n phoneInput: NbPhoneInputTexts\n }\n}\n\n/** The default texts, in the app's language. @internal */\nexport function nbPhoneInputTexts(): NbPhoneInputTexts {\n return {\n number: $localize`:@@nb.phoneInput.number:Phone number`,\n country: (name: string) => $localize`:@@nb.phoneInput.country:Country: ${name}:country:`,\n noCountry: $localize`:@@nb.phoneInput.noCountry:Choose a country`,\n search: $localize`:@@nb.phoneInput.search:Search countries`,\n invalid: $localize`:@@nb.phoneInput.invalid:Enter a valid phone number`,\n otherCountry: $localize`:@@nb.phoneInput.otherCountry:Enter a phone number from one of the allowed countries`\n }\n}\n\n/** @internal */\nexport function injectNbPhoneInputTexts() {\n return injectNbTexts('phoneInput', nbPhoneInputTexts)\n}\n","import { inject, LOCALE_ID } from '@angular/core'\nimport { AbstractControl, ValidationErrors, ValidatorFn } from '@angular/forms'\nimport { SchemaPath, validate } from '@angular/forms/signals'\nimport { injectNbValidationMessage, NbValidationError, nbValidationParam } from '@liquid-js/lyr-core'\nimport { CountryCode, getCountries, parsePhoneNumberFromString, PhoneNumber } from 'libphonenumber-js'\n\nimport { injectNbPhoneInputTexts, NbPhoneInputTexts, nbPhoneInputTexts } from './texts'\n\n/** The error kind of a phone number that isn't valid or isn't from an allowed country. */\nexport const NB_PHONE_NUMBER_ERROR = 'nbPhoneNumber' as const\n\n/**\n * What's wrong with a phone number: it isn't valid (`invalid`), or it's from a country that isn't allowed (`country`).\n */\nexport type NbPhoneNumberProblem = 'invalid' | 'country'\n\n/**\n * The `nbPhoneNumber` error, the same in signal, reactive and template-driven forms, as Angular gives parse errors:\n * its kind, what's wrong, and its message.\n */\nexport interface NbPhoneNumberError {\n kind: typeof NB_PHONE_NUMBER_ERROR\n problem: NbPhoneNumberProblem\n message: string\n}\n\n/** A value, or a function that gives it, e.g. from another control or a signal. */\nexport type NbPhoneNumberOption<T> = T | (() => T)\n\n/** A message of this validator's errors, or a function that gives it for what's wrong. */\nexport type NbPhoneNumberMessage = string | ((problem: NbPhoneNumberProblem) => string)\n\nexport interface NbPhoneNumberOptions {\n /** The country of numbers without a calling code; the app locale's country by default. */\n country?: NbPhoneNumberOption<CountryCode | undefined>\n /** The countries whose numbers pass, all by default. */\n countries?: NbPhoneNumberOption<ReadonlyArray<CountryCode> | undefined>\n /** The message of its errors, in place of the app's (`provideNbValidation`, `provideNbTexts`). */\n message?: NbPhoneNumberMessage\n}\n\n/** Where the errors take their messages and numbers their country from. @internal */\nexport interface NbPhoneNumberContext {\n texts: () => NbPhoneInputTexts\n /** The message of an error, as `nb-validation-errors` shows it. */\n message: (error: NbValidationError) => string\n country?: CountryCode\n}\n\nconst allCountries = new Set<string>(getCountries())\n\n/** The country of a locale, e.g. `GB` for `en-GB`, or `US` for `en`. @internal */\nexport function localeCountry(locale: string): CountryCode | undefined {\n try {\n const region = new Intl.Locale(locale).maximize().region\n return region && allCountries.has(region) ? (region as CountryCode) : undefined\n } catch {\n return undefined\n }\n}\n\n/** The valid number in a text, in the country unless it has a calling code. @internal */\nexport function parsePhoneNumber(text: string, country?: CountryCode): PhoneNumber | undefined {\n if (!text.trim()) {\n return undefined\n }\n const number = parsePhoneNumberFromString(text, country)\n return number?.isValid() ? number : undefined\n}\n\n/** What's wrong with a value as a phone number, if anything; an empty value is fine. @internal */\nexport function checkPhoneNumber(\n value: unknown,\n country?: CountryCode,\n countries?: ReadonlyArray<CountryCode>\n): NbPhoneNumberProblem | undefined {\n if (value === null || value === undefined || value === '') {\n return undefined\n }\n const number = parsePhoneNumber(String(value), country)\n if (!number) {\n return 'invalid'\n }\n return countries && !(number.country && countries.includes(number.country)) ? 'country' : undefined\n}\n\n/**\n * The error of a problem, with its message: the one given, or the app's, or the phone input's texts'. @internal\n */\nexport function phoneNumberError(\n context: NbPhoneNumberContext,\n problem: NbPhoneNumberProblem,\n message?: NbPhoneNumberMessage\n): NbPhoneNumberError {\n const own = typeof message === 'function' ? message(problem) : message\n if (own !== undefined) {\n return { kind: NB_PHONE_NUMBER_ERROR, problem, message: own }\n }\n const texts = context.texts()\n const error = {\n kind: NB_PHONE_NUMBER_ERROR,\n problem,\n message: problem === 'country' ? texts.otherCountry : texts.invalid\n }\n return { ...error, message: context.message({ kind: NB_PHONE_NUMBER_ERROR, params: error }) }\n}\n\n/** Validates a value with the options, as all the forms do. @internal */\nexport function validatePhoneNumber(\n value: unknown,\n options: NbPhoneNumberOptions,\n context: NbPhoneNumberContext\n): NbPhoneNumberError | undefined {\n const problem = checkPhoneNumber(value, read(options.country) ?? context.country, read(options.countries))\n return problem ? phoneNumberError(context, problem, options.message) : undefined\n}\n\nconst read = <T>(option: NbPhoneNumberOption<T>): T =>\n typeof option === 'function' ? (option as () => T)() : option\n\n/** The texts, the app's messages and the locale's country, from the injection context when there's one. @internal */\nexport function phoneNumberContext(): NbPhoneNumberContext {\n try {\n const texts = injectNbPhoneInputTexts()\n return {\n texts: () => texts(),\n message: injectNbValidationMessage(),\n country: localeCountry(inject(LOCALE_ID))\n }\n } catch {\n const texts = nbPhoneInputTexts()\n return {\n texts: () => texts,\n message: (error) => {\n const message = nbValidationParam(error, 'message')\n return typeof message === 'string' ? message : ''\n }\n }\n }\n}\n\n/**\n * Validates a phone number in reactive forms: an empty value passes, a number that isn't valid or isn't from one of\n * `countries` gets the `nbPhoneNumber` error, with its message. In templates, use the `nbPhoneNumber` attribute.\n *\n * ```ts\n * readonly phone = new FormControl('', nbPhoneNumberValidator({ countries: ['US', 'CA'] }));\n * ```\n *\n * The error's message is `message`, if given, or the one `nb-validation-errors` shows for `nbPhoneNumber`: the app's\n * (`provideNbValidation`, `provideNbTexts({ validation })`), or the phone input's texts, `invalid` or\n * `otherCountry`. Made in an injection context, e.g. in a field initializer, it reads numbers in the app locale's\n * country and has the app's messages; elsewhere, numbers need a calling code unless `country` is given, and the\n * messages are the default ones.\n */\nexport function nbPhoneNumberValidator(options: NbPhoneNumberOptions = {}): ValidatorFn {\n const context = phoneNumberContext()\n return (control: AbstractControl): ValidationErrors | null => {\n const error = validatePhoneNumber(control.value, options, context)\n return error ? { [NB_PHONE_NUMBER_ERROR]: error } : null\n }\n}\n\n/**\n * Validates a phone number in signal forms, as `nbPhoneNumberValidator` does:\n *\n * ```ts\n * readonly form = form(this.model, (path) => {\n * nbPhoneNumber(path.phone, { countries: ['US', 'CA'] });\n * });\n * ```\n */\nexport function nbPhoneNumber(\n path: SchemaPath<string | null | undefined>,\n options: NbPhoneNumberOptions = {}\n): void {\n const context = phoneNumberContext()\n validate(path, ({ value }) => validatePhoneNumber(value(), options, context))\n}\n","import {\n afterNextRender,\n booleanAttribute,\n ChangeDetectionStrategy,\n Component,\n computed,\n effect,\n ElementRef,\n forwardRef,\n inject,\n Injector,\n input,\n linkedSignal,\n LOCALE_ID,\n model,\n OnInit,\n resource,\n signal,\n untracked,\n viewChild,\n ViewEncapsulation\n} from '@angular/core'\nimport {\n ControlValueAccessor,\n NG_VALIDATORS,\n NG_VALUE_ACCESSOR,\n ValidationErrors,\n Validator\n} from '@angular/forms'\nimport {\n injectNbDefaults,\n NbAutocompleteComponent,\n NbAutocompleteDirective,\n NbButtonComponent,\n NbComponentOrCustomStatus,\n NbComponentShape,\n NbComponentSize,\n NbFormFieldComponent,\n NbIconComponent,\n NbInputDirective,\n NbOptionComponent,\n NbPrefixDirective,\n NbValidationDirective\n} from '@liquid-js/lyr-core'\nimport {\n CountryCode,\n getCountries,\n getCountryCallingCode,\n getExampleNumber,\n PhoneNumber\n} from 'libphonenumber-js'\nimport examples from 'libphonenumber-js/mobile/examples'\nimport { FlagComponent, FlagDatabase, FlagDatabaseKey } from 'nxt-flags'\n\nimport { loadCountryNames, NB_COUNTRY_NAMES } from './country-names'\nimport {\n checkPhoneNumber,\n localeCountry,\n NB_PHONE_NUMBER_ERROR,\n parsePhoneNumber,\n phoneNumberContext,\n phoneNumberError\n} from './phone-number.validator'\nimport { injectNbPhoneInputTexts } from './texts'\n\n/** A country in the list. */\ninterface NbPhoneCountry {\n code: CountryCode\n name: string\n callingCode: string\n /** The names, the calling code and the ISO code, as the search compares them. */\n search: string\n}\n\n/**\n * Flags of phone regions that aren't ISO countries: Ascension and Tristan da Cunha are part of Saint Helena, Ascension\n * and Tristan da Cunha (SH), whose flag they show.\n */\nconst flagFallbacks: Partial<Record<CountryCode, FlagDatabaseKey>> = { AC: 'sh', TA: 'sh' }\n\nconst allCountries = new Set<string>(getCountries())\n\n/** Text as the search compares it, without case and accents. */\nconst fold = (text: string) =>\n text\n .normalize('NFD')\n .replace(/\\p{Diacritic}/gu, '')\n .toLocaleLowerCase()\n\n/**\n * A phone number field with the country's flag, which picks the country:\n *\n * ```html\n * <nb-phone-input formControlName=\"phone\" />\n * ```\n *\n * @stacked-example(Showcase, phone-input/phone-input-showcase.component)\n *\n * ### Installation\n *\n * It parses and formats numbers with [`libphonenumber-js`](https://www.npmjs.com/package/libphonenumber-js), names\n * the countries with [`i18n-iso-countries`](https://www.npmjs.com/package/i18n-iso-countries)' language files, and\n * shows flags with [`nxt-flags`](https://www.npmjs.com/package/nxt-flags); install them and import\n * `NbPhoneInputComponent` from `@liquid-js/lyr-extras/phone-input`.\n *\n * ```sh\n * npm install libphonenumber-js i18n-iso-countries nxt-flags\n * ```\n *\n * The flags are images the app serves from `assets/flags`; add them to the assets in `angular.json`:\n *\n * ```json\n * { \"glob\": \"*.svg\", \"input\": \"node_modules/nxt-flags/assets/flags\", \"output\": \"assets/flags\" }\n * ```\n *\n * To serve them from elsewhere, e.g. a CDN, set the path with `provideFlagsPath()` from `nxt-flags`.\n *\n * ### Usage\n *\n * The user types the number in their country's format or with a calling code, e.g. `+44`, which picks the country.\n * The flag button replaces the field with a search of the countries, by name or calling code; Escape goes back.\n * The country is the one of the app's locale (`LOCALE_ID`) until the user or a number picks another, or set it with\n * `country`, which also tells which one is picked. It has the sizes, statuses, shapes and `ghost` look of `nbInput`,\n * and its `placeholder` and `readonly`; the placeholder is an example number of the country by default.\n * @stacked-example(Sizes and statuses, phone-input/phone-input-sizes.component)\n *\n * The value is the number in the `E.164` format, e.g. `+12015550123`, or `null` without one; when the field leaves,\n * it shows the number in its country's format, `(201) 555-0123`. While the text isn't a valid number, the value\n * stays the last valid one, or `null`, and the field has the `nbPhoneNumber` parse error,\n * `{ kind, problem: 'invalid', message }`, as Angular's controls report text they can't parse; so validators never\n * see the text. A number from a country that isn't in `countries`, which the list offers, has the same error with\n * `problem: 'country'`. The errors work in reactive, template-driven and signal forms alike.\n *\n * It works with `formControl`, `formControlName`, `ngModel` and signal forms' `[formField]`.\n * @stacked-example(Validation, phone-input/phone-input-validation.component)\n *\n * ### Validators\n *\n * Phone numbers in other fields, e.g. a text field or data from elsewhere, are checked the same way with validators:\n * `nbPhoneNumberValidator(options)` in reactive forms, the `nbPhoneNumber` attribute in template-driven forms, and\n * `nbPhoneNumber(path, options)` in signal forms. The options are the `country` of numbers without a\n * calling code, the app locale's by default, and the `countries` whose numbers pass, each a value or a function that\n * gives it, and the `message` of the errors, a text or a function of what's wrong, in place of the app's. Their\n * `nbPhoneNumber` error says what's wrong, `invalid` or `country`, with its message.\n *\n * ```ts\n * readonly phone = new FormControl<string | null>(null, nbPhoneNumberValidator({ countries: ['US', 'CA'] }));\n *\n * readonly contactForm = form(this.contact, (path) => {\n * nbPhoneNumber(path.phone, { countries: ['GB'] });\n * });\n * ```\n *\n * ```html\n * <input nbInput type=\"tel\" name=\"support\" ngModel nbPhoneNumber [nbPhoneNumberCountries]=\"['US', 'CA']\" />\n * ```\n *\n * ### Country names\n *\n * The countries are named in English. For other languages, provide the language file of `i18n-iso-countries`, e.g.\n * per locale's build, or loaded by `LOCALE_ID`:\n *\n * ```ts\n * providers: [provideNbCountryNames(() => import('i18n-iso-countries/langs/de.json'))]\n * ```\n *\n * Countries without a name in the file aren't in the list; their numbers are still accepted.\n */\n@Component({\n selector: 'nb-phone-input',\n templateUrl: './phone-input.component.html',\n styleUrl: './phone-input.component.scss',\n encapsulation: ViewEncapsulation.None,\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [\n NbFormFieldComponent,\n NbPrefixDirective,\n NbButtonComponent,\n NbIconComponent,\n NbInputDirective,\n NbAutocompleteDirective,\n NbAutocompleteComponent,\n NbOptionComponent,\n FlagComponent\n ],\n providers: [\n { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => NbPhoneInputComponent), multi: true },\n { provide: NG_VALIDATORS, useExisting: forwardRef(() => NbPhoneInputComponent), multi: true }\n ],\n host: {\n 'class': 'nb-phone-input',\n '[class.full-width]': 'fullWidth()'\n }\n})\nexport class NbPhoneInputComponent implements OnInit, ControlValueAccessor, Validator {\n // The app's defaults for fields, which the inputs below start from.\n protected readonly nbDefaults = injectNbDefaults('input')\n\n protected readonly texts = injectNbPhoneInputTexts()\n /** Where its errors take their messages from. */\n protected readonly errorContext = phoneNumberContext()\n protected readonly locale = inject(LOCALE_ID)\n protected readonly injector = inject(Injector)\n protected readonly validation = inject(NbValidationDirective, { self: true, optional: true })\n\n /**\n * The country of the number: the app locale's country at first, unless it's set, then the one the user or the number\n * picks.\n */\n readonly country = model<CountryCode>()\n /** The countries in the list, whose numbers pass, all by default. */\n readonly countries = input<ReadonlyArray<CountryCode>>()\n /** Field size: `tiny`, `small`, `medium` (default), `large` or `giant`. */\n readonly sizeInput = input<NbComponentSize | undefined>(undefined, { alias: 'size' })\n /** The size in use: the input's, the app's default, or 'medium'. */\n readonly size = linkedSignal<NbComponentSize>(() => this.sizeInput() ?? this.nbDefaults().size ?? 'medium')\n /** Field status: `basic` (default), `primary`, `info`, `success`, `warning`, `danger` or `control`. */\n readonly status = input<NbComponentOrCustomStatus>('basic')\n /** Field shape: `rectangle` (default), `semi-round` or `round`. */\n readonly shapeInput = input<NbComponentShape | undefined>(undefined, { alias: 'shape' })\n /** The shape in use: the input's, the app's default, or 'rectangle'. */\n readonly shape = linkedSignal<NbComponentShape>(() => this.shapeInput() ?? this.nbDefaults().shape ?? 'rectangle')\n readonly fullWidth = input(false, { transform: booleanAttribute })\n /** Shows the field without its background and border, as `nbInput`'s `ghost` does. */\n readonly ghost = input(false, { transform: booleanAttribute })\n readonly disabled = input(false, { transform: booleanAttribute })\n /** Lets the user read and select the number, but not change it or its country, as a read-only field. */\n readonly readonly = input(false, { transform: booleanAttribute })\n /** The number field's placeholder; an example number of the country by default. */\n readonly placeholder = input<string>()\n /** The country list's distance from the search field, as other fields' overlays have it. */\n readonly overlayOffset = input(8)\n /** Names the number field when there's no `aria-labelledby`; \"Phone number\" by default. */\n readonly ariaLabel = input<string | undefined>(undefined, { alias: 'aria-label' })\n /** The id of the element that names the number field, e.g. a `label`. */\n readonly ariaLabelledBy = input<string | undefined>(undefined, { alias: 'aria-labelledby' })\n\n /** What labels the field: its own `aria-labelledby` and an `nbLabel` of its `nbValidation`. */\n protected readonly fieldLabelledBy = computed(\n () => [this.ariaLabelledBy(), this.validation?.labelledBy()].filter(Boolean).join(' ') || null\n )\n\n /** The country the number is parsed in, the locale's until `country` has one. */\n readonly selectedCountry = computed(() => this.country() ?? localeCountry(this.locale))\n\n constructor() {\n // The number field is the control: it gets the validation's ARIA, not the host.\n this.validation?.delegateAria()\n // Another list of countries can change whether the number passes.\n effect(() => {\n this.countries()\n untracked(() => this.onValidatorChange())\n })\n }\n\n ngOnInit() {\n // `country` tells the country the field uses from the start, also when the binding gives none.\n if (!this.country()) {\n this.pickCountry(localeCountry(this.locale))\n }\n }\n\n protected readonly isDisabled = linkedSignal(() => this.disabled())\n protected readonly resolvedStatus = computed(() => this.validation?.status() ?? this.status())\n /** The field's buttons are white on colour, with the `control` status, and grey otherwise. */\n protected readonly buttonStatus = computed(() => (this.resolvedStatus() === 'control' ? 'control' : 'basic'))\n /** The number as the field shows it. */\n protected readonly text = signal('')\n /** Whether the text isn't a valid number. */\n protected readonly parseError = signal(false)\n /** Whether the search of the countries replaces the number field. */\n protected readonly picking = signal(false)\n protected readonly query = signal('')\n protected readonly namesSource = inject(NB_COUNTRY_NAMES)\n protected readonly names = resource({ loader: () => loadCountryNames(this.namesSource) })\n\n /** The countries with a name, in the language's order. */\n protected readonly list = computed(() => {\n const names = this.names.hasValue() ? this.names.value().countries : {}\n const only = this.countries()\n const codes = only ? only.filter((code) => allCountries.has(code)) : (getCountries() as CountryCode[])\n const list = new Array<NbPhoneCountry>()\n for (const code of codes) {\n const name = names[code]\n const all = Array.isArray(name) ? name : name ? [name] : []\n if (all.length) {\n const callingCode = getCountryCallingCode(code)\n list.push({ code, name: all[0], callingCode, search: fold(`${all.join(' ')} +${callingCode} ${code}`) })\n }\n }\n const collator = new Intl.Collator(this.locale)\n return list.sort((a, b) => collator.compare(a.name, b.name))\n })\n\n /** The countries the search finds. */\n protected readonly shown = computed(() => {\n const words = fold(this.query()).split(/\\s+/).filter(Boolean)\n return this.list().filter((country) => words.every((word) => country.search.includes(word)))\n })\n\n protected readonly countryName = computed(() => {\n const code = this.selectedCountry()\n return code && (this.list().find((country) => country.code === code)?.name ?? code)\n })\n\n protected readonly countryLabel = computed(() => {\n const name = this.countryName()\n return name ? this.texts().country(name) : this.texts().noCountry\n })\n\n /** An example number of the country, in its format. */\n protected readonly example = computed(() => {\n const code = this.selectedCountry()\n return code ? (getExampleNumber(code, examples)?.formatNational() ?? '') : ''\n })\n\n protected readonly numberField = viewChild.required<ElementRef<HTMLInputElement>>('number')\n protected readonly searchField = viewChild.required<ElementRef<HTMLInputElement>>('search')\n\n /** The value last given to the form, `null` without one. */\n protected value: string | null = null\n protected onChange: (value: string | null) => void = () => {}\n protected onTouched: () => void = () => {}\n protected onValidatorChange: () => void = () => {}\n\n writeValue(value?: string | null) {\n const text = value ?? ''\n const number = this.parse(text)\n this.pickCountry(number?.country)\n this.text.set(number ? this.display(number) : text)\n this.value = value ?? null\n this.setParseError(false)\n }\n\n registerOnChange(fn: (value: string | null) => void) {\n this.onChange = fn\n }\n\n registerOnTouched(fn: () => void) {\n this.onTouched = fn\n }\n\n registerOnValidatorChange(fn: () => void) {\n this.onValidatorChange = fn\n }\n\n setDisabledState(disabled: boolean) {\n this.isDisabled.set(disabled)\n }\n\n /** The parse error of text that isn't a valid number, or the error of a number from a country not in `countries`. */\n validate(): ValidationErrors | null {\n const problem = this.parseError()\n ? 'invalid'\n : checkPhoneNumber(this.value, this.selectedCountry(), this.countries())\n return problem ? { [NB_PHONE_NUMBER_ERROR]: phoneNumberError(this.errorContext, problem) } : null\n }\n\n /** Moves focus to the number. */\n focus() {\n this.numberField().nativeElement.focus()\n }\n\n /** Sets `country`, when it's another. */\n protected pickCountry(code?: CountryCode) {\n if (code && code !== this.country()) {\n this.country.set(code)\n }\n }\n\n /** The flag of a country, the unknown flag without one. */\n protected flag(code?: CountryCode): FlagDatabaseKey {\n const key = code?.toLowerCase()\n return (code && flagFallbacks[code]) ?? (key && key in FlagDatabase ? (key as FlagDatabaseKey) : 'xx')\n }\n\n protected typed(event: Event) {\n const text = (event.target as HTMLInputElement).value\n this.text.set(text)\n // A number with a calling code picks its country.\n this.pickCountry(this.parse(text)?.country)\n this.update()\n }\n\n protected left() {\n const number = this.parse(this.text())\n if (number) {\n this.text.set(this.display(number))\n }\n this.onTouched()\n }\n\n /** Replaces the number field with the search of the countries, whose list opens. */\n protected pick() {\n if (this.isDisabled() || this.readonly()) {\n return\n }\n const search = this.searchField().nativeElement\n search.value = ''\n this.query.set('')\n this.picking.set(true)\n afterNextRender(() => search.focus(), { injector: this.injector })\n }\n\n protected searched(event: Event) {\n this.query.set((event.target as HTMLInputElement).value)\n }\n\n protected chose(country?: NbPhoneCountry | string) {\n if (country && typeof country !== 'string') {\n this.country.set(country.code)\n // The text is a number of the new country.\n this.update()\n }\n this.stopPicking(true)\n }\n\n /**\n * Escape in the search goes back to the number, the list closing too; it's handled, so nothing else closes, e.g. a\n * dialog around it.\n */\n protected searchEscaped(event: Event) {\n event.preventDefault()\n this.stopPicking(true)\n }\n\n /** Leaving the search touches the control, as leaving an autocomplete's input does. */\n protected searchLeft() {\n this.stopPicking(false)\n this.onTouched()\n }\n\n /**\n * Shows the number field again, and moves focus to it after Escape or picking a country, which can come after the\n * search field lost focus to the list.\n */\n protected stopPicking(focus: boolean) {\n this.picking.set(false)\n if (focus) {\n afterNextRender(() => this.focus(), { injector: this.injector })\n }\n }\n\n /** What the search field shows: the text typed in it, or the name of the country picked. */\n protected readonly displayCountry = (value?: NbPhoneCountry | string) =>\n typeof value === 'string' ? value : (value?.name ?? '')\n\n /** The valid number in the text, in the picked country unless it has a calling code. */\n protected parse(text: string): PhoneNumber | undefined {\n return parsePhoneNumber(text, this.selectedCountry())\n }\n\n /** A number as the field shows it: in its country's format, or international without one. */\n protected display(number: PhoneNumber) {\n return number.country ? number.formatNational() : number.formatInternational()\n }\n\n /**\n * Gives the form the number in the text, when it's another; while the text isn't a valid number, the value stays\n * and the field has the parse error.\n */\n protected update() {\n const text = this.text().trim()\n const number = text ? this.parse(text) : undefined\n this.setParseError(!!text && !number)\n const value = number?.number ?? null\n if ((!text || number) && value !== this.value) {\n this.value = value\n this.onChange(value)\n }\n // Signal forms only check a value accessor's validators again when they're told to, e.g. for a number of a\n // country `countries` leaves out.\n this.onValidatorChange()\n }\n\n protected setParseError(parseError: boolean) {\n if (parseError !== this.parseError()) {\n this.parseError.set(parseError)\n this.onValidatorChange()\n }\n }\n}\n","<nb-form-field class=\"nb-phone-input-number\"\n [style.display]=\"picking() ? 'none' : null\">\n <button nbPrefix\n nbButton\n ghost\n type=\"button\"\n class=\"nb-phone-input-country\"\n [size]=\"size()\"\n [status]=\"buttonStatus()\"\n [disabled]=\"isDisabled() || readonly()\"\n [attr.aria-label]=\"countryLabel()\"\n (click)=\"pick()\">\n <nxt-flag [country]=\"flag(selectedCountry())\"\n size=\"s\" />\n <nb-icon icon=\"chevron-down-outline\"\n pack=\"essentials\"\n aria-hidden=\"true\" />\n </button>\n <input #number\n nbInput\n type=\"tel\"\n autocomplete=\"tel\"\n [fieldSize]=\"size()\"\n [status]=\"resolvedStatus()\"\n [shape]=\"shape()\"\n [fullWidth]=\"fullWidth()\"\n [ghost]=\"ghost()\"\n [disabled]=\"isDisabled()\"\n [readOnly]=\"readonly()\"\n [value]=\"text()\"\n [placeholder]=\"placeholder() ?? example()\"\n [attr.aria-label]=\"fieldLabelledBy() ? null : (ariaLabel() ?? texts().number)\"\n [attr.aria-labelledby]=\"fieldLabelledBy()\"\n [attr.aria-required]=\"validation?.ariaRequired()\"\n [attr.aria-invalid]=\"validation?.ariaInvalid()\"\n [attr.aria-describedby]=\"validation?.describedBy()\"\n (input)=\"typed($event)\"\n (blur)=\"left()\" />\n</nb-form-field>\n\n<!-- Stays in the page while it's hidden, so the list it opens still takes a click after it loses focus. -->\n<nb-form-field class=\"nb-phone-input-search\"\n [style.display]=\"picking() ? null : 'none'\">\n <nb-icon nbPrefix\n icon=\"search-outline\"\n pack=\"essentials\"\n aria-hidden=\"true\" />\n <input #search\n nbInput\n type=\"text\"\n autocomplete=\"off\"\n [fieldSize]=\"size()\"\n [status]=\"resolvedStatus()\"\n [shape]=\"shape()\"\n [fullWidth]=\"fullWidth()\"\n [ghost]=\"ghost()\"\n [placeholder]=\"texts().search\"\n [attr.aria-label]=\"texts().search\"\n [nbAutocomplete]=\"countryList\"\n [overlayOffset]=\"overlayOffset()\"\n (input)=\"searched($event)\"\n (keydown.escape)=\"searchEscaped($event)\"\n (blur)=\"searchLeft()\" />\n</nb-form-field>\n\n<nb-autocomplete #countryList\n [size]=\"size()\"\n [handleDisplayFn]=\"displayCountry\"\n (selectedChange)=\"chose($event)\">\n @for (country of shown(); track country.code) {\n <nb-option class=\"nb-phone-input-option\"\n [value]=\"country\">\n <nxt-flag [country]=\"flag(country.code)\"\n size=\"s\" />\n <span class=\"nb-phone-input-name\">{{ country.name }}</span>\n <span class=\"nb-phone-input-calling-code\">+{{ country.callingCode }}</span>\n </nb-option>\n }\n</nb-autocomplete>\n","import { Directive, effect, ElementRef, forwardRef, inject, input } from '@angular/core'\nimport { AbstractControl, NG_VALIDATORS, ValidationErrors, Validator } from '@angular/forms'\nimport type { CountryCode } from 'libphonenumber-js'\n\nimport {\n NB_PHONE_NUMBER_ERROR,\n NbPhoneNumberMessage,\n phoneNumberContext,\n validatePhoneNumber\n} from './phone-number.validator'\n\n/**\n * Validates a phone number in template-driven forms, as `nbPhoneNumberValidator` does in reactive forms:\n *\n * ```html\n * <input nbInput type=\"tel\" name=\"phone\" ngModel nbPhoneNumber [nbPhoneNumberCountries]=\"['US', 'CA']\" />\n * ```\n */\n@Directive({\n selector: '[nbPhoneNumber][ngModel],[nbPhoneNumber][formControl],[nbPhoneNumber][formControlName]',\n providers: [{ provide: NG_VALIDATORS, useExisting: forwardRef(() => NbPhoneNumberValidatorDirective), multi: true }],\n host: {\n // On a plain text field, the number reads left to right from the left in any page, as a tel field's does.\n '[style.text-align]': \"isInput ? 'left' : null\",\n '[style.unicode-bidi]': \"isInput ? 'plaintext' : null\"\n }\n})\nexport class NbPhoneNumberValidatorDirective implements Validator {\n /** The country of numbers without a calling code; the app locale's country by default. */\n readonly country = input<CountryCode>(undefined, { alias: 'nbPhoneNumberCountry' })\n /** The countries whose numbers pass, all by default. */\n readonly countries = input<ReadonlyArray<CountryCode>>(undefined, { alias: 'nbPhoneNumberCountries' })\n /** The message of its errors, in place of the app's. */\n readonly message = input<NbPhoneNumberMessage>(undefined, { alias: 'nbPhoneNumberMessage' })\n\n // By tag name, which a server's DOM also has.\n protected readonly isInput = inject<ElementRef<Element>>(ElementRef).nativeElement.tagName === 'INPUT'\n protected readonly context = phoneNumberContext()\n protected onValidatorChange: () => void = () => {}\n\n constructor() {\n // Other options can change whether the value passes.\n effect(() => {\n this.country()\n this.countries()\n this.message()\n this.onValidatorChange()\n })\n }\n\n validate(control: AbstractControl): ValidationErrors | null {\n const error = validatePhoneNumber(\n control.value,\n { country: this.country(), countries: this.countries(), message: this.message() },\n this.context\n )\n return error ? { [NB_PHONE_NUMBER_ERROR]: error } : null\n }\n\n registerOnValidatorChange(fn: () => void) {\n this.onValidatorChange = fn\n }\n}\n"],"mappings":";;;;;;;;AAgBA,MAAa,mBAAmB,IAAI,eAAqC,sBAAsB,EAC3F,qBAAqB,OAAO,oCAAoC,EAAE,MAAM,EAAE,MAAM,OAAM,EAAE,GAC3F,CAAA;AAUD,SAAgB,sBAAsB,OAA2B;CAC7D,OAAO,CAAC;EAAE,SAAS;EAAkB,UAAU;CAAK,CAAE;AAC1D;AAGA,eAAsB,iBAAiB,QAA4B;CAC/D,IAAI,OAAO,WAAW,YAClB,OAAO;CAEX,MAAM,SAAS,MAAM,OAAM;CAC3B,OAAO,aAAa,SAAS,OAAO,UAAU;AAClD;ACRA,SAAgB,oBAAiB;CAC7B,OAAO;EACH,QAAQ,SAAS;EACjB,UAAU,SAAiB,SAAS,qCAAqC,KAAI;EAC7E,WAAW,SAAS;EACpB,QAAQ,SAAS;EACjB,SAAS,SAAS;EAClB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A,SAAA;GAAA,UAAA;GAAA,MAAA;GAA+B,MAAA,CAAA;GAAA,QAAA,GAAA,gBAAA;EAAA,CAAA;CAAA;CAA/B;EAAA,KAAA,OAAA,GAAA,qBAAA;GAAA,YAAA;GAAA,SAAA;GAAA,MAAA;GAA+B,cAAA;GAAA,UAAA;GAAA,QAAA;IAAA,SAAA;KAAA,mBAAA;KAAA,YAAA;KAAA,UAAA;KAAA,YAAA;KAAA,mBAAA;IAAA;IAAA,WAAA;KAAA,mBAAA;KAAA,YAAA;KAAA,UAAA;KAAA,YAAA;KAAA,mBAAA;IAAA;IAAA,SAAA;KAAA,mBAAA;KAAA,YAAA;KAAA,UAAA;KAAA,YAAA;KAAA,mBAAA;IAAA;GAAA;GAAA,MAAA,EAAA,YAAA;IAAA,oBAAA;IAAA,sBAAA;GAAA,EAAA;GAAA,WAP7B,CAAC;IAAE,SAAS;IAAe,aAAa,iBAAiB,+BAA+B;IAAG,OAAO;GAAI,CAAE;GAAC,UAAA;EAAA,CAAA;CAAA;;AAO3G,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAA+B,YAAA,CAAA;EAT3C,MAAA;EAAU,MAAA,CAAA;GACP,UAAU;GACV,WAAW,CAAC;IAAE,SAAS;IAAe,aAAa,iBAAgB,+BAAgC;IAAG,OAAO;GAAI,CAAE;GACnH,MAAM;IAEF,sBAAsB;IACtB,wBAAwB;GAC3B;EACJ,CAAA"}
|
|
1
|
+
{"version":3,"file":"liquid-js-lyr-extras-phone-input.mjs","names":["allCountries"],"sources":["../../../packages/extras/phone-input/src/country-names.ts","../../../packages/extras/phone-input/src/texts.ts","../../../packages/extras/phone-input/src/phone-number.validator.ts","../../../packages/extras/phone-input/src/phone-input.component.ts","../../../packages/extras/phone-input/src/phone-input.component.html","../../../packages/extras/phone-input/src/phone-number.directive.ts"],"sourcesContent":["import { InjectionToken, Provider } from '@angular/core'\n\n/**\n * Country names in a language, as the language files of\n * [`i18n-iso-countries`](https://www.npmjs.com/package/i18n-iso-countries) have them, e.g. its `langs/de.json`: the\n * language and the names by ISO 3166-1 code, each a name or a list of names, the first of which is shown.\n */\nexport interface NbCountryNames {\n locale: string\n countries: Record<string, string | string[]>\n}\n\n/** Country names, or a function that loads them, e.g. `() => import('i18n-iso-countries/langs/de.json')`. */\nexport type NbCountryNamesSource = NbCountryNames | (() => Promise<NbCountryNames | { default: NbCountryNames }>)\n\n/** @internal */\nexport const NB_COUNTRY_NAMES = new InjectionToken<NbCountryNamesSource>('Lyra Country Names', {\n factory: () => () => import('i18n-iso-countries/langs/en.json', { with: { type: 'json' } })\n})\n\n/**\n * Sets the language of the country names in the phone input, English by default, for the app or for the components\n * inside the one that provides it:\n *\n * ```ts\n * providers: [provideNbCountryNames(() => import('i18n-iso-countries/langs/de.json'))]\n * ```\n */\nexport function provideNbCountryNames(names: NbCountryNamesSource): Provider[] {\n return [{ provide: NB_COUNTRY_NAMES, useValue: names }]\n}\n\n/** @internal */\nexport async function loadCountryNames(source: NbCountryNamesSource): Promise<NbCountryNames> {\n if (typeof source !== 'function') {\n return source\n }\n const loaded = await source()\n return 'default' in loaded ? loaded.default : loaded\n}\n","import { injectNbTexts, NbLocalize } from '@liquid-js/lyr-core'\n\n/** @internal */\ndeclare const $localize: NbLocalize\n\n/**\n * The texts of the phone input. `provideNbTexts({ phoneInput: { ... } })` changes them, and they're translated with\n * Angular's i18n, as `$localize` messages with ids like `@@nb.phoneInput.invalid`.\n */\nexport interface NbPhoneInputTexts {\n /** Names the number field when it has no `aria-label` or `aria-labelledby`. */\n number: string\n /** Label of the button that picks the country, given the country's name. */\n country: (name: string) => string\n /** Label of the button that picks the country while there's none. */\n noCountry: string\n /** Label and placeholder of the field that searches the countries. */\n search: string\n /** The message of the `nbPhoneNumber` error for a number that isn't valid. */\n invalid: string\n /** The message of the `nbPhoneNumber` error for a number from a country that isn't allowed. */\n otherCountry: string\n}\n\ndeclare module '@liquid-js/lyr-core' {\n interface NbTexts {\n phoneInput: NbPhoneInputTexts\n }\n}\n\n/** The default texts, in the app's language. @internal */\nexport function nbPhoneInputTexts(): NbPhoneInputTexts {\n return {\n number: $localize`:@@nb.phoneInput.number:Phone number`,\n country: (name: string) => $localize`:@@nb.phoneInput.country:Country: ${name}:country:`,\n noCountry: $localize`:@@nb.phoneInput.noCountry:Choose a country`,\n search: $localize`:@@nb.phoneInput.search:Search countries`,\n invalid: $localize`:@@nb.phoneInput.invalid:Enter a valid phone number`,\n otherCountry: $localize`:@@nb.phoneInput.otherCountry:Enter a phone number from one of the allowed countries`\n }\n}\n\n/** @internal */\nexport function injectNbPhoneInputTexts() {\n return injectNbTexts('phoneInput', nbPhoneInputTexts)\n}\n","import { inject, LOCALE_ID } from '@angular/core'\nimport { AbstractControl, ValidationErrors, ValidatorFn } from '@angular/forms'\nimport { SchemaPath, validate } from '@angular/forms/signals'\nimport { injectNbValidationMessage, NbValidationError, nbValidationParam } from '@liquid-js/lyr-core'\nimport { CountryCode, getCountries, parsePhoneNumberFromString, PhoneNumber } from 'libphonenumber-js'\n\nimport { injectNbPhoneInputTexts, NbPhoneInputTexts, nbPhoneInputTexts } from './texts'\n\n/** The error kind of a phone number that isn't valid or isn't from an allowed country. */\nexport const NB_PHONE_NUMBER_ERROR = 'nbPhoneNumber' as const\n\n/**\n * What's wrong with a phone number: it isn't valid (`invalid`), or it's from a country that isn't allowed (`country`).\n */\nexport type NbPhoneNumberProblem = 'invalid' | 'country'\n\n/**\n * The `nbPhoneNumber` error, the same in signal, reactive and template-driven forms, as Angular gives parse errors:\n * its kind, what's wrong, and its message.\n */\nexport interface NbPhoneNumberError {\n kind: typeof NB_PHONE_NUMBER_ERROR\n problem: NbPhoneNumberProblem\n message: string\n}\n\n/** A value, or a function that gives it, e.g. from another control or a signal. */\nexport type NbPhoneNumberOption<T> = T | (() => T)\n\n/** A message of this validator's errors, or a function that gives it for what's wrong. */\nexport type NbPhoneNumberMessage = string | ((problem: NbPhoneNumberProblem) => string)\n\nexport interface NbPhoneNumberOptions {\n /** The country of numbers without a calling code; the app locale's country by default. */\n country?: NbPhoneNumberOption<CountryCode | undefined>\n /** The countries whose numbers pass, all by default. */\n countries?: NbPhoneNumberOption<ReadonlyArray<CountryCode> | undefined>\n /** The message of its errors, in place of the app's (`provideNbValidation`, `provideNbTexts`). */\n message?: NbPhoneNumberMessage\n}\n\n/** Where the errors take their messages and numbers their country from. @internal */\nexport interface NbPhoneNumberContext {\n texts: () => NbPhoneInputTexts\n /** The message of an error, as `nb-validation-errors` shows it. */\n message: (error: NbValidationError) => string\n country?: CountryCode\n}\n\nconst allCountries = new Set<string>(getCountries())\n\n/** The country of a locale, e.g. `GB` for `en-GB`, or `US` for `en`. @internal */\nexport function localeCountry(locale: string): CountryCode | undefined {\n try {\n const region = new Intl.Locale(locale).maximize().region\n return region && allCountries.has(region) ? (region as CountryCode) : undefined\n } catch {\n return undefined\n }\n}\n\n/** The valid number in a text, in the country unless it has a calling code. @internal */\nexport function parsePhoneNumber(text: string, country?: CountryCode): PhoneNumber | undefined {\n if (!text.trim()) {\n return undefined\n }\n const number = parsePhoneNumberFromString(text, country)\n return number?.isValid() ? number : undefined\n}\n\n/** What's wrong with a value as a phone number, if anything; an empty value is fine. @internal */\nexport function checkPhoneNumber(\n value: unknown,\n country?: CountryCode,\n countries?: ReadonlyArray<CountryCode>\n): NbPhoneNumberProblem | undefined {\n if (value === null || value === undefined || value === '') {\n return undefined\n }\n const number = parsePhoneNumber(String(value), country)\n if (!number) {\n return 'invalid'\n }\n return countries && !(number.country && countries.includes(number.country)) ? 'country' : undefined\n}\n\n/**\n * The error of a problem, with its message: the one given, or the app's, or the phone input's texts'. @internal\n */\nexport function phoneNumberError(\n context: NbPhoneNumberContext,\n problem: NbPhoneNumberProblem,\n message?: NbPhoneNumberMessage\n): NbPhoneNumberError {\n const own = typeof message === 'function' ? message(problem) : message\n if (own !== undefined) {\n return { kind: NB_PHONE_NUMBER_ERROR, problem, message: own }\n }\n const texts = context.texts()\n const error = {\n kind: NB_PHONE_NUMBER_ERROR,\n problem,\n message: problem === 'country' ? texts.otherCountry : texts.invalid\n }\n return { ...error, message: context.message({ kind: NB_PHONE_NUMBER_ERROR, params: error }) }\n}\n\n/** Validates a value with the options, as all the forms do. @internal */\nexport function validatePhoneNumber(\n value: unknown,\n options: NbPhoneNumberOptions,\n context: NbPhoneNumberContext\n): NbPhoneNumberError | undefined {\n const problem = checkPhoneNumber(value, read(options.country) ?? context.country, read(options.countries))\n return problem ? phoneNumberError(context, problem, options.message) : undefined\n}\n\nconst read = <T>(option: NbPhoneNumberOption<T>): T =>\n typeof option === 'function' ? (option as () => T)() : option\n\n/** The texts, the app's messages and the locale's country, from the injection context when there's one. @internal */\nexport function phoneNumberContext(): NbPhoneNumberContext {\n try {\n const texts = injectNbPhoneInputTexts()\n return {\n texts: () => texts(),\n message: injectNbValidationMessage(),\n country: localeCountry(inject(LOCALE_ID))\n }\n } catch {\n const texts = nbPhoneInputTexts()\n return {\n texts: () => texts,\n message: (error) => {\n const message = nbValidationParam(error, 'message')\n return typeof message === 'string' ? message : ''\n }\n }\n }\n}\n\n/**\n * Validates a phone number in reactive forms: an empty value passes, a number that isn't valid or isn't from one of\n * `countries` gets the `nbPhoneNumber` error, with its message. In templates, use the `nbPhoneNumber` attribute.\n *\n * ```ts\n * readonly phone = new FormControl('', nbPhoneNumberValidator({ countries: ['US', 'CA'] }));\n * ```\n *\n * The error's message is `message`, if given, or the one `nb-validation-errors` shows for `nbPhoneNumber`: the app's\n * (`provideNbValidation`, `provideNbTexts({ validation })`), or the phone input's texts, `invalid` or\n * `otherCountry`. Made in an injection context, e.g. in a field initializer, it reads numbers in the app locale's\n * country and has the app's messages; elsewhere, numbers need a calling code unless `country` is given, and the\n * messages are the default ones.\n */\nexport function nbPhoneNumberValidator(options: NbPhoneNumberOptions = {}): ValidatorFn {\n const context = phoneNumberContext()\n return (control: AbstractControl): ValidationErrors | null => {\n const error = validatePhoneNumber(control.value, options, context)\n return error ? { [NB_PHONE_NUMBER_ERROR]: error } : null\n }\n}\n\n/**\n * Validates a phone number in signal forms, as `nbPhoneNumberValidator` does:\n *\n * ```ts\n * readonly form = form(this.model, (path) => {\n * nbPhoneNumber(path.phone, { countries: ['US', 'CA'] });\n * });\n * ```\n */\nexport function nbPhoneNumber(\n path: SchemaPath<string | null | undefined>,\n options: NbPhoneNumberOptions = {}\n): void {\n const context = phoneNumberContext()\n validate(path, ({ value }) => validatePhoneNumber(value(), options, context))\n}\n","import {\n afterNextRender,\n booleanAttribute,\n ChangeDetectionStrategy,\n Component,\n computed,\n effect,\n ElementRef,\n forwardRef,\n inject,\n Injector,\n input,\n linkedSignal,\n LOCALE_ID,\n model,\n OnInit,\n resource,\n signal,\n untracked,\n viewChild,\n ViewEncapsulation\n} from '@angular/core'\nimport {\n ControlValueAccessor,\n NG_VALIDATORS,\n NG_VALUE_ACCESSOR,\n ValidationErrors,\n Validator\n} from '@angular/forms'\nimport {\n injectNbDefaults,\n NbAutocompleteComponent,\n NbAutocompleteDirective,\n NbButtonComponent,\n NbComponentOrCustomStatus,\n NbComponentShape,\n NbComponentSize,\n NbFormFieldComponent,\n NbIconComponent,\n NbInputDirective,\n NbOptionComponent,\n NbPrefixDirective,\n NbValidationDirective\n} from '@liquid-js/lyr-core'\nimport {\n CountryCode,\n getCountries,\n getCountryCallingCode,\n getExampleNumber,\n PhoneNumber\n} from 'libphonenumber-js'\nimport examples from 'libphonenumber-js/mobile/examples'\nimport { FlagComponent, FlagDatabase, FlagDatabaseKey } from 'nxt-flags'\n\nimport { loadCountryNames, NB_COUNTRY_NAMES } from './country-names'\nimport {\n checkPhoneNumber,\n localeCountry,\n NB_PHONE_NUMBER_ERROR,\n parsePhoneNumber,\n phoneNumberContext,\n phoneNumberError\n} from './phone-number.validator'\nimport { injectNbPhoneInputTexts } from './texts'\n\n/** A country in the list. */\ninterface NbPhoneCountry {\n code: CountryCode\n name: string\n callingCode: string\n /** The names, the calling code and the ISO code, as the search compares them. */\n search: string\n}\n\n/**\n * Flags of phone regions that aren't ISO countries: Ascension and Tristan da Cunha are part of Saint Helena, Ascension\n * and Tristan da Cunha (SH), whose flag they show.\n */\nconst flagFallbacks: Partial<Record<CountryCode, FlagDatabaseKey>> = { AC: 'sh', TA: 'sh' }\n\nconst allCountries = new Set<string>(getCountries())\n\n/** Text as the search compares it, without case and accents. */\nconst fold = (text: string) =>\n text\n .normalize('NFD')\n .replace(/\\p{Diacritic}/gu, '')\n .toLocaleLowerCase()\n\n/**\n * A phone number field with the country's flag, which picks the country:\n *\n * ```html\n * <nb-phone-input formControlName=\"phone\" />\n * ```\n *\n * @stacked-example(Showcase, phone-input/phone-input-showcase.component)\n *\n * ### Installation\n *\n * It parses and formats numbers with [`libphonenumber-js`](https://www.npmjs.com/package/libphonenumber-js), names\n * the countries with [`i18n-iso-countries`](https://www.npmjs.com/package/i18n-iso-countries)' language files, and\n * shows flags with [`nxt-flags`](https://www.npmjs.com/package/nxt-flags); install them and import\n * `NbPhoneInputComponent` from `@liquid-js/lyr-extras/phone-input`.\n *\n * ```sh\n * npm install libphonenumber-js i18n-iso-countries nxt-flags\n * ```\n *\n * The flags are images the app serves from `assets/flags`; add them to the assets in `angular.json`:\n *\n * ```json\n * { \"glob\": \"*.svg\", \"input\": \"node_modules/nxt-flags/assets/flags\", \"output\": \"assets/flags\" }\n * ```\n *\n * To serve them from elsewhere, e.g. a CDN, set the path with `provideFlagsPath()` from `nxt-flags`.\n *\n * ### Usage\n *\n * The user types the number in their country's format or with a calling code, e.g. `+44`, which picks the country.\n * The flag button replaces the field with a search of the countries, by name or calling code; Escape goes back.\n * The country is the one of the app's locale (`LOCALE_ID`) until the user or a number picks another, or set it with\n * `country`, which also tells which one is picked. It has the sizes, statuses, shapes and `ghost` look of `nbInput`,\n * and its `placeholder` and `readonly`; the placeholder is an example number of the country by default.\n * @stacked-example(Sizes and statuses, phone-input/phone-input-sizes.component)\n *\n * The value is the number in the `E.164` format, e.g. `+12015550123`, or `null` without one; when the field leaves,\n * it shows the number in its country's format, `(201) 555-0123`. While the text isn't a valid number, the value\n * stays the last valid one, or `null`, and the field has the `nbPhoneNumber` parse error,\n * `{ kind, problem: 'invalid', message }`, as Angular's controls report text they can't parse; so validators never\n * see the text. A number from a country that isn't in `countries`, which the list offers, has the same error with\n * `problem: 'country'`. The errors work in reactive, template-driven and signal forms alike.\n *\n * It works with `formControl`, `formControlName`, `ngModel` and signal forms' `[formField]`.\n * @stacked-example(Validation, phone-input/phone-input-validation.component)\n *\n * ### Validators\n *\n * Phone numbers in other fields, e.g. a text field or data from elsewhere, are checked the same way with validators:\n * `nbPhoneNumberValidator(options)` in reactive forms, the `nbPhoneNumber` attribute in template-driven forms, and\n * `nbPhoneNumber(path, options)` in signal forms. The options are the `country` of numbers without a\n * calling code, the app locale's by default, and the `countries` whose numbers pass, each a value or a function that\n * gives it, and the `message` of the errors, a text or a function of what's wrong, in place of the app's. Their\n * `nbPhoneNumber` error says what's wrong, `invalid` or `country`, with its message.\n *\n * ```ts\n * readonly phone = new FormControl<string | null>(null, nbPhoneNumberValidator({ countries: ['US', 'CA'] }));\n *\n * readonly contactForm = form(this.contact, (path) => {\n * nbPhoneNumber(path.phone, { countries: ['GB'] });\n * });\n * ```\n *\n * ```html\n * <input nbInput type=\"tel\" name=\"support\" ngModel nbPhoneNumber [nbPhoneNumberCountries]=\"['US', 'CA']\" />\n * ```\n *\n * ### Country names\n *\n * The countries are named in English. For other languages, provide the language file of `i18n-iso-countries`, e.g.\n * per locale's build, or loaded by `LOCALE_ID`:\n *\n * ```ts\n * providers: [provideNbCountryNames(() => import('i18n-iso-countries/langs/de.json'))]\n * ```\n *\n * Countries without a name in the file aren't in the list; their numbers are still accepted.\n */\n@Component({\n selector: 'nb-phone-input',\n templateUrl: './phone-input.component.html',\n styleUrl: './phone-input.component.scss',\n encapsulation: ViewEncapsulation.None,\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [\n NbFormFieldComponent,\n NbPrefixDirective,\n NbButtonComponent,\n NbIconComponent,\n NbInputDirective,\n NbAutocompleteDirective,\n NbAutocompleteComponent,\n NbOptionComponent,\n FlagComponent\n ],\n providers: [\n { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => NbPhoneInputComponent), multi: true },\n { provide: NG_VALIDATORS, useExisting: forwardRef(() => NbPhoneInputComponent), multi: true }\n ],\n host: {\n 'class': 'nb-phone-input',\n '[class.full-width]': 'fullWidth()'\n }\n})\nexport class NbPhoneInputComponent implements OnInit, ControlValueAccessor, Validator {\n // The app's defaults for fields, which the inputs below start from.\n protected readonly nbDefaults = injectNbDefaults('input')\n\n protected readonly texts = injectNbPhoneInputTexts()\n /** Where its errors take their messages from. */\n protected readonly errorContext = phoneNumberContext()\n protected readonly locale = inject(LOCALE_ID)\n protected readonly injector = inject(Injector)\n protected readonly validation = inject(NbValidationDirective, { self: true, optional: true })\n\n /**\n * The country of the number: the app locale's country at first, unless it's set, then the one the user or the number\n * picks.\n */\n readonly country = model<CountryCode>()\n /** The countries in the list, whose numbers pass, all by default. */\n readonly countries = input<ReadonlyArray<CountryCode>>()\n /** Field size: `tiny`, `small`, `medium` (default), `large` or `giant`. */\n readonly sizeInput = input<NbComponentSize | undefined>(undefined, { alias: 'size' })\n /** The size in use: the input's, the app's default, or 'medium'. */\n readonly size = linkedSignal<NbComponentSize>(() => this.sizeInput() ?? this.nbDefaults().size ?? 'medium')\n /** Field status: `basic` (default), `primary`, `info`, `success`, `warning`, `danger` or `control`. */\n readonly status = input<NbComponentOrCustomStatus>('basic')\n /** Field shape: `rectangle` (default), `semi-round` or `round`. */\n readonly shapeInput = input<NbComponentShape | undefined>(undefined, { alias: 'shape' })\n /** The shape in use: the input's, the app's default, or 'rectangle'. */\n readonly shape = linkedSignal<NbComponentShape>(() => this.shapeInput() ?? this.nbDefaults().shape ?? 'rectangle')\n readonly fullWidth = input(false, { transform: booleanAttribute })\n /** Shows the field without its background and border, as `nbInput`'s `ghost` does. */\n readonly ghost = input(false, { transform: booleanAttribute })\n readonly disabled = input(false, { transform: booleanAttribute })\n /** Lets the user read and select the number, but not change it or its country, as a read-only field. */\n readonly readonly = input(false, { transform: booleanAttribute })\n /** The number field's placeholder; an example number of the country by default. */\n readonly placeholder = input<string>()\n /** The country list's distance from the search field, as other fields' overlays have it. */\n readonly overlayOffset = input(8)\n /** Names the number field when there's no `aria-labelledby`; \"Phone number\" by default. */\n readonly ariaLabel = input<string | undefined>(undefined, { alias: 'aria-label' })\n /** The id of the element that names the number field, e.g. a `label`. */\n readonly ariaLabelledBy = input<string | undefined>(undefined, { alias: 'aria-labelledby' })\n\n /** What labels the field: its own `aria-labelledby` and an `nbLabel` of its `nbValidation`. */\n protected readonly fieldLabelledBy = computed(\n () => [this.ariaLabelledBy(), this.validation?.labelledBy()].filter(Boolean).join(' ') || null\n )\n\n /** The country the number is parsed in, the locale's until `country` has one. */\n readonly selectedCountry = computed(() => this.country() ?? localeCountry(this.locale))\n\n constructor() {\n // The number field is the control: it gets the validation's ARIA, not the host.\n this.validation?.delegateAria()\n // Another list of countries can change whether the number passes.\n effect(() => {\n this.countries()\n untracked(() => this.onValidatorChange())\n })\n }\n\n ngOnInit() {\n // `country` tells the country the field uses from the start, also when the binding gives none.\n if (!this.country()) {\n this.pickCountry(localeCountry(this.locale))\n }\n }\n\n protected readonly isDisabled = linkedSignal(() => this.disabled())\n protected readonly resolvedStatus = computed(() => this.validation?.status() ?? this.status())\n /** The field's buttons are white on colour, with the `control` status, and grey otherwise. */\n protected readonly buttonStatus = computed(() => (this.resolvedStatus() === 'control' ? 'control' : 'basic'))\n /** The number as the field shows it. */\n protected readonly text = signal('')\n /** Whether the text isn't a valid number. */\n protected readonly parseError = signal(false)\n /** Whether the search of the countries replaces the number field. */\n protected readonly picking = signal(false)\n protected readonly query = signal('')\n protected readonly namesSource = inject(NB_COUNTRY_NAMES)\n protected readonly names = resource({ loader: () => loadCountryNames(this.namesSource) })\n\n /** The countries with a name, in the language's order. */\n protected readonly list = computed(() => {\n const names = this.names.hasValue() ? this.names.value().countries : {}\n const only = this.countries()\n const codes = only ? only.filter((code) => allCountries.has(code)) : (getCountries() as CountryCode[])\n const list = new Array<NbPhoneCountry>()\n for (const code of codes) {\n const name = names[code]\n const all = Array.isArray(name) ? name : name ? [name] : []\n if (all.length) {\n const callingCode = getCountryCallingCode(code)\n list.push({ code, name: all[0], callingCode, search: fold(`${all.join(' ')} +${callingCode} ${code}`) })\n }\n }\n const collator = new Intl.Collator(this.locale)\n return list.sort((a, b) => collator.compare(a.name, b.name))\n })\n\n /** The countries the search finds. */\n protected readonly shown = computed(() => {\n const words = fold(this.query()).split(/\\s+/).filter(Boolean)\n return this.list().filter((country) => words.every((word) => country.search.includes(word)))\n })\n\n protected readonly countryName = computed(() => {\n const code = this.selectedCountry()\n return code && (this.list().find((country) => country.code === code)?.name ?? code)\n })\n\n protected readonly countryLabel = computed(() => {\n const name = this.countryName()\n return name ? this.texts().country(name) : this.texts().noCountry\n })\n\n /** An example number of the country, in its format. */\n protected readonly example = computed(() => {\n const code = this.selectedCountry()\n return code ? (getExampleNumber(code, examples)?.formatNational() ?? '') : ''\n })\n\n protected readonly numberField = viewChild.required<ElementRef<HTMLInputElement>>('number')\n protected readonly searchField = viewChild.required<ElementRef<HTMLInputElement>>('search')\n\n /** The value last given to the form, `null` without one. */\n protected value: string | null = null\n protected onChange: (value: string | null) => void = () => {}\n protected onTouched: () => void = () => {}\n protected onValidatorChange: () => void = () => {}\n\n // Untracked, as forms write values from wherever the app sets them, e.g. an effect that mustn't come to depend\n // on the control.\n writeValue(value?: string | null) {\n untracked(() => {\n const text = value ?? ''\n const number = this.parse(text)\n this.pickCountry(number?.country)\n this.text.set(number ? this.display(number) : text)\n this.value = value ?? null\n this.setParseError(false)\n })\n }\n\n registerOnChange(fn: (value: string | null) => void) {\n this.onChange = fn\n }\n\n registerOnTouched(fn: () => void) {\n this.onTouched = fn\n }\n\n registerOnValidatorChange(fn: () => void) {\n this.onValidatorChange = fn\n }\n\n setDisabledState(disabled: boolean) {\n this.isDisabled.set(disabled)\n }\n\n /** The parse error of text that isn't a valid number, or the error of a number from a country not in `countries`. */\n validate(): ValidationErrors | null {\n const problem = this.parseError()\n ? 'invalid'\n : checkPhoneNumber(this.value, this.selectedCountry(), this.countries())\n return problem ? { [NB_PHONE_NUMBER_ERROR]: phoneNumberError(this.errorContext, problem) } : null\n }\n\n /** Moves focus to the number. */\n focus() {\n this.numberField().nativeElement.focus()\n }\n\n /** Sets `country`, when it's another. */\n protected pickCountry(code?: CountryCode) {\n if (code && code !== this.country()) {\n this.country.set(code)\n }\n }\n\n /** The flag of a country, the unknown flag without one. */\n protected flag(code?: CountryCode): FlagDatabaseKey {\n const key = code?.toLowerCase()\n return (code && flagFallbacks[code]) ?? (key && key in FlagDatabase ? (key as FlagDatabaseKey) : 'xx')\n }\n\n protected typed(event: Event) {\n const text = (event.target as HTMLInputElement).value\n this.text.set(text)\n // A number with a calling code picks its country.\n this.pickCountry(this.parse(text)?.country)\n this.update()\n }\n\n protected left() {\n const number = this.parse(this.text())\n if (number) {\n this.text.set(this.display(number))\n }\n this.onTouched()\n }\n\n /** Replaces the number field with the search of the countries, whose list opens. */\n protected pick() {\n if (this.isDisabled() || this.readonly()) {\n return\n }\n const search = this.searchField().nativeElement\n search.value = ''\n this.query.set('')\n this.picking.set(true)\n afterNextRender(() => search.focus(), { injector: this.injector })\n }\n\n protected searched(event: Event) {\n this.query.set((event.target as HTMLInputElement).value)\n }\n\n protected chose(country?: NbPhoneCountry | string) {\n if (country && typeof country !== 'string') {\n this.country.set(country.code)\n // The text is a number of the new country.\n this.update()\n }\n this.stopPicking(true)\n }\n\n /**\n * Escape in the search goes back to the number, the list closing too; it's handled, so nothing else closes, e.g. a\n * dialog around it.\n */\n protected searchEscaped(event: Event) {\n event.preventDefault()\n this.stopPicking(true)\n }\n\n /** Leaving the search touches the control, as leaving an autocomplete's input does. */\n protected searchLeft() {\n this.stopPicking(false)\n this.onTouched()\n }\n\n /**\n * Shows the number field again, and moves focus to it after Escape or picking a country, which can come after the\n * search field lost focus to the list.\n */\n protected stopPicking(focus: boolean) {\n this.picking.set(false)\n if (focus) {\n afterNextRender(() => this.focus(), { injector: this.injector })\n }\n }\n\n /** What the search field shows: the text typed in it, or the name of the country picked. */\n protected readonly displayCountry = (value?: NbPhoneCountry | string) =>\n typeof value === 'string' ? value : (value?.name ?? '')\n\n /** The valid number in the text, in the picked country unless it has a calling code. */\n protected parse(text: string): PhoneNumber | undefined {\n return parsePhoneNumber(text, this.selectedCountry())\n }\n\n /** A number as the field shows it: in its country's format, or international without one. */\n protected display(number: PhoneNumber) {\n return number.country ? number.formatNational() : number.formatInternational()\n }\n\n /**\n * Gives the form the number in the text, when it's another; while the text isn't a valid number, the value stays\n * and the field has the parse error.\n */\n protected update() {\n const text = this.text().trim()\n const number = text ? this.parse(text) : undefined\n this.setParseError(!!text && !number)\n const value = number?.number ?? null\n if ((!text || number) && value !== this.value) {\n this.value = value\n this.onChange(value)\n }\n // Signal forms only check a value accessor's validators again when they're told to, e.g. for a number of a\n // country `countries` leaves out.\n this.onValidatorChange()\n }\n\n protected setParseError(parseError: boolean) {\n if (parseError !== this.parseError()) {\n this.parseError.set(parseError)\n this.onValidatorChange()\n }\n }\n}\n","<nb-form-field class=\"nb-phone-input-number\"\n [style.display]=\"picking() ? 'none' : null\">\n <button nbPrefix\n nbButton\n ghost\n type=\"button\"\n class=\"nb-phone-input-country\"\n [size]=\"size()\"\n [status]=\"buttonStatus()\"\n [disabled]=\"isDisabled() || readonly()\"\n [attr.aria-label]=\"countryLabel()\"\n (click)=\"pick()\">\n <nxt-flag [country]=\"flag(selectedCountry())\"\n size=\"s\" />\n <nb-icon icon=\"chevron-down-outline\"\n pack=\"essentials\"\n aria-hidden=\"true\" />\n </button>\n <input #number\n nbInput\n type=\"tel\"\n autocomplete=\"tel\"\n [fieldSize]=\"size()\"\n [status]=\"resolvedStatus()\"\n [shape]=\"shape()\"\n [fullWidth]=\"fullWidth()\"\n [ghost]=\"ghost()\"\n [disabled]=\"isDisabled()\"\n [readOnly]=\"readonly()\"\n [value]=\"text()\"\n [placeholder]=\"placeholder() ?? example()\"\n [attr.aria-label]=\"fieldLabelledBy() ? null : (ariaLabel() ?? texts().number)\"\n [attr.aria-labelledby]=\"fieldLabelledBy()\"\n [attr.aria-required]=\"validation?.ariaRequired()\"\n [attr.aria-invalid]=\"validation?.ariaInvalid()\"\n [attr.aria-describedby]=\"validation?.describedBy()\"\n (input)=\"typed($event)\"\n (blur)=\"left()\" />\n</nb-form-field>\n\n<!-- Stays in the page while it's hidden, so the list it opens still takes a click after it loses focus. -->\n<nb-form-field class=\"nb-phone-input-search\"\n [style.display]=\"picking() ? null : 'none'\">\n <nb-icon nbPrefix\n icon=\"search-outline\"\n pack=\"essentials\"\n aria-hidden=\"true\" />\n <input #search\n nbInput\n type=\"text\"\n autocomplete=\"off\"\n [fieldSize]=\"size()\"\n [status]=\"resolvedStatus()\"\n [shape]=\"shape()\"\n [fullWidth]=\"fullWidth()\"\n [ghost]=\"ghost()\"\n [placeholder]=\"texts().search\"\n [attr.aria-label]=\"texts().search\"\n [nbAutocomplete]=\"countryList\"\n [overlayOffset]=\"overlayOffset()\"\n (input)=\"searched($event)\"\n (keydown.escape)=\"searchEscaped($event)\"\n (blur)=\"searchLeft()\" />\n</nb-form-field>\n\n<nb-autocomplete #countryList\n [size]=\"size()\"\n [handleDisplayFn]=\"displayCountry\"\n (selectedChange)=\"chose($event)\">\n @for (country of shown(); track country.code) {\n <nb-option class=\"nb-phone-input-option\"\n [value]=\"country\">\n <nxt-flag [country]=\"flag(country.code)\"\n size=\"s\" />\n <span class=\"nb-phone-input-name\">{{ country.name }}</span>\n <span class=\"nb-phone-input-calling-code\">+{{ country.callingCode }}</span>\n </nb-option>\n }\n</nb-autocomplete>\n","import { Directive, effect, ElementRef, forwardRef, inject, input } from '@angular/core'\nimport { AbstractControl, NG_VALIDATORS, ValidationErrors, Validator } from '@angular/forms'\nimport type { CountryCode } from 'libphonenumber-js'\n\nimport {\n NB_PHONE_NUMBER_ERROR,\n NbPhoneNumberMessage,\n phoneNumberContext,\n validatePhoneNumber\n} from './phone-number.validator'\n\n/**\n * Validates a phone number in template-driven forms, as `nbPhoneNumberValidator` does in reactive forms:\n *\n * ```html\n * <input nbInput type=\"tel\" name=\"phone\" ngModel nbPhoneNumber [nbPhoneNumberCountries]=\"['US', 'CA']\" />\n * ```\n */\n@Directive({\n selector: '[nbPhoneNumber][ngModel],[nbPhoneNumber][formControl],[nbPhoneNumber][formControlName]',\n providers: [{ provide: NG_VALIDATORS, useExisting: forwardRef(() => NbPhoneNumberValidatorDirective), multi: true }],\n host: {\n // On a plain text field, the number reads left to right from the left in any page, as a tel field's does.\n '[style.text-align]': \"isInput ? 'left' : null\",\n '[style.unicode-bidi]': \"isInput ? 'plaintext' : null\"\n }\n})\nexport class NbPhoneNumberValidatorDirective implements Validator {\n /** The country of numbers without a calling code; the app locale's country by default. */\n readonly country = input<CountryCode>(undefined, { alias: 'nbPhoneNumberCountry' })\n /** The countries whose numbers pass, all by default. */\n readonly countries = input<ReadonlyArray<CountryCode>>(undefined, { alias: 'nbPhoneNumberCountries' })\n /** The message of its errors, in place of the app's. */\n readonly message = input<NbPhoneNumberMessage>(undefined, { alias: 'nbPhoneNumberMessage' })\n\n // By tag name, which a server's DOM also has.\n protected readonly isInput = inject<ElementRef<Element>>(ElementRef).nativeElement.tagName === 'INPUT'\n protected readonly context = phoneNumberContext()\n protected onValidatorChange: () => void = () => {}\n\n constructor() {\n // Other options can change whether the value passes.\n effect(() => {\n this.country()\n this.countries()\n this.message()\n this.onValidatorChange()\n })\n }\n\n validate(control: AbstractControl): ValidationErrors | null {\n const error = validatePhoneNumber(\n control.value,\n { country: this.country(), countries: this.countries(), message: this.message() },\n this.context\n )\n return error ? { [NB_PHONE_NUMBER_ERROR]: error } : null\n }\n\n registerOnValidatorChange(fn: () => void) {\n this.onValidatorChange = fn\n }\n}\n"],"mappings":";;;;;;;;AAgBA,MAAa,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