@uxf/core 10.0.0 → 10.10.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 +0 -80
- package/package.json +1 -1
- package/utils/assert-not-nil.d.ts +2 -0
- package/utils/assert-not-nil.js +10 -0
- package/utils/is-empty.d.ts +1 -0
- package/utils/is-empty.js +10 -0
- package/utils/is-empty.test.d.ts +1 -0
- package/utils/is-empty.test.js +9 -0
- package/utils/last.d.ts +1 -0
- package/utils/last.js +10 -0
- package/utils/last.test.d.ts +1 -0
- package/utils/last.test.js +8 -0
package/README.md
CHANGED
|
@@ -328,86 +328,6 @@ queryParamToNumber(ctx.query.id);
|
|
|
328
328
|
queryParamToString(ctx.query.name);
|
|
329
329
|
```
|
|
330
330
|
|
|
331
|
-
## Utils
|
|
332
|
-
```tsx
|
|
333
|
-
import { cameCaseToDash } from "@uxf/core/utils/cameCaseToDash";
|
|
334
|
-
|
|
335
|
-
const example = cameCaseToDash("fooBar") /* returns "foo-bar" */
|
|
336
|
-
```
|
|
337
|
-
```tsx
|
|
338
|
-
import { composeRefs } from "@uxf/core/utils/composeRefs";
|
|
339
|
-
|
|
340
|
-
const firstRef = useRef<HTMLDivElement>(null);
|
|
341
|
-
const secondRef = useRef<HTMLDivElement>(null);
|
|
342
|
-
|
|
343
|
-
const example = <div ref={composeRefs(firstRef, secondRef)} />;
|
|
344
|
-
```
|
|
345
|
-
```tsx
|
|
346
|
-
import { cx } from "@uxf/core/utils/cx";
|
|
347
|
-
|
|
348
|
-
/* fork of https://github.com/lukeed/clsx */
|
|
349
|
-
const example = cx("foo", true && "bar", "baz", false && "bam", undefined) /* returns "foo bar baz" */
|
|
350
|
-
```
|
|
351
|
-
```tsx
|
|
352
|
-
import { forwardRef } from "@uxf/core/utils/forwardRef";
|
|
353
|
-
|
|
354
|
-
interface Props {
|
|
355
|
-
className?: string;
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
// will enforce 'displayName'
|
|
359
|
-
export const ExampleComponent = forwardRef<HTMLDivElement, Props>("ExampleComponent", (props, ref) => {
|
|
360
|
-
return <div className={props.className} ref={ref} />;
|
|
361
|
-
});
|
|
362
|
-
```
|
|
363
|
-
```tsx
|
|
364
|
-
import { isBrowser } from "@uxf/core/utils/isBrowser";
|
|
365
|
-
import { isServer } from "@uxf/core/utils/isServer";
|
|
366
|
-
|
|
367
|
-
const browserExample = isBrowser; /* returns true if DOM is available */
|
|
368
|
-
const serverExample = isServer; /* returns true if DOM is NOT available */
|
|
369
|
-
```
|
|
370
|
-
```tsx
|
|
371
|
-
import { slugify } from "@uxf/core/utils/slugify";
|
|
372
|
-
|
|
373
|
-
const example = slugify("Jak se dnes máte?") /* returns "jak-se-dnes-mate" */
|
|
374
|
-
```
|
|
375
|
-
```tsx
|
|
376
|
-
import { trimTrailingZeros } from "@uxf/core/utils/trimTrailingZeros";
|
|
377
|
-
|
|
378
|
-
const example = trimTrailingZeros("120,450") /* returns "120,45" */
|
|
379
|
-
```
|
|
380
|
-
|
|
381
|
-
```tsx
|
|
382
|
-
import { filterNullish } from "@uxf/core/utils/filter-nullish";
|
|
383
|
-
|
|
384
|
-
filterNullish([0, "text", null, undefined, [], {}]) /* returns [0, "text", [], {}] */
|
|
385
|
-
```
|
|
386
|
-
|
|
387
|
-
```tsx
|
|
388
|
-
import { isNil } from "@uxf/core/utils/is-nil";
|
|
389
|
-
|
|
390
|
-
isNil(null) /* returns true */
|
|
391
|
-
isNil(undefined) /* returns true */
|
|
392
|
-
isNil(true) /* returns false */
|
|
393
|
-
isNil(1) /* returns false */
|
|
394
|
-
isNil(0) /* returns false */
|
|
395
|
-
isNil([]) /* returns false */
|
|
396
|
-
isNil("string") /* returns false */
|
|
397
|
-
```
|
|
398
|
-
|
|
399
|
-
```tsx
|
|
400
|
-
import { isNotNil } from "@uxf/core/utils/is-not-nil";
|
|
401
|
-
|
|
402
|
-
isNotNil(null) /* returns false */
|
|
403
|
-
isNotNil(undefined) /* returns false */
|
|
404
|
-
isNotNil(true) /* returns true */
|
|
405
|
-
isNotNil(1) /* returns true */
|
|
406
|
-
isNotNil(0) /* returns true */
|
|
407
|
-
isNotNil([]) /* returns true */
|
|
408
|
-
isNotNil("string") /* returns true */
|
|
409
|
-
```
|
|
410
|
-
|
|
411
331
|
## Validators
|
|
412
332
|
```tsx
|
|
413
333
|
import { Validator } from "@uxf/core";
|
package/package.json
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assertNotNil = void 0;
|
|
4
|
+
const is_nil_1 = require("./is-nil");
|
|
5
|
+
function assertNotNil(value, errorMessage = "Value is nil.") {
|
|
6
|
+
if ((0, is_nil_1.isNil)(value)) {
|
|
7
|
+
throw new Error(errorMessage);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.assertNotNil = assertNotNil;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isEmpty(value: any[] | string): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const is_empty_1 = require("./is-empty");
|
|
4
|
+
test("is-empty", () => {
|
|
5
|
+
expect((0, is_empty_1.isEmpty)(["1"])).toBeFalsy();
|
|
6
|
+
expect((0, is_empty_1.isEmpty)([])).toBeTruthy();
|
|
7
|
+
expect((0, is_empty_1.isEmpty)("not-empty")).toBeFalsy();
|
|
8
|
+
expect((0, is_empty_1.isEmpty)("")).toBeTruthy();
|
|
9
|
+
});
|
package/utils/last.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function last<T>(value: T[]): T | undefined;
|
package/utils/last.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const last_1 = require("./last");
|
|
4
|
+
test("last", () => {
|
|
5
|
+
expect((0, last_1.last)(["1"])).toStrictEqual("1");
|
|
6
|
+
expect((0, last_1.last)(["1", "2", "3"])).toStrictEqual("3");
|
|
7
|
+
expect((0, last_1.last)([])).toBeUndefined();
|
|
8
|
+
});
|