lilact 0.15.4 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -6
- package/bin/bundle.cjs +148 -60
- package/dist/lilact.development.js +5332 -10264
- package/dist/lilact.development.js.map +7 -1
- package/dist/lilact.development.min.js +54 -11
- package/dist/lilact.development.min.js.map +7 -1
- package/dist/lilact.production.min.js +53 -10
- package/docs/assets/hierarchy.js +1 -1
- package/docs/classes/accessories.ErrorBoundary.html +11 -11
- package/docs/classes/accessories.Suspense.html +10 -10
- package/docs/classes/components.Component.html +11 -11
- package/docs/classes/components.HTMLComponent.html +11 -11
- package/docs/classes/components.RootComponent.html +11 -11
- package/docs/functions/accessories.DragHandle.html +1 -1
- package/docs/functions/accessories.Spinner.html +1 -1
- package/docs/functions/components.createComponent.html +1 -1
- package/docs/functions/components.createRoot.html +1 -1
- package/docs/functions/components.render.html +1 -1
- package/docs/functions/errors.globalErrorHandler.html +1 -1
- package/docs/functions/errors.traceError.html +1 -1
- package/docs/functions/hooks.createContext.html +1 -1
- package/docs/functions/hooks.useActionState.html +1 -1
- package/docs/functions/hooks.useCallback.html +1 -1
- package/docs/functions/hooks.useContext.html +1 -1
- package/docs/functions/hooks.useDeferredValue.html +1 -1
- package/docs/functions/hooks.useEffect.html +1 -1
- package/docs/functions/hooks.useHook.html +1 -1
- package/docs/functions/hooks.useId.html +1 -1
- package/docs/functions/hooks.useImperativeHandle.html +1 -1
- package/docs/functions/hooks.useLayoutEffect.html +1 -1
- package/docs/functions/hooks.useLocalStorage.html +1 -1
- package/docs/functions/hooks.useMemo.html +1 -1
- package/docs/functions/hooks.useReducer.html +1 -1
- package/docs/functions/hooks.useRef.html +1 -1
- package/docs/functions/hooks.useState.html +1 -1
- package/docs/functions/hooks.useTransition.html +1 -1
- package/docs/functions/misc.Fragment.html +2 -2
- package/docs/functions/misc.deepEqual.html +1 -1
- package/docs/functions/misc.findDOMNode.html +1 -1
- package/docs/functions/misc.forwardRef.html +1 -1
- package/docs/functions/misc.getComponentByPointer.html +1 -1
- package/docs/functions/misc.isAsync.html +1 -1
- package/docs/functions/misc.isClass.html +1 -1
- package/docs/functions/misc.isEmpty.html +1 -1
- package/docs/functions/misc.isError.html +1 -1
- package/docs/functions/misc.isThenable.html +1 -1
- package/docs/functions/misc.isValidElement.html +1 -1
- package/docs/functions/misc.shallowEqual.html +1 -1
- package/docs/functions/misc.toBool.html +1 -1
- package/docs/functions/redux.Provider.html +1 -1
- package/docs/functions/redux.combineReducers.html +1 -1
- package/docs/functions/redux.connect.html +1 -1
- package/docs/functions/redux.useDispatch.html +1 -1
- package/docs/functions/redux.useSelector.html +1 -1
- package/docs/functions/redux.useStore.html +1 -1
- package/docs/functions/router.HashRouter.html +1 -1
- package/docs/functions/router.Link.html +1 -1
- package/docs/functions/router.NavLink.html +1 -1
- package/docs/functions/router.Route.html +1 -1
- package/docs/functions/router.Routes.html +1 -1
- package/docs/functions/router.useLocation.html +1 -1
- package/docs/functions/router.useNavigate.html +1 -1
- package/docs/functions/run.lazy.html +1 -1
- package/docs/functions/run.require.html +1 -1
- package/docs/functions/run.run.html +1 -1
- package/docs/functions/run.runScripts.html +1 -1
- package/docs/functions/timers.animationFramePromise.html +1 -1
- package/docs/functions/timers.clearInterval.html +1 -1
- package/docs/functions/timers.clearTimeout.html +1 -1
- package/docs/functions/timers.grabTimers.html +1 -1
- package/docs/functions/timers.pauseTimers.html +1 -1
- package/docs/functions/timers.releaseTimers.html +1 -1
- package/docs/functions/timers.resetTimers.html +1 -1
- package/docs/functions/timers.resumeTimers.html +1 -1
- package/docs/functions/timers.setInterval.html +1 -1
- package/docs/functions/timers.setTimeout.html +1 -1
- package/docs/functions/timers.timeoutPromise.html +12 -12
- package/docs/functions/transition.CSSTransition.html +1 -1
- package/docs/functions/transition.SwitchTransition.html +1 -1
- package/docs/functions/transition.Transition.html +1 -1
- package/docs/functions/transition.TransitionGroup.html +1 -1
- package/docs/hierarchy.html +1 -1
- package/docs/index.html +8 -7
- package/docs/static/index.html +2 -0
- package/docs/static/lilact.development.js +5332 -10264
- package/docs/static/lilact.development.js.map +7 -0
- package/docs/static/lilact.development.min.js +54 -11
- package/docs/static/lilact.development.min.js.map +7 -0
- package/docs/static/lilact.production.min.js +53 -10
- package/docs/variables/accessories.SplitPane.html +1 -1
- package/docs/variables/misc.Children.html +2 -2
- package/package.json +11 -14
- package/root/index.html +2 -0
- package/root/lilact.development.js +5332 -10264
- package/root/lilact.development.js.map +7 -0
- package/root/lilact.development.min.js +54 -11
- package/root/lilact.development.min.js.map +7 -0
- package/root/lilact.production.min.js +53 -10
- package/{webpack.config.factory.cjs → scripts/build.mjs} +48 -73
- package/scripts/copy-dist-to-root.mjs +13 -0
- package/scripts/esbuild-preprocessor-plugin.cjs +29 -0
- package/scripts/preprocess.mjs +42 -0
- package/src/accessories.jsx +2 -28
- package/src/components.jsx +1 -1
- package/src/hooks.jsx +5 -6
- package/src/jsx.js +30 -26
- package/src/lilact.jsx +3 -2
- package/src/proptypes.jsx +407 -0
- package/tsconfig.json +1 -2
- package/typedoc.json +13 -13
- package/dist/lilact.development.min.js.LICENSE.txt +0 -83
- package/dist/lilact.production.min.js.map +0 -1
- package/src/loader.cjs +0 -59
- package/webpack.config.js +0 -206
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
/*
|
|
2
|
+
|
|
3
|
+
Lilact
|
|
4
|
+
Copyright (C) 2024-2026 Arash Kazemi <contact.arash.kazemi@gmail.com>
|
|
5
|
+
All rights reserved.
|
|
6
|
+
|
|
7
|
+
BSD-2-Clause
|
|
8
|
+
|
|
9
|
+
Redistribution and use in source and binary forms, with or without
|
|
10
|
+
modification, are permitted provided that the following conditions are met:
|
|
11
|
+
|
|
12
|
+
* Redistributions of source code must retain the above copyright
|
|
13
|
+
notice, this list of conditions and the following disclaimer.
|
|
14
|
+
* Redistributions in binary form must reproduce the above copyright
|
|
15
|
+
notice, this list of conditions and the following disclaimer in the
|
|
16
|
+
documentation and/or other materials provided with the distribution.
|
|
17
|
+
|
|
18
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
19
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
20
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
21
|
+
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
|
22
|
+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
23
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
24
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
25
|
+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
26
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
27
|
+
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
28
|
+
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
function isNullOrUndefined(v) {
|
|
32
|
+
return v === null || v === undefined;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function shallowCopy(obj) {
|
|
36
|
+
return Object.assign({}, obj);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function formatComponentName(componentName) {
|
|
40
|
+
return componentName || "<<anonymous>>";
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function defaultGetDisplayName(x) {
|
|
44
|
+
if (!x) return "Unknown";
|
|
45
|
+
return x.displayName || x.name || "Unknown";
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Build a prop validator with a consistent contract:
|
|
50
|
+
* validator(props, propName, componentName, location, propFullName)
|
|
51
|
+
* returns null if OK, Error if invalid.
|
|
52
|
+
*
|
|
53
|
+
* Each validator also gets `.isRequired`.
|
|
54
|
+
*/
|
|
55
|
+
function createPrimitiveValidator(typeCheck) {
|
|
56
|
+
const validator = function validate(props, propName, componentName, location, propFullName, secret) {
|
|
57
|
+
// secret is accepted for compatibility, but we don't gate on it.
|
|
58
|
+
const value = props[propName];
|
|
59
|
+
|
|
60
|
+
// Non-required: null/undefined is OK (matches prop-types behavior)
|
|
61
|
+
if (isNullOrUndefined(value)) return null;
|
|
62
|
+
|
|
63
|
+
if (typeCheck(value)) return null;
|
|
64
|
+
|
|
65
|
+
const expected = typeCheck.expectedType || "the correct type";
|
|
66
|
+
const actual = value === null ? "null" : typeof value;
|
|
67
|
+
return new Error(
|
|
68
|
+
`Invalid ${location} \`${propFullName}\` of type \`${actual}\` supplied to \`${formatComponentName(componentName)}\`, expected \`${expected}\`.`
|
|
69
|
+
);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
validator.isRequired = function validateRequired(props, propName, componentName, location, propFullName) {
|
|
73
|
+
const value = props[propName];
|
|
74
|
+
|
|
75
|
+
if (isNullOrUndefined(value)) {
|
|
76
|
+
return new Error(
|
|
77
|
+
`The ${location} \`${propFullName}\` is marked as required in \`${formatComponentName(componentName)}\`, but its value is \`${value}\`.`
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
return validator(props, propName, componentName, location, propFullName);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
return validator;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function createPropTypes() {
|
|
87
|
+
const PropTypes = {};
|
|
88
|
+
|
|
89
|
+
PropTypes.any = (function () {
|
|
90
|
+
const v = function validateAny(props, propName, componentName, location, propFullName) {
|
|
91
|
+
return null; // always ok
|
|
92
|
+
};
|
|
93
|
+
v.isRequired = function validateAnyRequired() {
|
|
94
|
+
return null; // always ok even if required
|
|
95
|
+
};
|
|
96
|
+
return v;
|
|
97
|
+
})();
|
|
98
|
+
|
|
99
|
+
PropTypes.array = createPrimitiveValidator((v) => Array.isArray(v));
|
|
100
|
+
PropTypes.array.expectedType = "array";
|
|
101
|
+
|
|
102
|
+
PropTypes.bool = createPrimitiveValidator((v) => typeof v === "boolean");
|
|
103
|
+
PropTypes.bool.expectedType = "boolean";
|
|
104
|
+
|
|
105
|
+
PropTypes.func = createPrimitiveValidator((v) => typeof v === "function");
|
|
106
|
+
PropTypes.func.expectedType = "function";
|
|
107
|
+
|
|
108
|
+
PropTypes.number = createPrimitiveValidator((v) => typeof v === "number" && !Number.isNaN(v));
|
|
109
|
+
PropTypes.number.expectedType = "number";
|
|
110
|
+
|
|
111
|
+
PropTypes.object = createPrimitiveValidator((v) => typeof v === "object" && v !== null && !Array.isArray(v));
|
|
112
|
+
PropTypes.object.expectedType = "object";
|
|
113
|
+
|
|
114
|
+
PropTypes.string = createPrimitiveValidator((v) => typeof v === "string");
|
|
115
|
+
PropTypes.string.expectedType = "string";
|
|
116
|
+
|
|
117
|
+
PropTypes.symbol = createPrimitiveValidator((v) => typeof v === "symbol");
|
|
118
|
+
PropTypes.symbol.expectedType = "symbol";
|
|
119
|
+
|
|
120
|
+
// ----- combinators -----
|
|
121
|
+
|
|
122
|
+
PropTypes.oneOf = function oneOf(values) {
|
|
123
|
+
const allowed = Array.isArray(values) ? values : [];
|
|
124
|
+
const validator = function validateOneOf(props, propName, componentName, location, propFullName) {
|
|
125
|
+
const value = props[propName];
|
|
126
|
+
if (isNullOrUndefined(value)) return null;
|
|
127
|
+
|
|
128
|
+
for (let i = 0; i < allowed.length; i++) {
|
|
129
|
+
if (value === allowed[i]) return null;
|
|
130
|
+
}
|
|
131
|
+
const actual = value === null ? "null" : typeof value;
|
|
132
|
+
return new Error(
|
|
133
|
+
`Invalid ${location} \`${propFullName}\` of value \`${String(value)}\` supplied to \`${formatComponentName(componentName)}\`, expected one of [${allowed.map(String).join(", ")}] (received type \`${actual}\`).`
|
|
134
|
+
);
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
validator.isRequired = function validateOneOfRequired(props, propName, componentName, location, propFullName) {
|
|
138
|
+
if (isNullOrUndefined(props[propName])) {
|
|
139
|
+
return new Error(
|
|
140
|
+
`The ${location} \`${propFullName}\` is marked as required in \`${formatComponentName(componentName)}\`, but its value is \`${props[propName]}\`.`
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
return validator(props, propName, componentName, location, propFullName);
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
return validator;
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
PropTypes.oneOfType = function oneOfType(validators) {
|
|
150
|
+
const vlist = validators || [];
|
|
151
|
+
const validator = function validateOneOfType(props, propName, componentName, location, propFullName) {
|
|
152
|
+
const value = props[propName];
|
|
153
|
+
if (isNullOrUndefined(value)) return null;
|
|
154
|
+
|
|
155
|
+
for (let i = 0; i < vlist.length; i++) {
|
|
156
|
+
const err = vlist[i](props, propName, componentName, location, propFullName);
|
|
157
|
+
if (err === null) return null;
|
|
158
|
+
}
|
|
159
|
+
return new Error(
|
|
160
|
+
`Invalid ${location} \`${propFullName}\` supplied to \`${formatComponentName(componentName)}\` (none of the allowed types matched).`
|
|
161
|
+
);
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
validator.isRequired = function validateOneOfTypeRequired(props, propName, componentName, location, propFullName) {
|
|
165
|
+
if (isNullOrUndefined(props[propName])) {
|
|
166
|
+
return new Error(
|
|
167
|
+
`The ${location} \`${propFullName}\` is marked as required in \`${formatComponentName(componentName)}\`, but its value is \`${props[propName]}\`.`
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
return validator(props, propName, componentName, location, propFullName);
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
return validator;
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
PropTypes.arrayOf = function arrayOf(innerValidator) {
|
|
177
|
+
const inner = innerValidator;
|
|
178
|
+
const validator = function validateArrayOf(props, propName, componentName, location, propFullName) {
|
|
179
|
+
const value = props[propName];
|
|
180
|
+
if (isNullOrUndefined(value)) return null;
|
|
181
|
+
if (!Array.isArray(value)) {
|
|
182
|
+
return new Error(
|
|
183
|
+
`Invalid ${location} \`${propFullName}\` of type \`${typeof value}\` supplied to \`${formatComponentName(componentName)}\`, expected an array.`
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
for (let i = 0; i < value.length; i++) {
|
|
188
|
+
const itemPath = `${propFullName}[${i}]`;
|
|
189
|
+
|
|
190
|
+
const itemErr = inner(
|
|
191
|
+
{ [propName]: value[i] },
|
|
192
|
+
propName,
|
|
193
|
+
componentName,
|
|
194
|
+
location,
|
|
195
|
+
itemPath
|
|
196
|
+
);
|
|
197
|
+
if (itemErr !== null) return itemErr;
|
|
198
|
+
}
|
|
199
|
+
return null;
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
validator.isRequired = function validateArrayOfRequired(props, propName, componentName, location, propFullName) {
|
|
203
|
+
if (isNullOrUndefined(props[propName])) {
|
|
204
|
+
return new Error(
|
|
205
|
+
`The ${location} \`${propFullName}\` is marked as required in \`${formatComponentName(componentName)}\`, but its value is \`${props[propName]}\`.`
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
return validator(props, propName, componentName, location, propFullName);
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
return validator;
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
PropTypes.objectOf = function objectOf(innerValidator) {
|
|
215
|
+
const inner = innerValidator;
|
|
216
|
+
const validator = function validateObjectOf(props, propName, componentName, location, propFullName) {
|
|
217
|
+
const value = props[propName];
|
|
218
|
+
if (isNullOrUndefined(value)) return null;
|
|
219
|
+
|
|
220
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
221
|
+
return new Error(
|
|
222
|
+
`Invalid ${location} \`${propFullName}\` of type \`${typeof value}\` supplied to \`${formatComponentName(componentName)}\`, expected an object.`
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const keys = Object.keys(value);
|
|
227
|
+
for (let i = 0; i < keys.length; i++) {
|
|
228
|
+
const k = keys[i];
|
|
229
|
+
const keyPath = `${propFullName}.${k}`;
|
|
230
|
+
const keyErr = inner(
|
|
231
|
+
{ [propName]: value[k] },
|
|
232
|
+
propName,
|
|
233
|
+
componentName,
|
|
234
|
+
location,
|
|
235
|
+
keyPath
|
|
236
|
+
);
|
|
237
|
+
if (keyErr !== null) return keyErr;
|
|
238
|
+
}
|
|
239
|
+
return null;
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
validator.isRequired = function validateObjectOfRequired(props, propName, componentName, location, propFullName) {
|
|
243
|
+
if (isNullOrUndefined(props[propName])) {
|
|
244
|
+
return new Error(
|
|
245
|
+
`The ${location} \`${propFullName}\` is marked as required in \`${formatComponentName(componentName)}\`, but its value is \`${props[propName]}\`.`
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
return validator(props, propName, componentName, location, propFullName);
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
return validator;
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
function makeShapeValidator(spec, { exact }) {
|
|
255
|
+
const keys = spec ? Object.keys(spec) : [];
|
|
256
|
+
|
|
257
|
+
const validator = function validateShapeLike(props, propName, componentName, location, propFullName) {
|
|
258
|
+
const value = props[propName];
|
|
259
|
+
const propIsMissing = isNullOrUndefined(value);
|
|
260
|
+
|
|
261
|
+
if (propIsMissing) return null; // optional shape/exact: missing is allowed
|
|
262
|
+
|
|
263
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
264
|
+
return new Error(
|
|
265
|
+
`Invalid ${location} \`${propFullName}\` of type \`${typeof value}\` supplied to \`${formatComponentName(componentName)}\`, expected an object.`
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// For exact, fail on extra keys
|
|
270
|
+
if (exact) {
|
|
271
|
+
const valueKeys = Object.keys(value);
|
|
272
|
+
for (let i = 0; i < valueKeys.length; i++) {
|
|
273
|
+
const k = valueKeys[i];
|
|
274
|
+
if (!Object.prototype.hasOwnProperty.call(spec, k)) {
|
|
275
|
+
const keyPath = `${propFullName}.${k}`;
|
|
276
|
+
return new Error(
|
|
277
|
+
`Invalid ${location} \`${keyPath}\` supplied to \`${formatComponentName(componentName)}\`: extra key \`${k}\` is not allowed by exact().`
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
// Validate spec keys
|
|
284
|
+
for (let i = 0; i < keys.length; i++) {
|
|
285
|
+
const k = keys[i];
|
|
286
|
+
const specValidator = spec[k];
|
|
287
|
+
const nestedVal = value[k];
|
|
288
|
+
const nestedPath = `${propFullName}.${k}`;
|
|
289
|
+
|
|
290
|
+
if (isNullOrUndefined(nestedVal)) {
|
|
291
|
+
// decide requiredness from whether specValidator has isRequired wrapper identity
|
|
292
|
+
// In prop-types, requiredness is encoded by calling `.isRequired`, which returns a validator that errors on missing.
|
|
293
|
+
// Here, we can detect by presence of an internal flag; we don't have one, so we handle requiredness by trying both:
|
|
294
|
+
// - call specValidator (optional) -> if it returns null/undefined-missing allowed
|
|
295
|
+
// - BUT we need correct behavior: specValidator itself is already the chosen validator (required or not).
|
|
296
|
+
// So just call specValidator normally with nested props; required validators will error if missing.
|
|
297
|
+
const err = specValidator(
|
|
298
|
+
{ [propName]: nestedVal },
|
|
299
|
+
propName,
|
|
300
|
+
componentName,
|
|
301
|
+
location,
|
|
302
|
+
nestedPath
|
|
303
|
+
);
|
|
304
|
+
if (err !== null) return err;
|
|
305
|
+
continue;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
// present: validate with specValidator
|
|
309
|
+
const err = specValidator(
|
|
310
|
+
{ [propName]: nestedVal },
|
|
311
|
+
propName,
|
|
312
|
+
componentName,
|
|
313
|
+
location,
|
|
314
|
+
nestedPath
|
|
315
|
+
);
|
|
316
|
+
if (err !== null) return err;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
return null;
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
validator.isRequired = function validateShapeLikeRequired(props, propName, componentName, location, propFullName) {
|
|
323
|
+
if (isNullOrUndefined(props[propName])) {
|
|
324
|
+
return new Error(
|
|
325
|
+
`The ${location} \`${propFullName}\` is marked as required in \`${formatComponentName(componentName)}\`, but its value is \`${props[propName]}\`.`
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
return validator(props, propName, componentName, location, propFullName);
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
return validator;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
PropTypes.shape = function shape(spec) {
|
|
335
|
+
return makeShapeValidator(spec, { exact: false });
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
PropTypes.exact = function exact(spec) {
|
|
339
|
+
return makeShapeValidator(spec, { exact: true });
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
PropTypes.instanceOf = function instanceOf(ClassOrConstructor) {
|
|
343
|
+
const validator = function validateInstanceOf(props, propName, componentName, location, propFullName) {
|
|
344
|
+
const value = props[propName];
|
|
345
|
+
if (isNullOrUndefined(value)) return null;
|
|
346
|
+
|
|
347
|
+
if (value instanceof ClassOrConstructor) return null;
|
|
348
|
+
|
|
349
|
+
return new Error(
|
|
350
|
+
`Invalid ${location} \`${propFullName}\` supplied to \`${formatComponentName(componentName)}\`: expected instance of \`${defaultGetDisplayName(ClassOrConstructor)}\`.`
|
|
351
|
+
);
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
validator.isRequired = function validateInstanceOfRequired(props, propName, componentName, location, propFullName) {
|
|
355
|
+
if (isNullOrUndefined(props[propName])) {
|
|
356
|
+
return new Error(
|
|
357
|
+
`The ${location} \`${propFullName}\` is marked as required in \`${formatComponentName(componentName)}\`, but its value is \`${props[propName]}\`.`
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
return validator(props, propName, componentName, location, propFullName);
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
return validator;
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
// ----- checkPropTypes -----
|
|
367
|
+
|
|
368
|
+
const warningCache = new Set();
|
|
369
|
+
|
|
370
|
+
PropTypes.checkPropTypes = function checkPropTypes(typeSpecs, values, location, componentName) {
|
|
371
|
+
if (!DEBUG) return;
|
|
372
|
+
|
|
373
|
+
if (!typeSpecs) return;
|
|
374
|
+
const specs = typeSpecs;
|
|
375
|
+
|
|
376
|
+
const component = formatComponentName(componentName);
|
|
377
|
+
|
|
378
|
+
const typeSpecKeys = Object.keys(specs);
|
|
379
|
+
for (let i = 0; i < typeSpecKeys.length; i++) {
|
|
380
|
+
const propKey = typeSpecKeys[i];
|
|
381
|
+
const validator = specs[propKey];
|
|
382
|
+
|
|
383
|
+
if (typeof validator !== "function") continue;
|
|
384
|
+
|
|
385
|
+
const fullName = propKey;
|
|
386
|
+
|
|
387
|
+
const err = validator(values || {}, propKey, component, location, fullName);
|
|
388
|
+
if (err instanceof Error) {
|
|
389
|
+
const cacheKey = `${component}|${location}|${propKey}|${err.message}`;
|
|
390
|
+
if (warningCache.has(cacheKey)) continue;
|
|
391
|
+
warningCache.add(cacheKey);
|
|
392
|
+
|
|
393
|
+
// mimic dev warnings
|
|
394
|
+
if (typeof console !== "undefined" && console.error) {
|
|
395
|
+
console.error(
|
|
396
|
+
`Warning: Failed prop type: ${err.message}`
|
|
397
|
+
);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
};
|
|
402
|
+
|
|
403
|
+
return PropTypes;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
// Export default PropTypes-like object
|
|
407
|
+
export const PropTypes = createPropTypes();
|
package/tsconfig.json
CHANGED
package/typedoc.json
CHANGED
|
@@ -7,18 +7,18 @@
|
|
|
7
7
|
},
|
|
8
8
|
"name": "Lilact",
|
|
9
9
|
"entryPoints": [
|
|
10
|
-
".tmp/router.
|
|
11
|
-
".tmp/accessories.
|
|
12
|
-
".tmp/components.
|
|
13
|
-
".tmp/errors.
|
|
14
|
-
// ".tmp/events.
|
|
15
|
-
".tmp/hooks.
|
|
16
|
-
".tmp/misc.
|
|
17
|
-
".tmp/run.
|
|
18
|
-
//".tmp/jsx
|
|
19
|
-
".tmp/redux.
|
|
20
|
-
".tmp/timers.
|
|
21
|
-
".tmp/transition.
|
|
22
|
-
// ".tmp/lilact.
|
|
10
|
+
".tmp/src/router.jsx",
|
|
11
|
+
".tmp/src/accessories.jsx",
|
|
12
|
+
".tmp/src/components.jsx",
|
|
13
|
+
".tmp/src/errors.jsx",
|
|
14
|
+
// ".tmp/src/events.jsx",
|
|
15
|
+
".tmp/src/hooks.jsx",
|
|
16
|
+
".tmp/src/misc.jsx",
|
|
17
|
+
".tmp/src/run.jsx",
|
|
18
|
+
//".tmp/src/jsxx.jsx",
|
|
19
|
+
".tmp/src/redux.jsx",
|
|
20
|
+
".tmp/src/timers.jsx",
|
|
21
|
+
".tmp/src/transition.jsx",
|
|
22
|
+
// ".tmp/src/lilact.jsx"
|
|
23
23
|
],
|
|
24
24
|
}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
object-assign
|
|
3
|
-
(c) Sindre Sorhus
|
|
4
|
-
@license MIT
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/*! ./checkPropTypes */
|
|
8
|
-
|
|
9
|
-
/*! ./cjs/react-is.development.js */
|
|
10
|
-
|
|
11
|
-
/*! ./factoryWithTypeCheckers */
|
|
12
|
-
|
|
13
|
-
/*! ./jsx.addons.js */
|
|
14
|
-
|
|
15
|
-
/*! ./lib/ReactPropTypesSecret */
|
|
16
|
-
|
|
17
|
-
/*! ./lib/has */
|
|
18
|
-
|
|
19
|
-
/*! ./lilact.jsx */
|
|
20
|
-
|
|
21
|
-
/*! ./symbols.jsx */
|
|
22
|
-
|
|
23
|
-
/*! ./vlq.js */
|
|
24
|
-
|
|
25
|
-
/*! object-assign */
|
|
26
|
-
|
|
27
|
-
/*! react-is */
|
|
28
|
-
|
|
29
|
-
/*!********************!*\
|
|
30
|
-
!*** ./src/jsx.js ***!
|
|
31
|
-
\********************/
|
|
32
|
-
|
|
33
|
-
/*!********************!*\
|
|
34
|
-
!*** ./src/vlq.js ***!
|
|
35
|
-
\********************/
|
|
36
|
-
|
|
37
|
-
/*!*********************!*\
|
|
38
|
-
!*** ./src/run.jsx ***!
|
|
39
|
-
\*********************/
|
|
40
|
-
|
|
41
|
-
/*!*************************!*\
|
|
42
|
-
!*** ./src/symbols.jsx ***!
|
|
43
|
-
\*************************/
|
|
44
|
-
|
|
45
|
-
/*!***************************!*\
|
|
46
|
-
!*** ./src/jsx.addons.js ***!
|
|
47
|
-
\***************************/
|
|
48
|
-
|
|
49
|
-
/*!*************************************!*\
|
|
50
|
-
!*** ./src/lilact.jsx + 28 modules ***!
|
|
51
|
-
\*************************************/
|
|
52
|
-
|
|
53
|
-
/*!****************************************!*\
|
|
54
|
-
!*** ./node_modules/react-is/index.js ***!
|
|
55
|
-
\****************************************/
|
|
56
|
-
|
|
57
|
-
/*!******************************************!*\
|
|
58
|
-
!*** ./node_modules/prop-types/index.js ***!
|
|
59
|
-
\******************************************/
|
|
60
|
-
|
|
61
|
-
/*!********************************************!*\
|
|
62
|
-
!*** ./node_modules/prop-types/lib/has.js ***!
|
|
63
|
-
\********************************************/
|
|
64
|
-
|
|
65
|
-
/*!*********************************************!*\
|
|
66
|
-
!*** ./node_modules/object-assign/index.js ***!
|
|
67
|
-
\*********************************************/
|
|
68
|
-
|
|
69
|
-
/*!***************************************************!*\
|
|
70
|
-
!*** ./node_modules/prop-types/checkPropTypes.js ***!
|
|
71
|
-
\***************************************************/
|
|
72
|
-
|
|
73
|
-
/*!***********************************************************!*\
|
|
74
|
-
!*** ./node_modules/react-is/cjs/react-is.development.js ***!
|
|
75
|
-
\***********************************************************/
|
|
76
|
-
|
|
77
|
-
/*!************************************************************!*\
|
|
78
|
-
!*** ./node_modules/prop-types/factoryWithTypeCheckers.js ***!
|
|
79
|
-
\************************************************************/
|
|
80
|
-
|
|
81
|
-
/*!*************************************************************!*\
|
|
82
|
-
!*** ./node_modules/prop-types/lib/ReactPropTypesSecret.js ***!
|
|
83
|
-
\*************************************************************/
|