@iabbb/bds-react 0.38.0-alpha.0 → 0.38.0-alpha.2

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.
Files changed (51) hide show
  1. package/package.json +2 -7
  2. package/dist/README.md +0 -0
  3. package/dist/bds-react.js +0 -9
  4. package/dist/bds-react.js.map +0 -1
  5. package/dist/package.json +0 -33
  6. package/rollup.config.mjs +0 -36
  7. package/src/Button/Button.js +0 -54
  8. package/src/Button/index.js +0 -1
  9. package/src/CallToAction/CallToAction.js +0 -18
  10. package/src/CallToAction/index.js +0 -1
  11. package/src/ErrorSummary/ErrorSummary.js +0 -66
  12. package/src/ErrorSummary/index.js +0 -2
  13. package/src/FieldTextInput/FieldTextInput.js +0 -50
  14. package/src/FieldTextInput/index.js +0 -1
  15. package/src/Pagination/Pagination.js +0 -107
  16. package/src/Pagination/index.js +0 -1
  17. package/src/Typography/Typography.js +0 -34
  18. package/src/Typography/index.js +0 -1
  19. package/src/index.js +0 -6
  20. /package/{dist/Button → Button}/Button.js +0 -0
  21. /package/{dist/Button → Button}/Button.js.map +0 -0
  22. /package/{dist/Button → Button}/index.js +0 -0
  23. /package/{dist/Button → Button}/index.js.map +0 -0
  24. /package/{dist/CallToAction → CallToAction}/CallToAction.js +0 -0
  25. /package/{dist/CallToAction → CallToAction}/CallToAction.js.map +0 -0
  26. /package/{dist/CallToAction → CallToAction}/index.js +0 -0
  27. /package/{dist/CallToAction → CallToAction}/index.js.map +0 -0
  28. /package/{dist/ErrorSummary → ErrorSummary}/ErrorSummary.js +0 -0
  29. /package/{dist/ErrorSummary → ErrorSummary}/ErrorSummary.js.map +0 -0
  30. /package/{dist/ErrorSummary → ErrorSummary}/index.js +0 -0
  31. /package/{dist/ErrorSummary → ErrorSummary}/index.js.map +0 -0
  32. /package/{dist/FieldTextInput → FieldTextInput}/FieldTextInput.js +0 -0
  33. /package/{dist/FieldTextInput → FieldTextInput}/FieldTextInput.js.map +0 -0
  34. /package/{dist/FieldTextInput → FieldTextInput}/index.js +0 -0
  35. /package/{dist/FieldTextInput → FieldTextInput}/index.js.map +0 -0
  36. /package/{dist/Pagination → Pagination}/Pagination.js +0 -0
  37. /package/{dist/Pagination → Pagination}/Pagination.js.map +0 -0
  38. /package/{dist/Pagination → Pagination}/index.js +0 -0
  39. /package/{dist/Pagination → Pagination}/index.js.map +0 -0
  40. /package/{dist/Typography → Typography}/Typography.js +0 -0
  41. /package/{dist/Typography → Typography}/Typography.js.map +0 -0
  42. /package/{dist/Typography → Typography}/index.js +0 -0
  43. /package/{dist/Typography → Typography}/index.js.map +0 -0
  44. /package/{dist/_rollupPluginBabelHelpers-4a7b2c14.js → _rollupPluginBabelHelpers-4a7b2c14.js} +0 -0
  45. /package/{dist/_rollupPluginBabelHelpers-4a7b2c14.js.map → _rollupPluginBabelHelpers-4a7b2c14.js.map} +0 -0
  46. /package/{dist/_rollupPluginBabelHelpers-4a841245.js → _rollupPluginBabelHelpers-4a841245.js} +0 -0
  47. /package/{dist/_rollupPluginBabelHelpers-4a841245.js.map → _rollupPluginBabelHelpers-4a841245.js.map} +0 -0
  48. /package/{dist/_rollupPluginBabelHelpers-faf45dab.js → _rollupPluginBabelHelpers-faf45dab.js} +0 -0
  49. /package/{dist/_rollupPluginBabelHelpers-faf45dab.js.map → _rollupPluginBabelHelpers-faf45dab.js.map} +0 -0
  50. /package/{dist/index.js → index.js} +0 -0
  51. /package/{dist/index.js.map → index.js.map} +0 -0
