@nuralyui/input 0.0.9 → 0.0.10
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/bundle.js +1277 -0
- package/input.component.d.ts +118 -26
- package/input.component.js +229 -228
- package/input.component.js.map +1 -1
- package/input.style.js +154 -0
- package/input.style.js.map +1 -1
- package/input.style.variable.js +19 -0
- package/input.style.variable.js.map +1 -1
- package/input.types.d.ts +90 -1
- package/input.types.js +73 -0
- package/input.types.js.map +1 -1
- package/package.json +16 -2
- package/demo/input-demo.d.ts +0 -19
- package/demo/input-demo.d.ts.map +0 -1
- package/demo/input-demo.js +0 -339
- package/demo/input-demo.js.map +0 -1
- package/index.d.ts.map +0 -1
- package/input.component.d.ts.map +0 -1
- package/input.style.d.ts.map +0 -1
- package/input.style.variable.d.ts.map +0 -1
- package/input.types.d.ts.map +0 -1
- package/mixins/focus-mixin.d.ts +0 -60
- package/mixins/focus-mixin.d.ts.map +0 -1
- package/mixins/focus-mixin.js +0 -65
- package/mixins/focus-mixin.js.map +0 -1
- package/mixins/index.d.ts +0 -9
- package/mixins/index.d.ts.map +0 -1
- package/mixins/index.js +0 -9
- package/mixins/index.js.map +0 -1
- package/mixins/number-mixin.d.ts +0 -51
- package/mixins/number-mixin.d.ts.map +0 -1
- package/mixins/number-mixin.js +0 -131
- package/mixins/number-mixin.js.map +0 -1
- package/mixins/selection-mixin.d.ts +0 -57
- package/mixins/selection-mixin.d.ts.map +0 -1
- package/mixins/selection-mixin.js +0 -80
- package/mixins/selection-mixin.js.map +0 -1
- package/react.d.ts.map +0 -1
- package/test/hy-input_test.d.ts +0 -2
- package/test/hy-input_test.d.ts.map +0 -1
- package/test/hy-input_test.js +0 -159
- package/test/hy-input_test.js.map +0 -1
- package/utils/index.d.ts +0 -8
- package/utils/index.d.ts.map +0 -1
- package/utils/index.js +0 -8
- package/utils/index.js.map +0 -1
- package/utils/input-renderers.d.ts +0 -54
- package/utils/input-renderers.d.ts.map +0 -1
- package/utils/input-renderers.js +0 -174
- package/utils/input-renderers.js.map +0 -1
- package/utils/input-validation.utils.d.ts +0 -26
- package/utils/input-validation.utils.d.ts.map +0 -1
- package/utils/input-validation.utils.js +0 -105
- package/utils/input-validation.utils.js.map +0 -1
- package/validation.d.ts.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hy-input_test.js","sourceRoot":"","sources":["../../../../src/components/input/test/hy-input_test.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,EAAuC,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnF,OAAO,oBAAoB,CAAC;AAE5B,KAAK,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC3B,IAAI,CAAC,oBAAoB,EAAE,GAAS,EAAE;QACpC,MAAM,EAAE,GAAmB,MAAM,OAAO,CAAC,IAAI,CAAA,wBAAwB,CAAC,CAAC;QACvE,MAAM,cAAc,GAAG,EAAE,CAAC,UAAW,CAAC,aAAa,CAAC,kBAAkB,CAAE,CAAC;QACzE,MAAM,KAAK,GAAG,EAAE,CAAC,UAAW,CAAC,aAAa,CAAC,OAAO,CAAE,CAAC;QACrD,MAAM,IAAI,GAAG,EAAE,CAAC,UAAW,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QAClD,MAAM,YAAY,GAAG,IAAK,CAAC,aAAa,EAAE,CAAC;QAC3C,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC;QAChC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,qCAAqB,CAAC;QAC/C,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QACxC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,EA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AAE;QAChC,MAAM,EAAE,GAAmB,MAAM,OAAO,CAAC,IAAI,CAAA,gCAAgC,CAAC,CAAC;QAC/E,MAAM,KAAK,GAAG,EAAE,CAAC,UAAW,CAAC,aAAa,CAAC,OAAO,CAAE,CAAC;QACrD,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;QAClC,IAAI,UAAU,GAAG,KAAK,CAAC;QACvB,KAAK,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE;YACnC,UAAU,GAAG,IAAI,CAAC;QACpB,CAAC,CAAC,CAAC;QACH,KAAK,CAAC,KAAK,EAAE,CAAC;QAEd,MAAM,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { html, fixture, expect } from '@open-wc/testing';\nimport { NrInputElement } from '../input.component';\nimport { INPUT_STATE, INPUT_SIZE, INPUT_TYPE, EMPTY_STRING } from '../input.types';\nimport '../input.component';\nimport { HyIconElement } from '../../icon';\nsuite('NrInputElement', () => {\n test('default properties', async () => {\n const el: NrInputElement = await fixture(html`<nr-input> </nr-input>`);\n const inputContainer = el.shadowRoot!.querySelector('#input-container')!;\n const input = el.shadowRoot!.querySelector('input')!;\n const slot = el.shadowRoot!.querySelector('slot');\n const assignedNode = slot!.assignedNodes();\n expect(el.disabled).to.be.false;\n expect(el.state).to.equal(INPUT_STATE.Default);\n expect(el.value).to.equal(EMPTY_STRING);\n expect(el.size).to.equal(INPUT_SIZE.Medium);\n expect(el.type).to.equal(INPUT_TYPE.TEXT);\n expect(el.placeholder).to.equal(EMPTY_STRING);\n expect(el.min).to.be.undefined;\n expect(el.max).to.be.undefined;\n expect(el.step).to.be.undefined;\n\n expect(input).to.not.have.attribute('min');\n expect(input).to.not.have.attribute('max');\n expect(input).to.not.have.attribute('step');\n expect(input.disabled).to.be.false;\n expect(input.type).to.equal(INPUT_TYPE.TEXT);\n expect(input.value).to.equal(EMPTY_STRING);\n expect(input.placeholder).to.equal(EMPTY_STRING);\n expect(inputContainer).to.have.attribute('data-size', INPUT_SIZE.Medium);\n expect(inputContainer.querySelector('#warning-icon')).to.be.null;\n expect(inputContainer.querySelector('#error-icon')).to.be.null;\n expect(inputContainer.querySelector('#password-icon')).to.be.null;\n expect(inputContainer.querySelector('#number-icons')).to.be.null;\n expect(assignedNode.length).to.equal(0);\n });\n\n test('input type password', async () => {\n const el: NrInputElement = await fixture(html`<nr-input type=\"password\"> </nr-input>`);\n const inputContainer = el.shadowRoot!.querySelector('#input-container')!;\n let passwordIcon: HyIconElement = inputContainer.querySelector('#password-icon')!;\n expect(inputContainer.querySelector('#number-icons')).to.be.null;\n expect(passwordIcon).to.exist;\n expect(passwordIcon).to.have.attribute('name', 'eye');\n passwordIcon.click();\n await el.updateComplete;\n expect(el.inputType).to.equal('text');\n passwordIcon = inputContainer.querySelector('#password-icon')!;\n expect(passwordIcon).to.have.attribute('name', 'eye-slash');\n });\n\n suite('input type number', () => {\n test('init number input ', async () => {\n const step = 5;\n const min = 10;\n const max = 100;\n const el: NrInputElement = await fixture(\n html`<nr-input type=\"number\" step=${step} min=${min} max=${max}> </nr-input>`\n );\n const inputContainer = el.shadowRoot!.querySelector('#input-container')!;\n const input = el.shadowRoot!.querySelector('input')!;\n const passwordIcon: HyIconElement = inputContainer.querySelector('#password-icon')!;\n const numberIcon = inputContainer.querySelector('#number-icons');\n expect(passwordIcon).to.be.null;\n expect(numberIcon).to.exist;\n expect(input).to.have.attribute('min', min.toString());\n expect(input).to.have.attribute('max', max.toString());\n expect(input).to.have.attribute('step', step.toString());\n });\n test('increment number', async () => {\n const step = 5;\n const min = 10;\n const el: NrInputElement = await fixture(html`<nr-input type=\"number\" step=${step} min=${min}> </nr-input>`);\n const inputContainer = el.shadowRoot!.querySelector('#input-container')!;\n const input = el.shadowRoot!.querySelector('input')!;\n const numberIcon = inputContainer.querySelector('#number-icons');\n const plusButton: HyIconElement = numberIcon!.querySelector(\"[name='plus']\")!;\n plusButton.click();\n expect(input.value).to.equal((min + step).toString());\n });\n test('decrement number', async () => {\n const step = 5;\n const el: NrInputElement = await fixture(html`<nr-input type=\"number\" step=${step}> </nr-input>`);\n const inputContainer = el.shadowRoot!.querySelector('#input-container')!;\n const input = el.shadowRoot!.querySelector('input')!;\n const inputValue = input.value;\n const numberIcon = inputContainer.querySelector('#number-icons');\n const minusButton: HyIconElement = numberIcon!.querySelector(\"[name='minus']\")!;\n minusButton.click();\n expect(input.value).to.equal((+inputValue - step).toString());\n });\n });\n\n suite('input with state', () => {\n test('warning input', async () => {\n const inputState = INPUT_STATE.Warning;\n const el: NrInputElement = await fixture(html`<nr-input state=${inputState}> </nr-input>`);\n const inputContainer = el.shadowRoot!.querySelector('#input-container')!;\n expect(inputContainer.querySelector('#warning-icon')).to.exist;\n expect(inputContainer.querySelector('#error-icon')).to.not.exist;\n });\n test('error input', async () => {\n const inputState = INPUT_STATE.Error;\n const el: NrInputElement = await fixture(html`<nr-input state=${inputState}> </nr-input>`);\n const inputContainer = el.shadowRoot!.querySelector('#input-container')!;\n expect(inputContainer.querySelector('#warning-icon')).to.not.exist;\n expect(inputContainer.querySelector('#error-icon')).to.exist;\n });\n });\n suite('input with size', () => {\n test('large input', async () => {\n const inputSize = INPUT_SIZE.Large;\n const el: NrInputElement = await fixture(html`<nr-input size=${inputSize}> </nr-input>`);\n const inputContainer = el.shadowRoot!.querySelector('#input-container')!;\n expect(inputContainer).to.have.attribute('data-size', inputSize);\n });\n test('medium input', async () => {\n const inputSize = INPUT_SIZE.Medium;\n const el: NrInputElement = await fixture(html`<nr-input size=${inputSize}> </nr-input>`);\n const inputContainer = el.shadowRoot!.querySelector('#input-container')!;\n expect(inputContainer).to.have.attribute('data-size', inputSize);\n });\n });\n test('input with placeholder', async () => {\n const placeholder = 'text of placeholder';\n const el: NrInputElement = await fixture(html`<nr-input placeholder=${placeholder}> </nr-input>`);\n const input = el.shadowRoot!.querySelector('input')!;\n expect(input).to.have.attribute('placeholder', placeholder);\n });\n\n test('input with label', async () => {\n const inputLabel = 'input label';\n const el: NrInputElement = await fixture(html`<nr-input> <span slot=\"label\">${inputLabel}</span> </nr-input>`);\n const slot = el.shadowRoot!.querySelector('slot');\n const assignedNode = slot!.assignedNodes();\n expect(assignedNode[0]).to.have.attribute('slot', 'label');\n expect(assignedNode[0].textContent).to.equal(inputLabel);\n });\n\n test('input with helper text', async () => {\n const inputHelper = 'input helper';\n const el: NrInputElement = await fixture(\n html`<nr-input> <span slot=\"helper-text\">${inputHelper}</span> </nr-input>`\n );\n const slot = el.shadowRoot!.querySelectorAll('slot');\n const assignedNode = slot[1].assignedNodes();\n expect(assignedNode[0]).to.have.attribute('slot', 'helper-text');\n expect(assignedNode[0].textContent).to.equal(inputHelper);\n });\n\n test('input disabled', async () => {\n const el: NrInputElement = await fixture(html`<nr-input disabled></nr-input>`);\n const input = el.shadowRoot!.querySelector('input')!;\n expect(input.disabled).to.be.true;\n let inputFocus = false;\n input.addEventListener('focus', () => {\n inputFocus = true;\n });\n input.focus();\n\n expect(inputFocus).to.equal(false);\n });\n});\n"]}
|
package/utils/index.d.ts
DELETED
package/utils/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/input/utils/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC"}
|
package/utils/index.js
DELETED
package/utils/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/input/utils/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2023 Google Laabidi Aymen\n * SPDX-License-Identifier: MIT\n */\n\nexport { InputValidationUtils } from './input-validation.utils.js';\nexport { InputRenderUtils } from './input-renderers.js';\n"]}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2023 Google Laabidi Aymen
|
|
4
|
-
* SPDX-License-Identifier: MIT
|
|
5
|
-
*/
|
|
6
|
-
import { TemplateResult, nothing } from 'lit';
|
|
7
|
-
/**
|
|
8
|
-
* Rendering utilities for input component icons and elements
|
|
9
|
-
*/
|
|
10
|
-
export declare class InputRenderUtils {
|
|
11
|
-
/**
|
|
12
|
-
* Renders prefix slot content
|
|
13
|
-
*/
|
|
14
|
-
static renderPrefix(): TemplateResult;
|
|
15
|
-
/**
|
|
16
|
-
* Renders suffix slot content
|
|
17
|
-
*/
|
|
18
|
-
static renderSuffix(): TemplateResult;
|
|
19
|
-
/**
|
|
20
|
-
* Renders addon before slot content (outside input borders)
|
|
21
|
-
* Only renders if hasAddonBefore is true
|
|
22
|
-
*/
|
|
23
|
-
static renderAddonBefore(hasAddonBefore: boolean, onSlotChange: (e: Event) => void): TemplateResult | typeof nothing;
|
|
24
|
-
/**
|
|
25
|
-
* Renders addon after slot content (outside input borders)
|
|
26
|
-
* Only renders if hasAddonAfter is true
|
|
27
|
-
*/
|
|
28
|
-
static renderAddonAfter(hasAddonAfter: boolean, onSlotChange: (e: Event) => void): TemplateResult | typeof nothing;
|
|
29
|
-
/**
|
|
30
|
-
* Renders the copy icon when withCopy is enabled
|
|
31
|
-
*/
|
|
32
|
-
static renderCopyIcon(withCopy: boolean, disabled: boolean, readonly: boolean, onCopy: () => void, onKeydown: (e: KeyboardEvent) => void): TemplateResult | typeof nothing;
|
|
33
|
-
/**
|
|
34
|
-
* Renders the clear icon when allowClear is enabled and there's content
|
|
35
|
-
*/
|
|
36
|
-
static renderClearIcon(allowClear: boolean, value: string, disabled: boolean, readonly: boolean, onClear: () => void, onKeydown: (e: KeyboardEvent) => void): TemplateResult | typeof nothing;
|
|
37
|
-
/**
|
|
38
|
-
* Renders state-based icons (warning, error)
|
|
39
|
-
*/
|
|
40
|
-
static renderStateIcon(state: string): TemplateResult | typeof nothing;
|
|
41
|
-
/**
|
|
42
|
-
* Renders the calendar icon for calendar input type
|
|
43
|
-
*/
|
|
44
|
-
static renderCalendarIcon(state: string, type: string): TemplateResult | typeof nothing;
|
|
45
|
-
/**
|
|
46
|
-
* Renders password toggle icon
|
|
47
|
-
*/
|
|
48
|
-
static renderPasswordIcon(type: string, inputType: string, disabled: boolean, readonly: boolean, onToggle: () => void, onKeydown: (e: KeyboardEvent) => void): TemplateResult | typeof nothing;
|
|
49
|
-
/**
|
|
50
|
-
* Renders number input increment/decrement icons
|
|
51
|
-
*/
|
|
52
|
-
static renderNumberIcons(type: string, state: string, disabled: boolean, readonly: boolean, onIncrement: () => void, onDecrement: () => void, onKeydown: (e: KeyboardEvent) => void): TemplateResult | typeof nothing;
|
|
53
|
-
}
|
|
54
|
-
//# sourceMappingURL=input-renderers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"input-renderers.d.ts","sourceRoot":"","sources":["../../../../src/components/input/utils/input-renderers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAQ,cAAc,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAGpD;;GAEG;AACH,qBAAa,gBAAgB;IAE3B;;OAEG;IACH,MAAM,CAAC,YAAY,IAAI,cAAc;IAQrC;;OAEG;IACH,MAAM,CAAC,YAAY,IAAI,cAAc;IAQrC;;;OAGG;IACH,MAAM,CAAC,iBAAiB,CAAC,cAAc,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC,CAAC,EAAE,KAAK,KAAK,IAAI,GAAG,cAAc,GAAG,OAAO,OAAO;I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,EAAE,MAAM,IAAI,EACvB,WAAW,EAAE,MAAM,IAAI,EACvB,SAAS,EAAE,CAAC,CAAC,EAAE,aAAa,KAAK,IAAI,GACpC,cAAc,GAAG,OAAO,OAAO;CA0BnC"}
|
package/utils/input-renderers.js
DELETED
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2023 Google Laabidi Aymen
|
|
4
|
-
* SPDX-License-Identifier: MIT
|
|
5
|
-
*/
|
|
6
|
-
import { html, nothing } from 'lit';
|
|
7
|
-
/**
|
|
8
|
-
* Rendering utilities for input component icons and elements
|
|
9
|
-
*/
|
|
10
|
-
export class InputRenderUtils {
|
|
11
|
-
/**
|
|
12
|
-
* Renders prefix slot content
|
|
13
|
-
*/
|
|
14
|
-
static renderPrefix() {
|
|
15
|
-
return html `
|
|
16
|
-
<div class="input-prefix">
|
|
17
|
-
<slot name="prefix"></slot>
|
|
18
|
-
</div>
|
|
19
|
-
`;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Renders suffix slot content
|
|
23
|
-
*/
|
|
24
|
-
static renderSuffix() {
|
|
25
|
-
return html `
|
|
26
|
-
<div class="input-suffix">
|
|
27
|
-
<slot name="suffix"></slot>
|
|
28
|
-
</div>
|
|
29
|
-
`;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Renders addon before slot content (outside input borders)
|
|
33
|
-
* Only renders if hasAddonBefore is true
|
|
34
|
-
*/
|
|
35
|
-
static renderAddonBefore(hasAddonBefore, onSlotChange) {
|
|
36
|
-
if (!hasAddonBefore)
|
|
37
|
-
return nothing;
|
|
38
|
-
return html `
|
|
39
|
-
<div class="input-addon-before">
|
|
40
|
-
<slot name="addon-before" @slotchange=${onSlotChange}></slot>
|
|
41
|
-
</div>
|
|
42
|
-
`;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Renders addon after slot content (outside input borders)
|
|
46
|
-
* Only renders if hasAddonAfter is true
|
|
47
|
-
*/
|
|
48
|
-
static renderAddonAfter(hasAddonAfter, onSlotChange) {
|
|
49
|
-
if (!hasAddonAfter)
|
|
50
|
-
return nothing;
|
|
51
|
-
return html `
|
|
52
|
-
<div class="input-addon-after">
|
|
53
|
-
<slot name="addon-after" @slotchange=${onSlotChange}></slot>
|
|
54
|
-
</div>
|
|
55
|
-
`;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Renders the copy icon when withCopy is enabled
|
|
59
|
-
*/
|
|
60
|
-
static renderCopyIcon(withCopy, disabled, readonly, onCopy, onKeydown) {
|
|
61
|
-
if (!withCopy)
|
|
62
|
-
return nothing;
|
|
63
|
-
return html `<hy-icon
|
|
64
|
-
name="copy"
|
|
65
|
-
type="regular"
|
|
66
|
-
id="copy-icon"
|
|
67
|
-
role="button"
|
|
68
|
-
aria-label="Copy input value"
|
|
69
|
-
tabindex="0"
|
|
70
|
-
@click=${!disabled && !readonly ? onCopy : nothing}
|
|
71
|
-
@keydown=${onKeydown}
|
|
72
|
-
></hy-icon>`;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Renders the clear icon when allowClear is enabled and there's content
|
|
76
|
-
*/
|
|
77
|
-
static renderClearIcon(allowClear, value, disabled, readonly, onClear, onKeydown) {
|
|
78
|
-
if (!allowClear || !value || disabled || readonly)
|
|
79
|
-
return nothing;
|
|
80
|
-
return html `<hy-icon
|
|
81
|
-
name="times-circle"
|
|
82
|
-
type="regular"
|
|
83
|
-
id="clear-icon"
|
|
84
|
-
role="button"
|
|
85
|
-
aria-label="Clear input value"
|
|
86
|
-
tabindex="0"
|
|
87
|
-
@click=${onClear}
|
|
88
|
-
@keydown=${onKeydown}
|
|
89
|
-
></hy-icon>`;
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Renders state-based icons (warning, error)
|
|
93
|
-
*/
|
|
94
|
-
static renderStateIcon(state) {
|
|
95
|
-
switch (state) {
|
|
96
|
-
case "warning" /* INPUT_STATE.Warning */:
|
|
97
|
-
return html `<hy-icon name="warning" id="warning-icon"></hy-icon>`;
|
|
98
|
-
case "error" /* INPUT_STATE.Error */:
|
|
99
|
-
return html `<hy-icon name="exclamation-circle" id="error-icon"></hy-icon>`;
|
|
100
|
-
default:
|
|
101
|
-
return nothing;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Renders the calendar icon for calendar input type
|
|
106
|
-
*/
|
|
107
|
-
static renderCalendarIcon(state, type) {
|
|
108
|
-
if (state !== "default" /* INPUT_STATE.Default */ || type !== "calendar" /* INPUT_TYPE.CALENDAR */) {
|
|
109
|
-
return nothing;
|
|
110
|
-
}
|
|
111
|
-
return html `<hy-icon name="calendar" type="regular" id="calendar-icon"></hy-icon>`;
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Renders password toggle icon
|
|
115
|
-
*/
|
|
116
|
-
static renderPasswordIcon(type, inputType, disabled, readonly, onToggle, onKeydown) {
|
|
117
|
-
if (type !== "password" /* INPUT_TYPE.PASSWORD */)
|
|
118
|
-
return nothing;
|
|
119
|
-
if (inputType === "text" /* INPUT_TYPE.TEXT */) {
|
|
120
|
-
return html `<hy-icon
|
|
121
|
-
name="eye-slash"
|
|
122
|
-
type="regular"
|
|
123
|
-
id="password-icon"
|
|
124
|
-
role="button"
|
|
125
|
-
aria-label="Hide password"
|
|
126
|
-
tabindex="0"
|
|
127
|
-
@click=${!disabled && !readonly ? onToggle : nothing}
|
|
128
|
-
@keydown=${onKeydown}
|
|
129
|
-
></hy-icon>`;
|
|
130
|
-
}
|
|
131
|
-
else {
|
|
132
|
-
return html `<hy-icon
|
|
133
|
-
name="eye"
|
|
134
|
-
type="regular"
|
|
135
|
-
id="password-icon"
|
|
136
|
-
role="button"
|
|
137
|
-
aria-label="Show password"
|
|
138
|
-
tabindex="0"
|
|
139
|
-
@click=${!disabled && !readonly ? onToggle : nothing}
|
|
140
|
-
@keydown=${onKeydown}
|
|
141
|
-
></hy-icon>`;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Renders number input increment/decrement icons
|
|
146
|
-
*/
|
|
147
|
-
static renderNumberIcons(type, state, disabled, readonly, onIncrement, onDecrement, onKeydown) {
|
|
148
|
-
if (type !== "number" /* INPUT_TYPE.NUMBER */)
|
|
149
|
-
return nothing;
|
|
150
|
-
return html `
|
|
151
|
-
<div id="number-icons">
|
|
152
|
-
${state !== "default" /* INPUT_STATE.Default */ ? html `<span id="icons-separator">|</span>` : nothing}
|
|
153
|
-
<hy-icon
|
|
154
|
-
name="minus"
|
|
155
|
-
aria-label="Decrease value"
|
|
156
|
-
role="button"
|
|
157
|
-
tabindex="0"
|
|
158
|
-
@click=${!disabled && !readonly ? onDecrement : nothing}
|
|
159
|
-
@keydown=${onKeydown}
|
|
160
|
-
></hy-icon>
|
|
161
|
-
<span id="icons-separator">|</span>
|
|
162
|
-
<hy-icon
|
|
163
|
-
name="plus"
|
|
164
|
-
aria-label="Increase value"
|
|
165
|
-
role="button"
|
|
166
|
-
tabindex="0"
|
|
167
|
-
@click=${!disabled && !readonly ? onIncrement : nothing}
|
|
168
|
-
@keydown=${onKeydown}
|
|
169
|
-
></hy-icon>
|
|
170
|
-
</div>
|
|
171
|
-
`;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
//# sourceMappingURL=input-renderers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"input-renderers.js","sourceRoot":"","sources":["../../../../src/components/input/utils/input-renderers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,IAAI,EAAkB,OAAO,EAAE,MAAM,KAAK,CAAC;AAGpD;;GAEG;AACH,MAAM,OAAO,gBAAgB;IAE3B;;OAEG;IACH,MAAM,CAAC,YAAY;QACjB,OAAO,IAAI,CAAA;;;;KAIV,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,YAAY;QACjB,OAA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* @license\n * Copyright 2023 Google Laabidi Aymen\n * SPDX-License-Identifier: MIT\n */\n\nimport { html, TemplateResult, nothing } from 'lit';\nimport { INPUT_TYPE, INPUT_STATE } from '../input.types.js';\n\n/**\n * Rendering utilities for input component icons and elements\n */\nexport class InputRenderUtils {\n\n /**\n * Renders prefix slot content\n */\n static renderPrefix(): TemplateResult {\n return html`\n <div class=\"input-prefix\">\n <slot name=\"prefix\"></slot>\n </div>\n `;\n }\n\n /**\n * Renders suffix slot content \n */\n static renderSuffix(): TemplateResult {\n return html`\n <div class=\"input-suffix\">\n <slot name=\"suffix\"></slot>\n </div>\n `;\n }\n\n /**\n * Renders addon before slot content (outside input borders)\n * Only renders if hasAddonBefore is true\n */\n static renderAddonBefore(hasAddonBefore: boolean, onSlotChange: (e: Event) => void): TemplateResult | typeof nothing {\n if (!hasAddonBefore) return nothing;\n \n return html`\n <div class=\"input-addon-before\">\n <slot name=\"addon-before\" @slotchange=${onSlotChange}></slot>\n </div>\n `;\n }\n\n /**\n * Renders addon after slot content (outside input borders) \n * Only renders if hasAddonAfter is true\n */\n static renderAddonAfter(hasAddonAfter: boolean, onSlotChange: (e: Event) => void): TemplateResult | typeof nothing {\n if (!hasAddonAfter) return nothing;\n \n return html`\n <div class=\"input-addon-after\">\n <slot name=\"addon-after\" @slotchange=${onSlotChange}></slot>\n </div>\n `;\n }\n\n /**\n * Renders the copy icon when withCopy is enabled\n */\n static renderCopyIcon(\n withCopy: boolean,\n disabled: boolean,\n readonly: boolean,\n onCopy: () => void,\n onKeydown: (e: KeyboardEvent) => void\n ): TemplateResult | typeof nothing {\n if (!withCopy) return nothing;\n \n return html`<hy-icon\n name=\"copy\"\n type=\"regular\"\n id=\"copy-icon\"\n role=\"button\"\n aria-label=\"Copy input value\"\n tabindex=\"0\"\n @click=${!disabled && !readonly ? onCopy : nothing}\n @keydown=${onKeydown}\n ></hy-icon>`;\n }\n\n /**\n * Renders the clear icon when allowClear is enabled and there's content\n */\n static renderClearIcon(\n allowClear: boolean,\n value: string,\n disabled: boolean,\n readonly: boolean,\n onClear: () => void,\n onKeydown: (e: KeyboardEvent) => void\n ): TemplateResult | typeof nothing {\n if (!allowClear || !value || disabled || readonly) return nothing;\n \n return html`<hy-icon\n name=\"times-circle\"\n type=\"regular\"\n id=\"clear-icon\"\n role=\"button\"\n aria-label=\"Clear input value\"\n tabindex=\"0\"\n @click=${onClear}\n @keydown=${onKeydown}\n ></hy-icon>`;\n }\n\n /**\n * Renders state-based icons (warning, error)\n */\n static renderStateIcon(state: string): TemplateResult | typeof nothing {\n switch (state) {\n case INPUT_STATE.Warning:\n return html`<hy-icon name=\"warning\" id=\"warning-icon\"></hy-icon>`;\n case INPUT_STATE.Error:\n return html`<hy-icon name=\"exclamation-circle\" id=\"error-icon\"></hy-icon>`;\n default:\n return nothing;\n }\n }\n\n /**\n * Renders the calendar icon for calendar input type\n */\n static renderCalendarIcon(\n state: string,\n type: string\n ): TemplateResult | typeof nothing {\n if (state !== INPUT_STATE.Default || type !== INPUT_TYPE.CALENDAR) {\n return nothing;\n }\n \n return html`<hy-icon name=\"calendar\" type=\"regular\" id=\"calendar-icon\"></hy-icon>`;\n }\n\n /**\n * Renders password toggle icon\n */\n static renderPasswordIcon(\n type: string,\n inputType: string,\n disabled: boolean,\n readonly: boolean,\n onToggle: () => void,\n onKeydown: (e: KeyboardEvent) => void\n ): TemplateResult | typeof nothing {\n if (type !== INPUT_TYPE.PASSWORD) return nothing;\n \n if (inputType === INPUT_TYPE.TEXT) {\n return html`<hy-icon\n name=\"eye-slash\"\n type=\"regular\"\n id=\"password-icon\"\n role=\"button\"\n aria-label=\"Hide password\"\n tabindex=\"0\"\n @click=${!disabled && !readonly ? onToggle : nothing}\n @keydown=${onKeydown}\n ></hy-icon>`;\n } else {\n return html`<hy-icon\n name=\"eye\"\n type=\"regular\"\n id=\"password-icon\"\n role=\"button\"\n aria-label=\"Show password\"\n tabindex=\"0\"\n @click=${!disabled && !readonly ? onToggle : nothing}\n @keydown=${onKeydown}\n ></hy-icon>`;\n }\n }\n\n /**\n * Renders number input increment/decrement icons\n */\n static renderNumberIcons(\n type: string,\n state: string,\n disabled: boolean,\n readonly: boolean,\n onIncrement: () => void,\n onDecrement: () => void,\n onKeydown: (e: KeyboardEvent) => void\n ): TemplateResult | typeof nothing {\n if (type !== INPUT_TYPE.NUMBER) return nothing;\n \n return html`\n <div id=\"number-icons\">\n ${state !== INPUT_STATE.Default ? html`<span id=\"icons-separator\">|</span>` : nothing}\n <hy-icon \n name=\"minus\" \n aria-label=\"Decrease value\"\n role=\"button\"\n tabindex=\"0\"\n @click=${!disabled && !readonly ? onDecrement : nothing}\n @keydown=${onKeydown}\n ></hy-icon>\n <span id=\"icons-separator\">|</span>\n <hy-icon \n name=\"plus\" \n aria-label=\"Increase value\"\n role=\"button\"\n tabindex=\"0\"\n @click=${!disabled && !readonly ? onIncrement : nothing}\n @keydown=${onKeydown}\n ></hy-icon>\n </div>\n `;\n }\n}\n"]}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2023 Google Laabidi Aymen
|
|
4
|
-
* SPDX-License-Identifier: MIT
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Validation utilities for input components
|
|
8
|
-
*/
|
|
9
|
-
export declare class InputValidationUtils {
|
|
10
|
-
/**
|
|
11
|
-
* Validates numeric properties (min, max, step) to ensure they are valid numbers
|
|
12
|
-
*/
|
|
13
|
-
static validateNumericProperties(type: string, min?: string, max?: string, step?: string): void;
|
|
14
|
-
/**
|
|
15
|
-
* Prevents non-numeric characters from being typed in number inputs
|
|
16
|
-
*/
|
|
17
|
-
static preventNonNumericInput(keyDownEvent: KeyboardEvent, min?: string): void;
|
|
18
|
-
/**
|
|
19
|
-
* Validates a numeric value against min/max constraints
|
|
20
|
-
*/
|
|
21
|
-
static validateNumericValue(value: string, min?: string, max?: string): {
|
|
22
|
-
isValid: boolean;
|
|
23
|
-
warnings: string[];
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=input-validation.utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"input-validation.utils.d.ts","sourceRoot":"","sources":["../../../../src/components/input/utils/input-validation.utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;GAEG;AACH,qBAAa,oBAAoB;IAE/B;;OAEG;IACH,MAAM,CAAC,yBAAyB,CAC9B,IAAI,EAAE,MAAM,EACZ,GAAG,CAAC,EAAE,MAAM,EACZ,GAAG,CAAC,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,MAAM,GACZ,IAAI;IAiBP;;OAEG;IACH,MAAM,CAAC,sBAAsB,CAC3B,YAAY,EAAE,aAAa,EAC3B,GAAG,CAAC,EAAE,MAAM,GACX,IAAI;IAyDP;;OAEG;IACH,MAAM,CAAC,oBAAoB,CACzB,KAAK,EAAE,MAAM,EACb,GAAG,CAAC,EAAE,MAAM,EACZ,GAAG,CAAC,EAAE,MAAM,GACX;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;KAAE;CA0B5C"}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2023 Google Laabidi Aymen
|
|
4
|
-
* SPDX-License-Identifier: MIT
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Validation utilities for input components
|
|
8
|
-
*/
|
|
9
|
-
export class InputValidationUtils {
|
|
10
|
-
/**
|
|
11
|
-
* Validates numeric properties (min, max, step) to ensure they are valid numbers
|
|
12
|
-
*/
|
|
13
|
-
static validateNumericProperties(type, min, max, step) {
|
|
14
|
-
if (type === "number" /* INPUT_TYPE.NUMBER */) {
|
|
15
|
-
if (min && isNaN(Number(min))) {
|
|
16
|
-
console.warn(`Invalid min value: "${min}" is not a valid number`);
|
|
17
|
-
}
|
|
18
|
-
if (max && isNaN(Number(max))) {
|
|
19
|
-
console.warn(`Invalid max value: "${max}" is not a valid number`);
|
|
20
|
-
}
|
|
21
|
-
if (step && isNaN(Number(step))) {
|
|
22
|
-
console.warn(`Invalid step value: "${step}" is not a valid number`);
|
|
23
|
-
}
|
|
24
|
-
if (min && max && Number(min) >= Number(max)) {
|
|
25
|
-
console.warn(`Invalid range: min value (${min}) should be less than max value (${max})`);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Prevents non-numeric characters from being typed in number inputs
|
|
31
|
-
*/
|
|
32
|
-
static preventNonNumericInput(keyDownEvent, min) {
|
|
33
|
-
const key = keyDownEvent.key;
|
|
34
|
-
const target = keyDownEvent.target;
|
|
35
|
-
const currentValue = target.value;
|
|
36
|
-
const cursorPosition = target.selectionStart || 0;
|
|
37
|
-
// Allow control keys (backspace, delete, tab, escape, enter, arrow keys, etc.)
|
|
38
|
-
const allowedControlKeys = [
|
|
39
|
-
'Backspace', 'Delete', 'Tab', 'Escape', 'Enter',
|
|
40
|
-
'ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown',
|
|
41
|
-
'Home', 'End', 'PageUp', 'PageDown'
|
|
42
|
-
];
|
|
43
|
-
// Allow Ctrl/Cmd combinations (copy, paste, select all, etc.)
|
|
44
|
-
if (keyDownEvent.ctrlKey || keyDownEvent.metaKey) {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
// Allow control keys
|
|
48
|
-
if (allowedControlKeys.includes(key)) {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
// Allow digits
|
|
52
|
-
if (/^\d$/.test(key)) {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
// Allow decimal point (.) only once and allow it at the beginning for values like ".5"
|
|
56
|
-
if (key === '.' || key === ',') {
|
|
57
|
-
const hasDecimal = currentValue.includes('.') || currentValue.includes(',');
|
|
58
|
-
if (!hasDecimal) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
// Allow minus sign (-) only at the beginning and if min allows negative numbers
|
|
63
|
-
if (key === '-') {
|
|
64
|
-
const hasMinusSign = currentValue.includes('-');
|
|
65
|
-
const minAllowsNegative = !min || Number(min) < 0;
|
|
66
|
-
if (!hasMinusSign && cursorPosition === 0 && minAllowsNegative) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
// Allow plus sign (+) only at the beginning
|
|
71
|
-
if (key === '+') {
|
|
72
|
-
const hasPlusSign = currentValue.includes('+');
|
|
73
|
-
if (!hasPlusSign && cursorPosition === 0) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
// If we reach here, prevent the key input
|
|
78
|
-
keyDownEvent.preventDefault();
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Validates a numeric value against min/max constraints
|
|
82
|
-
*/
|
|
83
|
-
static validateNumericValue(value, min, max) {
|
|
84
|
-
const warnings = [];
|
|
85
|
-
if (!value) {
|
|
86
|
-
return { isValid: true, warnings };
|
|
87
|
-
}
|
|
88
|
-
const numericValue = Number(value);
|
|
89
|
-
if (isNaN(numericValue)) {
|
|
90
|
-
return {
|
|
91
|
-
isValid: false,
|
|
92
|
-
warnings: [`Invalid numeric value: "${value}"`]
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
// Check min/max constraints
|
|
96
|
-
if (min && numericValue < Number(min)) {
|
|
97
|
-
warnings.push(`Value ${numericValue} is below minimum ${min}`);
|
|
98
|
-
}
|
|
99
|
-
if (max && numericValue > Number(max)) {
|
|
100
|
-
warnings.push(`Value ${numericValue} is above maximum ${max}`);
|
|
101
|
-
}
|
|
102
|
-
return { isValid: true, warnings };
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
//# sourceMappingURL=input-validation.utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"input-validation.utils.js","sourceR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ACZ,GAAY;QAEZ,MAAM,QAAQ,GAAa,EAAE,CAAC;QAE9B,IAAI,CAAC,KAAK,EAAE;YACV,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;SACpC;QAED,MAAM,YAAY,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QAEnC,IAAI,KAAK,CAAC,YAAY,CAAC,EAAE;YACvB,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,QAAQ,EAAE,CAAC,2BAA2B,KAAK,GAAG,CAAC;aAChD,CAAC;SACH;QAED,4BAA4B;QAC5B,IAAI,GAAG,IAAI,YAAY,GAAG,MAAM,CAAC,GAAG,CAAC,EAAE;YACrC,QAAQ,CAAC,IAAI,CAAC,SAAS,YAAY,qBAAqB,GAAG,EAAE,CAAC,CAAC;SAChE;QACD,IAAI,GAAG,IAAI,YAAY,GAAG,MAAM,CAAC,GAAG,CAAC,EAAE;YACrC,QAAQ,CAAC,IAAI,CAAC,SAAS,YAAY,qBAAqB,GAAG,EAAE,CAAC,CAAC;SAChE;QAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;IACrC,CAAC;CACF","sourcesContent":["/**\n * @license\n * Copyright 2023 Google Laabidi Aymen\n * SPDX-License-Identifier: MIT\n */\n\nimport { INPUT_TYPE } from '../input.types.js';\n\n/**\n * Validation utilities for input components\n */\nexport class InputValidationUtils {\n \n /**\n * Validates numeric properties (min, max, step) to ensure they are valid numbers\n */\n static validateNumericProperties(\n type: string,\n min?: string,\n max?: string,\n step?: string\n ): void {\n if (type === INPUT_TYPE.NUMBER) {\n if (min && isNaN(Number(min))) {\n console.warn(`Invalid min value: \"${min}\" is not a valid number`);\n }\n if (max && isNaN(Number(max))) {\n console.warn(`Invalid max value: \"${max}\" is not a valid number`);\n }\n if (step && isNaN(Number(step))) {\n console.warn(`Invalid step value: \"${step}\" is not a valid number`);\n }\n if (min && max && Number(min) >= Number(max)) {\n console.warn(`Invalid range: min value (${min}) should be less than max value (${max})`);\n }\n }\n }\n\n /**\n * Prevents non-numeric characters from being typed in number inputs\n */\n static preventNonNumericInput(\n keyDownEvent: KeyboardEvent,\n min?: string\n ): void {\n const key = keyDownEvent.key;\n const target = keyDownEvent.target as HTMLInputElement;\n const currentValue = target.value;\n const cursorPosition = target.selectionStart || 0;\n\n // Allow control keys (backspace, delete, tab, escape, enter, arrow keys, etc.)\n const allowedControlKeys = [\n 'Backspace', 'Delete', 'Tab', 'Escape', 'Enter',\n 'ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown',\n 'Home', 'End', 'PageUp', 'PageDown'\n ];\n\n // Allow Ctrl/Cmd combinations (copy, paste, select all, etc.)\n if (keyDownEvent.ctrlKey || keyDownEvent.metaKey) {\n return;\n }\n\n // Allow control keys\n if (allowedControlKeys.includes(key)) {\n return;\n }\n\n // Allow digits\n if (/^\\d$/.test(key)) {\n return;\n }\n\n // Allow decimal point (.) only once and allow it at the beginning for values like \".5\"\n if (key === '.' || key === ',') {\n const hasDecimal = currentValue.includes('.') || currentValue.includes(',');\n if (!hasDecimal) {\n return;\n }\n }\n\n // Allow minus sign (-) only at the beginning and if min allows negative numbers\n if (key === '-') {\n const hasMinusSign = currentValue.includes('-');\n const minAllowsNegative = !min || Number(min) < 0;\n if (!hasMinusSign && cursorPosition === 0 && minAllowsNegative) {\n return;\n }\n }\n\n // Allow plus sign (+) only at the beginning\n if (key === '+') {\n const hasPlusSign = currentValue.includes('+');\n if (!hasPlusSign && cursorPosition === 0) {\n return;\n }\n }\n\n // If we reach here, prevent the key input\n keyDownEvent.preventDefault();\n }\n\n /**\n * Validates a numeric value against min/max constraints\n */\n static validateNumericValue(\n value: string,\n min?: string,\n max?: string\n ): { isValid: boolean; warnings: string[] } {\n const warnings: string[] = [];\n \n if (!value) {\n return { isValid: true, warnings };\n }\n\n const numericValue = Number(value);\n \n if (isNaN(numericValue)) {\n return { \n isValid: false, \n warnings: [`Invalid numeric value: \"${value}\"`] \n };\n }\n\n // Check min/max constraints\n if (min && numericValue < Number(min)) {\n warnings.push(`Value ${numericValue} is below minimum ${min}`);\n }\n if (max && numericValue > Number(max)) {\n warnings.push(`Value ${numericValue} is above maximum ${max}`);\n }\n\n return { isValid: true, warnings };\n }\n}\n"]}
|
package/validation.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../src/components/input/validation.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,IAAI,QAAmF,CAAA;AAEpG,eAAO,MAAM,SAAS,QAAS,CAAC"}
|