@progress/kendo-react-inputs 9.0.0-develop.2 → 9.0.0-develop.4
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 +63 -62
- package/colors/ColorContrastLabels.mjs +10 -1
- package/colors/ColorContrastSvg.mjs +14 -2
- package/colors/ColorInput.js +1 -1
- package/colors/ColorInput.mjs +12 -9
- package/colors/ColorPalette.js +1 -1
- package/colors/ColorPalette.mjs +13 -14
- package/colors/ColorPicker.mjs +62 -79
- package/colors/FlatColorPicker.mjs +68 -22
- package/colors/models/palette-presets.mjs +656 -12
- package/colors/utils/color-cache.js +1 -1
- package/colors/utils/color-cache.mjs +3 -6
- package/colors/utils/color-parser.js +1 -1
- package/colors/utils/color-parser.mjs +2 -5
- package/dist/cdn/js/kendo-react-inputs.js +1 -1
- package/index.d.mts +1 -1
- package/index.d.ts +1 -1
- package/input/Input.js +1 -1
- package/input/Input.mjs +14 -10
- package/input/InputClearValue.mjs +6 -11
- package/input/InputPrefix.mjs +17 -18
- package/input/InputSeparator.mjs +12 -10
- package/input/InputSuffix.mjs +17 -18
- package/input/InputValidationIcon.mjs +3 -1
- package/maskedtextbox/masking.service.js +1 -1
- package/maskedtextbox/masking.service.mjs +2 -2
- package/maskedtextbox/parsing/parsers.js +1 -1
- package/maskedtextbox/parsing/parsers.mjs +22 -23
- package/numerictextbox/NumericTextBox.mjs +259 -320
- package/numerictextbox/utils/index.mjs +16 -14
- package/package-metadata.mjs +1 -1
- package/package.json +8 -8
- package/radiobutton/RadioButton.mjs +7 -18
- package/radiobutton/RadioGroup.mjs +3 -6
- package/range-slider/RangeSlider.mjs +68 -62
- package/rating/Rating.mjs +73 -90
- package/rating/RatingItem.mjs +29 -50
- package/signature/Signature.mjs +60 -93
- package/slider/SliderLabel.mjs +6 -10
- package/switch/Switch.mjs +9 -5
- package/textarea/TextArea.mjs +19 -47
- package/textbox/Textbox.mjs +37 -55
package/index.d.mts
CHANGED
|
@@ -2120,7 +2120,7 @@ declare type NumericTextBoxInputType = 'tel' | 'text' | 'number';
|
|
|
2120
2120
|
/**
|
|
2121
2121
|
* Represents the props of the [KendoReact NumericTextBox component]({% slug overview_numerictextbox %}).
|
|
2122
2122
|
*/
|
|
2123
|
-
export declare interface NumericTextBoxProps extends FormComponentProps, Omit<
|
|
2123
|
+
export declare interface NumericTextBoxProps extends FormComponentProps, Omit<React.HTMLAttributes<HTMLElement>, 'defaultValue' | 'prefix' | 'onChange' | 'onBlur' | 'onFocus'> {
|
|
2124
2124
|
/**
|
|
2125
2125
|
* Sets a class of the NumericTextBox DOM element.
|
|
2126
2126
|
*/
|
package/index.d.ts
CHANGED
|
@@ -2120,7 +2120,7 @@ declare type NumericTextBoxInputType = 'tel' | 'text' | 'number';
|
|
|
2120
2120
|
/**
|
|
2121
2121
|
* Represents the props of the [KendoReact NumericTextBox component]({% slug overview_numerictextbox %}).
|
|
2122
2122
|
*/
|
|
2123
|
-
export declare interface NumericTextBoxProps extends FormComponentProps, Omit<
|
|
2123
|
+
export declare interface NumericTextBoxProps extends FormComponentProps, Omit<React.HTMLAttributes<HTMLElement>, 'defaultValue' | 'prefix' | 'onChange' | 'onBlur' | 'onFocus'> {
|
|
2124
2124
|
/**
|
|
2125
2125
|
* Sets a class of the NumericTextBox DOM element.
|
|
2126
2126
|
*/
|
package/input/Input.js
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("react"),a=require("prop-types"),l=require("@progress/kendo-react-common"),P=require("@progress/kendo-react-labels"),L=require("../package-metadata.js");function D(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const h=D(I),s=class s extends h.Component{constructor(e){super(e),this._input=null,this.focus=()=>{this._input&&this._input.focus()},this.isInvalid=t=>{let i=!1;for(
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("react"),a=require("prop-types"),l=require("@progress/kendo-react-common"),P=require("@progress/kendo-react-labels"),L=require("../package-metadata.js");function D(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const h=D(I),s=class s extends h.Component{constructor(e){super(e),this._input=null,this.focus=()=>{this._input&&this._input.focus()},this.isInvalid=t=>{let i=!1;for(const r in t)t.hasOwnProperty(r)&&(i=i||!!t[r]);return i},this.setValidity=()=>{this._input&&this._input.setCustomValidity&&(this.validity.valid||!this.validityStyles?this._input.classList.remove("k-invalid"):this._input.classList.add("k-invalid"),this._input.setCustomValidity(this.validity.valid?"":this.props.validationMessage||""))},this.handleChange=t=>{this.setState({value:t.target.value}),this.valueDuringOnChange=t.target.value,this.props.onChange&&this.props.onChange.call(void 0,{syntheticEvent:t,nativeEvent:t.nativeEvent,value:t.target.value,target:this}),this.valueDuringOnChange=void 0},this.handleAutoFill=t=>{if(t.animationName==="autoFillStart"){const i=t.target.parentNode;i&&i.classList.contains("k-empty")&&i.classList.remove("k-empty")}},l.validatePackage(L.packageMetadata),this.state={value:this.props.defaultValue||s.defaultProps.defaultValue}}get _inputId(){return this.props.id}get element(){return this._input}get value(){return this.valueDuringOnChange!==void 0?this.valueDuringOnChange:this.props.value!==void 0?this.props.value:this.state.value}get name(){return this.props.name}get validity(){const e={badInput:this._input?this._input.validity.badInput:!1,patternMismatch:this._input?this._input.validity.patternMismatch:!1,rangeOverflow:this._input?this._input.validity.rangeOverflow:!1,rangeUnderflow:this._input?this._input.validity.rangeUnderflow:!1,stepMismatch:this._input?this._input.validity.stepMismatch:!1,tooLong:this._input?this._input.validity.tooLong:!1,typeMismatch:this._input?this._input.validity.typeMismatch:!1,valueMissing:this._input?this._input.validity.valueMissing:!1};return{...e,customError:this.props.validationMessage!==void 0,valid:this.props.valid!==void 0?this.props.valid:this._input?!this.isInvalid(e):!0}}get validityStyles(){return this.props.validityStyles!==void 0?this.props.validityStyles:s.defaultProps.validityStyles}componentDidMount(){this.forceUpdate()}componentDidUpdate(){this.setValidity()}render(){const{className:e,label:t,labelClassName:i,id:r,validationMessage:N,defaultValue:V,valid:k,unstyled:u,visited:w,touched:q,modified:F,autoFocus:m,ariaLabelledBy:b,ariaDescribedBy:_,validityStyles:E,style:c,ariaLabel:C,...o}=this.props,v=r||this._inputId,p=!this.validityStyles||this.validity.valid,M=u&&u.uInput,S=l.classNames(e,l.uInput.input({c:M,invalid:!p,disabled:this.props.disabled})),y=h.createElement("input",{"aria-labelledby":b,"aria-describedby":_,"aria-disabled":this.props.disabled||void 0,"aria-invalid":!p||void 0,"aria-label":C||void 0,...o,style:t?void 0:c,value:this.value,id:v,autoFocus:m,className:S,onChange:this.handleChange,onAnimationStart:this.handleAutoFill,ref:O=>{this._input=O}});return t?h.createElement(P.FloatingLabel,{label:t,labelClassName:i,editorId:v,editorValue:String(this.value),editorValid:p,editorDisabled:o.disabled,editorPlaceholder:o.placeholder,children:y,style:c,dir:o.dir,unstyled:u}):y}};s.displayName="Input",s.propTypes={label:a.string,labelClassName:a.string,validationMessage:a.string,required:a.bool,validate:a.bool,id:a.string,ariaLabelledBy:a.string,ariaDescribedBy:a.string,ariaLabel:a.string,autoFocus:a.bool},s.defaultProps={defaultValue:"",required:!1,validityStyles:!0,autoFocus:!1};let d=s;const g=l.createPropsContext(),f=l.withIdHOC(l.withPropsContext(g,l.withUnstyledHOC(d)));f.displayName="KendoReactInput";exports.Input=f;exports.InputPropsContext=g;exports.InputWithoutContext=d;
|
package/input/Input.mjs
CHANGED
|
@@ -17,13 +17,11 @@ const s = class s extends o.Component {
|
|
|
17
17
|
this._input && this._input.focus();
|
|
18
18
|
}, this.isInvalid = (t) => {
|
|
19
19
|
let a = !1;
|
|
20
|
-
for (
|
|
20
|
+
for (const l in t)
|
|
21
21
|
t.hasOwnProperty(l) && (a = a || !!t[l]);
|
|
22
22
|
return a;
|
|
23
23
|
}, this.setValidity = () => {
|
|
24
|
-
this._input && this._input.setCustomValidity && (this.validity.valid || !this.validityStyles ? this._input.classList.remove("k-invalid") : this._input.classList.add("k-invalid"), this._input.setCustomValidity(
|
|
25
|
-
this.validity.valid ? "" : this.props.validationMessage || ""
|
|
26
|
-
));
|
|
24
|
+
this._input && this._input.setCustomValidity && (this.validity.valid || !this.validityStyles ? this._input.classList.remove("k-invalid") : this._input.classList.add("k-invalid"), this._input.setCustomValidity(this.validity.valid ? "" : this.props.validationMessage || ""));
|
|
27
25
|
}, this.handleChange = (t) => {
|
|
28
26
|
this.setState({
|
|
29
27
|
value: t.target.value
|
|
@@ -35,7 +33,7 @@ const s = class s extends o.Component {
|
|
|
35
33
|
}), this.valueDuringOnChange = void 0;
|
|
36
34
|
}, this.handleAutoFill = (t) => {
|
|
37
35
|
if (t.animationName === "autoFillStart") {
|
|
38
|
-
|
|
36
|
+
const a = t.target.parentNode;
|
|
39
37
|
a && a.classList.contains("k-empty") && a.classList.remove("k-empty");
|
|
40
38
|
}
|
|
41
39
|
}, C(D), this.state = {
|
|
@@ -125,13 +123,14 @@ const s = class s extends o.Component {
|
|
|
125
123
|
style: u,
|
|
126
124
|
ariaLabel: m,
|
|
127
125
|
...n
|
|
128
|
-
} = this.props, h = l || this._inputId, d = !this.validityStyles || this.validity.valid, f = r && r.uInput, b = M(
|
|
129
|
-
|
|
126
|
+
} = this.props, h = l || this._inputId, d = !this.validityStyles || this.validity.valid, f = r && r.uInput, b = M(
|
|
127
|
+
e,
|
|
128
|
+
S.input({
|
|
130
129
|
c: f,
|
|
131
130
|
invalid: !d,
|
|
132
131
|
disabled: this.props.disabled
|
|
133
|
-
}
|
|
134
|
-
)
|
|
132
|
+
})
|
|
133
|
+
), v = /* @__PURE__ */ o.createElement(
|
|
135
134
|
"input",
|
|
136
135
|
{
|
|
137
136
|
"aria-labelledby": y,
|
|
@@ -188,7 +187,12 @@ s.displayName = "Input", s.propTypes = {
|
|
|
188
187
|
autoFocus: !1
|
|
189
188
|
};
|
|
190
189
|
let p = s;
|
|
191
|
-
const O = I(), w = L(
|
|
190
|
+
const O = I(), w = L(
|
|
191
|
+
V(
|
|
192
|
+
O,
|
|
193
|
+
N(p)
|
|
194
|
+
)
|
|
195
|
+
);
|
|
192
196
|
w.displayName = "KendoReactInput";
|
|
193
197
|
export {
|
|
194
198
|
w as Input,
|
|
@@ -9,18 +9,13 @@
|
|
|
9
9
|
import * as e from "react";
|
|
10
10
|
import { useUnstyled as c, classNames as m, uInput as o } from "@progress/kendo-react-common";
|
|
11
11
|
const p = e.forwardRef((t, a) => {
|
|
12
|
-
const n = e.useRef(null), l = e.useRef(null), s = c(), u = s && s.uInput, r = m(
|
|
13
|
-
{
|
|
12
|
+
const n = e.useRef(null), l = e.useRef(null), s = c(), u = s && s.uInput, r = m(
|
|
13
|
+
o.clearButton({
|
|
14
14
|
c: u
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
() => ({ element: l.current })
|
|
20
|
-
), e.useImperativeHandle(
|
|
21
|
-
a,
|
|
22
|
-
() => n.current
|
|
23
|
-
), /* @__PURE__ */ e.createElement("span", { ...t, className: r });
|
|
15
|
+
}),
|
|
16
|
+
t.className
|
|
17
|
+
);
|
|
18
|
+
return e.useImperativeHandle(n, () => ({ element: l.current })), e.useImperativeHandle(a, () => n.current), /* @__PURE__ */ e.createElement("span", { ...t, className: r });
|
|
24
19
|
});
|
|
25
20
|
p.displayName = "KendoReactInputClearValue";
|
|
26
21
|
export {
|
package/input/InputPrefix.mjs
CHANGED
|
@@ -8,24 +8,23 @@
|
|
|
8
8
|
"use client";
|
|
9
9
|
import * as e from "react";
|
|
10
10
|
import { useUnstyled as u, classNames as o, uTextBox as x } from "@progress/kendo-react-common";
|
|
11
|
-
const f = e.forwardRef(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
a,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
});
|
|
11
|
+
const f = e.forwardRef(
|
|
12
|
+
({ orientation: t = "horizontal", ...s }, r) => {
|
|
13
|
+
const a = e.useRef(null), c = e.useRef(null), n = u(), l = n && n.uTextBox;
|
|
14
|
+
e.useImperativeHandle(a, () => ({ element: c.current })), e.useImperativeHandle(r, () => a.current);
|
|
15
|
+
const m = e.useMemo(
|
|
16
|
+
() => o(
|
|
17
|
+
x.prefix({
|
|
18
|
+
c: l,
|
|
19
|
+
orientation: t
|
|
20
|
+
}),
|
|
21
|
+
s.className
|
|
22
|
+
),
|
|
23
|
+
[s.className, l, t]
|
|
24
|
+
);
|
|
25
|
+
return /* @__PURE__ */ e.createElement("span", { ...s, className: m });
|
|
26
|
+
}
|
|
27
|
+
);
|
|
29
28
|
f.displayName = "KendoReactInputPrefix";
|
|
30
29
|
export {
|
|
31
30
|
f as InputPrefix
|
package/input/InputSeparator.mjs
CHANGED
|
@@ -8,16 +8,18 @@
|
|
|
8
8
|
"use client";
|
|
9
9
|
import * as e from "react";
|
|
10
10
|
import { classNames as l } from "@progress/kendo-react-common";
|
|
11
|
-
const u = e.forwardRef(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
a,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
const u = e.forwardRef(
|
|
12
|
+
({ orientation: r = "vertical", ...t }, n) => {
|
|
13
|
+
const a = e.useRef(null), s = e.useRef(null);
|
|
14
|
+
return e.useImperativeHandle(a, () => ({ element: s.current })), e.useImperativeHandle(n, () => a.current), /* @__PURE__ */ e.createElement(
|
|
15
|
+
"span",
|
|
16
|
+
{
|
|
17
|
+
...t,
|
|
18
|
+
className: l("k-input-separator", t.className, `k-input-separator-${r}`)
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
);
|
|
21
23
|
u.displayName = "KendoReactInputSeparator";
|
|
22
24
|
export {
|
|
23
25
|
u as InputSeparator
|
package/input/InputSuffix.mjs
CHANGED
|
@@ -8,24 +8,23 @@
|
|
|
8
8
|
"use client";
|
|
9
9
|
import * as e from "react";
|
|
10
10
|
import { useUnstyled as o, classNames as r, uTextBox as f } from "@progress/kendo-react-common";
|
|
11
|
-
const x = e.forwardRef(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
a,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
});
|
|
11
|
+
const x = e.forwardRef(
|
|
12
|
+
({ orientation: t = "horizontal", ...s }, u) => {
|
|
13
|
+
const a = e.useRef(null), c = e.useRef(null), n = o(), l = n && n.uTextBox;
|
|
14
|
+
e.useImperativeHandle(a, () => ({ element: c.current })), e.useImperativeHandle(u, () => a.current);
|
|
15
|
+
const m = e.useMemo(
|
|
16
|
+
() => r(
|
|
17
|
+
f.suffix({
|
|
18
|
+
c: l,
|
|
19
|
+
orientation: t
|
|
20
|
+
}),
|
|
21
|
+
s.className
|
|
22
|
+
),
|
|
23
|
+
[s.className, l, t]
|
|
24
|
+
);
|
|
25
|
+
return /* @__PURE__ */ e.createElement("span", { ...s, className: m });
|
|
26
|
+
}
|
|
27
|
+
);
|
|
29
28
|
x.displayName = "KendoReactInputSuffix";
|
|
30
29
|
export {
|
|
31
30
|
x as InputSuffix
|
|
@@ -8,7 +8,9 @@
|
|
|
8
8
|
"use client";
|
|
9
9
|
import { IconWrap as n, classNames as o } from "@progress/kendo-react-common";
|
|
10
10
|
import * as e from "react";
|
|
11
|
-
const c = e.forwardRef(
|
|
11
|
+
const c = e.forwardRef(
|
|
12
|
+
(a, t) => /* @__PURE__ */ e.createElement(n, { ref: t, ...a, className: o("k-input-validation-icon", a.className) })
|
|
13
|
+
);
|
|
12
14
|
c.displayName = "KendoReactInputValidationIcon";
|
|
13
15
|
export {
|
|
14
16
|
c as InputValidationIcon
|
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./parsing/combinators.js"),a=require("./parsing/parsers.js");class u{constructor(){this.rules={},this.prompt="_",this.mask="",this.promptPlaceholder=" ",this.includeLiterals=!1,this.maskTokens=[],this.unmaskTokens=[],this.rawTokens=[],this.validationTokens=[]}update({mask:e="",prompt:s="",promptPlaceholder:t=" ",rules:r={},includeLiterals:n=!1}){this.mask=e,this.prompt=s,this.promptPlaceholder=t,this.rules=r,this.includeLiterals=n,this.tokenize()}validationValue(e=""){let s=e;return i.sequence(this.validationTokens).run(e).fold(t=>{s=t.join("")}),s}rawValue(e=""){let s=e;return this.rawTokens.length&&i.sequence(this.rawTokens).run(e).fold(t=>{s=t.join("")}),s}maskRaw(e=""){let s=e;return this.maskTokens.length&&i.sequence(this.maskTokens).run(e).fold(t=>{s=t.join("")}),s}maskInput(e,s,t){return e.length<s.length?this.maskRemoved(e,s,t):this.maskInserted(e,s,t)}maskInRange(e,s,t,r){let n=""
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./parsing/combinators.js"),a=require("./parsing/parsers.js");class u{constructor(){this.rules={},this.prompt="_",this.mask="",this.promptPlaceholder=" ",this.includeLiterals=!1,this.maskTokens=[],this.unmaskTokens=[],this.rawTokens=[],this.validationTokens=[]}update({mask:e="",prompt:s="",promptPlaceholder:t=" ",rules:r={},includeLiterals:n=!1}){this.mask=e,this.prompt=s,this.promptPlaceholder=t,this.rules=r,this.includeLiterals=n,this.tokenize()}validationValue(e=""){let s=e;return i.sequence(this.validationTokens).run(e).fold(t=>{s=t.join("")}),s}rawValue(e=""){let s=e;return this.rawTokens.length&&i.sequence(this.rawTokens).run(e).fold(t=>{s=t.join("")}),s}maskRaw(e=""){let s=e;return this.maskTokens.length&&i.sequence(this.maskTokens).run(e).fold(t=>{s=t.join("")}),s}maskInput(e,s,t){return e.length<s.length?this.maskRemoved(e,s,t):this.maskInserted(e,s,t)}maskInRange(e,s,t,r){let n="";const l=r,o=s.split("").slice(0,t),h=s.split("").slice(r);return i.sequence(this.maskTokens.slice(t,r)).run(e).fold(k=>{n=o.concat(k).concat(h).join("")}),{selection:l,value:n}}maskRemoved(e,s,t){let r="",n=t;const l=e.split("").slice(t),o=e.split("").slice(0,t).join(""),h=this.maskTokens.length-(e.length-t);return i.sequence(this.maskTokens.slice(0,h)).run(o,s).fold(k=>{n=this.adjustPosition(k,n),r=k.concat(l).join("")}),{selection:n,value:r}}adjustPosition(e,s){const t=e[s];return!this.maskTokens[s].isLiteral(t)&&t!==this.prompt?s+1:s}maskInserted(e,s,t){let r="",n=t;const l=e.slice(0,t);return i.sequence(this.unmaskTokens).run(l,s).chain(o=>{n=o.join("").length;const h=s.slice(n);return i.sequence(this.maskTokens).run(o.join("")+h,s)}).fold(o=>{r=o.join("")}),{selection:n,value:r}}get maskTokenCreator(){const{prompt:e,promptPlaceholder:s}=this;return{literal:t=>a.literal(t),mask:t=>a.mask({prompt:e,promptPlaceholder:s})(t)}}get unmaskTokenCreator(){return{literal:e=>a.unliteral(e),mask:e=>a.unmask(this.prompt)(e)}}get rawTokenCreator(){const{prompt:e,promptPlaceholder:s,includeLiterals:t}=this;return{literal:r=>a.rawLiteral(t),mask:r=>a.rawMask({prompt:e,promptPlaceholder:s})}}get validationTokenCreator(){const{prompt:e}=this;return{literal:s=>a.rawLiteral(!1),mask:s=>a.rawMask({prompt:e,promptPlaceholder:""})}}tokenize(){i.greedy(a.token(this.rules,this.maskTokenCreator)).run(this.mask).fold((e,s)=>{this.maskTokens=e}),i.greedy(a.token(this.rules,this.unmaskTokenCreator)).run(this.mask).fold((e,s)=>{this.unmaskTokens=e}),i.greedy(a.token(this.rules,this.rawTokenCreator)).run(this.mask).fold((e,s)=>{this.rawTokens=e}),i.greedy(a.token(this.rules,this.validationTokenCreator)).run(this.mask).fold((e,s)=>{this.validationTokens=e})}}exports.MaskingService=u;
|
|
@@ -40,8 +40,8 @@ class C {
|
|
|
40
40
|
return e.length < s.length ? this.maskRemoved(e, s, t) : this.maskInserted(e, s, t);
|
|
41
41
|
}
|
|
42
42
|
maskInRange(e, s, t, r) {
|
|
43
|
-
let n = ""
|
|
44
|
-
const a = s.split("").slice(0, t), l = s.split("").slice(r);
|
|
43
|
+
let n = "";
|
|
44
|
+
const o = r, a = s.split("").slice(0, t), l = s.split("").slice(r);
|
|
45
45
|
return i(this.maskTokens.slice(t, r)).run(e).fold((h) => {
|
|
46
46
|
n = a.concat(h).concat(l).join("");
|
|
47
47
|
}), {
|
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./result.js"),o=require("./stream.js"),w=r=>(r||"").split(""),a="\\";class s{constructor(t){this.parse=t}run(t,e=""){return t instanceof o.Stream?this.parse(t):this.parse(new o.Stream(w(t),w(e)))}map(t){return new s(e=>this.parse(e).map(t))}chain(t){return new s(e=>this.parse(e).chain((l
|
|
8
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./result.js"),o=require("./stream.js"),w=r=>(r||"").split(""),a="\\";class s{constructor(t){this.parse=t}run(t,e=""){return t instanceof o.Stream?this.parse(t):this.parse(new o.Stream(w(t),w(e)))}map(t){return new s(e=>this.parse(e).map(t))}chain(t){return new s(e=>this.parse(e).chain((u,l)=>t(u).run(l)))}isLiteral(t){return this.run(t).type===n.ResultType.Literal}}const p=r=>t=>new s(e=>{const{prompt:u,promptPlaceholder:l}=r;for(;!e.eof();){const{char:i,control:c}=e.peek();if(i===c&&c===u)return e.eat(),new n.Result(u,e,n.ResultType.Mask);if(t.test(i))return e.eat(),new n.Result(i,e,n.ResultType.Mask);if(i===l)return e.eat(),new n.Result(u,e,n.ResultType.Mask);e.eat_input()}return e.eat(),new n.Result(u,e,n.ResultType.Mask)}),R=r=>new s(t=>t.peek().char===r?(t.eat(),new n.Result(r,t,n.ResultType.Literal)):new n.Result(r,t,n.ResultType.Literal)),h=r=>t=>new s(e=>{for(;!e.eof();){const{char:u,control:l}=e.peek();if(u===r&&l===r)return e.eat(),new n.Result(u,e);if(t.test(u))return e.eat(),new n.Result(u,e);e.eat_input()}return e.eat(),new n.Result("",e)}),f=r=>new s(t=>{if(t.eof())return new n.Result("",t);const{char:e}=t.peek();return e===r&&t.eat(),new n.Result(r,t)}),k=(r,t)=>new s(e=>{let{char:u}=e.next();const l=r[u];return u===a?(u=e.next().char,new n.Result(t.literal(u),e)):l?new n.Result(t.mask(l),e):new n.Result(t.literal(u),e)}),y=r=>new s(t=>{const{prompt:e,promptPlaceholder:u}=r,{char:l}=t.next();return l===e?new n.Result(u,t):new n.Result(l,t)}),T=r=>new s(t=>{const{char:e}=t.next();return r?new n.Result(e,t):new n.Result("",t)});exports.Parser=s;exports.literal=R;exports.mask=p;exports.rawLiteral=T;exports.rawMask=y;exports.token=k;exports.unliteral=f;exports.unmask=h;
|
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
8
|
"use client";
|
|
9
|
-
import { Result as i, ResultType as
|
|
9
|
+
import { Result as i, ResultType as u } from "./result.mjs";
|
|
10
10
|
import { Stream as p } from "./stream.mjs";
|
|
11
11
|
const h = (t) => (t || "").split(""), a = "\\";
|
|
12
|
-
class
|
|
12
|
+
class o {
|
|
13
13
|
constructor(e) {
|
|
14
14
|
this.parse = e;
|
|
15
15
|
}
|
|
@@ -18,30 +18,30 @@ class u {
|
|
|
18
18
|
}
|
|
19
19
|
// map :: Functor f => f a ~> (a -> b) -> f b
|
|
20
20
|
map(e) {
|
|
21
|
-
return new
|
|
21
|
+
return new o((n) => this.parse(n).map(e));
|
|
22
22
|
}
|
|
23
23
|
// chain :: Chain m => m a ~> (a -> m b) -> m b
|
|
24
24
|
chain(e) {
|
|
25
|
-
return new
|
|
25
|
+
return new o((n) => this.parse(n).chain((r, c) => e(r).run(c)));
|
|
26
26
|
}
|
|
27
27
|
isLiteral(e) {
|
|
28
|
-
return this.run(e).type ===
|
|
28
|
+
return this.run(e).type === u.Literal;
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
const k = (t) => (e) => new
|
|
31
|
+
const k = (t) => (e) => new o((n) => {
|
|
32
32
|
const { prompt: r, promptPlaceholder: c } = t;
|
|
33
33
|
for (; !n.eof(); ) {
|
|
34
|
-
const { char:
|
|
35
|
-
if (
|
|
36
|
-
return n.eat(), new i(r, n,
|
|
37
|
-
if (e.test(
|
|
38
|
-
return n.eat(), new i(
|
|
39
|
-
if (
|
|
40
|
-
return n.eat(), new i(r, n,
|
|
34
|
+
const { char: w, control: l } = n.peek();
|
|
35
|
+
if (w === l && l === r)
|
|
36
|
+
return n.eat(), new i(r, n, u.Mask);
|
|
37
|
+
if (e.test(w))
|
|
38
|
+
return n.eat(), new i(w, n, u.Mask);
|
|
39
|
+
if (w === c)
|
|
40
|
+
return n.eat(), new i(r, n, u.Mask);
|
|
41
41
|
n.eat_input();
|
|
42
42
|
}
|
|
43
|
-
return n.eat(), new i(r, n,
|
|
44
|
-
}), x = (t) => new
|
|
43
|
+
return n.eat(), new i(r, n, u.Mask);
|
|
44
|
+
}), x = (t) => new o((e) => e.peek().char === t ? (e.eat(), new i(t, e, u.Literal)) : new i(t, e, u.Literal)), L = (t) => (e) => new o((n) => {
|
|
45
45
|
for (; !n.eof(); ) {
|
|
46
46
|
const { char: r, control: c } = n.peek();
|
|
47
47
|
if (r === t && c === t)
|
|
@@ -51,25 +51,24 @@ const k = (t) => (e) => new u((n) => {
|
|
|
51
51
|
n.eat_input();
|
|
52
52
|
}
|
|
53
53
|
return n.eat(), new i("", n);
|
|
54
|
-
}), M = (t) => new
|
|
54
|
+
}), M = (t) => new o((e) => {
|
|
55
55
|
if (e.eof())
|
|
56
56
|
return new i("", e);
|
|
57
57
|
const { char: n } = e.peek();
|
|
58
58
|
return n === t && e.eat(), new i(t, e);
|
|
59
|
-
}), A = (t, e) => new
|
|
59
|
+
}), A = (t, e) => new o((n) => {
|
|
60
60
|
let { char: r } = n.next();
|
|
61
61
|
const c = t[r];
|
|
62
62
|
return r === a ? (r = n.next().char, new i(e.literal(r), n)) : c ? new i(e.mask(c), n) : new i(e.literal(r), n);
|
|
63
|
-
}), R = (t) => new
|
|
64
|
-
const { prompt: n, promptPlaceholder: r } = t;
|
|
65
|
-
let { char: c } = e.next();
|
|
63
|
+
}), R = (t) => new o((e) => {
|
|
64
|
+
const { prompt: n, promptPlaceholder: r } = t, { char: c } = e.next();
|
|
66
65
|
return c === n ? new i(r, e) : new i(c, e);
|
|
67
|
-
}), y = (t) => new
|
|
68
|
-
|
|
66
|
+
}), y = (t) => new o((e) => {
|
|
67
|
+
const { char: n } = e.next();
|
|
69
68
|
return t ? new i(n, e) : new i("", e);
|
|
70
69
|
});
|
|
71
70
|
export {
|
|
72
|
-
|
|
71
|
+
o as Parser,
|
|
73
72
|
x as literal,
|
|
74
73
|
k as mask,
|
|
75
74
|
y as rawLiteral,
|