package/package.json CHANGED
@@ -1,12 +1,7 @@
1
1
  {
2
2
  "name": "@iabbb/bds-react",
3
- "version": "0.38.0-alpha.0",
3
+ "version": "0.38.0-alpha.2",
4
4
  "main": "dist/bds-react.js",
5
- "exports": {
6
- "./*": "./dist/*",
7
- "./package.json": "./package.json",
8
- "./README.md": "./README.md"
9
- },
10
5
  "scripts": {
11
6
  "build": "cross-env NODE_ENV=production rollup -c",
12
7
  "dev": "rollup -c -w"
@@ -29,7 +24,7 @@
29
24
  "rollup": "3.25.1"
30
25
  },
31
26
  "peerDependencies": {
32
- "@iabbb/bds": "0.38.0-alpha.0",
27
+ "@iabbb/bds": "0.38.0-alpha.1",
33
28
  "react": "^18.0.0"
34
29
  }
35
30
  }
package/dist/README.md DELETED
File without changes
package/dist/bds-react.js DELETED
@@ -1,9 +0,0 @@
1
- export { default as Button } from './Button/Button.js';
2
- export { default as CallToAction } from './CallToAction/CallToAction.js';
3
- export { default as ErrorSummary } from './ErrorSummary/ErrorSummary.js';
4
- export { default as FieldTextInput } from './FieldTextInput/FieldTextInput.js';
5
- export { default as Pagination } from './Pagination/Pagination.js';
6
- export { default as Typography } from './Typography/Typography.js';
7
- import './_rollupPluginBabelHelpers-faf45dab.js';
8
- import 'react';
9
- //# sourceMappingURL=bds-react.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bds-react.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
package/dist/package.json DELETED
@@ -1,33 +0,0 @@
1
- {
2
- "name": "@bds/react",
3
- "version": "0.37.2",
4
- "main": "dist/bds-react.js",
5
- "exports": {
6
- "./*": "./dist/*"
7
- },
8
- "scripts": {
9
- "build": "cross-env NODE_ENV=production rollup -c",
10
- "dev": "rollup -c -w"
11
- },
12
- "dependencies": {
13
- "@lit-labs/react": "1.2.0"
14
- },
15
- "devDependencies": {
16
- "@babel/core": "7.22.8",
17
- "@babel/preset-env": "7.22.7",
18
- "@babel/preset-react": "7.22.5",
19
- "@iabbb/bds": "*",
20
- "@rollup/plugin-babel": "6.0.3",
21
- "@rollup/plugin-commonjs": "25.0.2",
22
- "@rollup/plugin-node-resolve": "15.1.0",
23
- "@rollup/plugin-terser": "0.4.3",
24
- "cross-env": "7.0.3",
25
- "glob": "10.3.1",
26
- "react": "18.2.0",
27
- "rollup": "3.25.1"
28
- },
29
- "peerDependencies": {
30
- "@iabbb/bds": "0.37.2",
31
- "react": "^18.0.0"
32
- }
33
- }
package/rollup.config.mjs DELETED
@@ -1,36 +0,0 @@
1
- import babel from '@rollup/plugin-babel';
2
- import commonjs from '@rollup/plugin-commonjs'
3
- import resolve from '@rollup/plugin-node-resolve'
4
- import { globSync } from 'glob';
5
- import path from 'node:path';
6
- import { fileURLToPath } from 'node:url';
7
-
8
- // https://gist.github.com/BenjaminWFox/567fd293013090ec565b61228088087a
9
- export default {
10
- input: {
11
- ['index']: 'src/index.js',
12
- ...Object.fromEntries(
13
- globSync('src/**/*.js').map((file) => [
14
- path.relative('src', file.slice(0, file.length - path.extname(file).length)),
15
- fileURLToPath(new URL(file, import.meta.url)),
16
- ]),
17
- ),
18
- },
19
- output: {
20
- dir: 'dist',
21
- format: 'es',
22
- sourcemap: true,
23
- },
24
- plugins: [
25
- resolve(),
26
- babel({
27
- presets: ['@babel/env', '@babel/preset-react']
28
- }),
29
- commonjs({
30
- namedExports: {
31
- 'react-is': ['isForwardRef', 'isValidElementType'],
32
- },
33
- }),
34
- ],
35
- external: ['react']
36
- };
@@ -1,54 +0,0 @@
1
- // import clsx from 'clsx';
2
- import * as React from 'react';
3
-
4
- const DEBOUNCE_TIMEOUT_IN_SECONDS = 1;
5
-
6
- const Button = React.forwardRef(
7
- ({ children, className, onClick, preventDoubleClick = false, variant = 'standard', ...props }, ref) => {
8
- const debounceClicks = React.useRef(false);
9
-
10
- const handleClick = (event) => {
11
- // 👇 button is not configured to ignore double clicks
12
- if (!preventDoubleClick) {
13
- if (onClick) {
14
- onClick(event);
15
- }
16
-
17
- return;
18
- }
19
-
20
- // 👇 button has been clicked recently, and subsequent clicks are prevented
21
- if (debounceClicks.current) {
22
- event.preventDefault();
23
- return false;
24
- }
25
-
26
- if (onClick) {
27
- onClick(event);
28
- }
29
-
30
- // 👇 block from double clicks
31
- debounceClicks.current = true;
32
-
33
- // 👇 and remove the block after a given amount of seconds
34
- setTimeout(() => {
35
- debounceClicks.current = false;
36
- }, DEBOUNCE_TIMEOUT_IN_SECONDS * 1000);
37
- };
38
-
39
- return (
40
- <button
41
- className={variant === 'unstyled' ? 'bds-button-unstyled' : 'bds-button'}
42
- // className={clsx(variant === 'unstyled' ? 'bds-button-unstyled' : 'bds-button', className)}
43
- data-type={variant !== 'standard' && variant !== 'unstyled' ? variant : null}
44
- onClick={handleClick}
45
- ref={ref}
46
- {...props}
47
- >
48
- {children}
49
- </button>
50
- );
51
- },
52
- );
53
-
54
- export default Button;
@@ -1 +0,0 @@
1
- export { default } from './Button';
@@ -1,18 +0,0 @@
1
- // import clsx from 'clsx';
2
- import * as React from 'react';
3
-
4
- const CallToAction = React.forwardRef(({ children, className, variant = 'standard', ...props }, ref) => {
5
- return (
6
- <a
7
- // className={clsx('bds-cta', className)}
8
- className="bds-cta"
9
- data-type={variant !== 'standard' ? variant : null}
10
- ref={ref}
11
- {...props}
12
- >
13
- {children}
14
- </a>
15
- );
16
- });
17
-
18
- export default CallToAction;
@@ -1 +0,0 @@
1
- export { default } from './CallToAction';
@@ -1,66 +0,0 @@
1
- import ErrorSummaryWebComponent from '@iabbb/bds/src/blocks/ErrorSummary/ErrorSummary.mjs';
2
- import { createComponent } from '@lit-labs/react';
3
- import * as React from 'react';
4
-
5
- const ReactErrorSummary = createComponent({
6
- tagName: 'bds-error-summary',
7
- elementClass: ErrorSummaryWebComponent,
8
- react: React,
9
- });
10
-
11
- const FINAL_FORM_ERROR = 'FINAL_FORM/form-error';
12
- export const FormErrorKey = '_form';
13
-
14
- export default function ErrorSummary({ errors, mapNameToId = (name) => name, ...props }) {
15
- const headingId = React.useId();
16
- const groupRef = React.useRef(null);
17
-
18
- return (
19
- <ReactErrorSummary role="group" aria-labelledby={headingId} ref={groupRef} tabIndex={-1} {...props}>
20
- <h2 className="bds-h5" id={headingId}>
21
- <svg
22
- xmlns="http://www.w3.org/2000/svg"
23
- viewBox="0 0 512 512"
24
- aria-hidden="true"
25
- height="1em"
26
- width="1em"
27
- fill="currentColor"
28
- >
29
- <path d="M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7.2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8.2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24v112c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224c0-17.7-14.3-32-32-32s-32 14.3-32 32 14.3 32 32 32 32-14.3 32-32z" />
30
- </svg>
31
- Issue
32
- </h2>
33
- <ul>
34
- {Object.keys(errors).map((errorKey) => {
35
- const message = errors[errorKey];
36
- const isFormError = [FINAL_FORM_ERROR, FormErrorKey].includes(errorKey);
37
-
38
- if (isFormError) {
39
- return <li key={errorKey} dangerouslySetInnerHTML={{ __html: message }} />;
40
- }
41
-
42
- const isArrayField = Array.isArray(message);
43
-
44
- const messages = isArrayField ? message : [message];
45
-
46
- return (
47
- <React.Fragment key={errorKey}>
48
- {messages.map((fieldMessage, index) => {
49
- const inputId = `${mapNameToId(errorKey)}${isArrayField ? `[${index}]` : ''}`;
50
-
51
- return (
52
- <li key={inputId}>
53
- <a href={`#${inputId}`}>
54
- {fieldMessage}
55
- {messages.length > 1 ? ` (${index + 1} of ${messages.length})` : undefined}
56
- </a>
57
- </li>
58
- );
59
- })}
60
- </React.Fragment>
61
- );
62
- })}
63
- </ul>
64
- </ReactErrorSummary>
65
- );
66
- }
@@ -1,2 +0,0 @@
1
- export { default } from './ErrorSummary';
2
- export * from './ErrorSummary';
@@ -1,50 +0,0 @@
1
- // import clsx from 'clsx';
2
- import * as React from 'react';
3
-
4
- export default function FieldTextInput({ as, error, hint, id, isOptional = false, label, ...props }) {
5
- id = id ?? props.name;
6
-
7
- const errorId = React.useId();
8
- const hintId = React.useId();
9
-
10
- const InputComponent = as ?? 'input';
11
-
12
- return (
13
- <div
14
- // className={clsx('bds-text-input', 'stack')}
15
- className="bds-text-input stack"
16
- >
17
- <label htmlFor={id}>
18
- {label}
19
- {isOptional && ' (optional)'}
20
- </label>
21
- {hint && (
22
- <span className="bds-hint" id={hintId}>
23
- {hint}
24
- </span>
25
- )}
26
- {error && (
27
- <span className="bds-error" id={errorId}>
28
- <svg
29
- xmlns="http://www.w3.org/2000/svg"
30
- viewBox="0 0 512 512"
31
- aria-hidden="true"
32
- height="1em"
33
- width="1em"
34
- fill="currentColor"
35
- >
36
- <path d="M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7.2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8.2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24v112c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224c0-17.7-14.3-32-32-32s-32 14.3-32 32 14.3 32 32 32 32-14.3 32-32z" />
37
- </svg>
38
- {error}
39
- </span>
40
- )}
41
- <InputComponent
42
- aria-invalid={error ? true : undefined}
43
- aria-describedby={error && hint ? `${hintId} ${errorId}` : error ? errorId : hint ? hintId : undefined}
44
- aria-required={isOptional ? undefined : true}
45
- id={id}
46
- {...props}
47
- />
48
- </div>
49
- );
50
- }
@@ -1 +0,0 @@
1
- export { default } from './FieldTextInput';
@@ -1,107 +0,0 @@
1
- // import clsx from 'clsx';
2
- import * as React from 'react';
3
-
4
- function usePages(currentPage, totalPages) {
5
- const pages = [1, currentPage - 1, currentPage, currentPage + 1, totalPages].filter(
6
- (x) => x >= 1 && x <= totalPages,
7
- );
8
- return [...new Set(pages)];
9
- }
10
-
11
- export default function Pagination({ buildPageUrl, className, currentPage, onPageClick, totalPages, ...props }) {
12
- const pages = usePages(currentPage, totalPages);
13
-
14
- return (
15
- <nav
16
- aria-label="pagination"
17
- // className={clsx('bds-pagination', className)}
18
- className="bds-pagination"
19
- {...props}
20
- >
21
- {currentPage !== 1 && (
22
- <>
23
- <a href={buildPageUrl(1)} className="bds-first-page">
24
- <svg
25
- xmlns="http://www.w3.org/2000/svg"
26
- aria-hidden="true"
27
- focusable="false"
28
- height="1em"
29
- width="auto"
30
- viewBox="0 63.95 512 384.1"
31
- >
32
- <path d="M459.5 440.6c9.5 7.9 22.8 9.7 34.1 4.4s18.4-16.6 18.4-29V96c0-12.4-7.2-23.7-18.4-29s-24.5-3.6-34.1 4.4L288 214.3v83.4l171.5 142.9zM256 352V96c0-12.4-7.2-23.7-18.4-29s-24.5-3.6-34.1 4.4l-192 160C4.2 237.5 0 246.5 0 256s4.2 18.5 11.5 24.6l192 160c9.5 7.9 22.8 9.7 34.1 4.4s18.4-16.6 18.4-29v-64z" />
33
- </svg>
34
- First
35
- </a>
36
- <a aria-label="previous" href={buildPageUrl(currentPage - 1)} rel="prev">
37
- <svg
38
- xmlns="http://www.w3.org/2000/svg"
39
- aria-hidden="true"
40
- focusable="false"
41
- width="auto"
42
- height="1em"
43
- viewBox="0.02 95.9 192.08 320.17"
44
- >
45
- <path d="M9.4 278.6c-12.5-12.5-12.5-32.8 0-45.3l128-128c9.2-9.2 22.9-11.9 34.9-6.9s19.8 16.6 19.8 29.6v256c0 12.9-7.8 24.6-19.8 29.6s-25.7 2.2-34.9-6.9l-128-128z" />
46
- </svg>
47
- Prev.
48
- </a>
49
- </>
50
- )}
51
- <ul>
52
- {pages.map((page, index) => {
53
- const handlePageClick = () => {
54
- if (!onPageClick) return;
55
-
56
- onPageClick(page);
57
- };
58
-
59
- return (
60
- <React.Fragment key={page}>
61
- <li>
62
- <a
63
- aria-current={page === currentPage ? 'page' : undefined}
64
- href={buildPageUrl(page)}
65
- onClick={handlePageClick}
66
- >
67
- <span className="visually-hidden">Page</span> {page}
68
- </a>
69
- </li>
70
- {pages[index + 1] > page + 1 ? <li data-overflow="">...</li> : null}
71
- </React.Fragment>
72
- );
73
- })}
74
- </ul>
75
- {currentPage !== totalPages && (
76
- <>
77
- <a href={buildPageUrl(currentPage + 1)} rel="next">
78
- Next
79
- <svg
80
- xmlns="http://www.w3.org/2000/svg"
81
- aria-hidden="true"
82
- focusable="false"
83
- viewBox="63.9 95.9 192.1 320.17"
84
- width="auto"
85
- height="1em"
86
- >
87
- <path d="M246.6 278.6c12.5-12.5 12.5-32.8 0-45.3l-128-128c-9.2-9.2-22.9-11.9-34.9-6.9S63.9 115 63.9 128v256c0 12.9 7.8 24.6 19.8 29.6s25.7 2.2 34.9-6.9l128-128z" />
88
- </svg>
89
- </a>
90
- <a href={buildPageUrl(totalPages)} className="bds-last-page">
91
- Last
92
- <svg
93
- xmlns="http://www.w3.org/2000/svg"
94
- aria-hidden="true"
95
- focusable="false"
96
- width="auto"
97
- height="1em"
98
- viewBox="0 63.95 512 384.1"
99
- >
100
- <path d="M52.5 440.6c-9.5 7.9-22.8 9.7-34.1 4.4S0 428.4 0 416V96c0-12.4 7.2-23.7 18.4-29s24.5-3.6 34.1 4.4L224 214.3v83.4L52.5 440.6zM256 352V96c0-12.4 7.2-23.7 18.4-29s24.5-3.6 34.1 4.4l192 160c7.3 6.1 11.5 15.1 11.5 24.6s-4.2 18.5-11.5 24.6l-192 160c-9.5 7.9-22.8 9.7-34.1 4.4S256 428.4 256 416v-64z" />
101
- </svg>
102
- </a>
103
- </>
104
- )}
105
- </nav>
106
- );
107
- }
@@ -1 +0,0 @@
1
- export { default } from './Pagination';
@@ -1,34 +0,0 @@
1
- // import clsx from 'clsx';
2
- import * as React from 'react';
3
-
4
- const componentMap = {
5
- h1: 'h1',
6
- h2: 'h2',
7
- h3: 'h3',
8
- h4: 'h4',
9
- h5: 'h5',
10
- body: 'p',
11
- };
12
-
13
- const classMap = {
14
- h1: 'bds-h1',
15
- h2: 'bds-h2',
16
- h3: 'bds-h3',
17
- h4: 'bds-h4',
18
- h5: 'bds-h5',
19
- body: 'bds-body',
20
- };
21
-
22
- const Typography = React.forwardRef(({ className, component, variant = 'body', ...props }, ref) => {
23
- const Component = component ?? componentMap[variant];
24
- return (
25
- <Component
26
- // className={clsx(classMap[variant], className)}
27
- className={classMap[variant]}
28
- ref={ref}
29
- {...props}
30
- />
31
- );
32
- });
33
-
34
- export default Typography;
@@ -1 +0,0 @@
1
- export { default } from './Typography';
package/src/index.js DELETED
@@ -1,6 +0,0 @@
1
- export { default as Button } from './Button/index';
2
- export { default as CallToAction } from './CallToAction/index';
3
- export { default as ErrorSummary } from './ErrorSummary/index';
4
- export { default as FieldTextInput } from './FieldTextInput/index';
5
- export { default as Pagination } from './Pagination/index';
6
- export { default as Typography } from './Typography/index';
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes