@papillonarts/library 0.38.0 → 0.40.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.
@@ -0,0 +1,9 @@
1
+ import { Canvas, Meta } from '@storybook/addon-docs/blocks'
2
+
3
+ import * as NumberStories from './Number.story'
4
+
5
+ <Meta of={NumberStories} />
6
+
7
+ # Number
8
+
9
+ <Canvas of={NumberStories.Features} />
@@ -0,0 +1,9 @@
1
+ import { Canvas, Meta } from '@storybook/addon-docs/blocks'
2
+
3
+ import * as ObjectStories from './Object.story'
4
+
5
+ <Meta of={ObjectStories} />
6
+
7
+ # Object
8
+
9
+ <Canvas of={ObjectStories.Features} />
@@ -0,0 +1,9 @@
1
+ import { Canvas, Meta } from '@storybook/addon-docs/blocks'
2
+
3
+ import * as PaginationStories from './Pagination.library.story'
4
+
5
+ <Meta of={PaginationStories} />
6
+
7
+ # Pagination
8
+
9
+ <Canvas of={PaginationStories.Features} />
@@ -0,0 +1,9 @@
1
+ import { Canvas, Meta } from '@storybook/addon-docs/blocks'
2
+
3
+ import * as SortStories from './Sort.story'
4
+
5
+ <Meta of={SortStories} />
6
+
7
+ # Sort
8
+
9
+ <Canvas of={SortStories.Features} />
@@ -0,0 +1,9 @@
1
+ import { Canvas, Meta } from '@storybook/addon-docs/blocks'
2
+
3
+ import * as StoreStories from './Store.story'
4
+
5
+ <Meta of={StoreStories} />
6
+
7
+ # Store
8
+
9
+ <Canvas of={StoreStories.Features} />
@@ -1,2 +1,2 @@
1
- export { getAppMockStore } from './mock';
1
+ export declare function getAppMockStore(customAppState: any): any;
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/store/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/store/index.ts"],"names":[],"mappings":"AAIA,wBAAgB,eAAe,CAAC,cAAc,KAAA,OAE7C"}
@@ -1,12 +1,14 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
- Object.defineProperty(exports, "getAppMockStore", {
7
- enumerable: true,
8
- get: function get() {
9
- return _mock.getAppMockStore;
10
- }
11
- });
12
- var _mock = require("./mock");
7
+ exports.getAppMockStore = getAppMockStore;
8
+ var _reduxMockStore = _interopRequireDefault(require("redux-mock-store"));
9
+ var _reduxThunk = require("redux-thunk");
10
+ /* eslint-disable import-x/no-named-as-default */
11
+
12
+ function getAppMockStore(customAppState) {
13
+ return (0, _reduxMockStore["default"])([_reduxThunk.thunk])(customAppState);
14
+ }
@@ -0,0 +1,9 @@
1
+ import { Canvas, Meta } from '@storybook/addon-docs/blocks'
2
+
3
+ import * as StringStories from './String.story'
4
+
5
+ <Meta of={StringStories} />
6
+
7
+ # String
8
+
9
+ <Canvas of={StringStories.Features} />
@@ -1,8 +1,67 @@
1
- export declare function getCapizalizedString({ string, separator }: {
2
- string: string;
3
- separator: string;
1
+ /**
2
+ * Capitalize the first character of each segment in a string split by a separator.
3
+ *
4
+ * Splits the input string by the specified separator, trims whitespace from each segment,
5
+ * filters out empty segments, capitalizes the first character of each remaining segment,
6
+ * and joins them with spaces.
7
+ *
8
+ * @param {Object} params - Function parameters
9
+ * @param {string} [params.input] - The string to capitalize. Accepts undefined or empty strings, which return an empty string.
10
+ * @param {string} [params.separator='-'] - The delimiter to split segments. Defaults to hyphen.
11
+ * @returns {string} Capitalized string with segments joined by spaces, or empty string if input is falsy/empty.
12
+ *
13
+ * @example
14
+ * getCapitalizedString({ input: 'hello-world', separator: '-' })
15
+ * // => 'Hello World'
16
+ *
17
+ * @example
18
+ * getCapitalizedString({ input: ' foo - bar ', separator: '-' })
19
+ * // => 'Foo Bar'
20
+ *
21
+ * @example
22
+ * getCapitalizedString({ input: undefined })
23
+ * // => ''
24
+ */
25
+ export declare function getCapitalizedString({ input, separator }: {
26
+ input?: string;
27
+ separator?: string;
4
28
  }): string;
29
+ /**
30
+ * Generate a random alphanumeric string using base-36 encoding.
31
+ *
32
+ * Uses `Math.random()` (non-cryptographic) to produce a lowercase alphanumeric string.
33
+ * String length is variable (~11 characters typical, but not guaranteed).
34
+ *
35
+ * @returns {string} A random alphanumeric string with letters (a-z) and digits (0-9).
36
+ *
37
+ * @example
38
+ * getRandomAlphanumericString()
39
+ * // => '4feornbt361' (example output, varies each call)
40
+ *
41
+ * @note For cryptographic purposes, use `crypto.getRandomValues()` or `crypto.randomUUID()` instead.
42
+ */
5
43
  export declare function getRandomAlphanumericString(): string;
44
+ /**
45
+ * Generate a random alphanumeric string of a specific length.
46
+ *
47
+ * Creates a string of the requested length using characters from the alphanumeric set
48
+ * (A-Z, a-z, 0-9). Uses `Math.random()` for character selection (non-cryptographic).
49
+ *
50
+ * @param {Object} params - Function parameters
51
+ * @param {number} params.length - Desired string length. Must be a non-negative integer.
52
+ * @returns {string} A random alphanumeric string of exactly the specified length, or empty string if length is 0.
53
+ * @throws {TypeError} If length is not a non-negative integer.
54
+ *
55
+ * @example
56
+ * getRandomAlphanumericStringByLength({ length: 8 })
57
+ * // => 'aB3xYz9W' (example output, varies each call)
58
+ *
59
+ * @example
60
+ * getRandomAlphanumericStringByLength({ length: 0 })
61
+ * // => ''
62
+ *
63
+ * @note For cryptographic purposes, use `crypto.getRandomValues()` instead.
64
+ */
6
65
  export declare function getRandomAlphanumericStringByLength({ length }: {
7
66
  length: number;
8
67
  }): string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/string/index.ts"],"names":[],"mappings":"AAAA,wBAAgB,oBAAoB,CAAC,EAAE,MAAM,EAAE,SAAe,EAAE,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAK/G;AAED,wBAAgB,2BAA2B,IAAI,MAAM,CAEpD;AAED,wBAAgB,mCAAmC,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAO1F"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/string/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,KAAK,EAAE,SAAe,EAAE,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAS/G;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,2BAA2B,IAAI,MAAM,CAEpD;AAID;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,mCAAmC,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAY1F"}
@@ -3,26 +3,96 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getCapizalizedString = getCapizalizedString;
6
+ exports.getCapitalizedString = getCapitalizedString;
7
7
  exports.getRandomAlphanumericString = getRandomAlphanumericString;
8
8
  exports.getRandomAlphanumericStringByLength = getRandomAlphanumericStringByLength;
9
- function getCapizalizedString(_ref) {
10
- var string = _ref.string,
9
+ /**
10
+ * Capitalize the first character of each segment in a string split by a separator.
11
+ *
12
+ * Splits the input string by the specified separator, trims whitespace from each segment,
13
+ * filters out empty segments, capitalizes the first character of each remaining segment,
14
+ * and joins them with spaces.
15
+ *
16
+ * @param {Object} params - Function parameters
17
+ * @param {string} [params.input] - The string to capitalize. Accepts undefined or empty strings, which return an empty string.
18
+ * @param {string} [params.separator='-'] - The delimiter to split segments. Defaults to hyphen.
19
+ * @returns {string} Capitalized string with segments joined by spaces, or empty string if input is falsy/empty.
20
+ *
21
+ * @example
22
+ * getCapitalizedString({ input: 'hello-world', separator: '-' })
23
+ * // => 'Hello World'
24
+ *
25
+ * @example
26
+ * getCapitalizedString({ input: ' foo - bar ', separator: '-' })
27
+ * // => 'Foo Bar'
28
+ *
29
+ * @example
30
+ * getCapitalizedString({ input: undefined })
31
+ * // => ''
32
+ */
33
+ function getCapitalizedString(_ref) {
34
+ var input = _ref.input,
11
35
  _ref$separator = _ref.separator,
12
36
  separator = _ref$separator === void 0 ? '-' : _ref$separator;
13
- var splitted = string.split(separator);
14
- var capitalized = splitted.map(function (splittedItem) {
15
- return "".concat(splittedItem.charAt(0).toUpperCase()).concat(splittedItem.slice(1));
16
- });
17
- return capitalized.join(' ');
37
+ if (typeof input !== 'string' || input.length === 0) return '';
38
+ var parts = input.split(separator).map(function (p) {
39
+ return p.trim();
40
+ }).filter(Boolean);
41
+ if (parts.length === 0) return '';
42
+ return parts.map(function (part) {
43
+ return "".concat(part.charAt(0).toUpperCase()).concat(part.slice(1));
44
+ }).join(' ');
18
45
  }
46
+
47
+ /**
48
+ * Generate a random alphanumeric string using base-36 encoding.
49
+ *
50
+ * Uses `Math.random()` (non-cryptographic) to produce a lowercase alphanumeric string.
51
+ * String length is variable (~11 characters typical, but not guaranteed).
52
+ *
53
+ * @returns {string} A random alphanumeric string with letters (a-z) and digits (0-9).
54
+ *
55
+ * @example
56
+ * getRandomAlphanumericString()
57
+ * // => '4feornbt361' (example output, varies each call)
58
+ *
59
+ * @note For cryptographic purposes, use `crypto.getRandomValues()` or `crypto.randomUUID()` instead.
60
+ */
19
61
  function getRandomAlphanumericString() {
20
62
  return Math.random().toString(36).slice(2);
21
63
  }
64
+ var ALPHANUMERIC_CHARACTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
65
+
66
+ /**
67
+ * Generate a random alphanumeric string of a specific length.
68
+ *
69
+ * Creates a string of the requested length using characters from the alphanumeric set
70
+ * (A-Z, a-z, 0-9). Uses `Math.random()` for character selection (non-cryptographic).
71
+ *
72
+ * @param {Object} params - Function parameters
73
+ * @param {number} params.length - Desired string length. Must be a non-negative integer.
74
+ * @returns {string} A random alphanumeric string of exactly the specified length, or empty string if length is 0.
75
+ * @throws {TypeError} If length is not a non-negative integer.
76
+ *
77
+ * @example
78
+ * getRandomAlphanumericStringByLength({ length: 8 })
79
+ * // => 'aB3xYz9W' (example output, varies each call)
80
+ *
81
+ * @example
82
+ * getRandomAlphanumericStringByLength({ length: 0 })
83
+ * // => ''
84
+ *
85
+ * @note For cryptographic purposes, use `crypto.getRandomValues()` instead.
86
+ */
22
87
  function getRandomAlphanumericStringByLength(_ref2) {
23
88
  var length = _ref2.length;
24
- var randomAlphanumericString = '';
25
- var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
26
- for (var i = 0; i < length; i += 1) randomAlphanumericString += characters.charAt(Math.floor(Math.random() * characters.length));
27
- return randomAlphanumericString !== '' ? randomAlphanumericString : getRandomAlphanumericString();
89
+ var n = Number(length);
90
+ if (!Number.isInteger(n) || n < 0) throw new TypeError('length must be a non-negative integer');
91
+ if (n === 0) return '';
92
+ var result = '';
93
+ var charsLen = ALPHANUMERIC_CHARACTERS.length;
94
+ for (var i = 0; i < n; i += 1) {
95
+ result += ALPHANUMERIC_CHARACTERS.charAt(Math.floor(Math.random() * charsLen));
96
+ }
97
+ return result;
28
98
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@papillonarts/library",
3
- "version": "0.38.0",
3
+ "version": "0.40.0",
4
4
  "description": "Papillon Arts Library",
5
5
  "homepage": "https://github.com/papillonarts/papillonarts/tree/master/packages/library",
6
6
  "repository": {
@@ -23,7 +23,6 @@
23
23
  "./browser": "./build/browser/index.js",
24
24
  "./date": "./build/date/index.js",
25
25
  "./event": "./build/event/index.js",
26
- "./hooks": "./build/hooks/index.js",
27
26
  "./number": "./build/number/index.js",
28
27
  "./object": "./build/object/index.js",
29
28
  "./pagination": "./build/pagination/index.js",
@@ -44,5 +43,5 @@
44
43
  "build-acceptance": "npm run build",
45
44
  "build-release": "npm run build"
46
45
  },
47
- "gitHead": "af44ef015fbdee8b28e2dfbe647d8587e4307ce6"
46
+ "gitHead": "7a19d357d33591ad460a6cb42f18963082beffd8"
48
47
  }
@@ -1,129 +0,0 @@
1
- // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
2
-
3
- exports[`<Array /> Render must match checkAccessibilityIssues() 1`] = `
4
- <div>
5
- <pre
6
- style="display: block; overflow-x: auto; background: rgb(43, 48, 59); color: rgb(192, 197, 206); padding: 0.5em;"
7
- >
8
- <code
9
- class="language-typescript"
10
- style="white-space: pre;"
11
- >
12
- <span>
13
-
14
-
15
- </span>
16
- <span>
17
-
18
- </span>
19
- <span
20
- style="color: rgb(180, 142, 173);"
21
- >
22
- export
23
- </span>
24
- <span>
25
-
26
- </span>
27
- <span
28
- class="hljs-function"
29
- style="color: rgb(180, 142, 173);"
30
- >
31
- function
32
- </span>
33
- <span
34
- class="hljs-function"
35
- >
36
-
37
- </span>
38
- <span
39
- class="hljs-function"
40
- style="color: rgb(143, 161, 179);"
41
- >
42
- checkAccessibilityIssues
43
- </span>
44
- <span
45
- class="hljs-function"
46
- >
47
- (
48
- </span>
49
- <span
50
- class="hljs-function"
51
- style="color: rgb(208, 135, 112);"
52
- >
53
- react, reactDOM, delay
54
- </span>
55
- <span
56
- class="hljs-function"
57
- >
58
- )
59
- </span>
60
- <span>
61
- {
62
-
63
- </span>
64
- <span>
65
-
66
- </span>
67
- <span
68
- style="color: rgb(180, 142, 173);"
69
- >
70
- if
71
- </span>
72
- <span>
73
- (process.env.NODE_ENV !==
74
- </span>
75
- <span
76
- style="color: rgb(163, 190, 140);"
77
- >
78
- 'production'
79
- </span>
80
- <span>
81
- ) {
82
-
83
- </span>
84
- <span>
85
-
86
- </span>
87
- <span
88
- style="color: rgb(180, 142, 173);"
89
- >
90
- const
91
- </span>
92
- <span>
93
- axe =
94
- </span>
95
- <span
96
- style="color: rgb(208, 135, 112);"
97
- >
98
- require
99
- </span>
100
- <span>
101
- (
102
- </span>
103
- <span
104
- style="color: rgb(163, 190, 140);"
105
- >
106
- '@axe-core/react'
107
- </span>
108
- <span>
109
- )
110
-
111
- </span>
112
- axe(react, reactDOM, delay)
113
-
114
- }
115
-
116
- }
117
-
118
- </code>
119
- </pre>
120
- </div>
121
- `;
122
-
123
- exports[`<Array /> Render must match features() 1`] = `
124
- <div>
125
- <p>
126
- mock-file
127
- </p>
128
- </div>
129
- `;