@internetarchive/elements 0.2.11 → 0.2.12-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -87,9 +87,15 @@ Add to Jest config:
|
|
|
87
87
|
|
|
88
88
|
## Development
|
|
89
89
|
|
|
90
|
+
Requires Node 24+ and pnpm 11+. `engine-strict=true` in `.npmrc` makes an older
|
|
91
|
+
Node fail the install instead of warning, but nothing hard-blocks `npm install`:
|
|
92
|
+
npm ignores `engines.pnpm`, and there's deliberately no preinstall guard since it
|
|
93
|
+
would run for consumers too. Use pnpm. `packageManager` and the committed
|
|
94
|
+
`pnpm-lock.yaml` are what point you at it.
|
|
95
|
+
|
|
90
96
|
```zsh
|
|
91
|
-
|
|
92
|
-
|
|
97
|
+
pnpm install
|
|
98
|
+
pnpm run dev
|
|
93
99
|
```
|
|
94
100
|
|
|
95
101
|
## Versioning and Publishing
|
|
@@ -97,10 +103,10 @@ npm run dev
|
|
|
97
103
|
### Prerelease Version
|
|
98
104
|
|
|
99
105
|
1. Create prerelease version on your branch:
|
|
100
|
-
1. `
|
|
106
|
+
1. `pnpm version prerelease --preid=<some_prefix>`
|
|
101
107
|
2. If you use JIRA, recommend using the ticket number, ie `--preid=webdev-1234`
|
|
102
108
|
3. This will also create a `git` tag
|
|
103
|
-
2. Push the tag that was created in the `
|
|
109
|
+
2. Push the tag that was created in the `pnpm version` step
|
|
104
110
|
3. Publish prerelease to npm:
|
|
105
111
|
1. Go to the [Element release page](https://github.com/internetarchive/elements/releases)
|
|
106
112
|
2. Tap `Draft a new release` button
|
|
@@ -113,7 +119,7 @@ npm run dev
|
|
|
113
119
|
|
|
114
120
|
1. Use [Semantic Versioning](https://semver.org) to determine release number
|
|
115
121
|
2. On the `main` branch:
|
|
116
|
-
1. Run `
|
|
122
|
+
1. Run `pnpm version [major | minor | patch]`
|
|
117
123
|
2. `git push && git push --tags`
|
|
118
124
|
3. Publish release to npm:
|
|
119
125
|
1. Go to the [Element release page](https://github.com/internetarchive/elements/releases)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ia-otp-input.d.ts","sourceRoot":"","sources":["../../../../src/elements/ia-otp-input/ia-otp-input.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EACV,cAAc,EACd,cAAc,EAEd,cAAc,EACf,MAAM,KAAK,CAAC;AAcb;;;;GAIG;AACH,qBACa,UAAW,SAAQ,UAAU;IAGxC,YAAY,CAAC,EAAE,MAAM,CAAC;IAItB,QAAQ,EAAE,OAAO,CAAS;IAI1B,QAAQ,EAAE,MAAM,CAAK;IAIrB,WAAW,EAAE,OAAO,CAAQ;IAI5B,OAAO,CAAC,YAAY,CAAyB;IAI7C,OAAO,CAAC,MAAM,CAAgC;IAE9C,MAAM,IAAI,cAAc;IAmBxB,SAAS,CAAC,YAAY,IAAI,IAAI;IAI9B,SAAS,CAAC,UAAU,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI;IAYnD,OAAO,CAAC,WAAW;IAoBnB,OAAO,CAAC,aAAa;IAmCrB;;OAEG;IACH,OAAO,CAAC,WAAW;IAOnB;;;OAGG;IACH,OAAO,CAAC,UAAU;
|
|
1
|
+
{"version":3,"file":"ia-otp-input.d.ts","sourceRoot":"","sources":["../../../../src/elements/ia-otp-input/ia-otp-input.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EACV,cAAc,EACd,cAAc,EAEd,cAAc,EACf,MAAM,KAAK,CAAC;AAcb;;;;GAIG;AACH,qBACa,UAAW,SAAQ,UAAU;IAGxC,YAAY,CAAC,EAAE,MAAM,CAAC;IAItB,QAAQ,EAAE,OAAO,CAAS;IAI1B,QAAQ,EAAE,MAAM,CAAK;IAIrB,WAAW,EAAE,OAAO,CAAQ;IAI5B,OAAO,CAAC,YAAY,CAAyB;IAI7C,OAAO,CAAC,MAAM,CAAgC;IAE9C,MAAM,IAAI,cAAc;IAmBxB,SAAS,CAAC,YAAY,IAAI,IAAI;IAI9B,SAAS,CAAC,UAAU,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI;IAYnD,OAAO,CAAC,WAAW;IAoBnB,OAAO,CAAC,aAAa;IAmCrB;;OAEG;IACH,OAAO,CAAC,WAAW;IAOnB;;;OAGG;IACH,OAAO,CAAC,UAAU;IAyBlB,yDAAyD;IACzD,OAAO,CAAC,WAAW;IAKnB,6DAA6D;IAC7D,OAAO,CAAC,oBAAoB;IAU5B,OAAO,CAAC,aAAa;IAUrB,MAAM,KAAK,MAAM,IAAI,cAAc,CA4BlC;CACF"}
|
|
@@ -122,6 +122,8 @@ let IAOTPInput = class IAOTPInput extends LitElement {
|
|
|
122
122
|
* Submits the result if enough characters are filled.
|
|
123
123
|
*/
|
|
124
124
|
fillInputs(value) {
|
|
125
|
+
if (typeof value !== 'string')
|
|
126
|
+
value = String(value ?? '');
|
|
125
127
|
if (value === '')
|
|
126
128
|
this.clearInputs();
|
|
127
129
|
const charsToFill = value
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ia-otp-input.js","sourceRoot":"","sources":["../../../../src/elements/ia-otp-input/ia-otp-input.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,IAAI,EACJ,UAAU,EAGV,GAAG,GAEJ,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,WAAW,MAAM,0BAA0B,CAAC;AAEnD;;GAEG;AACH,MAAM,MAAM,GAAG;IACb,aAAa,EAAE,eAAe;CAC/B,CAAC;AAEF,MAAM,aAAa,GAAG,UAAU,CAAC;AACjC,MAAM,kBAAkB,GAAG,gBAAgB,CAAC;AAE5C;;;;GAIG;AAEI,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,UAAU;IAAnC;;QAKL,mCAAmC;QAEnC,aAAQ,GAAY,KAAK,CAAC;QAE1B,qDAAqD;QAErD,aAAQ,GAAW,CA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,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDACL;AAItB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;4CACF;AAI1B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CACN;AAIrB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;+CACA;AAIpB;IADP,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDACkB;AAIrC;IADP,QAAQ,CAAC,OAAO,CAAC;0CAC4B;AAvBnC,UAAU;IADtB,aAAa,CAAC,cAAc,CAAC;GACjB,UAAU,CAgNtB","sourcesContent":["import {\n html,\n LitElement,\n TemplateResult,\n CSSResultGroup,\n css,\n PropertyValues,\n} from 'lit';\nimport { property, customElement, queryAll } from 'lit/decorators.js';\nimport themeStyles from '@src/themes/theme-styles';\n\n/**\n * Custom event options for the component\n */\nconst Events = {\n CodeSubmitted: 'codeSubmitted',\n};\n\nconst NUMERIC_REGEX = /^[0-9]+$/;\nconst ALPHANUMERIC_REGEX = /^[a-zA-Z0-9]+$/;\n\n/**\n * Renders an input for OTP entry, which combines a series of separate\n * inputs into one, shifting focus as needed and handling paste and backspace\n * events.\n */\n@customElement('ia-otp-input')\nexport class IAOTPInput extends LitElement {\n /* An optional value to prefill the inputs with */\n @property({ type: String })\n prefillValue?: string;\n\n /* Whether to disable all inputs */\n @property({ type: Boolean })\n disabled: boolean = false;\n\n /* Number of characters to expect for the passcode */\n @property({ type: Number })\n numChars: number = 6;\n\n /* Whether to restrict entry to numeric characters */\n @property({ type: Boolean })\n numericOnly: boolean = true;\n\n /* Regex for allowed characters. Updates based on numeric only */\n @property({ type: Object })\n private allowedChars: RegExp = NUMERIC_REGEX;\n\n /* Array of OTP inputs */\n @queryAll('input')\n private inputs!: NodeListOf<HTMLInputElement>;\n\n render(): TemplateResult {\n return html`\n ${[...Array(this.numChars).keys()].map(\n (i) =>\n html`<input\n id=\"OTP-input-${i}\"\n part=\"input\"\n type=\"text\"\n autocomplete=${i === 0 ? 'one-time-code' : 'off'}\n inputmode=${this.numericOnly ? 'numeric' : 'text'}\n ?disabled=${this.disabled}\n @beforeinput=${this.handleInput}\n @paste=${this.handlePaste}\n @keydown=${this.handleKeydown}\n />`,\n )}\n `;\n }\n\n protected firstUpdated(): void {\n this.inputs[0].focus();\n }\n\n protected willUpdate(changed: PropertyValues): void {\n if (changed.has('numericOnly')) {\n this.allowedChars = this.numericOnly ? NUMERIC_REGEX : ALPHANUMERIC_REGEX;\n }\n\n if (changed.has('prefillValue') && this.prefillValue !== undefined) {\n this.fillInputs(this.prefillValue);\n this.prefillValue = undefined;\n }\n }\n\n /* Shifts forward on input */\n private handleInput(e: InputEvent): void {\n e.preventDefault();\n const input = e.target as HTMLInputElement;\n const addedValue = e.data;\n\n if (!addedValue) return;\n if (addedValue.length > 1) {\n this.fillInputs(addedValue);\n return;\n }\n if (!this.allowedChars.test(addedValue)) return;\n\n input.value = addedValue;\n const next = input.nextElementSibling as HTMLInputElement;\n if (next) next.focus();\n\n this.submitIfInputsFilled();\n }\n\n /* Performs special actions associated with some keys */\n private handleKeydown(e: KeyboardEvent): void {\n const input = e.target as HTMLInputElement;\n const key = e.key;\n const prev = input.previousElementSibling as HTMLInputElement;\n const next = input.nextElementSibling as HTMLInputElement;\n\n switch (key) {\n case 'Backspace':\n case 'Delete':\n e.preventDefault();\n if (prev) prev.focus();\n\n if (input.value === '') {\n prev.value = '';\n break;\n }\n\n input.value = '';\n break;\n case 'Tab':\n input.select();\n break;\n case 'ArrowRight':\n case 'Right':\n e.preventDefault();\n if (next) next.focus();\n break;\n case 'ArrowLeft':\n case 'Left':\n e.preventDefault();\n if (prev) prev.focus();\n break;\n }\n }\n\n /**\n * Transmits pasted data to the input-filling function\n */\n private handlePaste(e: ClipboardEvent): void {\n e.preventDefault();\n\n const pastedText = e.clipboardData?.getData('text');\n if (pastedText) this.fillInputs(pastedText);\n }\n\n /**\n * Fills as many inputs as possible with the specified value, starting from the beginning.\n * Submits the result if enough characters are filled.\n */\n private fillInputs(value: string) {\n if (value === '') this.clearInputs();\n\n const charsToFill = value\n .split('')\n .filter((char) => this.allowedChars.test(char))\n .slice(0, this.numChars);\n\n if (!charsToFill || charsToFill.length === 0) return;\n charsToFill.forEach(\n (char, i) => ((this.inputs[i] as HTMLInputElement).value = char),\n );\n\n if (charsToFill.length === this.numChars) {\n this.triggerSubmit(charsToFill.join(''));\n this.inputs[this.numChars - 1].focus();\n return;\n }\n\n const next = this.inputs[charsToFill.length];\n next.focus();\n }\n\n /** Clears all inputs and returns focus to first input */\n private clearInputs(): void {\n this.inputs.forEach((input) => (input.value = ''));\n this.inputs[0].focus();\n }\n\n /** Checks whether all inputs are filled and submits if so */\n private submitIfInputsFilled(): void {\n const code: string[] = [];\n this.inputs.forEach((input) => {\n if (input.value) code.push(input.value);\n });\n\n if (code.length === this.numChars) this.triggerSubmit(code.join(''));\n }\n\n /* Submits code */\n private triggerSubmit(code: string): void {\n this.dispatchEvent(\n new CustomEvent(Events.CodeSubmitted, {\n detail: this.numericOnly ? code : code.toUpperCase(),\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n static get styles(): CSSResultGroup {\n return [\n themeStyles,\n css`\n :host {\n --primary-text-color--: var(--primary-text-color);\n --font-size-lg--: var(--font-size-lg);\n }\n\n :host {\n display: flex;\n flex-direction: row;\n flex-wrap: nowrap;\n gap: 5px;\n }\n\n input {\n color: var(--primary-text-color--);\n font-size: var(--font-size-lg--);\n width: var(--font-size-lg--);\n font-weight: bold;\n height: calc(var(--font-size-lg--) + 1.25rem);\n text-align: center;\n text-transform: uppercase;\n padding: 0;\n }\n `,\n ];\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ia-otp-input.js","sourceRoot":"","sources":["../../../../src/elements/ia-otp-input/ia-otp-input.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,IAAI,EACJ,UAAU,EAGV,GAAG,GAEJ,M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AC,QAAQ;YAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IACvE,CAAC;IAED,kBAAkB;IACV,aAAa,CAAC,IAAY;QAChC,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,MAAM,CAAC,aAAa,EAAE;YACpC,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE;YACpD,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,IAAI;SACf,CAAC,CACH,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,MAAM;QACf,OAAO;YACL,WAAW;YACX,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;OAuBF;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AA/MC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDACL;AAItB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;4CACF;AAI1B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CACN;AAIrB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;+CACA;AAIpB;IADP,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDACkB;AAIrC;IADP,QAAQ,CAAC,OAAO,CAAC;0CAC4B;AAvBnC,UAAU;IADtB,aAAa,CAAC,cAAc,CAAC;GACjB,UAAU,CAkNtB","sourcesContent":["import {\n html,\n LitElement,\n TemplateResult,\n CSSResultGroup,\n css,\n PropertyValues,\n} from 'lit';\nimport { property, customElement, queryAll } from 'lit/decorators.js';\nimport themeStyles from '@src/themes/theme-styles';\n\n/**\n * Custom event options for the component\n */\nconst Events = {\n CodeSubmitted: 'codeSubmitted',\n};\n\nconst NUMERIC_REGEX = /^[0-9]+$/;\nconst ALPHANUMERIC_REGEX = /^[a-zA-Z0-9]+$/;\n\n/**\n * Renders an input for OTP entry, which combines a series of separate\n * inputs into one, shifting focus as needed and handling paste and backspace\n * events.\n */\n@customElement('ia-otp-input')\nexport class IAOTPInput extends LitElement {\n /* An optional value to prefill the inputs with */\n @property({ type: String })\n prefillValue?: string;\n\n /* Whether to disable all inputs */\n @property({ type: Boolean })\n disabled: boolean = false;\n\n /* Number of characters to expect for the passcode */\n @property({ type: Number })\n numChars: number = 6;\n\n /* Whether to restrict entry to numeric characters */\n @property({ type: Boolean })\n numericOnly: boolean = true;\n\n /* Regex for allowed characters. Updates based on numeric only */\n @property({ type: Object })\n private allowedChars: RegExp = NUMERIC_REGEX;\n\n /* Array of OTP inputs */\n @queryAll('input')\n private inputs!: NodeListOf<HTMLInputElement>;\n\n render(): TemplateResult {\n return html`\n ${[...Array(this.numChars).keys()].map(\n (i) =>\n html`<input\n id=\"OTP-input-${i}\"\n part=\"input\"\n type=\"text\"\n autocomplete=${i === 0 ? 'one-time-code' : 'off'}\n inputmode=${this.numericOnly ? 'numeric' : 'text'}\n ?disabled=${this.disabled}\n @beforeinput=${this.handleInput}\n @paste=${this.handlePaste}\n @keydown=${this.handleKeydown}\n />`,\n )}\n `;\n }\n\n protected firstUpdated(): void {\n this.inputs[0].focus();\n }\n\n protected willUpdate(changed: PropertyValues): void {\n if (changed.has('numericOnly')) {\n this.allowedChars = this.numericOnly ? NUMERIC_REGEX : ALPHANUMERIC_REGEX;\n }\n\n if (changed.has('prefillValue') && this.prefillValue !== undefined) {\n this.fillInputs(this.prefillValue);\n this.prefillValue = undefined;\n }\n }\n\n /* Shifts forward on input */\n private handleInput(e: InputEvent): void {\n e.preventDefault();\n const input = e.target as HTMLInputElement;\n const addedValue = e.data;\n\n if (!addedValue) return;\n if (addedValue.length > 1) {\n this.fillInputs(addedValue);\n return;\n }\n if (!this.allowedChars.test(addedValue)) return;\n\n input.value = addedValue;\n const next = input.nextElementSibling as HTMLInputElement;\n if (next) next.focus();\n\n this.submitIfInputsFilled();\n }\n\n /* Performs special actions associated with some keys */\n private handleKeydown(e: KeyboardEvent): void {\n const input = e.target as HTMLInputElement;\n const key = e.key;\n const prev = input.previousElementSibling as HTMLInputElement;\n const next = input.nextElementSibling as HTMLInputElement;\n\n switch (key) {\n case 'Backspace':\n case 'Delete':\n e.preventDefault();\n if (prev) prev.focus();\n\n if (input.value === '') {\n prev.value = '';\n break;\n }\n\n input.value = '';\n break;\n case 'Tab':\n input.select();\n break;\n case 'ArrowRight':\n case 'Right':\n e.preventDefault();\n if (next) next.focus();\n break;\n case 'ArrowLeft':\n case 'Left':\n e.preventDefault();\n if (prev) prev.focus();\n break;\n }\n }\n\n /**\n * Transmits pasted data to the input-filling function\n */\n private handlePaste(e: ClipboardEvent): void {\n e.preventDefault();\n\n const pastedText = e.clipboardData?.getData('text');\n if (pastedText) this.fillInputs(pastedText);\n }\n\n /**\n * Fills as many inputs as possible with the specified value, starting from the beginning.\n * Submits the result if enough characters are filled.\n */\n private fillInputs(value: string) {\n if (typeof value !== 'string') value = String(value ?? '');\n\n if (value === '') this.clearInputs();\n\n const charsToFill = value\n .split('')\n .filter((char) => this.allowedChars.test(char))\n .slice(0, this.numChars);\n\n if (!charsToFill || charsToFill.length === 0) return;\n charsToFill.forEach(\n (char, i) => ((this.inputs[i] as HTMLInputElement).value = char),\n );\n\n if (charsToFill.length === this.numChars) {\n this.triggerSubmit(charsToFill.join(''));\n this.inputs[this.numChars - 1].focus();\n return;\n }\n\n const next = this.inputs[charsToFill.length];\n next.focus();\n }\n\n /** Clears all inputs and returns focus to first input */\n private clearInputs(): void {\n this.inputs.forEach((input) => (input.value = ''));\n this.inputs[0].focus();\n }\n\n /** Checks whether all inputs are filled and submits if so */\n private submitIfInputsFilled(): void {\n const code: string[] = [];\n this.inputs.forEach((input) => {\n if (input.value) code.push(input.value);\n });\n\n if (code.length === this.numChars) this.triggerSubmit(code.join(''));\n }\n\n /* Submits code */\n private triggerSubmit(code: string): void {\n this.dispatchEvent(\n new CustomEvent(Events.CodeSubmitted, {\n detail: this.numericOnly ? code : code.toUpperCase(),\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n static get styles(): CSSResultGroup {\n return [\n themeStyles,\n css`\n :host {\n --primary-text-color--: var(--primary-text-color);\n --font-size-lg--: var(--font-size-lg);\n }\n\n :host {\n display: flex;\n flex-direction: row;\n flex-wrap: nowrap;\n gap: 5px;\n }\n\n input {\n color: var(--primary-text-color--);\n font-size: var(--font-size-lg--);\n width: var(--font-size-lg--);\n font-weight: bold;\n height: calc(var(--font-size-lg--) + 1.25rem);\n text-align: center;\n text-transform: uppercase;\n padding: 0;\n }\n `,\n ];\n }\n}\n"]}
|
|
@@ -7,7 +7,7 @@ export declare class IASnow extends LitElement {
|
|
|
7
7
|
snowConfig?: SnowflakesParams;
|
|
8
8
|
private snowing;
|
|
9
9
|
private snowflakes?;
|
|
10
|
-
render(): import("lit
|
|
10
|
+
render(): import("lit").TemplateResult<1>;
|
|
11
11
|
protected willUpdate(_changedProperties: PropertyValues): void;
|
|
12
12
|
private get startButtonTemplate();
|
|
13
13
|
private get clearButtonTemplate();
|
package/package.json
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@internetarchive/elements",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.12-rc.0",
|
|
4
4
|
"description": "A web component library from the Internet Archive.",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"types": "./dist/src/elements/index.d.ts",
|
|
7
7
|
"type": "module",
|
|
8
|
+
"packageManager": "pnpm@11.20.0",
|
|
9
|
+
"engines": {
|
|
10
|
+
"node": ">=24",
|
|
11
|
+
"pnpm": ">=11"
|
|
12
|
+
},
|
|
8
13
|
"publishConfig": {
|
|
9
14
|
"access": "public"
|
|
10
15
|
},
|
|
@@ -35,8 +40,11 @@
|
|
|
35
40
|
"tslib": "^2.8.1"
|
|
36
41
|
},
|
|
37
42
|
"devDependencies": {
|
|
43
|
+
"@eslint/eslintrc": "^3.3.5",
|
|
44
|
+
"@eslint/js": "^9.39.1",
|
|
38
45
|
"@open-wc/testing-helpers": "^3.0.1",
|
|
39
46
|
"@typescript-eslint/eslint-plugin": "^8.46.4",
|
|
47
|
+
"@typescript-eslint/parser": "^8.46.4",
|
|
40
48
|
"@vitest/browser": "^4.0.8",
|
|
41
49
|
"@vitest/browser-playwright": "^4.0.8",
|
|
42
50
|
"@vitest/coverage-v8": "^4.0.8",
|
|
@@ -51,7 +59,7 @@
|
|
|
51
59
|
"highlight.js": "^11.11.1",
|
|
52
60
|
"madge": "^8.0.0",
|
|
53
61
|
"playwright": "^1.60.0",
|
|
54
|
-
"prettier": "
|
|
62
|
+
"prettier": "3.6.2",
|
|
55
63
|
"ts-lit-plugin": "^2.0.2",
|
|
56
64
|
"tsc-alias": "^1.8.16",
|
|
57
65
|
"typescript": "^5.9.3",
|