@magmonium/one 0.4.29 → 0.4.31

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.
Files changed (78) hide show
  1. package/assets/docs/en/app-release.md +0 -11
  2. package/assets/i18n/en.json +2 -0
  3. package/fesm2022/magmonium-one-attribute-value-CLBOZcme.mjs +255 -0
  4. package/fesm2022/magmonium-one-attribute-value-CLBOZcme.mjs.map +1 -0
  5. package/fesm2022/magmonium-one-base-checkbox-D7NYJdU3.mjs +77 -0
  6. package/fesm2022/magmonium-one-base-checkbox-D7NYJdU3.mjs.map +1 -0
  7. package/fesm2022/magmonium-one-base-dropdown-CEDsqaPz.mjs +604 -0
  8. package/fesm2022/magmonium-one-base-dropdown-CEDsqaPz.mjs.map +1 -0
  9. package/fesm2022/magmonium-one-base-input-BOaD-WIi.mjs +183 -0
  10. package/fesm2022/magmonium-one-base-input-BOaD-WIi.mjs.map +1 -0
  11. package/fesm2022/magmonium-one-base-text-D6p6_vsb.mjs +94 -0
  12. package/fesm2022/magmonium-one-base-text-D6p6_vsb.mjs.map +1 -0
  13. package/fesm2022/magmonium-one-button-rVNnp6G8.mjs +1281 -0
  14. package/fesm2022/magmonium-one-button-rVNnp6G8.mjs.map +1 -0
  15. package/fesm2022/magmonium-one-checkbox-rj4XHxb3.mjs +365 -0
  16. package/fesm2022/magmonium-one-checkbox-rj4XHxb3.mjs.map +1 -0
  17. package/fesm2022/magmonium-one-color-utl-CirPzUFk.mjs +449 -0
  18. package/fesm2022/magmonium-one-color-utl-CirPzUFk.mjs.map +1 -0
  19. package/fesm2022/magmonium-one-directives-DOBENX_K.mjs +1285 -0
  20. package/fesm2022/magmonium-one-directives-DOBENX_K.mjs.map +1 -0
  21. package/fesm2022/magmonium-one-file.service-Bo06pU3_.mjs +65 -0
  22. package/fesm2022/magmonium-one-file.service-Bo06pU3_.mjs.map +1 -0
  23. package/fesm2022/magmonium-one-group-Cue4x6tD.mjs +428 -0
  24. package/fesm2022/magmonium-one-group-Cue4x6tD.mjs.map +1 -0
  25. package/fesm2022/magmonium-one-header-DPVnaEOV.mjs +380 -0
  26. package/fesm2022/magmonium-one-header-DPVnaEOV.mjs.map +1 -0
  27. package/fesm2022/magmonium-one-icon-Dso-9RMN.mjs +833 -0
  28. package/fesm2022/magmonium-one-icon-Dso-9RMN.mjs.map +1 -0
  29. package/fesm2022/magmonium-one-image-editor-C7AtzEf6.mjs +438 -0
  30. package/fesm2022/magmonium-one-image-editor-C7AtzEf6.mjs.map +1 -0
  31. package/fesm2022/magmonium-one-image-frame-BTSaUSAi.mjs +116 -0
  32. package/fesm2022/magmonium-one-image-frame-BTSaUSAi.mjs.map +1 -0
  33. package/fesm2022/magmonium-one-input-DqHPorA1.mjs +39 -0
  34. package/fesm2022/magmonium-one-input-DqHPorA1.mjs.map +1 -0
  35. package/fesm2022/magmonium-one-label-B30Q4Vut.mjs +574 -0
  36. package/fesm2022/magmonium-one-label-B30Q4Vut.mjs.map +1 -0
  37. package/fesm2022/magmonium-one-m-ref-Dt0DCm8X.mjs +147 -0
  38. package/fesm2022/magmonium-one-m-ref-Dt0DCm8X.mjs.map +1 -0
  39. package/fesm2022/magmonium-one-menu-BBOnOK4M.mjs +887 -0
  40. package/fesm2022/magmonium-one-menu-BBOnOK4M.mjs.map +1 -0
  41. package/fesm2022/magmonium-one-multi-range-DCOwngql.mjs +458 -0
  42. package/fesm2022/magmonium-one-multi-range-DCOwngql.mjs.map +1 -0
  43. package/fesm2022/magmonium-one-options-asset-D8Gg1yNl.mjs +97 -0
  44. package/fesm2022/magmonium-one-options-asset-D8Gg1yNl.mjs.map +1 -0
  45. package/fesm2022/magmonium-one-otp-DLF7Pq94.mjs +261 -0
  46. package/fesm2022/magmonium-one-otp-DLF7Pq94.mjs.map +1 -0
  47. package/fesm2022/magmonium-one-password-BSOU4RI0.mjs +217 -0
  48. package/fesm2022/magmonium-one-password-BSOU4RI0.mjs.map +1 -0
  49. package/fesm2022/magmonium-one-radio-CYnWLXPZ.mjs +111 -0
  50. package/fesm2022/magmonium-one-radio-CYnWLXPZ.mjs.map +1 -0
  51. package/fesm2022/magmonium-one-range-CmmZAr57.mjs +216 -0
  52. package/fesm2022/magmonium-one-range-CmmZAr57.mjs.map +1 -0
  53. package/fesm2022/magmonium-one-rolldown-runtime-DpJrqANO.mjs +11 -0
  54. package/fesm2022/magmonium-one-selector-DDnBYNLr.mjs +1065 -0
  55. package/fesm2022/magmonium-one-selector-DDnBYNLr.mjs.map +1 -0
  56. package/fesm2022/magmonium-one-size-converter-B-UubQQ0.mjs +1057 -0
  57. package/fesm2022/magmonium-one-size-converter-B-UubQQ0.mjs.map +1 -0
  58. package/fesm2022/magmonium-one-text-FXb-RyBh.mjs +406 -0
  59. package/fesm2022/magmonium-one-text-FXb-RyBh.mjs.map +1 -0
  60. package/fesm2022/magmonium-one-text-output-D2XQWyL0.mjs +296 -0
  61. package/fesm2022/magmonium-one-text-output-D2XQWyL0.mjs.map +1 -0
  62. package/fesm2022/magmonium-one-theme-a7GlFbzE.mjs +1 -0
  63. package/fesm2022/magmonium-one-toggle-C0eTrtkt.mjs +231 -0
  64. package/fesm2022/magmonium-one-toggle-C0eTrtkt.mjs.map +1 -0
  65. package/fesm2022/magmonium-one.mjs +49231 -2
  66. package/fesm2022/magmonium-one.mjs.map +1 -1
  67. package/package.json +8 -8
  68. package/types/magmonium-one.d.ts +13801 -9510
  69. package/fesm2022/magmonium-one-image-editor-DYbS7fRP.mjs +0 -290
  70. package/fesm2022/magmonium-one-image-editor-DYbS7fRP.mjs.map +0 -1
  71. package/fesm2022/magmonium-one-magmonium-one-jBGfJvgl.mjs +0 -41576
  72. package/fesm2022/magmonium-one-magmonium-one-jBGfJvgl.mjs.map +0 -1
  73. package/fesm2022/magmonium-one-otp-DY1B1djA.mjs +0 -201
  74. package/fesm2022/magmonium-one-otp-DY1B1djA.mjs.map +0 -1
  75. package/fesm2022/magmonium-one-password-CzMwV84X.mjs +0 -105
  76. package/fesm2022/magmonium-one-password-CzMwV84X.mjs.map +0 -1
  77. package/fesm2022/magmonium-one-toggle-EoE3fKjl.mjs +0 -62
  78. package/fesm2022/magmonium-one-toggle-EoE3fKjl.mjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"magmonium-one-options-asset-D8Gg1yNl.mjs","names":[],"sources":["../../../../libs/one/src/lib/shared/ui/form/directive/options-source.directive.ts","../../../../libs/one/src/lib/shared/ui/input/lib/options-asset.ts"],"sourcesContent":["import { Directive, input } from '@angular/core';\n\n/**\n * Names the AssetOptions list a Field chooses from (CONTEXT.md OptionsSource).\n * The markup spelling of the `optionsAsset:` config key, added beside it rather\n * than in place of it (ADR 0010) — a Field still described by a file keeps\n * declaring the key inside that file.\n *\n * Carries the name and nothing else. Resolution stays where it already lives,\n * in the inputs that read `config.optionsAsset` — the SectionFormItem folds\n * this name into its config, so a Dropdown or a SelectableCard cannot tell\n * which of the two spellings it came from, and there is no second resolver to\n * drift from the first.\n */\n@Directive({\n selector: '[mOptions]',\n})\nexport class OptionsSourceDirective {\n readonly name = input<string | undefined>(undefined, { alias: 'mOptions' });\n}\n","import { computed, effect, inject, Signal, untracked } from '@angular/core';\nimport { rxResource } from '@angular/core/rxjs-interop';\nimport { of } from 'rxjs';\nimport { DropdownOption, DropdownValue } from '../model/input';\nimport { AssetStore } from '../../../stores/asset.store';\nimport { OPTIONS_SOURCE } from '../../../config/tokens';\n// Direct path rather than the form barrel: the barrel pulls in the form's\n// components, which import these inputs back.\nimport { OptionsSourceDirective } from '../../form/directive/options-source.directive';\n\n// One row of a `mag_assets/options/<name>.yml` asset. `id` is accepted\n// alongside `value` because option assets predate the field types that read\n// them, and several were written with `id`.\nexport type AssetOption = {\n id?: string;\n value?: string;\n label: string;\n icon?: string;\n disabled?: boolean;\n default?: boolean;\n};\n\n// Option assets are written either flat or as rows of rows (the same shape a\n// form's `inputs` uses), so both are flattened before mapping.\nexport function normalizeAssetOptions(\n data: AssetOption[] | AssetOption[][] | undefined\n): DropdownOption[] {\n if (!data?.length) return [];\n const flat: AssetOption[] = Array.isArray(data[0])\n ? (data as AssetOption[][]).flat()\n : (data as AssetOption[]);\n return flat.map((option) => ({\n value: option.value ?? option.id ?? '',\n label: option.label,\n icon: option.icon,\n disabled: option.disabled,\n ...(option.default === true ? { default: true } : {}),\n }));\n}\n\n/**\n * The choices an OptionsSource resolves to, for whichever Field reads it —\n * Dropdown, SelectableCard, ToggleRadio. One resolver rather than one per\n * Field: the name means the same list wherever it is written, and a second\n * copy of this would be a second answer that could drift.\n *\n * The name comes from the `mOptions` directive on the Field's tag, which is\n * the spelling of the list key (ADR 0010). An `optionsAsset:` written in a\n * field asset is passed in by the Fields that still read one, and outranks the\n * directive — the nearer declaration wins, same order every other key follows.\n * The directive is injected rather than passed because an input created inside\n * a `m-section-form-item` sits under that item's host, where the directive is.\n *\n * OPTIONS_SOURCE is read ahead of the fetch, so a list held only in memory (a\n * visual editor's unsaved OptionSets) fills the Field without ever being a\n * file. Must be called from an injection context.\n */\nexport function assetOptions(\n name?: () => string | undefined\n): Signal<DropdownOption[]> {\n const assetStore = inject(AssetStore);\n const optionsSource = inject(OPTIONS_SOURCE, { optional: true });\n const directive = inject(OptionsSourceDirective, { optional: true });\n\n const assetName = computed(\n () => name?.()?.trim() || directive?.name()?.trim() || undefined\n );\n\n const suppliedRows = computed(() => {\n const key = assetName();\n if (!key) return undefined;\n const rows = optionsSource?.()?.[key];\n return Array.isArray(rows)\n ? (rows as AssetOption[] | AssetOption[][])\n : undefined;\n });\n\n const resource = rxResource({\n // A supplied list is the answer, so the fetch never starts — asking for a\n // file that exists only in memory would 404 on every keystroke that edits it.\n params: () => (suppliedRows() ? undefined : assetName()),\n stream: ({ params }) => {\n if (!params) return of(undefined);\n return assetStore.resolve<AssetOption[] | AssetOption[][]>(\n 'options',\n params,\n true\n );\n },\n });\n\n return computed(() =>\n normalizeAssetOptions(suppliedRows() ?? resource.value())\n );\n}\n\n/** Whether a Field holds nothing yet — no scalar, an empty string or list. */\nconst isEmptyValue = (value: unknown): boolean =>\n value === undefined ||\n value === null ||\n value === '' ||\n (Array.isArray(value) && value.length === 0);\n\n/**\n * Starts a Field on its list's `default` row when it holds no value of its own\n * (m-one-ui CONTEXT.md OptionSet). The Field's own value — its config, its form\n * data — outranks the row, so a value already held is kept.\n *\n * Each marked row is consulted once: a User who clears the pick is not handed\n * it back, and only a list that moves its mark offers the new row. A disabled\n * row is never preset — the User could not have picked it either. Must be\n * called from an injection context.\n */\nexport function presetDefaultOption(\n options: () => readonly DropdownOption<DropdownValue>[],\n current: () => unknown,\n apply: (value: DropdownValue) => void\n): void {\n let consulted: DropdownValue | undefined;\n effect(() => {\n const row = options().find((option) => option.default && !option.disabled);\n if (!row || row.value === consulted) return;\n consulted = row.value;\n untracked(() => {\n if (isEmptyValue(current())) apply(row.value);\n });\n });\n}\n"],"mappings":";;;;;AAiBA,IAAa,yBAAb,MAAa,uBAAsB;CACxB,OAAO,MAA0B,QAAS;EAAA,GAAA,YAAA,EAAA,WAAA,OAAA,+BAAA,CAAA;EAAI,OAAO;CAAU,CAAA;CAD7D,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAsB,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAtB,OAAA,OAAA,GAAA,qBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,MAAA;EAAsB,cAAA;EAAA,UAAA;EAAA,QAAA,EAAA,MAAA;GAAA,mBAAA;GAAA,YAAA;GAAA,UAAA;GAAA,YAAA;GAAA,mBAAA;EAAA,EAAA;EAAA,UAAA;CAAA,CAAA;;AAAtB,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAsB,YAAA,CAAA;EAHlC,MAAA;EAAU,MAAA,CAAA,EACT,UAAU,aACX,CAAA;;;;;;;;;;;ACQD,SAAgB,sBACd,MAAiD;CAEjD,IAAI,CAAC,MA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IAAI;CACJ,aAAY;EACV,MAAM,MAAM,QAAO,CAAE,CAAC,MAAM,WAAW,OAAO,WAAW,CAAC,OAAO,QAAQ;EACzE,IAAI,CAAC,OAAO,IAAI,UAAU,WAAW;EACrC,YAAY,IAAI;EAChB,gBAAe;GACb,IAAI,aAAa,QAAO,CAAE,GAAG,MAAM,IAAI,KAAK;EAC9C,CAAC;CACH,CAAC;AACH"}
@@ -0,0 +1,261 @@
1
+ import { B as IS_DESIGN_MODE } from "./magmonium-one-size-converter-B-UubQQ0.mjs";
2
+ import { t as LabelComponent } from "./magmonium-one-label-B30Q4Vut.mjs";
3
+ import { t as TextOutputComponent } from "./magmonium-one-text-output-D2XQWyL0.mjs";
4
+ import { t as BaseTextInputComponent } from "./magmonium-one-base-text-D6p6_vsb.mjs";
5
+ import * as i0 from "@angular/core";
6
+ import { ChangeDetectionStrategy, Component, afterRenderEffect, computed, effect, inject, signal, untracked, viewChildren } from "@angular/core";
7
+ import { CommonModule } from "@angular/common";
8
+ var OtpInputComponent = class OtpInputComponent extends BaseTextInputComponent {
9
+ otpValues = signal([], ...ngDevMode ? [{ debugName: "otpValues" }] : /* istanbul ignore next */ []);
10
+ otpInputs = viewChildren("otpInput", ...ngDevMode ? [{ debugName: "otpInputs" }] : /* istanbul ignore next */ []);
11
+ otpConfig = computed(() => this.config(), ...ngDevMode ? [{ debugName: "otpConfig" }] : /* istanbul ignore next */ []);
12
+ otpArray = computed(() => {
13
+ const length = this.otpConfig()?.length || 6;
14
+ return Array(length).fill(0);
15
+ }, ...ngDevMode ? [{ debugName: "otpArray" }] : /* istanbul ignore next */ []);
16
+ isDesignMode = !!inject(IS_DESIGN_MODE, { optional: true });
17
+ isDisabled = computed(() => this.isDesignMode || this.disabled(), ...ngDevMode ? [{ debugName: "isDisabled" }] : /* istanbul ignore next */ []);
18
+ hasAutofocused = false;
19
+ constructor() {
20
+ super();
21
+ effect(() => {
22
+ const length = this.otpConfig()?.length || 6;
23
+ this.otpValues.set(Array(length).fill(""));
24
+ });
25
+ afterRenderEffect(() => {
26
+ const inputs = this.otpInputs();
27
+ if (!this.focused() || !inputs.length || this.hasAutofocused) return;
28
+ this.hasAutofocused = true;
29
+ untracked(() => this.focusInput(0));
30
+ });
31
+ }
32
+ onInput = (event, index) => {
33
+ if (this.isDisabled()) return;
34
+ const input = event.target;
35
+ let value = input.value;
36
+ value = value.replace(/[^a-zA-Z0-9]/g, "");
37
+ if (value.length > 1) value = value.slice(-1);
38
+ input.value = value.toUpperCase();
39
+ const newValues = [...this.otpValues()];
40
+ newValues[index] = value.toUpperCase();
41
+ this.otpValues.set(newValues);
42
+ const length = this.otpConfig()?.length || 6;
43
+ if (value && index < length - 1) this.focusInput(index + 1);
44
+ this.updateValue();
45
+ };
46
+ onKeyDown = (event, index) => {
47
+ if (this.isDisabled()) return;
48
+ const input = event.target;
49
+ const length = this.otpConfig()?.length || 6;
50
+ const isAlphaNumeric = /^[a-zA-Z0-9]$/.test(event.key);
51
+ const isControlKey = [
52
+ "Backspace",
53
+ "Delete",
54
+ "ArrowLeft",
55
+ "ArrowRight",
56
+ "Tab"
57
+ ].includes(event.key);
58
+ if (!isAlphaNumeric && !isControlKey) {
59
+ event.preventDefault();
60
+ return;
61
+ }
62
+ if (event.key === "Backspace") {
63
+ if (!input.value && index > 0) this.focusInput(index - 1);
64
+ }
65
+ if (event.key === "ArrowLeft" && index > 0) {
66
+ event.preventDefault();
67
+ this.focusInput(index - 1);
68
+ }
69
+ if (event.key === "ArrowRight" && index < length - 1) {
70
+ event.preventDefault();
71
+ this.focusInput(index + 1);
72
+ }
73
+ };
74
+ onPaste = (event) => {
75
+ if (this.isDisabled()) return;
76
+ event.preventDefault();
77
+ event.stopPropagation();
78
+ const length = this.otpConfig()?.length || 6;
79
+ const alphanumeric = (event.clipboardData?.getData("text") || "").replace(/[^a-zA-Z0-9]/g, "").slice(0, length);
80
+ if (alphanumeric.length > 0) {
81
+ const newValues = Array(length).fill("");
82
+ alphanumeric.split("").forEach((char, index) => {
83
+ if (index < length) newValues[index] = char.toUpperCase();
84
+ });
85
+ this.otpValues.set(newValues);
86
+ this.updateValue();
87
+ const focusIndex = Math.min(alphanumeric.length, length - 1);
88
+ setTimeout(() => this.focusInput(focusIndex), 0);
89
+ }
90
+ };
91
+ focusInput(index) {
92
+ if (this.isDisabled()) return;
93
+ const inputs = this.otpInputs();
94
+ if (inputs[index]) inputs[index].nativeElement.focus();
95
+ }
96
+ updateValue() {
97
+ const otpValue = this.otpValues().join("");
98
+ this.setValue(otpValue);
99
+ }
100
+ static ɵfac = i0.ɵɵngDeclareFactory({
101
+ minVersion: "12.0.0",
102
+ version: "22.2.1",
103
+ ngImport: i0,
104
+ type: OtpInputComponent,
105
+ deps: [],
106
+ target: i0.ɵɵFactoryTarget.Component
107
+ });
108
+ static ɵcmp = i0.ɵɵngDeclareComponent({
109
+ minVersion: "17.0.0",
110
+ version: "22.2.1",
111
+ type: OtpInputComponent,
112
+ isStandalone: true,
113
+ selector: "m-otp-input",
114
+ viewQueries: [{
115
+ propertyName: "otpInputs",
116
+ predicate: ["otpInput"],
117
+ descendants: true,
118
+ isSignal: true
119
+ }],
120
+ usesInheritance: true,
121
+ ngImport: i0,
122
+ template: `
123
+ @if (otpConfig(); as otp) {
124
+ <m-label
125
+ [for]="otp.name"
126
+ [placeholder]="otp.label"
127
+ [params]="otp.params"
128
+ [required]="required()"
129
+ [disabled]="isDisabled()"
130
+ />
131
+ <div class="otp-container">
132
+ @for (item of otpArray(); track $index) {
133
+ <input
134
+ [id]="$index === 0 ? (otp.name ?? '') : ''"
135
+ #otpInput
136
+ type="text"
137
+ maxlength="1"
138
+ [class.error]="showErrors()"
139
+ [disabled]="isDisabled()"
140
+ [value]="otpValues()[$index] || ''"
141
+ (input)="onInput($event, $index)"
142
+ (keydown)="onKeyDown($event, $index)"
143
+ (paste)="onPaste($event)"
144
+ />
145
+ }
146
+ </div>
147
+ @if (showErrors()) {
148
+ @for (error of errors(); track $index) {
149
+ <m-text-output
150
+ variant="footer"
151
+ color="error"
152
+ [label]="error.message"
153
+ />
154
+ }
155
+ }
156
+ }
157
+ `,
158
+ isInline: true,
159
+ styles: ["@keyframes toggle-pulse{0%,to{transform:scale(1)}50%{transform:scale(1.02)}}@keyframes thumb-slide{0%{transform:translate(0) scale(1)}50%{transform:translate(.3em) scale(.9)}to{transform:translate(.6em) scale(1)}}:host{display:block;width:100%}.otp-container{display:flex;width:100%;justify-content:space-between;gap:var(--m-otp-input-gap, .375em )}.otp-container input{appearance:none;box-sizing:border-box;flex:0 0 auto;width:calc(var(--input-size, 1em) * 2.25);height:calc(var(--input-size, 1em) * 2.25);min-height:calc(var(--input-size, 1em) * 2.25);text-align:center;font-size:var(--input-size, 1em);font-weight:var(--m-otp-input-font-weight, 600);font-family:inherit;color:var(--m-otp-input-color, var(--m-text-input-color, var(--m-text)));background:var(--m-otp-input-background, var(--m-text-input-background, var(--m-background)));border-width:var(--m-otp-input-border-width, var(--m-input-border-width, 2px));border-style:solid;border-color:var(--m-otp-input-border, var(--m-text-input-border, var(--m-input-color, var(--m-mm))));border-radius:var(--m-otp-input-radius, var(--m-input-radius, 4px));transition:var(--m-otp-input-transition, var(--m-text-input-transition, border-color .2s ease, box-shadow .2s ease));text-transform:uppercase;box-shadow:var(--m-text-input-shadow, none)}.otp-container input:hover:not(:disabled):not(.error){border-color:var(--m-otp-input-hover-border, var(--m-text-input-hover-border, color-mix(in srgb, var(--m-input-color, var(--m-mm)) 45%, rgba(0, 0, 0, .12))));background:var(--m-otp-input-hover-background, var(--m-text-input-hover-background, var(--m-text-input-background, var(--m-background))))}.otp-container input:focus{outline:none;border-color:var(--m-otp-input-focus-border, var(--m-text-input-focus-border, color-mix(in srgb, var(--m-focus) 45%, transparent)));box-shadow:var(--m-text-input-shadow, none);background:var(--m-otp-input-focus-background, var(--m-text-input-focus-background, var(--m-text-input-background, var(--m-background))))}.otp-container input.error{border-color:var(--m-error);box-shadow:none}.otp-container input:disabled{background-color:var(--m-frame);cursor:not-allowed;color:var(--m-text-tertiary);border-color:var(--m-border);opacity:.6}\n"],
160
+ dependencies: [
161
+ {
162
+ kind: "component",
163
+ type: LabelComponent,
164
+ selector: "m-label",
165
+ inputs: [
166
+ "for",
167
+ "placeholder",
168
+ "params",
169
+ "required",
170
+ "disabled",
171
+ "color",
172
+ "noTranslate"
173
+ ]
174
+ },
175
+ {
176
+ kind: "component",
177
+ type: TextOutputComponent,
178
+ selector: "m-text-output",
179
+ inputs: [
180
+ "config",
181
+ "align",
182
+ "variant",
183
+ "color",
184
+ "fontWeight",
185
+ "label",
186
+ "noTranslate",
187
+ "params"
188
+ ],
189
+ outputs: ["configChange", "clicked"]
190
+ },
191
+ {
192
+ kind: "ngmodule",
193
+ type: CommonModule
194
+ }
195
+ ],
196
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
197
+ });
198
+ };
199
+ i0.ɵɵngDeclareClassMetadata({
200
+ minVersion: "12.0.0",
201
+ version: "22.2.1",
202
+ ngImport: i0,
203
+ type: OtpInputComponent,
204
+ decorators: [{
205
+ type: Component,
206
+ args: [{
207
+ selector: "m-otp-input",
208
+ template: `
209
+ @if (otpConfig(); as otp) {
210
+ <m-label
211
+ [for]="otp.name"
212
+ [placeholder]="otp.label"
213
+ [params]="otp.params"
214
+ [required]="required()"
215
+ [disabled]="isDisabled()"
216
+ />
217
+ <div class="otp-container">
218
+ @for (item of otpArray(); track $index) {
219
+ <input
220
+ [id]="$index === 0 ? (otp.name ?? '') : ''"
221
+ #otpInput
222
+ type="text"
223
+ maxlength="1"
224
+ [class.error]="showErrors()"
225
+ [disabled]="isDisabled()"
226
+ [value]="otpValues()[$index] || ''"
227
+ (input)="onInput($event, $index)"
228
+ (keydown)="onKeyDown($event, $index)"
229
+ (paste)="onPaste($event)"
230
+ />
231
+ }
232
+ </div>
233
+ @if (showErrors()) {
234
+ @for (error of errors(); track $index) {
235
+ <m-text-output
236
+ variant="footer"
237
+ color="error"
238
+ [label]="error.message"
239
+ />
240
+ }
241
+ }
242
+ }
243
+ `,
244
+ imports: [
245
+ LabelComponent,
246
+ TextOutputComponent,
247
+ CommonModule
248
+ ],
249
+ changeDetection: ChangeDetectionStrategy.OnPush,
250
+ styles: ["@keyframes toggle-pulse{0%,to{transform:scale(1)}50%{transform:scale(1.02)}}@keyframes thumb-slide{0%{transform:translate(0) scale(1)}50%{transform:translate(.3em) scale(.9)}to{transform:translate(.6em) scale(1)}}:host{display:block;width:100%}.otp-container{display:flex;width:100%;justify-content:space-between;gap:var(--m-otp-input-gap, .375em )}.otp-container input{appearance:none;box-sizing:border-box;flex:0 0 auto;width:calc(var(--input-size, 1em) * 2.25);height:calc(var(--input-size, 1em) * 2.25);min-height:calc(var(--input-size, 1em) * 2.25);text-align:center;font-size:var(--input-size, 1em);font-weight:var(--m-otp-input-font-weight, 600);font-family:inherit;color:var(--m-otp-input-color, var(--m-text-input-color, var(--m-text)));background:var(--m-otp-input-background, var(--m-text-input-background, var(--m-background)));border-width:var(--m-otp-input-border-width, var(--m-input-border-width, 2px));border-style:solid;border-color:var(--m-otp-input-border, var(--m-text-input-border, var(--m-input-color, var(--m-mm))));border-radius:var(--m-otp-input-radius, var(--m-input-radius, 4px));transition:var(--m-otp-input-transition, var(--m-text-input-transition, border-color .2s ease, box-shadow .2s ease));text-transform:uppercase;box-shadow:var(--m-text-input-shadow, none)}.otp-container input:hover:not(:disabled):not(.error){border-color:var(--m-otp-input-hover-border, var(--m-text-input-hover-border, color-mix(in srgb, var(--m-input-color, var(--m-mm)) 45%, rgba(0, 0, 0, .12))));background:var(--m-otp-input-hover-background, var(--m-text-input-hover-background, var(--m-text-input-background, var(--m-background))))}.otp-container input:focus{outline:none;border-color:var(--m-otp-input-focus-border, var(--m-text-input-focus-border, color-mix(in srgb, var(--m-focus) 45%, transparent)));box-shadow:var(--m-text-input-shadow, none);background:var(--m-otp-input-focus-background, var(--m-text-input-focus-background, var(--m-text-input-background, var(--m-background))))}.otp-container input.error{border-color:var(--m-error);box-shadow:none}.otp-container input:disabled{background-color:var(--m-frame);cursor:not-allowed;color:var(--m-text-tertiary);border-color:var(--m-border);opacity:.6}\n"]
251
+ }]
252
+ }],
253
+ ctorParameters: () => [],
254
+ propDecorators: { otpInputs: [{
255
+ type: i0.ViewChildren,
256
+ args: ["otpInput", { isSignal: true }]
257
+ }] }
258
+ });
259
+ export { OtpInputComponent };
260
+
261
+ //# sourceMappingURL=magmonium-one-otp-DLF7Pq94.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"magmonium-one-otp-DLF7Pq94.mjs","names":[],"sources":["../../../../libs/one/src/lib/shared/ui/input/ui/text/otp.ts"],"sourcesContent":["import {\n afterRenderEffect,\n ChangeDetectionStrategy,\n Component,\n computed,\n effect,\n ElementRef,\n inject,\n signal,\n untracked,\n viewChildren,\n} from '@angular/core';\nimport { LabelComponent } from '../label';\nimport { TextOutputComponent } from '../../../text-output';\nimport { BaseTextInputComponent } from './base-text';\nimport { CommonModule } from '@angular/common';\nimport { OtpInput } from '../../model/input';\nimport { IS_DESIGN_MODE } from '../../../../config/tokens';\n\n@Component({\n selector: 'm-otp-input',\n template: `\n @if (otpConfig(); as otp) {\n <m-label\n [for]=\"otp.name\"\n [placeholder]=\"otp.label\"\n [params]=\"otp.params\"\n [required]=\"required()\"\n [disabled]=\"isDisabled()\"\n />\n <div class=\"otp-container\">\n @for (item of otpArray(); track $index) {\n <input\n [id]=\"$index === 0 ? (otp.name ?? '') : ''\"\n #otpInput\n type=\"text\"\n maxlength=\"1\"\n [class.error]=\"showErrors()\"\n [disabled]=\"isDisabled()\"\n [value]=\"otpValues()[$index] || ''\"\n (input)=\"onInput($event, $index)\"\n (keydown)=\"onKeyDown($event, $index)\"\n (paste)=\"onPaste($event)\"\n />\n }\n </div>\n @if (showErrors()) {\n @for (error of errors(); track $index) {\n <m-text-output\n variant=\"footer\"\n color=\"error\"\n [label]=\"error.message\"\n />\n }\n }\n }\n `,\n styleUrl: './otp.sass',\n imports: [LabelComponent, TextOutputComponent, CommonModule],\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class OtpInputComponent extends BaseTextInputComponent<OtpInput> {\n otpValues = signal<string[]>([]);\n otpInputs = viewChildren<ElementRef<HTMLInputElement>>('otpInput');\n protected readonly otpConfig = computed(() => this.config() as OtpInput);\n otpArray = computed(() => {\n const length = this.otpConfig()?.length || 6;\n return Array(length).fill(0);\n });\n\n // Inert on the Canvas — other inputs stay idle because they never autofocus;\n // OTP used to steal focus and look live while composing (DesignMode).\n private readonly isDesignMode = !!inject(IS_DESIGN_MODE, { optional: true });\n protected readonly isDisabled = computed(\n () => this.isDesignMode || this.disabled()\n );\n\n // BaseText answers `focused` by focusing its `#inputElement`, and an OTP has\n // none — it has a row of boxes. Without this the caret never lands on an OTP\n // field, so the form that opens on one (login's verification step) reads as\n // dead until the User clicks it.\n private hasAutofocused = false;\n\n constructor() {\n super();\n effect(() => {\n const length = this.otpConfig()?.length || 6;\n this.otpValues.set(Array(length).fill(''));\n });\n\n afterRenderEffect(() => {\n const inputs = this.otpInputs();\n if (!this.focused() || !inputs.length || this.hasAutofocused) return;\n this.hasAutofocused = true;\n untracked(() => this.focusInput(0));\n });\n }\n\n onInput = (event: Event, index: number): void => {\n if (this.isDisabled()) return;\n const input = event.target as HTMLInputElement;\n let value = input.value;\n\n value = value.replace(/[^a-zA-Z0-9]/g, '');\n\n if (value.length > 1) {\n value = value.slice(-1);\n }\n\n input.value = value.toUpperCase();\n\n const newValues = [...this.otpValues()];\n newValues[index] = value.toUpperCase();\n this.otpValues.set(newValues);\n\n const length = this.otpConfig()?.length || 6;\n if (value && index < length - 1) {\n this.focusInput(index + 1);\n }\n this.updateValue();\n };\n\n onKeyDown = (event: KeyboardEvent, index: number): void => {\n if (this.isDisabled()) return;\n const input = event.target as HTMLInputElement;\n const length = this.otpConfig()?.length || 6;\n\n const isAlphaNumeric = /^[a-zA-Z0-9]$/.test(event.key);\n const isControlKey = [\n 'Backspace',\n 'Delete',\n 'ArrowLeft',\n 'ArrowRight',\n 'Tab',\n ].includes(event.key);\n\n if (!isAlphaNumeric && !isControlKey) {\n event.preventDefault();\n return;\n }\n\n if (event.key === 'Backspace') {\n if (!input.value && index > 0) {\n this.focusInput(index - 1);\n }\n }\n if (event.key === 'ArrowLeft' && index > 0) {\n event.preventDefault();\n this.focusInput(index - 1);\n }\n if (event.key === 'ArrowRight' && index < length - 1) {\n event.preventDefault();\n this.focusInput(index + 1);\n }\n };\n\n onPaste = (event: ClipboardEvent): void => {\n if (this.isDisabled()) return;\n event.preventDefault();\n event.stopPropagation();\n\n const length = this.otpConfig()?.length || 6;\n const pastedData = event.clipboardData?.getData('text') || '';\n\n const alphanumeric = pastedData\n .replace(/[^a-zA-Z0-9]/g, '')\n .slice(0, length);\n\n if (alphanumeric.length > 0) {\n const newValues = Array(length).fill('');\n alphanumeric.split('').forEach((char, index) => {\n if (index < length) {\n newValues[index] = char.toUpperCase();\n }\n });\n\n this.otpValues.set(newValues);\n this.updateValue();\n\n const focusIndex = Math.min(alphanumeric.length, length - 1);\n setTimeout(() => this.focusInput(focusIndex), 0);\n }\n };\n\n private focusInput(index: number): void {\n if (this.isDisabled()) return;\n const inputs = this.otpInputs();\n if (inputs[index]) {\n inputs[index].nativeElement.focus();\n }\n }\n\n private updateValue(): void {\n const otpValue = this.otpValues().join('');\n this.setValue(otpValue);\n }\n}\n"],"mappings":";;;;;;;AA6DA,IAAa,oBAAb,MAAa,0BAA0B,uBAAgC;CACrE,YAAY,OAAiB,CAAA,GAAG,GAAA,YAAA,CAAA,EAAA,WAAA,YAAA,CAAA,+BAAA,CAAA,CAAA;CAChC,YAAY,aAA2C,YAAW,GAAA,YAAA,CAAA,EAAA,WAAA,YAAA,CAAA,+BAAA,CAAA,CAAA;CAC/C,YAAY,eAAe,KAAK,OAAM,GAAe,GAAA,YAAA,CAAA,EAAA,WAAA,YAAA,CAAA,+BAAA,CAAA,CAAA;CACxE,WAAW,eAAc;EACvB,MAAM,SAAS,KAAK,UAAS,CAAE,EAAE,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AM,QAAA,CAAA,+qEAAA;EAAA,CAAA;CAIQ,CAAA;CAAA,sBAAA,CAAA;CAAA,gBAAA,EAAA,WAAA,CAAA;EAAA,MAAA,GAAA;EAAA,MAAA,CAAA,YAAU,EAAA,UAAA,KAAA,CAAA;CAAA,CAAA,EAAA;AAAA,CAAA"}
@@ -0,0 +1,217 @@
1
+ import { c as TranslatePipe } from "./magmonium-one-size-converter-B-UubQQ0.mjs";
2
+ import { t as LabelComponent } from "./magmonium-one-label-B30Q4Vut.mjs";
3
+ import { t as ButtonComponent } from "./magmonium-one-button-rVNnp6G8.mjs";
4
+ import { t as TextOutputComponent } from "./magmonium-one-text-output-D2XQWyL0.mjs";
5
+ import { t as BaseTextInputComponent } from "./magmonium-one-base-text-D6p6_vsb.mjs";
6
+ import * as i0 from "@angular/core";
7
+ import { ChangeDetectionStrategy, Component, computed, signal } from "@angular/core";
8
+ var PasswordInputComponent = class PasswordInputComponent extends BaseTextInputComponent {
9
+ isPassword = signal(true, ...ngDevMode ? [{ debugName: "isPassword" }] : /* istanbul ignore next */ []);
10
+ type = computed(() => this.isPassword() ? "password" : "text", ...ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []);
11
+ button = computed(() => !this.isPassword() ? "eye" : "eye_close", ...ngDevMode ? [{ debugName: "button" }] : /* istanbul ignore next */ []);
12
+ toggleType() {
13
+ this.isPassword.update((now) => !now);
14
+ }
15
+ onInput(event) {
16
+ const target = event.target;
17
+ this.setValue(target?.value ?? "");
18
+ }
19
+ static ɵfac = i0.ɵɵngDeclareFactory({
20
+ minVersion: "12.0.0",
21
+ version: "22.2.1",
22
+ ngImport: i0,
23
+ type: PasswordInputComponent,
24
+ deps: null,
25
+ target: i0.ɵɵFactoryTarget.Component
26
+ });
27
+ static ɵcmp = i0.ɵɵngDeclareComponent({
28
+ minVersion: "17.0.0",
29
+ version: "22.2.1",
30
+ type: PasswordInputComponent,
31
+ isStandalone: true,
32
+ selector: "m-password-input",
33
+ usesInheritance: true,
34
+ ngImport: i0,
35
+ template: `
36
+ @if (config(); as text) {
37
+ <m-label
38
+ [for]="text.name"
39
+ [placeholder]="text.label"
40
+ [params]="text.params"
41
+ [required]="required()"
42
+ [disabled]="disabled()"
43
+ />
44
+ <div class="input-wrapper">
45
+ <input
46
+ [id]="text.name ?? ''"
47
+ [attr.data-testid]="text.testid ?? (text.name ? text.name + '-input' : null)"
48
+ [value]="value()"
49
+ #inputElement
50
+ [class.error]="showErrors()"
51
+ [disabled]="disabled()"
52
+ [placeholder]="(text.placeholder ?? '') | translate: text.params"
53
+ (input)="onInput($event)"
54
+ (focus)="isFocused.set(true)"
55
+ (blur)="isFocused.set(false); touched.set(true)"
56
+ [type]="type()"
57
+ />
58
+ <m-one-button
59
+ type="button"
60
+ [disabled]="disabled()"
61
+ [name]="button()"
62
+ [color]="iconColor()"
63
+ (clicked)="toggleType()"
64
+ />
65
+ </div>
66
+ @if (showErrors()) {
67
+ @for (error of errors(); track $index) {
68
+ <m-text-output
69
+ variant="footer"
70
+ color="error"
71
+ [label]="error.message"
72
+ />
73
+ }
74
+ }
75
+ }
76
+ `,
77
+ isInline: true,
78
+ styles: ["@keyframes toggle-pulse{0%,to{transform:scale(1)}50%{transform:scale(1.02)}}@keyframes thumb-slide{0%{transform:translate(0) scale(1)}50%{transform:translate(.3em) scale(.9)}to{transform:translate(.6em) scale(1)}}:host{display:block;width:100%}.input-wrapper{display:flex;align-items:center;background:var(--m-background);overflow:hidden;height:calc(var(--input-size, 1em) * 2);min-height:calc(var(--input-size, 1em) * 2);border-width:max(1px,var(--input-size, 1em) * .0625);border-radius:calc(var(--input-size, 1em) * .4);padding:calc(var(--input-size, 1em) * .5) calc(var(--input-size, 1em) * .5);gap:calc(var(--input-size, 1em) * .375);font-size:var(--input-size, 1em);border-width:var(--m-input-border-width, 1px);border-radius:var(--m-input-radius, calc(var(--input-size, 1em) * .5));height:calc(var(--input-size, 1em) * 2.25);min-height:calc(var(--input-size, 1em) * 2.25);padding-top:0;padding-bottom:0;border-color:var(--m-input-color, var(--m-mm));transition:border-color .2s ease,box-shadow .2s ease,background-color .2s ease,opacity .2s ease}.input-wrapper:hover:not(:disabled){background-color:color-mix(in srgb,var(--m-input-color, var(--m-mm)) 6%,transparent)}.input-wrapper:disabled{opacity:.6;cursor:not-allowed}.input-wrapper{border-style:solid;backdrop-filter:var(--m-text-input-backdrop-filter, none);-webkit-backdrop-filter:var(--m-text-input-backdrop-filter, none);box-shadow:var(--m-text-input-shadow, none)}.input-wrapper:has(>m-one-button,>m-button,>.input-indicator,>.input-suffix,>m-icon:last-child){padding-right:0}.input-wrapper:focus-visible:not(:disabled),.input-wrapper:focus-within:not(:disabled){border-color:var(--m-text-input-focus-border, var(--m-focus));box-shadow:none}.input-wrapper:has(.warning){border-color:var(--m-input-warning-border, var(--m-warning));background:var(--m-input-warning-background, color-mix(in srgb, var(--m-warning) 6%, var(--m-background)));box-shadow:none}.input-wrapper:has(.warning):focus-within{border-color:var(--m-input-warning-border, var(--m-warning));background:var(--m-input-warning-background, color-mix(in srgb, var(--m-warning) 6%, var(--m-background)))}.input-wrapper:has(.warning) input::placeholder,.input-wrapper:has(.warning) textarea::placeholder{color:var(--m-warning, var(--m-warning))}.input-wrapper:has(.error){border-color:var(--m-error);background:var(--m-input-error-background, color-mix(in srgb, var(--m-error) 5%, var(--m-background)));box-shadow:none}.input-wrapper:has(.error):focus-within{border-color:var(--m-error);background:var(--m-input-error-background, color-mix(in srgb, var(--m-error) 5%, var(--m-background)));box-shadow:none}.input-wrapper input::placeholder,.input-wrapper textarea::placeholder{color:var(--m-border, var(--m-border))}.input-wrapper:focus-within input::placeholder,.input-wrapper:focus-visible input::placeholder,.input-wrapper:focus-within textarea::placeholder,.input-wrapper:focus-visible textarea::placeholder{color:var(--m-focus, var(--m-focus))}.input-wrapper:has(.error) input::placeholder,.input-wrapper:has(.error) textarea::placeholder{color:var(--m-error, var(--m-error))}.input-wrapper input,.input-wrapper textarea{flex:1;border:none;outline:none;background:transparent;color:var(--m-text);font-family:inherit;font-size:inherit;padding:0}.input-wrapper input:focus,.input-wrapper textarea:focus{border-color:transparent;box-shadow:none}.input-wrapper{width:100%;padding-left:var(--m-password-input-padding-left, var(--m-label-required-space, .75em));background:var(--m-password-input-background, var(--m-background));border-color:var(--m-password-input-border, var(--m-input-color, var(--m-mm)))}.input-wrapper:hover:not(:has(.error)){border-color:var(--m-password-input-hover-border, color-mix(in srgb, var(--m-input-color, var(--m-mm)) 45%, rgba(0, 0, 0, .12)))}.input-wrapper .m-icon{--m-icon-size: 1.1em !important}.input-wrapper input{appearance:none;font-size:1em}.input-wrapper .m-one-button{height:100%;display:flex;align-items:center;justify-content:center;--m-button-size: 1em !important}\n"],
79
+ dependencies: [
80
+ {
81
+ kind: "component",
82
+ type: LabelComponent,
83
+ selector: "m-label",
84
+ inputs: [
85
+ "for",
86
+ "placeholder",
87
+ "params",
88
+ "required",
89
+ "disabled",
90
+ "color",
91
+ "noTranslate"
92
+ ]
93
+ },
94
+ {
95
+ kind: "component",
96
+ type: TextOutputComponent,
97
+ selector: "m-text-output",
98
+ inputs: [
99
+ "config",
100
+ "align",
101
+ "variant",
102
+ "color",
103
+ "fontWeight",
104
+ "label",
105
+ "noTranslate",
106
+ "params"
107
+ ],
108
+ outputs: ["configChange", "clicked"]
109
+ },
110
+ {
111
+ kind: "component",
112
+ type: ButtonComponent,
113
+ selector: "m-button,m-one-button",
114
+ inputs: [
115
+ "config",
116
+ "color",
117
+ "labelClass",
118
+ "fullWidth",
119
+ "nav",
120
+ "navParams",
121
+ "href",
122
+ "disabled",
123
+ "variant",
124
+ "name",
125
+ "baseUrl",
126
+ "one",
127
+ "remote",
128
+ "label",
129
+ "noTranslate",
130
+ "params",
131
+ "noNative",
132
+ "icon",
133
+ "isRightIcon",
134
+ "iconOnly",
135
+ "stacked",
136
+ "imgSrc",
137
+ "nonClickable",
138
+ "inverted",
139
+ "isSubmit",
140
+ "tabindex"
141
+ ],
142
+ outputs: ["configChange", "clicked"]
143
+ },
144
+ {
145
+ kind: "pipe",
146
+ type: TranslatePipe,
147
+ name: "translate"
148
+ }
149
+ ],
150
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
151
+ });
152
+ };
153
+ i0.ɵɵngDeclareClassMetadata({
154
+ minVersion: "12.0.0",
155
+ version: "22.2.1",
156
+ ngImport: i0,
157
+ type: PasswordInputComponent,
158
+ decorators: [{
159
+ type: Component,
160
+ args: [{
161
+ selector: "m-password-input",
162
+ template: `
163
+ @if (config(); as text) {
164
+ <m-label
165
+ [for]="text.name"
166
+ [placeholder]="text.label"
167
+ [params]="text.params"
168
+ [required]="required()"
169
+ [disabled]="disabled()"
170
+ />
171
+ <div class="input-wrapper">
172
+ <input
173
+ [id]="text.name ?? ''"
174
+ [attr.data-testid]="text.testid ?? (text.name ? text.name + '-input' : null)"
175
+ [value]="value()"
176
+ #inputElement
177
+ [class.error]="showErrors()"
178
+ [disabled]="disabled()"
179
+ [placeholder]="(text.placeholder ?? '') | translate: text.params"
180
+ (input)="onInput($event)"
181
+ (focus)="isFocused.set(true)"
182
+ (blur)="isFocused.set(false); touched.set(true)"
183
+ [type]="type()"
184
+ />
185
+ <m-one-button
186
+ type="button"
187
+ [disabled]="disabled()"
188
+ [name]="button()"
189
+ [color]="iconColor()"
190
+ (clicked)="toggleType()"
191
+ />
192
+ </div>
193
+ @if (showErrors()) {
194
+ @for (error of errors(); track $index) {
195
+ <m-text-output
196
+ variant="footer"
197
+ color="error"
198
+ [label]="error.message"
199
+ />
200
+ }
201
+ }
202
+ }
203
+ `,
204
+ imports: [
205
+ LabelComponent,
206
+ TextOutputComponent,
207
+ ButtonComponent,
208
+ TranslatePipe
209
+ ],
210
+ changeDetection: ChangeDetectionStrategy.OnPush,
211
+ styles: ["@keyframes toggle-pulse{0%,to{transform:scale(1)}50%{transform:scale(1.02)}}@keyframes thumb-slide{0%{transform:translate(0) scale(1)}50%{transform:translate(.3em) scale(.9)}to{transform:translate(.6em) scale(1)}}:host{display:block;width:100%}.input-wrapper{display:flex;align-items:center;background:var(--m-background);overflow:hidden;height:calc(var(--input-size, 1em) * 2);min-height:calc(var(--input-size, 1em) * 2);border-width:max(1px,var(--input-size, 1em) * .0625);border-radius:calc(var(--input-size, 1em) * .4);padding:calc(var(--input-size, 1em) * .5) calc(var(--input-size, 1em) * .5);gap:calc(var(--input-size, 1em) * .375);font-size:var(--input-size, 1em);border-width:var(--m-input-border-width, 1px);border-radius:var(--m-input-radius, calc(var(--input-size, 1em) * .5));height:calc(var(--input-size, 1em) * 2.25);min-height:calc(var(--input-size, 1em) * 2.25);padding-top:0;padding-bottom:0;border-color:var(--m-input-color, var(--m-mm));transition:border-color .2s ease,box-shadow .2s ease,background-color .2s ease,opacity .2s ease}.input-wrapper:hover:not(:disabled){background-color:color-mix(in srgb,var(--m-input-color, var(--m-mm)) 6%,transparent)}.input-wrapper:disabled{opacity:.6;cursor:not-allowed}.input-wrapper{border-style:solid;backdrop-filter:var(--m-text-input-backdrop-filter, none);-webkit-backdrop-filter:var(--m-text-input-backdrop-filter, none);box-shadow:var(--m-text-input-shadow, none)}.input-wrapper:has(>m-one-button,>m-button,>.input-indicator,>.input-suffix,>m-icon:last-child){padding-right:0}.input-wrapper:focus-visible:not(:disabled),.input-wrapper:focus-within:not(:disabled){border-color:var(--m-text-input-focus-border, var(--m-focus));box-shadow:none}.input-wrapper:has(.warning){border-color:var(--m-input-warning-border, var(--m-warning));background:var(--m-input-warning-background, color-mix(in srgb, var(--m-warning) 6%, var(--m-background)));box-shadow:none}.input-wrapper:has(.warning):focus-within{border-color:var(--m-input-warning-border, var(--m-warning));background:var(--m-input-warning-background, color-mix(in srgb, var(--m-warning) 6%, var(--m-background)))}.input-wrapper:has(.warning) input::placeholder,.input-wrapper:has(.warning) textarea::placeholder{color:var(--m-warning, var(--m-warning))}.input-wrapper:has(.error){border-color:var(--m-error);background:var(--m-input-error-background, color-mix(in srgb, var(--m-error) 5%, var(--m-background)));box-shadow:none}.input-wrapper:has(.error):focus-within{border-color:var(--m-error);background:var(--m-input-error-background, color-mix(in srgb, var(--m-error) 5%, var(--m-background)));box-shadow:none}.input-wrapper input::placeholder,.input-wrapper textarea::placeholder{color:var(--m-border, var(--m-border))}.input-wrapper:focus-within input::placeholder,.input-wrapper:focus-visible input::placeholder,.input-wrapper:focus-within textarea::placeholder,.input-wrapper:focus-visible textarea::placeholder{color:var(--m-focus, var(--m-focus))}.input-wrapper:has(.error) input::placeholder,.input-wrapper:has(.error) textarea::placeholder{color:var(--m-error, var(--m-error))}.input-wrapper input,.input-wrapper textarea{flex:1;border:none;outline:none;background:transparent;color:var(--m-text);font-family:inherit;font-size:inherit;padding:0}.input-wrapper input:focus,.input-wrapper textarea:focus{border-color:transparent;box-shadow:none}.input-wrapper{width:100%;padding-left:var(--m-password-input-padding-left, var(--m-label-required-space, .75em));background:var(--m-password-input-background, var(--m-background));border-color:var(--m-password-input-border, var(--m-input-color, var(--m-mm)))}.input-wrapper:hover:not(:has(.error)){border-color:var(--m-password-input-hover-border, color-mix(in srgb, var(--m-input-color, var(--m-mm)) 45%, rgba(0, 0, 0, .12)))}.input-wrapper .m-icon{--m-icon-size: 1.1em !important}.input-wrapper input{appearance:none;font-size:1em}.input-wrapper .m-one-button{height:100%;display:flex;align-items:center;justify-content:center;--m-button-size: 1em !important}\n"]
212
+ }]
213
+ }]
214
+ });
215
+ export { PasswordInputComponent };
216
+
217
+ //# sourceMappingURL=magmonium-one-password-BSOU4RI0.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"magmonium-one-password-BSOU4RI0.mjs","names":[],"sources":["../../../../libs/one/src/lib/shared/ui/input/ui/text/password.ts"],"sourcesContent":["import {\n ChangeDetectionStrategy,\n Component,\n computed,\n signal,\n} from '@angular/core';\nimport { LabelComponent } from '../label';\nimport { TextOutputComponent } from '../../../text-output';\nimport { BaseTextInputComponent } from './base-text';\nimport { ButtonComponent } from '../../../button/ui/button';\nimport { TranslatePipe } from '../../../../pipe';\n\n@Component({\n selector: 'm-password-input',\n template: `\n @if (config(); as text) {\n <m-label\n [for]=\"text.name\"\n [placeholder]=\"text.label\"\n [params]=\"text.params\"\n [required]=\"required()\"\n [disabled]=\"disabled()\"\n />\n <div class=\"input-wrapper\">\n <input\n [id]=\"text.name ?? ''\"\n [attr.data-testid]=\"text.testid ?? (text.name ? text.name + '-input' : null)\"\n [value]=\"value()\"\n #inputElement\n [class.error]=\"showErrors()\"\n [disabled]=\"disabled()\"\n [placeholder]=\"(text.placeholder ?? '') | translate: text.params\"\n (input)=\"onInput($event)\"\n (focus)=\"isFocused.set(true)\"\n (blur)=\"isFocused.set(false); touched.set(true)\"\n [type]=\"type()\"\n />\n <m-one-button\n type=\"button\"\n [disabled]=\"disabled()\"\n [name]=\"button()\"\n [color]=\"iconColor()\"\n (clicked)=\"toggleType()\"\n />\n </div>\n @if (showErrors()) {\n @for (error of errors(); track $index) {\n <m-text-output\n variant=\"footer\"\n color=\"error\"\n [label]=\"error.message\"\n />\n }\n }\n }\n `,\n imports: [LabelComponent, TextOutputComponent, ButtonComponent, TranslatePipe],\n styleUrl: './password.sass',\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class PasswordInputComponent extends BaseTextInputComponent {\n isPassword = signal<boolean>(true);\n type = computed(() => (this.isPassword() ? 'password' : 'text'));\n button = computed(() => (!this.isPassword() ? 'eye' : 'eye_close'));\n\n protected toggleType() {\n this.isPassword.update((now) => !now);\n }\n\n protected onInput(event: Event): void {\n const target = event.target as HTMLInputElement;\n this.setValue(target?.value ?? '');\n }\n}\n"],"mappings":";;;;;;;AA4DA,IAAa,yBAAb,MAAa,+BAA+B,uBAAsB;CAChE,aAAa,OAAgB,MAAK,GAAA,YAAA,CAAA,EAAA,WAAA,aAAA,CAAA,+BAAA,CAAA,CAAA;CAClC,OAAO,eAAgB,KAAK,WAAU,IAAK,aAAa,QAAQ,GAAA,YAAA,CAAA,EAAA,WAAA,OAAA,CAAA,+BAAA,CAAA,CAAA;CAChE,SAAS,eAAgB,CA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