@joystick.js/ui-canary 0.0.0-canary.28 → 0.0.0-canary.280
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/build.js +15 -0
- package/dist/index.js +20 -20
- package/increment_version.js +3 -0
- package/index.html +7 -0
- package/package.json +9 -13
- package/src/accounts/authenticated.js +8 -0
- package/src/accounts/index.js +21 -0
- package/src/accounts/login.js +7 -0
- package/src/accounts/logout.js +8 -0
- package/src/accounts/recover_password.js +7 -0
- package/src/accounts/request.js +70 -0
- package/src/accounts/reset_password.js +7 -0
- package/src/accounts/signup.js +7 -0
- package/src/accounts/user.js +8 -0
- package/src/api/get.js +73 -0
- package/src/api/index.js +10 -0
- package/src/api/set.js +83 -0
- package/src/attach_joystick_to_window.js +31 -0
- package/src/cache/class.js +98 -0
- package/src/cache/index.js +5 -0
- package/src/component/class.js +365 -0
- package/src/component/css/compile.js +108 -0
- package/src/component/data/compile.js +44 -0
- package/src/component/data/fetch.js +12 -0
- package/src/component/data/load_data_from_window.js +14 -0
- package/src/component/dom/is_valid_attribute_name.js +11 -0
- package/src/component/events/attach_event_listener_for_element.js +32 -0
- package/src/component/events/serialize.js +12 -0
- package/src/component/index.js +17 -0
- package/src/component/methods/compile.js +28 -0
- package/src/component/props/compile.js +21 -0
- package/src/component/props/compile_default.js +21 -0
- package/src/component/register_component_options.js +44 -0
- package/src/component/render_methods/component.js +54 -0
- package/src/component/render_methods/component_ssr.js +22 -0
- package/src/component/render_methods/each.js +19 -0
- package/src/component/render_methods/i18n.js +50 -0
- package/src/component/render_methods/index.js +19 -0
- package/src/component/render_methods/when.js +20 -0
- package/src/component/state/compile.js +21 -0
- package/src/component/url/compile.js +39 -0
- package/src/component/validate_component_options/has_required_options.js +9 -0
- package/src/component/validate_component_options/index.js +16 -0
- package/src/component/validate_component_options/required_options.js +5 -0
- package/src/component/virtual_dom/diff.js +61 -0
- package/src/component/virtual_dom/diff_attributes.js +37 -0
- package/src/component/virtual_dom/diff_children.js +74 -0
- package/src/component/virtual_dom/element_patch_functions.js +31 -0
- package/src/component/virtual_dom/map_patch_functions_to_nodes.js +14 -0
- package/src/component/virtual_dom/render_virtual_dom_to_dom.js +37 -0
- package/src/external/get.js +9 -0
- package/src/external/track.js +10 -0
- package/src/forms/validate.js +306 -0
- package/src/forms/validators/credit_card.js +19 -0
- package/src/forms/validators/custom.js +5 -0
- package/src/forms/validators/email.js +12 -0
- package/src/forms/validators/equals.js +5 -0
- package/src/forms/validators/index.js +43 -0
- package/src/forms/validators/matches.js +5 -0
- package/src/forms/validators/max_length.js +5 -0
- package/src/forms/validators/min_length.js +5 -0
- package/src/forms/validators/phone.js +14 -0
- package/src/forms/validators/postal_code.js +204 -0
- package/src/forms/validators/regex.js +5 -0
- package/src/forms/validators/required.js +13 -0
- package/src/forms/validators/semver.js +14 -0
- package/src/forms/validators/slug.js +12 -0
- package/src/forms/validators/strong_password.js +12 -0
- package/src/forms/validators/url.js +12 -0
- package/src/forms/validators/vat.js +54 -0
- package/src/index.js +55 -0
- package/src/lib/constants.js +13 -0
- package/src/lib/debounce.js +9 -0
- package/src/lib/generate_cookie_header.js +7 -0
- package/src/lib/generate_id.js +15 -0
- package/src/lib/get_joystick_environment.js +13 -0
- package/src/lib/log_request_errors.js +15 -0
- package/src/lib/nested_object_diff.js +164 -0
- package/src/lib/parse_json.js +12 -0
- package/src/lib/throw_framework_error.js +5 -0
- package/src/lib/types.js +59 -0
- package/src/mount/index.js +45 -0
- package/src/test/create_file.js +10 -0
- package/src/test/index.js +13 -0
- package/src/test/track_function_call.js +16 -0
- package/src/tree/add_node_to_tree.js +6 -0
- package/src/tree/clean_up.js +11 -0
- package/src/tree/get_child_instance_ids.js +7 -0
- package/src/tree/get_children_from_tree.js +25 -0
- package/src/tree/get_css_from_tree.js +43 -0
- package/src/tree/get_event_listeners_for_nodes.js +15 -0
- package/src/tree/get_node_from_tree.js +7 -0
- package/src/tree/get_parent_from_tree.js +8 -0
- package/src/tree/jobs/index.js +201 -0
- package/src/tree/jobs/run.js +11 -0
- package/src/tree/replace_child_in_vdom.js +18 -0
- package/src/upload/index.js +72 -0
- package/src/websockets/client.js +125 -0
- package/src/websockets/register_on_component.js +27 -0
- package/test.js +145 -0
- package/README.md +0 -8
- package/_package.json +0 -26
- package/canary.js +0 -12
- package/dist/accounts/authenticated.js +0 -1
- package/dist/accounts/index.js +0 -1
- package/dist/accounts/login.js +0 -1
- package/dist/accounts/logout.js +0 -1
- package/dist/accounts/recoverPassword.js +0 -1
- package/dist/accounts/request.js +0 -1
- package/dist/accounts/resetPassword.js +0 -1
- package/dist/accounts/signup.js +0 -1
- package/dist/accounts/user.js +0 -1
- package/dist/api/get.js +0 -1
- package/dist/api/index.js +0 -1
- package/dist/api/set.js +0 -1
- package/dist/attachJoystickToWindow.js +0 -1
- package/dist/cache/class.js +0 -1
- package/dist/cache/index.js +0 -1
- package/dist/component/class/css/compile.js +0 -21
- package/dist/component/class/css/prefix.js +0 -1
- package/dist/component/class/data/compile.js +0 -1
- package/dist/component/class/data/fetch.js +0 -1
- package/dist/component/class/data/findComponentDataFromSSR.js +0 -1
- package/dist/component/class/data/loadDataFromWindow.js +0 -1
- package/dist/component/class/events/_registerListeners.js +0 -1
- package/dist/component/class/events/_unregisterListeners.js +0 -1
- package/dist/component/class/events/registerListeners.js +0 -1
- package/dist/component/class/events/serialize.js +0 -1
- package/dist/component/class/events/unregisterListeners.js +0 -1
- package/dist/component/class/index.js +0 -21
- package/dist/component/class/lifecycle/compile.js +0 -1
- package/dist/component/class/methods/compile.js +0 -1
- package/dist/component/class/options/allowedComponentOptions.js +0 -1
- package/dist/component/class/options/allowedDOMEvents.js +0 -1
- package/dist/component/class/options/allowedLifecycleMethods.js +0 -1
- package/dist/component/class/options/defaultLifecycleMethods.js +0 -1
- package/dist/component/class/options/hasAllRequiredOptions.js +0 -1
- package/dist/component/class/options/registerOptions.js +0 -21
- package/dist/component/class/options/requiredOptions.js +0 -1
- package/dist/component/class/options/validateOptions.js +0 -1
- package/dist/component/class/options/validators/css.js +0 -1
- package/dist/component/class/options/validators/events.js +0 -1
- package/dist/component/class/options/validators/index.js +0 -1
- package/dist/component/class/options/validators/lifecycle.js +0 -1
- package/dist/component/class/options/validators/methods.js +0 -1
- package/dist/component/class/options/validators/name.js +0 -1
- package/dist/component/class/options/validators/render.js +0 -1
- package/dist/component/class/options/validators/websockets.js +0 -1
- package/dist/component/class/options/validators/wrapper.js +0 -1
- package/dist/component/class/props/compile.js +0 -1
- package/dist/component/class/props/compileDefault.js +0 -1
- package/dist/component/class/render/clearTimersOnChildren.js +0 -1
- package/dist/component/class/render/forMount.js +0 -1
- package/dist/component/class/render/getExistingPropsMap.js +0 -1
- package/dist/component/class/render/getExistingStateMap.js +0 -1
- package/dist/component/class/render/getUpdatedDOM.js +0 -1
- package/dist/component/class/render/sanitizeHTML.js +0 -1
- package/dist/component/class/render/toHTML.js +0 -1
- package/dist/component/class/render/wrapHTML.js +0 -1
- package/dist/component/class/renderMethods/compile.js +0 -1
- package/dist/component/class/renderMethods/component.js +0 -1
- package/dist/component/class/renderMethods/dragDrop/attachEventListeners.js +0 -1
- package/dist/component/class/renderMethods/dragDrop/concept.js +0 -0
- package/dist/component/class/renderMethods/dragDrop/draggable.js +0 -1
- package/dist/component/class/renderMethods/dragDrop/droppable.js +0 -1
- package/dist/component/class/renderMethods/dragDrop/index.js +0 -1
- package/dist/component/class/renderMethods/dragDrop/isBefore.js +0 -1
- package/dist/component/class/renderMethods/each.js +0 -1
- package/dist/component/class/renderMethods/i18n.js +0 -1
- package/dist/component/class/renderMethods/index.js +0 -1
- package/dist/component/class/renderMethods/when.js +0 -1
- package/dist/component/class/state/compile.js +0 -1
- package/dist/component/class/url/compile.js +0 -1
- package/dist/component/class/virtualDOM/build.js +0 -1
- package/dist/component/class/virtualDOM/buildTree.js +0 -1
- package/dist/component/class/virtualDOM/diff/attributes.js +0 -1
- package/dist/component/class/virtualDOM/diff/children.js +0 -1
- package/dist/component/class/virtualDOM/diff/elementPatchFunctions.js +0 -1
- package/dist/component/class/virtualDOM/diff/index.js +0 -1
- package/dist/component/class/virtualDOM/diff/mapPatchFunctionsToNodes.js +0 -1
- package/dist/component/class/virtualDOM/renderTreeToDOM.js +0 -1
- package/dist/component/index.js +0 -21
- package/dist/component/renderComponentToHTML.js +0 -1
- package/dist/component/tree/addChildToParent.js +0 -1
- package/dist/component/tree/clearChildrenOnParent.js +0 -1
- package/dist/component/tree/findComponentInTreeByField.js +0 -1
- package/dist/component/tree/replaceChildInVDOMTree.js +0 -1
- package/dist/component/tree/updateParentInstanceInTree.js +0 -1
- package/dist/css/getCSSFromTree.js +0 -21
- package/dist/css/update.js +0 -21
- package/dist/forms/validate.js +0 -1
- package/dist/forms/validators/creditCard.js +0 -1
- package/dist/forms/validators/email.js +0 -1
- package/dist/forms/validators/equals.js +0 -1
- package/dist/forms/validators/index.js +0 -1
- package/dist/forms/validators/matches.js +0 -1
- package/dist/forms/validators/maxLength.js +0 -1
- package/dist/forms/validators/minLength.js +0 -1
- package/dist/forms/validators/phone.js +0 -1
- package/dist/forms/validators/postalCode.js +0 -1
- package/dist/forms/validators/required.js +0 -1
- package/dist/forms/validators/semVer.js +0 -1
- package/dist/forms/validators/slug.js +0 -1
- package/dist/forms/validators/strongPassword.js +0 -1
- package/dist/forms/validators/types.js +0 -1
- package/dist/forms/validators/url.js +0 -1
- package/dist/forms/validators/vat.js +0 -1
- package/dist/html/index.js +0 -1
- package/dist/lib/addToQueue.js +0 -1
- package/dist/lib/assignOptionsToInstance.js +0 -1
- package/dist/lib/constants.js +0 -1
- package/dist/lib/debounce.js +0 -1
- package/dist/lib/generateId.js +0 -1
- package/dist/lib/isNode.js +0 -1
- package/dist/lib/isValidAttributeName.js +0 -1
- package/dist/lib/logRequestErrors.js +0 -1
- package/dist/lib/parseJSON.js +0 -1
- package/dist/lib/processQueue.js +0 -1
- package/dist/lib/queueArray.js +0 -1
- package/dist/lib/serializeEvents.js +0 -1
- package/dist/lib/stringContainsHTML.js +0 -1
- package/dist/lib/throttle.js +0 -1
- package/dist/lib/throwFrameworkError.js +0 -1
- package/dist/lib/types.js +0 -1
- package/dist/lib/windowIsUndefined.js +0 -1
- package/dist/mount/appendToTarget.js +0 -1
- package/dist/mount/index.js +0 -1
- package/dist/mount/initializeJoystickComponentTree.js +0 -1
- package/dist/overrideTimers.js +0 -1
- package/dist/upload/index.js +0 -1
- package/dist/websockets/client.js +0 -1
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Postal Code
|
|
3
|
+
* https://gist.github.com/jamesbar2/1c677c22df8f21e869cca7e439fc3f5b
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import types from "../../lib/types.js";
|
|
7
|
+
|
|
8
|
+
const regexes = {
|
|
9
|
+
AF: /^\d{4}$/,
|
|
10
|
+
AX: /^\d{5}$/,
|
|
11
|
+
AL: /^\d{4}$/,
|
|
12
|
+
DZ: /^\d{5}$/,
|
|
13
|
+
AS: /^\d{5}(-{1}\d{4,6})$/,
|
|
14
|
+
AD: /^[Aa][Dd]\d{3}$/,
|
|
15
|
+
AI: /^[Aa][I][-][2][6][4][0]$/,
|
|
16
|
+
AR: /^\d{4}|[A-Za-z]\d{4}[a-zA-Z]{3}$/,
|
|
17
|
+
AM: /^\d{4}$/,
|
|
18
|
+
AC: /^[Aa][Ss][Cc][Nn]\s{0,1}[1][Zz][Zz]$/,
|
|
19
|
+
AU: /^\d{4}$/,
|
|
20
|
+
AT: /^\d{4}$/,
|
|
21
|
+
AZ: /^[Aa][Zz]\d{4}$/,
|
|
22
|
+
BH: /^\d{3,4}$/,
|
|
23
|
+
BD: /^\d{4}$/,
|
|
24
|
+
BB: /^[Aa][Zz]\d{5}$/,
|
|
25
|
+
BY: /^\d{6}$/,
|
|
26
|
+
BE: /^\d{4}$/,
|
|
27
|
+
BM: /^[A-Za-z]{2}\s([A-Za-z]{2}|\d{2})$/,
|
|
28
|
+
BT: /^\d{5}$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{6}\s\(\d{3}-\d{3}\)$/,
|
|
96
|
+
XK: /^\d{5}$/,
|
|
97
|
+
KW: /^\d{5}$/,
|
|
98
|
+
KG: /^\d{6}$/,
|
|
99
|
+
LV: /^[Ll][Vv][- ]{0,1}\d{4}$/,
|
|
100
|
+
LA: /^\d{5}$/,
|
|
101
|
+
LB: /^\d{4}\s{0,1}\d{4}$/,
|
|
102
|
+
LS: /^\d{3}$/,
|
|
103
|
+
LR: /^\d{4}$/,
|
|
104
|
+
LY: /^\d{5}$/,
|
|
105
|
+
LI: /^\d{4}$/,
|
|
106
|
+
LT: /^[Ll][Tt][- ]{0,1}\d{5}$/,
|
|
107
|
+
LU: /^\d{4}$/,
|
|
108
|
+
MK: /^\d{4}$/,
|
|
109
|
+
MG: /^\d{3}$/,
|
|
110
|
+
MV: /^\d{4,5}$/,
|
|
111
|
+
MY: /^\d{5}$/,
|
|
112
|
+
MT: /^[A-Za-z]{3}\s{0,1}\d{4}$/,
|
|
113
|
+
MH: /^\d{5}$/,
|
|
114
|
+
MQ: /^972\d{2}$/,
|
|
115
|
+
YT: /^976\d{2}$/,
|
|
116
|
+
FM: /^\d{5}(-{1}\d{4})$/,
|
|
117
|
+
MX: /^\d{5}$/,
|
|
118
|
+
MD: /^[Mm][Dd][- ]{0,1}\d{4}$/,
|
|
119
|
+
MC: /^980\d{2}$/,
|
|
120
|
+
MN: /^\d{5}$/,
|
|
121
|
+
ME: /^\d{5}$/,
|
|
122
|
+
MS: /^[Mm][Ss][Rr]\s{0,1}\d{4}$/,
|
|
123
|
+
MA: /^\d{5}$/,
|
|
124
|
+
MZ: /^\d{4}$/,
|
|
125
|
+
MM: /^\d{5}$/,
|
|
126
|
+
NA: /^\d{5}$/,
|
|
127
|
+
NP: /^\d{5}$/,
|
|
128
|
+
NL: /^\d{4}\s{0,1}[A-Za-z]{2}$/,
|
|
129
|
+
NC: /^988\d{2}$/,
|
|
130
|
+
NZ: /^\d{4}$/,
|
|
131
|
+
NI: /^\d{5}$/,
|
|
132
|
+
NE: /^\d{4}$/,
|
|
133
|
+
NG: /^\d{6}$/,
|
|
134
|
+
NF: /^\d{4}$/,
|
|
135
|
+
MP: /^\d{5}$/,
|
|
136
|
+
NO: /^\d{4}$/,
|
|
137
|
+
OM: /^\d{3}$/,
|
|
138
|
+
PK: /^\d{5}$/,
|
|
139
|
+
PW: /^\d{5}$/,
|
|
140
|
+
PA: /^\d{6}$/,
|
|
141
|
+
PG: /^\d{3}$/,
|
|
142
|
+
PY: /^\d{4}$/,
|
|
143
|
+
PE: /^\d{5}$/,
|
|
144
|
+
PH: /^\d{4}$/,
|
|
145
|
+
PN: /^[Pp][Cc][Rr][Nn]\s{0,1}[1][Zz]{2}$/,
|
|
146
|
+
PL: /^\d{2}[- ]{0,1}\d{3}$/,
|
|
147
|
+
PT: /^\d{4}$/,
|
|
148
|
+
PR: /^\d{5}$/,
|
|
149
|
+
RE: /^974\d{2}$/,
|
|
150
|
+
RO: /^\d{6}$/,
|
|
151
|
+
RU: /^\d{6}$/,
|
|
152
|
+
BL: /^97133$/,
|
|
153
|
+
SH: /^[Ss][Tt][Hh][Ll]\s{0,1}[1][Zz]{2}$/,
|
|
154
|
+
MF: /^97150$/,
|
|
155
|
+
PM: /^97500$/,
|
|
156
|
+
VC: /^[Vv][Cc]\d{4}$/,
|
|
157
|
+
SM: /^4789\d$/,
|
|
158
|
+
SA: /^\d{5}(-{1}\d{4})?$/,
|
|
159
|
+
SN: /^\d{5}$/,
|
|
160
|
+
RS: /^\d{5}$/,
|
|
161
|
+
SG: /^\d{2}$/,
|
|
162
|
+
SK: /^\d{5}\s\(\d{3}\s\d{2}\)$/,
|
|
163
|
+
SI: /^([Ss][Ii][- ]{0,1}){0,1}\d{4}$/,
|
|
164
|
+
ZA: /^\d{4}$/,
|
|
165
|
+
GS: /^[Ss][Ii][Qq]{2}\s{0,1}[1][Zz]{2}$/,
|
|
166
|
+
ES: /^\d{5}$/,
|
|
167
|
+
LK: /^\d{5}$/,
|
|
168
|
+
SD: /^\d{5}$/,
|
|
169
|
+
SZ: /^[A-Za-z]\d{3}$/,
|
|
170
|
+
SE: /^\d{3}\s*\d{2}$/,
|
|
171
|
+
CH: /^\d{4}$/,
|
|
172
|
+
SJ: /^\d{4}$/,
|
|
173
|
+
TW: /^\d{5}$/,
|
|
174
|
+
TJ: /^\d{6}$/,
|
|
175
|
+
TH: /^\d{5}$/,
|
|
176
|
+
TT: /^\d{6}$/,
|
|
177
|
+
TN: /^\d{4}$/,
|
|
178
|
+
TR: /^\d{5}$/,
|
|
179
|
+
TM: /^\d{6}$/,
|
|
180
|
+
TC: /^[Tt][Kk][Cc][Aa]\s{0,1}[1][Zz]{2}$/,
|
|
181
|
+
UA: /^\d{5}$/,
|
|
182
|
+
GB: /^[A-Z]{1,2}[0-9R][0-9A-Z]?\s*[0-9][A-Z-[CIKMOV]]{2}/,
|
|
183
|
+
US: /^\b\d{5}\b(?:[- ]{1}\d{4})?$/,
|
|
184
|
+
UY: /^\d{5}$/,
|
|
185
|
+
VI: /^\d{5}$/,
|
|
186
|
+
UZ: /^\d{3} \d{3}$/,
|
|
187
|
+
VA: /^120$/,
|
|
188
|
+
VE: /^\d{4}(\s[a-zA-Z]{1})?$/,
|
|
189
|
+
VN: /^\d{6}$/,
|
|
190
|
+
WF: /^986\d{2}$/,
|
|
191
|
+
ZM: /^\d{5}$/
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
const postal_code = (rule, value = "") => {
|
|
195
|
+
const regex = types.is_object(rule) && rule.iso ? regexes[rule.iso || 'US'] : regexes.US;
|
|
196
|
+
|
|
197
|
+
if (types.is_object(rule)) {
|
|
198
|
+
return rule.rule === true ? !!value.match(regex) : !value.match(regex);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
return rule === true ? !!value.match(regex) : !value.match(regex);
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
export default postal_code;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const required = (rule, value = "", options = { isChecked: false }) => {
|
|
2
|
+
if (!options.isChecked) {
|
|
3
|
+
return rule === true
|
|
4
|
+
? value && value.trim() !== ""
|
|
5
|
+
: value && value.trim() === "";
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
if (options.isChecked) {
|
|
9
|
+
return rule === true ? value : !value;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default required;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Semver
|
|
3
|
+
* https://ihateregex.io/expr/semver/
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const regex = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
|
|
7
|
+
|
|
8
|
+
const semver = (rule, value = "") => {
|
|
9
|
+
return rule === true
|
|
10
|
+
? !!value.match(regex)
|
|
11
|
+
: !value.match(regex);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default semver;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Strong Password
|
|
3
|
+
* https://ihateregex.io/expr/password/
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const regex = /^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$ %^&*-]).{8,}$/;
|
|
7
|
+
|
|
8
|
+
const strong_password = (rule, value = "") => {
|
|
9
|
+
return rule === true ? !!value.match(regex) : !value.match(regex);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export default strong_password;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* URL
|
|
3
|
+
* https://ihateregex.io/expr/url/
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const regex = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()!@:%_\+.~#?&\/\/=]*)/;
|
|
7
|
+
|
|
8
|
+
const url = (rule, value = "") => {
|
|
9
|
+
return rule === true ? !!value.match(regex) : !value.match(regex);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export default url;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VAT
|
|
3
|
+
* https://gist.github.com/marcinlerka/630cc05d11bb10c5f1904506ff92abcd
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import types from "../../lib/types.js";
|
|
7
|
+
|
|
8
|
+
const regexes = {
|
|
9
|
+
AT: (/^(AT)(U\d{8}$)/i),
|
|
10
|
+
BE: (/^(BE)(\d{10}$)/i),
|
|
11
|
+
BG: (/^(BG)(\d{9,10}$)/i),
|
|
12
|
+
CY: (/^(CY)([0-5|9]\d{7}[A-Z]$)/i),
|
|
13
|
+
CZ: (/^(CZ)(\d{8,10})?$/i),
|
|
14
|
+
DE: (/^(DE)([1-9]\d{8}$)/i),
|
|
15
|
+
DK: (/^(DK)(\d{8}$)/i),
|
|
16
|
+
EE: (/^(EE)(10\d{7}$)/i),
|
|
17
|
+
EL: (/^(EL)(\d{9}$)/i),
|
|
18
|
+
ES: (/^(ES)([0-9A-Z][0-9]{7}[0-9A-Z]$)/i),
|
|
19
|
+
EU: (/^(EU)(\d{9}$)/i),
|
|
20
|
+
FI: (/^(FI)(\d{8}$)/i),
|
|
21
|
+
FR: (/^(FR)([0-9A-Z]{2}[0-9]{9}$)/i),
|
|
22
|
+
GB: (/^(GB)((?:[0-9]{12}|[0-9]{9}|(?:GD|HA)[0-9]{3})$)/i),
|
|
23
|
+
GR: (/^(GR)(\d{8,9}$)/i),
|
|
24
|
+
HR: (/^(HR)(\d{11}$)/i),
|
|
25
|
+
HU: (/^(HU)(\d{8}$)/i),
|
|
26
|
+
IE: (/^(IE)([0-9A-Z\*\+]{7}[A-Z]{1,2}$)/i),
|
|
27
|
+
IT: (/^(IT)(\d{11}$)/i),
|
|
28
|
+
LV: (/^(LV)(\d{11}$)/i),
|
|
29
|
+
LT: (/^(LT)(\d{9}$|\d{12}$)/i),
|
|
30
|
+
LU: (/^(LU)(\d{8}$)/i),
|
|
31
|
+
MT: (/^(MT)([1-9]\d{7}$)/i),
|
|
32
|
+
NL: (/^(NL)(\d{9}B\d{2}$)/i),
|
|
33
|
+
NO: (/^(NO)(\d{9}$)/i),
|
|
34
|
+
PL: (/^(PL)(\d{10}$)/i),
|
|
35
|
+
PT: (/^(PT)(\d{9}$)/i),
|
|
36
|
+
RO: (/^(RO)([1-9]\d{1,9}$)/i),
|
|
37
|
+
RU: (/^(RU)(\d{10}$|\d{12}$)/i),
|
|
38
|
+
RS: (/^(RS)(\d{9}$)/i),
|
|
39
|
+
SI: (/^(SI)([1-9]\d{7}$)/i),
|
|
40
|
+
SK: (/^(SK)([1-9]\d[(2-4)|(6-9)]\d{7}$)/i),
|
|
41
|
+
SE: (/^(SE)(\d{10}01$)/i)
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const vat = (rule, value = "") => {
|
|
45
|
+
const regex = types.is_object(rule) && rule.iso ? regexes[rule.iso || 'EU'] : regexes.EU;
|
|
46
|
+
|
|
47
|
+
if (types.is_object(rule)) {
|
|
48
|
+
return rule.rule === true ? !!value.match(regex) : !value.match(regex);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return rule === true ? !!value.match(regex) : !value.match(regex);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export default vat;
|
package/src/index.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import _accounts from './accounts/index.js';
|
|
2
|
+
import _cache from './cache/index.js';
|
|
3
|
+
import _get_external from './external/get.js';
|
|
4
|
+
import _test from './test/index.js';
|
|
5
|
+
import _track_external from './external/track.js';
|
|
6
|
+
import _upload from "./upload/index.js";
|
|
7
|
+
import api from "./api/index.js";
|
|
8
|
+
import attach_joystick_to_window from './attach_joystick_to_window.js';
|
|
9
|
+
import component from './component/index.js';
|
|
10
|
+
import generate_id from './lib/generate_id.js';
|
|
11
|
+
import get_joystick_environment from './lib/get_joystick_environment.js';
|
|
12
|
+
import mount from './mount/index.js';
|
|
13
|
+
|
|
14
|
+
const joystick_environment = get_joystick_environment();
|
|
15
|
+
|
|
16
|
+
export const accounts = _accounts;
|
|
17
|
+
export const cache = _cache;
|
|
18
|
+
export const external = {
|
|
19
|
+
get: _get_external,
|
|
20
|
+
track: _track_external,
|
|
21
|
+
};
|
|
22
|
+
export const get = api.get;
|
|
23
|
+
export const global_state = _cache('app', {});
|
|
24
|
+
export const set = api.set;
|
|
25
|
+
export const test = _test;
|
|
26
|
+
export const upload = _upload;
|
|
27
|
+
|
|
28
|
+
const joystick = {
|
|
29
|
+
_external: {},
|
|
30
|
+
_internal: {
|
|
31
|
+
tree: [],
|
|
32
|
+
},
|
|
33
|
+
accounts,
|
|
34
|
+
cache,
|
|
35
|
+
component,
|
|
36
|
+
env: {
|
|
37
|
+
development: joystick_environment === 'development',
|
|
38
|
+
staging: joystick_environment === 'staging',
|
|
39
|
+
production: joystick_environment === 'production',
|
|
40
|
+
test: joystick_environment === 'test',
|
|
41
|
+
},
|
|
42
|
+
external,
|
|
43
|
+
get,
|
|
44
|
+
global_state,
|
|
45
|
+
id: generate_id,
|
|
46
|
+
mount,
|
|
47
|
+
set,
|
|
48
|
+
test,
|
|
49
|
+
upload,
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
attach_joystick_to_window(joystick);
|
|
53
|
+
|
|
54
|
+
export default joystick;
|
|
55
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const CSS_COMMENT_REGEX = new RegExp(/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g);
|
|
2
|
+
export const CSS_SELECTOR_REGEX = new RegExp(/([^\r\n,{}]+)(,(?=[^}]*{)|\s*{)/g);
|
|
3
|
+
export const JOYSTICK_COMMENT_REGEX = new RegExp(/\<\!\-\-(?:.|\n|\r)*?-->/g);
|
|
4
|
+
export const WHEN_TAG_REGEX = new RegExp('<when>|</when>', 'g');
|
|
5
|
+
|
|
6
|
+
const constants = {
|
|
7
|
+
CSS_COMMENT_REGEX,
|
|
8
|
+
CSS_SELECTOR_REGEX,
|
|
9
|
+
JOYSTICK_COMMENT_REGEX,
|
|
10
|
+
WHEN_TAG_REGEX,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default constants;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890'.split('');
|
|
2
|
+
|
|
3
|
+
const generate_id = (length = 16) => {
|
|
4
|
+
let id = '';
|
|
5
|
+
let i = 0;
|
|
6
|
+
|
|
7
|
+
while (i < length) {
|
|
8
|
+
id += characters[Math.floor(Math.random() * (characters.length - 1))];
|
|
9
|
+
i += 1;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return id;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default generate_id;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const get_joystick_environment = () => {
|
|
2
|
+
if (typeof window !== 'undefined') {
|
|
3
|
+
return window.__joystick_environment__;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
if (typeof process !== 'undefined') {
|
|
7
|
+
return process.env.NODE_ENV;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return null;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default get_joystick_environment;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const log_request_errors = (label = '', errors = []) => {
|
|
2
|
+
console.error(`${label} failed with the following errors:`);
|
|
3
|
+
|
|
4
|
+
for (let i = 0; i < errors?.length; i += 1) {
|
|
5
|
+
const error = errors[i];
|
|
6
|
+
|
|
7
|
+
console.error(error.message);
|
|
8
|
+
|
|
9
|
+
if (error.stack) {
|
|
10
|
+
console.error(error.stack);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default log_request_errors;
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* nested-object-diff
|
|
3
|
+
* https://github.com/eraykose/nested-object-diff
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
class Diff {
|
|
7
|
+
constructor(type, path) {
|
|
8
|
+
this.type = type;
|
|
9
|
+
this.path = path ? path.toString() : '';
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
class EditDiff extends Diff {
|
|
14
|
+
constructor(path, original, current) {
|
|
15
|
+
super('E', path);
|
|
16
|
+
|
|
17
|
+
this.original = original;
|
|
18
|
+
this.current = current;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
class DiffMoved extends Diff {
|
|
23
|
+
constructor(path, item, original_index, current_index) {
|
|
24
|
+
super('M', path);
|
|
25
|
+
|
|
26
|
+
this.item = item;
|
|
27
|
+
this.original_index = original_index;
|
|
28
|
+
this.current_index = current_index;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
class DeleteDiff extends Diff {
|
|
33
|
+
constructor(path, original) {
|
|
34
|
+
super('D', path);
|
|
35
|
+
|
|
36
|
+
this.original = original;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
class NewDiff extends Diff {
|
|
41
|
+
constructor(path, current) {
|
|
42
|
+
super('A', path);
|
|
43
|
+
|
|
44
|
+
this.current = current;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const get_path = (current_path, key) => {
|
|
49
|
+
return current_path ? `${current_path}.${key}` : key;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const diff = (original, current, options = {}) => {
|
|
53
|
+
const diff_data = [];
|
|
54
|
+
const match_key = options.match_key;
|
|
55
|
+
const types = options.types || ['E', 'A', 'D', 'M'];
|
|
56
|
+
|
|
57
|
+
const nested_diff_match = (original_data, current_data, current_path, match_key) => {
|
|
58
|
+
original_data.forEach((original_item, original_item_index) => {
|
|
59
|
+
const current_found_item_index = current_data.findIndex(
|
|
60
|
+
current_item => current_item[match_key] === original_item[match_key]
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
if (current_found_item_index > -1) {
|
|
64
|
+
if (types.indexOf('M') > -1 && original_item_index !== current_found_item_index) {
|
|
65
|
+
diff_data.push(
|
|
66
|
+
new DiffMoved(current_path, original_item, original_item_index, current_found_item_index)
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
nested_diff(
|
|
71
|
+
original_item,
|
|
72
|
+
current_data[current_found_item_index],
|
|
73
|
+
get_path(current_path, current_found_item_index)
|
|
74
|
+
);
|
|
75
|
+
} else if (types.indexOf('D') > -1) {
|
|
76
|
+
diff_data.push(new DeleteDiff(current_path, original_item));
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
current_data.forEach((current_item, key) => {
|
|
81
|
+
const original_found_item_index = original_data.findIndex(
|
|
82
|
+
original_item => current_item[match_key] === original_item[match_key]
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
if (types.indexOf('A') > -1 && original_found_item_index === -1) {
|
|
86
|
+
diff_data.push(new NewDiff(get_path(current_path, key), current_item));
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const nested_diff = (original_data, current_data, current_path) => {
|
|
92
|
+
const typeof_original_data = Object.prototype.toString.call(original_data);
|
|
93
|
+
const typeof_current_data = Object.prototype.toString.call(current_data);
|
|
94
|
+
|
|
95
|
+
if (types.indexOf('E') > -1 && typeof_original_data !== typeof_current_data) {
|
|
96
|
+
diff_data.push(new EditDiff(current_path, original_data, current_data));
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (typeof_original_data === '[object Object]') {
|
|
101
|
+
Object.getOwnPropertyNames(original_data).forEach(key => {
|
|
102
|
+
if (Object.prototype.hasOwnProperty.call(current_data, key)) {
|
|
103
|
+
nested_diff(original_data[key], current_data[key], get_path(current_path, key));
|
|
104
|
+
} else if (types.indexOf('D') > -1) {
|
|
105
|
+
diff_data.push(new DeleteDiff(get_path(current_path, key), original_data[key]));
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
Object.getOwnPropertyNames(current_data).forEach(key => {
|
|
110
|
+
if (
|
|
111
|
+
types.indexOf('A') > -1 &&
|
|
112
|
+
!Object.prototype.hasOwnProperty.call(original_data, key)
|
|
113
|
+
) {
|
|
114
|
+
diff_data.push(new NewDiff(get_path(current_path, key), current_data[key]));
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
} else if (typeof_original_data === '[object Array]') {
|
|
118
|
+
if (!match_key) {
|
|
119
|
+
let original_data_length = original_data.length - 1;
|
|
120
|
+
let current_data_length = current_data.length - 1;
|
|
121
|
+
|
|
122
|
+
if (types.indexOf('D') > -1) {
|
|
123
|
+
while (original_data_length > current_data_length) {
|
|
124
|
+
diff_data.push(
|
|
125
|
+
new DeleteDiff(
|
|
126
|
+
get_path(current_path, original_data_length),
|
|
127
|
+
original_data[original_data_length--]
|
|
128
|
+
)
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (types.indexOf('A') > -1) {
|
|
134
|
+
while (current_data_length > original_data_length) {
|
|
135
|
+
diff_data.push(
|
|
136
|
+
new NewDiff(
|
|
137
|
+
get_path(current_path, current_data_length),
|
|
138
|
+
current_data[current_data_length--]
|
|
139
|
+
)
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
for (; original_data_length >= 0; --original_data_length) {
|
|
145
|
+
nested_diff(
|
|
146
|
+
original_data[original_data_length],
|
|
147
|
+
current_data[original_data_length],
|
|
148
|
+
get_path(current_path, original_data_length)
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
} else {
|
|
152
|
+
nested_diff_match(original_data, current_data, current_path, match_key);
|
|
153
|
+
}
|
|
154
|
+
} else if (types.indexOf('E') > -1 && original_data !== current_data) {
|
|
155
|
+
diff_data.push(new EditDiff(current_path, original_data, current_data));
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
nested_diff(original, current);
|
|
160
|
+
|
|
161
|
+
return diff_data;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
export default diff;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const parse_json = (json = '{}') => {
|
|
2
|
+
try {
|
|
3
|
+
const parsed_json = JSON.parse(json);
|
|
4
|
+
return parsed_json;
|
|
5
|
+
} catch {
|
|
6
|
+
// NOTE: If the above catches, we didn't get valid JSON. Just return
|
|
7
|
+
// whatever we got to the request (e.g., a string).
|
|
8
|
+
return json;
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export default parse_json;
|