@progress/kendo-react-inputs 9.0.0-develop.2 → 9.0.0-develop.20
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 +15 -12
- 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/HexInput.js +1 -1
- package/colors/HexInput.mjs +9 -8
- 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 +21 -87
- package/index.d.ts +21 -87
- package/index.js +1 -1
- package/index.mjs +65 -66
- package/input/Input.js +1 -1
- package/input/Input.mjs +144 -179
- 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 +9 -9
- 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/input/Input.mjs
CHANGED
|
@@ -6,192 +6,157 @@
|
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
8
|
"use client";
|
|
9
|
-
import * as
|
|
10
|
-
import
|
|
11
|
-
import { validatePackage as
|
|
12
|
-
import { FloatingLabel as
|
|
13
|
-
import { packageMetadata as
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
get element() {
|
|
52
|
-
return this._input;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Gets the value of the Input.
|
|
56
|
-
*/
|
|
57
|
-
get value() {
|
|
58
|
-
return this.valueDuringOnChange !== void 0 ? this.valueDuringOnChange : this.props.value !== void 0 ? this.props.value : this.state.value;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Gets the `name` property of the Input.
|
|
62
|
-
*/
|
|
63
|
-
get name() {
|
|
64
|
-
return this.props.name;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Represents the validity state into which the Input is set.
|
|
68
|
-
*/
|
|
69
|
-
get validity() {
|
|
70
|
-
const e = {
|
|
71
|
-
badInput: this._input ? this._input.validity.badInput : !1,
|
|
72
|
-
patternMismatch: this._input ? this._input.validity.patternMismatch : !1,
|
|
73
|
-
rangeOverflow: this._input ? this._input.validity.rangeOverflow : !1,
|
|
74
|
-
rangeUnderflow: this._input ? this._input.validity.rangeUnderflow : !1,
|
|
75
|
-
stepMismatch: this._input ? this._input.validity.stepMismatch : !1,
|
|
76
|
-
tooLong: this._input ? this._input.validity.tooLong : !1,
|
|
77
|
-
typeMismatch: this._input ? this._input.validity.typeMismatch : !1,
|
|
78
|
-
valueMissing: this._input ? this._input.validity.valueMissing : !1
|
|
9
|
+
import * as r from "react";
|
|
10
|
+
import a from "prop-types";
|
|
11
|
+
import { validatePackage as J, applyDefaultProps as Q, useUnstyled as W, useId as X, classNames as Y, uInput as Z, createPropsContext as _ } from "@progress/kendo-react-common";
|
|
12
|
+
import { FloatingLabel as $ } from "@progress/kendo-react-labels";
|
|
13
|
+
import { packageMetadata as ee } from "../package-metadata.mjs";
|
|
14
|
+
const I = r.forwardRef((L, M) => {
|
|
15
|
+
const P = r.useContext(te).call(void 0, L);
|
|
16
|
+
J(ee);
|
|
17
|
+
const [, x] = r.useReducer((t) => t, !0), i = Q(P, ae), {
|
|
18
|
+
className: E,
|
|
19
|
+
label: o,
|
|
20
|
+
labelClassName: N,
|
|
21
|
+
id: k,
|
|
22
|
+
validationMessage: v,
|
|
23
|
+
defaultValue: R,
|
|
24
|
+
valid: p,
|
|
25
|
+
unstyled: f,
|
|
26
|
+
// Removed to support direct use in Form Field component
|
|
27
|
+
visited: ie,
|
|
28
|
+
touched: ne,
|
|
29
|
+
modified: se,
|
|
30
|
+
autoFocus: V,
|
|
31
|
+
ariaLabelledBy: w,
|
|
32
|
+
ariaDescribedBy: F,
|
|
33
|
+
validityStyles: m,
|
|
34
|
+
style: y,
|
|
35
|
+
ariaLabel: U,
|
|
36
|
+
...B
|
|
37
|
+
} = i, D = W(), g = f || D, O = g && g.uInput, S = X(), [T, q] = r.useState({
|
|
38
|
+
value: R
|
|
39
|
+
}), b = k || S, e = r.useRef(null), s = r.useRef(void 0), u = r.useRef(null), A = () => {
|
|
40
|
+
e.current && e.current.focus();
|
|
41
|
+
}, c = () => s.current !== void 0 ? s.current : i.value !== void 0 ? i.value : T.value, l = () => {
|
|
42
|
+
const t = {
|
|
43
|
+
badInput: e.current ? e.current.validity.badInput : !1,
|
|
44
|
+
patternMismatch: e.current ? e.current.validity.patternMismatch : !1,
|
|
45
|
+
rangeOverflow: e.current ? e.current.validity.rangeOverflow : !1,
|
|
46
|
+
rangeUnderflow: e.current ? e.current.validity.rangeUnderflow : !1,
|
|
47
|
+
stepMismatch: e.current ? e.current.validity.stepMismatch : !1,
|
|
48
|
+
tooLong: e.current ? e.current.validity.tooLong : !1,
|
|
49
|
+
typeMismatch: e.current ? e.current.validity.typeMismatch : !1,
|
|
50
|
+
valueMissing: e.current ? e.current.validity.valueMissing : !1
|
|
79
51
|
};
|
|
80
52
|
return {
|
|
81
|
-
...
|
|
82
|
-
customError:
|
|
83
|
-
valid:
|
|
53
|
+
...t,
|
|
54
|
+
customError: v !== void 0,
|
|
55
|
+
valid: p !== void 0 ? p : e.current ? !G(t) : !0
|
|
84
56
|
};
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
"
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
unstyled: r
|
|
169
|
-
}
|
|
170
|
-
) : v;
|
|
171
|
-
}
|
|
172
|
-
};
|
|
173
|
-
s.displayName = "Input", s.propTypes = {
|
|
174
|
-
label: i.string,
|
|
175
|
-
labelClassName: i.string,
|
|
176
|
-
validationMessage: i.string,
|
|
177
|
-
required: i.bool,
|
|
178
|
-
validate: i.bool,
|
|
179
|
-
id: i.string,
|
|
180
|
-
ariaLabelledBy: i.string,
|
|
181
|
-
ariaDescribedBy: i.string,
|
|
182
|
-
ariaLabel: i.string,
|
|
183
|
-
autoFocus: i.bool
|
|
184
|
-
}, s.defaultProps = {
|
|
57
|
+
};
|
|
58
|
+
r.useImperativeHandle(u, () => ({
|
|
59
|
+
element: e.current,
|
|
60
|
+
props: i,
|
|
61
|
+
get value() {
|
|
62
|
+
return c();
|
|
63
|
+
},
|
|
64
|
+
name: i.name,
|
|
65
|
+
get validity() {
|
|
66
|
+
return l();
|
|
67
|
+
},
|
|
68
|
+
focus: A
|
|
69
|
+
})), r.useImperativeHandle(M, () => u.current);
|
|
70
|
+
const G = (t) => {
|
|
71
|
+
let n = !1;
|
|
72
|
+
for (const C in t)
|
|
73
|
+
t.hasOwnProperty(C) && (n = n || !!t[C]);
|
|
74
|
+
return n;
|
|
75
|
+
}, d = !m || l().valid, H = Y(
|
|
76
|
+
E,
|
|
77
|
+
Z.input({
|
|
78
|
+
c: O,
|
|
79
|
+
invalid: !d,
|
|
80
|
+
disabled: i.disabled
|
|
81
|
+
})
|
|
82
|
+
), K = () => {
|
|
83
|
+
e.current && e.current.setCustomValidity && (l().valid || !m ? e.current.classList.remove("k-invalid") : e.current.classList.add("k-invalid"), e.current.setCustomValidity(l().valid ? "" : v || ""));
|
|
84
|
+
}, j = (t) => {
|
|
85
|
+
q({
|
|
86
|
+
value: t.target.value
|
|
87
|
+
}), s.current = t.target.value, i.onChange && i.onChange.call(void 0, {
|
|
88
|
+
syntheticEvent: t,
|
|
89
|
+
nativeEvent: t.nativeEvent,
|
|
90
|
+
value: t.target.value,
|
|
91
|
+
target: u.current
|
|
92
|
+
}), s.current = void 0;
|
|
93
|
+
}, z = (t) => {
|
|
94
|
+
if (t.animationName === "autoFillStart") {
|
|
95
|
+
const n = t.target.parentNode;
|
|
96
|
+
n && n.classList.contains("k-empty") && n.classList.remove("k-empty");
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
r.useEffect(() => {
|
|
100
|
+
x();
|
|
101
|
+
}, []), r.useEffect(() => {
|
|
102
|
+
K();
|
|
103
|
+
});
|
|
104
|
+
const h = /* @__PURE__ */ r.createElement(
|
|
105
|
+
"input",
|
|
106
|
+
{
|
|
107
|
+
"aria-labelledby": w,
|
|
108
|
+
"aria-describedby": F,
|
|
109
|
+
"aria-disabled": i.disabled || void 0,
|
|
110
|
+
"aria-invalid": !d || void 0,
|
|
111
|
+
"aria-label": U || void 0,
|
|
112
|
+
...B,
|
|
113
|
+
style: o ? void 0 : y,
|
|
114
|
+
value: c(),
|
|
115
|
+
id: b,
|
|
116
|
+
autoFocus: V,
|
|
117
|
+
className: H,
|
|
118
|
+
onChange: j,
|
|
119
|
+
onAnimationStart: z,
|
|
120
|
+
ref: e
|
|
121
|
+
}
|
|
122
|
+
);
|
|
123
|
+
return o ? /* @__PURE__ */ r.createElement(
|
|
124
|
+
$,
|
|
125
|
+
{
|
|
126
|
+
label: o,
|
|
127
|
+
labelClassName: N,
|
|
128
|
+
editorId: b,
|
|
129
|
+
editorValue: String(c()),
|
|
130
|
+
editorValid: d,
|
|
131
|
+
editorDisabled: i.disabled,
|
|
132
|
+
editorPlaceholder: i.placeholder,
|
|
133
|
+
children: h,
|
|
134
|
+
style: y,
|
|
135
|
+
dir: i.dir,
|
|
136
|
+
unstyled: f
|
|
137
|
+
}
|
|
138
|
+
) : h;
|
|
139
|
+
}), te = _(), ae = {
|
|
185
140
|
defaultValue: "",
|
|
186
141
|
required: !1,
|
|
187
142
|
validityStyles: !0,
|
|
188
143
|
autoFocus: !1
|
|
189
144
|
};
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
145
|
+
I.displayName = "KendoReactInput";
|
|
146
|
+
I.propTypes = {
|
|
147
|
+
label: a.string,
|
|
148
|
+
labelClassName: a.string,
|
|
149
|
+
validationMessage: a.string,
|
|
150
|
+
required: a.bool,
|
|
151
|
+
validate: a.bool,
|
|
152
|
+
id: a.string,
|
|
153
|
+
ariaLabelledBy: a.string,
|
|
154
|
+
ariaDescribedBy: a.string,
|
|
155
|
+
ariaLabel: a.string,
|
|
156
|
+
autoFocus: a.bool,
|
|
157
|
+
value: a.oneOfType([a.string, a.number, a.array])
|
|
158
|
+
};
|
|
193
159
|
export {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
p as InputWithoutContext
|
|
160
|
+
I as Input,
|
|
161
|
+
te as InputPropsContext
|
|
197
162
|
};
|
|
@@ -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,
|