@bookjane2/bookjane-design-library 9.0.8 → 9.0.10

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 (23) hide show
  1. package/lib/components/BKJAddressInput/BKJAddressInput.stories.d.ts +36 -1
  2. package/lib/components/BKJAddressInput/BKJAddressInput.stories.d.ts.map +1 -1
  3. package/lib/components/BKJAddressInput/BKJAddressInput.stories.js +33 -3
  4. package/lib/components/BKJAddressInput/BKJAddressInput.stories.js.map +1 -1
  5. package/lib/components/BKJAddressInput/BKJAddressInput.test.d.ts +2 -0
  6. package/lib/components/BKJAddressInput/BKJAddressInput.test.d.ts.map +1 -0
  7. package/lib/components/BKJAddressInput/BKJAddressInput.test.js +198 -0
  8. package/lib/components/BKJAddressInput/BKJAddressInput.test.js.map +1 -0
  9. package/lib/components/BKJTextArea/BKJTextArea.d.ts.map +1 -1
  10. package/lib/components/BKJTextArea/BKJTextArea.js +17 -2
  11. package/lib/components/BKJTextArea/BKJTextArea.js.map +1 -1
  12. package/lib/components/BKJTextArea/BKJTextArea.stories.d.ts +4 -0
  13. package/lib/components/BKJTextArea/BKJTextArea.stories.d.ts.map +1 -1
  14. package/lib/components/BKJTextArea/BKJTextArea.stories.js +22 -2
  15. package/lib/components/BKJTextArea/BKJTextArea.stories.js.map +1 -1
  16. package/lib/components/BKJTextArea/BKJTextArea.styled.d.ts.map +1 -1
  17. package/lib/components/BKJTextArea/BKJTextArea.styled.js +2 -1
  18. package/lib/components/BKJTextArea/BKJTextArea.styled.js.map +1 -1
  19. package/lib/components/BKJTextArea/BKJTextArea.test.d.ts +2 -0
  20. package/lib/components/BKJTextArea/BKJTextArea.test.d.ts.map +1 -0
  21. package/lib/components/BKJTextArea/BKJTextArea.test.js +117 -0
  22. package/lib/components/BKJTextArea/BKJTextArea.test.js.map +1 -0
  23. package/package.json +1 -1
@@ -2,8 +2,43 @@ import { IBKJAddressInputProps } from './BKJAddressInput.types.js';
2
2
  declare const _default: {
3
3
  title: string;
4
4
  component: import("react").FC<IBKJAddressInputProps>;
5
- argTypes: {};
5
+ argTypes: {
6
+ label: {
7
+ name: string;
8
+ control: string;
9
+ };
10
+ disabled: {
11
+ name: string;
12
+ type: string;
13
+ };
14
+ error: {
15
+ name: string;
16
+ control: string;
17
+ };
18
+ name: {
19
+ table: {
20
+ disable: boolean;
21
+ };
22
+ };
23
+ value: {
24
+ table: {
25
+ disable: boolean;
26
+ };
27
+ };
28
+ onChange: {
29
+ table: {
30
+ disable: boolean;
31
+ };
32
+ };
33
+ className: {
34
+ table: {
35
+ disable: boolean;
36
+ };
37
+ };
38
+ };
6
39
  };
7
40
  export default _default;
8
41
  export declare const Default: import("@storybook/core/csf").AnnotatedStoryFn<import("@storybook/react").ReactRenderer, IBKJAddressInputProps>;
42
+ export declare const Disabled: import("@storybook/core/csf").AnnotatedStoryFn<import("@storybook/react").ReactRenderer, IBKJAddressInputProps>;
43
+ export declare const Error: import("@storybook/core/csf").AnnotatedStoryFn<import("@storybook/react").ReactRenderer, IBKJAddressInputProps>;
9
44
  //# sourceMappingURL=BKJAddressInput.stories.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BKJAddressInput.stories.d.ts","sourceRoot":"","sources":["../../../src/components/BKJAddressInput/BKJAddressInput.stories.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;;;;;;AAEhE,wBAIE;AAIF,eAAO,MAAM,OAAO,iHAAoB,CAAC"}
1
+ {"version":3,"file":"BKJAddressInput.stories.d.ts","sourceRoot":"","sources":["../../../src/components/BKJAddressInput/BKJAddressInput.stories.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEhE,wBAYE;AAIF,eAAO,MAAM,OAAO,iHAAoB,CAAC;AASzC,eAAO,MAAM,QAAQ,iHAAoB,CAAC;AAS1C,eAAO,MAAM,KAAK,iHAAoB,CAAC"}
@@ -3,9 +3,39 @@ import { BKJAddressInput } from './BKJAddressInput.js';
3
3
  export default {
4
4
  title: 'Input Elements/BKJAddressInput',
5
5
  component: BKJAddressInput,
6
- argTypes: {},
6
+ argTypes: {
7
+ label: { name: 'Label', control: 'text' },
8
+ disabled: { name: 'Disabled', type: 'boolean' },
9
+ error: { name: 'Error', control: 'text' },
10
+ name: { table: { disable: true } },
11
+ value: { table: { disable: true } },
12
+ onChange: { table: { disable: true } },
13
+ className: { table: { disable: true } },
14
+ },
7
15
  };
8
- const Template = ({ ...props }) => _jsx(BKJAddressInput, { ...props });
16
+ const Template = (args) => _jsx(BKJAddressInput, { ...args });
9
17
  export const Default = Template.bind({});
10
- Default.args = {};
18
+ Default.args = {
19
+ label: 'Address',
20
+ name: 'address',
21
+ value: '',
22
+ disabled: false,
23
+ onChange: () => { },
24
+ };
25
+ export const Disabled = Template.bind({});
26
+ Disabled.args = {
27
+ label: 'Address',
28
+ name: 'address-disabled',
29
+ value: '',
30
+ disabled: true,
31
+ onChange: () => { },
32
+ };
33
+ export const Error = Template.bind({});
34
+ Error.args = {
35
+ label: 'Address',
36
+ name: 'address-error',
37
+ value: '',
38
+ error: 'Enter a valid address',
39
+ onChange: () => { },
40
+ };
11
41
  //# sourceMappingURL=BKJAddressInput.stories.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BKJAddressInput.stories.js","sourceRoot":"","sources":["../../../src/components/BKJAddressInput/BKJAddressInput.stories.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD,eAAe;IACb,KAAK,EAAE,gCAAgC;IACvC,SAAS,EAAE,eAAe;IAC1B,QAAQ,EAAE,EAAE;CACb,CAAC;AAEF,MAAM,QAAQ,GAAmC,CAAC,EAAE,GAAG,KAAK,EAAE,EAAE,EAAE,CAAC,KAAC,eAAe,OAAK,KAAK,GAAI,CAAC;AAElG,MAAM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AAM,CAAC,MAAM,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC1C,QAAQ,CAAC,IAAI,GAAG;IACd,KAAK,EAAE,SAAS;IAChB,IAAI,EAAE,kBAAkB;IACxB,KAAK,EAAE,EAAE;IACT,QAAQ,EAAE,IAAI;IACd,QAAQ,EAAE,GAAG,EAAE,GAAE,CAAC;CACnB,CAAC;AAEF,MAAM,CAAC,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACvC,KAAK,CAAC,IAAI,GAAG;IACX,KAAK,EAAE,SAAS;IAChB,IAAI,EAAE,eAAe;IACrB,KAAK,EAAE,EAAE;IACT,KAAK,EAAE,uBAAuB;IAC9B,QAAQ,EAAE,GAAG,EAAE,GAAE,CAAC;CACnB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=BKJAddressInput.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BKJAddressInput.test.d.ts","sourceRoot":"","sources":["../../../src/components/BKJAddressInput/BKJAddressInput.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,198 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ // jsdom does not implement ResizeObserver / IntersectionObserver.
3
+ // react-virtual and react-popper (used by BKJComboBoxAsync's dropdown) rely
4
+ // on them — matching the shim installed in BKJComboBoxAsync.test.tsx.
5
+ class ResizeObserverMock {
6
+ observe() { }
7
+ unobserve() { }
8
+ disconnect() { }
9
+ }
10
+ globalThis.ResizeObserver =
11
+ ResizeObserverMock;
12
+ class IntersectionObserverMock {
13
+ constructor(_cb) {
14
+ Object.defineProperty(this, "root", {
15
+ enumerable: true,
16
+ configurable: true,
17
+ writable: true,
18
+ value: null
19
+ });
20
+ Object.defineProperty(this, "rootMargin", {
21
+ enumerable: true,
22
+ configurable: true,
23
+ writable: true,
24
+ value: ''
25
+ });
26
+ Object.defineProperty(this, "thresholds", {
27
+ enumerable: true,
28
+ configurable: true,
29
+ writable: true,
30
+ value: []
31
+ });
32
+ }
33
+ observe() { }
34
+ unobserve() { }
35
+ disconnect() { }
36
+ takeRecords() {
37
+ return [];
38
+ }
39
+ }
40
+ globalThis.IntersectionObserver =
41
+ IntersectionObserverMock;
42
+ import { act, fireEvent, screen } from '@testing-library/react';
43
+ import { axe } from 'jest-axe';
44
+ import { renderAndCheckA11y, renderWithTheme } from '../../test-utils/index.js';
45
+ import { BKJAddressInput } from './BKJAddressInput.js';
46
+ const getQueryPredictionsMock = jest.fn();
47
+ const geocodeMock = jest.fn();
48
+ beforeEach(() => {
49
+ window.google = {
50
+ maps: {
51
+ places: {
52
+ AutocompleteService: jest.fn().mockImplementation(() => ({
53
+ getQueryPredictions: getQueryPredictionsMock,
54
+ })),
55
+ },
56
+ Geocoder: jest.fn().mockImplementation(() => ({
57
+ geocode: geocodeMock,
58
+ })),
59
+ },
60
+ };
61
+ });
62
+ afterEach(() => {
63
+ delete window.google;
64
+ jest.clearAllMocks();
65
+ document.querySelectorAll('#dropdown-root').forEach((el) => el.remove());
66
+ });
67
+ const openDropdown = async (input) => {
68
+ await act(async () => {
69
+ input.focus();
70
+ await Promise.resolve();
71
+ });
72
+ };
73
+ describe('BKJAddressInput', () => {
74
+ describe('Keyboard', () => {
75
+ it('combobox input is focusable when not disabled', () => {
76
+ renderWithTheme(_jsx(BKJAddressInput, { label: "Address", name: "address", value: "", onChange: () => { } }));
77
+ const input = screen.getByRole('combobox');
78
+ input.focus();
79
+ expect(input).toHaveFocus();
80
+ });
81
+ it('disabled combobox input cannot receive focus', () => {
82
+ renderWithTheme(_jsx(BKJAddressInput, { label: "Address", name: "address", value: "", disabled: true, onChange: () => { } }));
83
+ const input = screen.getByRole('combobox');
84
+ input.focus();
85
+ expect(input).not.toHaveFocus();
86
+ });
87
+ });
88
+ describe('Accessibility', () => {
89
+ it('has no accessibility violations on labelled default (idle)', async () => {
90
+ const { axeResults } = await renderAndCheckA11y(_jsx(BKJAddressInput, { label: "Address", name: "address", value: "", onChange: () => { } }));
91
+ expect(axeResults).toHaveNoViolations();
92
+ });
93
+ // NOTE: the FR-005(b) loading-state and FR-005(c) populated-predictions
94
+ // axe assertions are scoped to `renderResult.container` (the component's
95
+ // own output), NOT `document.body`. Running axe against the full body
96
+ // when the dropdown is open surfaces two pre-existing defects in
97
+ // `BKJComboBoxAsync`'s option rendering:
98
+ // 1. `nested-interactive` — `<li role="option">` has focusable
99
+ // descendants (the inner BKJCheckbox for multi-select support).
100
+ // 2. `label` — the inner BKJCheckbox's explicit label is hidden and
101
+ // does not satisfy the accessible-name rule.
102
+ // FR-008 bars this ticket from editing `BKJComboBoxAsync`; a separate
103
+ // follow-up should remediate both in BKJComboBoxAsyncItem. In the
104
+ // meantime, these tests still verify axe on the input + label surface
105
+ // during async activity without regressing on the pre-existing upstream.
106
+ it('has no accessibility violations with populated predictions', async () => {
107
+ getQueryPredictionsMock.mockImplementation((_, callback) => {
108
+ callback([
109
+ { place_id: 'pid-1', description: '123 Main St, Toronto' },
110
+ { place_id: 'pid-2', description: '456 King St, Toronto' },
111
+ ]);
112
+ });
113
+ jest.useFakeTimers();
114
+ const renderResult = renderWithTheme(_jsx(BKJAddressInput, { label: "Address", name: "address", value: "", onChange: () => { } }));
115
+ const input = screen.getByRole('combobox');
116
+ await openDropdown(input);
117
+ fireEvent.change(input, { target: { value: '123 Main' } });
118
+ act(() => {
119
+ jest.advanceTimersByTime(500);
120
+ });
121
+ // Switch back to real timers BEFORE axe — axe-core uses setTimeout
122
+ // internally for work-chunking and hangs under fake timers.
123
+ jest.useRealTimers();
124
+ const axeResults = await axe(renderResult.container);
125
+ expect(axeResults).toHaveNoViolations();
126
+ });
127
+ it('has no accessibility violations while predictions are loading', async () => {
128
+ getQueryPredictionsMock.mockImplementation(() => {
129
+ /* pending — callback never invoked */
130
+ });
131
+ jest.useFakeTimers();
132
+ const renderResult = renderWithTheme(_jsx(BKJAddressInput, { label: "Address", name: "address", value: "", onChange: () => { } }));
133
+ const input = screen.getByRole('combobox');
134
+ await openDropdown(input);
135
+ fireEvent.change(input, { target: { value: '123 Main' } });
136
+ act(() => {
137
+ jest.advanceTimersByTime(500);
138
+ });
139
+ expect(getQueryPredictionsMock).toHaveBeenCalledTimes(1);
140
+ const firstCall = getQueryPredictionsMock.mock.calls[0];
141
+ expect(firstCall).toBeDefined();
142
+ expect(firstCall[0]).toEqual({ input: '123 Main' });
143
+ jest.useRealTimers();
144
+ const axeResults = await axe(renderResult.container);
145
+ expect(axeResults).toHaveNoViolations();
146
+ });
147
+ it('exposes aria-busy="true" somewhere in the subtree while the predictions request is in-flight', async () => {
148
+ getQueryPredictionsMock.mockImplementation(() => {
149
+ /* pending */
150
+ });
151
+ jest.useFakeTimers();
152
+ try {
153
+ renderWithTheme(_jsx(BKJAddressInput, { label: "Address", name: "address", value: "", onChange: () => { } }));
154
+ const input = screen.getByRole('combobox');
155
+ await openDropdown(input);
156
+ fireEvent.change(input, { target: { value: '123 Main' } });
157
+ act(() => {
158
+ jest.advanceTimersByTime(500);
159
+ });
160
+ // FR-005a location-agnostic — WEB-4815 placed aria-busy on the
161
+ // portal'd listbox, so we query document.body rather than the
162
+ // render container. See contracts/mock-boundary.md §3.
163
+ expect(document.body.querySelector('[aria-busy="true"]')).not.toBeNull();
164
+ }
165
+ finally {
166
+ jest.useRealTimers();
167
+ }
168
+ });
169
+ it('clears aria-busy across the subtree when the predictions request completes', async () => {
170
+ let capturedCallback;
171
+ getQueryPredictionsMock.mockImplementation((_, callback) => {
172
+ capturedCallback = callback;
173
+ });
174
+ jest.useFakeTimers();
175
+ try {
176
+ renderWithTheme(_jsx(BKJAddressInput, { label: "Address", name: "address", value: "", onChange: () => { } }));
177
+ const input = screen.getByRole('combobox');
178
+ await openDropdown(input);
179
+ fireEvent.change(input, { target: { value: '123 Main' } });
180
+ act(() => {
181
+ jest.advanceTimersByTime(500);
182
+ });
183
+ expect(document.body.querySelector('[aria-busy="true"]')).not.toBeNull();
184
+ act(() => {
185
+ capturedCallback?.([
186
+ { place_id: 'pid-1', description: '123 Main St, Toronto' },
187
+ ]);
188
+ });
189
+ // Accepts both attribute-absent and aria-busy="false" shapes.
190
+ expect(document.body.querySelector('[aria-busy="true"]')).toBeNull();
191
+ }
192
+ finally {
193
+ jest.useRealTimers();
194
+ }
195
+ });
196
+ });
197
+ });
198
+ //# sourceMappingURL=BKJAddressInput.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BKJAddressInput.test.js","sourceRoot":"","sources":["../../../src/components/BKJAddressInput/BKJAddressInput.test.tsx"],"names":[],"mappings":";AAAA,kEAAkE;AAClE,4EAA4E;AAC5E,sEAAsE;AACtE,MAAM,kBAAkB;IACtB,OAAO,KAAU,CAAC;IAClB,SAAS,KAAU,CAAC;IACpB,UAAU,KAAU,CAAC;CACtB;AACA,UAAuE,CAAC,cAAc;IACrF,kBAAkB,CAAC;AACrB,MAAM,wBAAwB;IAC5B,YAAY,GAAiC;QAO7C;;;;mBAAuB,IAAI;WAAC;QAC5B;;;;mBAAa,EAAE;WAAC;QAChB;;;;mBAAoC,EAAE;WAAC;IATS,CAAC;IACjD,OAAO,KAAU,CAAC;IAClB,SAAS,KAAU,CAAC;IACpB,UAAU,KAAU,CAAC;IACrB,WAAW;QACT,OAAO,EAAE,CAAC;IACZ,CAAC;CAIF;AACA,UAAmF,CAAC,oBAAoB;IACvG,wBAAwB,CAAC;AAE3B,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAKpD,MAAM,uBAAuB,GAAG,IAAI,CAAC,EAAE,EAGpC,CAAC;AACJ,MAAM,WAAW,GAAG,IAAI,CAAC,EAAE,EAAE,CAA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,UAAU,EAAE,EAAE,CAAC,CAAC;gBAC3D,GAAG,CAAC,GAAG,EAAE;oBACP,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC;gBAChC,CAAC,CAAC,CAAC;gBAEH,MAAM,CACJ,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,oBAAoB,CAAC,CAClD,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;gBAEjB,GAAG,CAAC,GAAG,EAAE;oBACP,gBAAgB,EAAE,CAAC;wBACjB,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE;qBAC3D,CAAC,CAAC;gBACL,CAAC,CAAC,CAAC;gBAEH,8DAA8D;gBAC9D,MAAM,CACJ,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,oBAAoB,CAAC,CAClD,CAAC,QAAQ,EAAE,CAAC;YACf,CAAC;oBAAS,CAAC;gBACT,IAAI,CAAC,aAAa,EAAE,CAAC;YACvB,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"BKJTextArea.d.ts","sourceRoot":"","sources":["../../../src/components/BKJTextArea/BKJTextArea.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAe,EAAE,EAAwB,MAAM,OAAO,CAAC;AAS9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,eAAO,MAAM,WAAW,EAAE,EAAE,CAAC,iBAAiB,CA8D5C,CAAC"}
1
+ {"version":3,"file":"BKJTextArea.d.ts","sourceRoot":"","sources":["../../../src/components/BKJTextArea/BKJTextArea.tsx"],"names":[],"mappings":"AACA,OAAO,EAAe,EAAE,EAA0C,MAAM,OAAO,CAAC;AAWhF,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,eAAO,MAAM,WAAW,EAAE,EAAE,CAAC,iBAAiB,CAuF5C,CAAC"}
@@ -1,8 +1,21 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { forwardRef, useState } from 'react';
2
+ import { useTextField } from '@react-aria/textfield';
3
+ import { forwardRef, Fragment, useRef, useState } from 'react';
4
+ import { isBoolean, isFormValidationErrorDisplayed } from '../../common.types.js';
5
+ import { mergeRefs } from '../BKJSelect/utils/mergeRefs.js';
3
6
  import { Input, InputErrorMessage, InputLabel, RequiredAsterisk, TextInputWrapper, WordCount, } from './BKJTextArea.styled.js';
4
7
  export const BKJTextArea = forwardRef((props, ref) => {
5
8
  const { label, error, maxLength = 500, required, disabled, onChange, className, width, height, ...rest } = props;
9
+ const innerRef = useRef({});
10
+ const hasStringyError = isFormValidationErrorDisplayed(error) && !isBoolean(error);
11
+ const { labelProps, inputProps, errorMessageProps } = useTextField({
12
+ label: label || 'Text area',
13
+ isRequired: required,
14
+ isDisabled: disabled,
15
+ inputElementType: 'textarea',
16
+ errorMessage: hasStringyError ? error : undefined,
17
+ validationState: isFormValidationErrorDisplayed(error) ? 'invalid' : 'valid',
18
+ }, innerRef);
6
19
  const [charCount, setCharCount] = useState(props.value ? props.value.toLocaleString().length : 0);
7
20
  const countChars = (e) => {
8
21
  const text = e.target.value;
@@ -13,6 +26,8 @@ export const BKJTextArea = forwardRef((props, ref) => {
13
26
  onChange(e);
14
27
  countChars(e);
15
28
  };
16
- return (_jsxs(TextInputWrapper, { className: className, children: [label && (_jsxs(InputLabel, { disabled: disabled, children: [label, " ", required && _jsx(RequiredAsterisk, { children: "\u00A0*" })] })), _jsx(Input, { ref: ref, error: !!error, onChange: handleChange, maxLength: maxLength, disabled: disabled, width: width, height: height, ...rest }), _jsxs(WordCount, { disabled: disabled, error: error ? (Array.isArray(error) ? !!error.length : !!error) : false, children: [`${charCount}/${maxLength}`, error && Array.isArray(error) ? (error.map((err) => _jsx(InputErrorMessage, { children: err }, err))) : (_jsx(InputErrorMessage, { children: error }))] })] }));
29
+ return (_jsxs(TextInputWrapper, { className: className, children: [label && (_jsxs(InputLabel, { ...labelProps, disabled: disabled, children: [label, " ", required && _jsx(RequiredAsterisk, { children: "\u00A0*" })] })), _jsx(Input, { ...inputProps, ref: mergeRefs([innerRef, ref]), error: !!error, onChange: handleChange, maxLength: maxLength, disabled: disabled, width: width, height: height, value: props.value, ...rest }), _jsxs(WordCount, { disabled: disabled, error: error ? (Array.isArray(error) ? !!error.length : !!error) : false, children: [`${charCount}/${maxLength}`, hasStringyError && (_jsx(InputErrorMessage, { ...errorMessageProps, children: Array.isArray(error)
30
+ ? error.map((err, i) => (_jsxs(Fragment, { children: [i > 0 && _jsx("br", {}), err] }, `${err}-${i}`)))
31
+ : error }))] })] }));
17
32
  });
18
33
  //# sourceMappingURL=BKJTextArea.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BKJTextArea.js","sourceRoot":"","sources":["../../../src/components/BKJTextArea/BKJTextArea.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAmB,UAAU,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9D,OAAO,EACL,KAAK,EACL,iBAAiB,EACjB,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,SAAS,GACV,MAAM,sBAAsB,CAAC;AAG9B,MAAM,CAAC,MAAM,WAAW,GAA0B,UAAU,CAG1D,CAAC,KAAK,EAAE,GAAG,EAAe,EAAE;IAC5B,MAAM,EACJ,KAAK,EACL,KAAK,EACL,SAAS,GAAG,GAAG,EACf,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,KAAK,EACL,MAAM,EACN,GAAG,IAAI,EACR,GAAG,KAAK,CAAC;IAEV,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CACxC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,cAAc,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CACtD,CAAC;IAEF,MAAM,UAAU,GAAG,CAAC,CAAmC,EAAE,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CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,aAEvE,GAAG,SAAS,IAAI,SAAS,EAAE,EAE3B,eAAe,IAAI,CAClB,KAAC,iBAAiB,OAAK,iBAAiB,YACrC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;4BACnB,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CACpB,MAAC,QAAQ,eACN,CAAC,GAAG,CAAC,IAAI,cAAM,EACf,GAAG,KAFS,GAAG,GAAG,IAAI,CAAC,EAAE,CAGjB,CACZ,CAAC;4BACJ,CAAC,CAAC,KAAK,GACS,CACrB,IACS,IACK,CACpB,CAAC;AACJ,CAAC,CAAC,CAAC"}
@@ -44,5 +44,9 @@ declare const Setup: {
44
44
  };
45
45
  };
46
46
  export declare const Default: import("@storybook/core/csf").AnnotatedStoryFn<import("@storybook/react").ReactRenderer, IBKJTextAreaProps>;
47
+ export declare const WithError: import("@storybook/core/csf").AnnotatedStoryFn<import("@storybook/react").ReactRenderer, IBKJTextAreaProps>;
48
+ export declare const WithArrayError: import("@storybook/core/csf").AnnotatedStoryFn<import("@storybook/react").ReactRenderer, IBKJTextAreaProps>;
49
+ export declare const Required: import("@storybook/core/csf").AnnotatedStoryFn<import("@storybook/react").ReactRenderer, IBKJTextAreaProps>;
50
+ export declare const Disabled: import("@storybook/core/csf").AnnotatedStoryFn<import("@storybook/react").ReactRenderer, IBKJTextAreaProps>;
47
51
  export default Setup;
48
52
  //# sourceMappingURL=BKJTextArea.stories.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BKJTextArea.stories.d.ts","sourceRoot":"","sources":["../../../src/components/BKJTextArea/BKJTextArea.stories.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,QAAA,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4CV,CAAC;AAQF,eAAO,MAAM,OAAO,6GAAoB,CAAC;AAUzC,eAAe,KAAK,CAAC"}
1
+ {"version":3,"file":"BKJTextArea.stories.d.ts","sourceRoot":"","sources":["../../../src/components/BKJTextArea/BKJTextArea.stories.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGxD,QAAA,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4CV,CAAC;AAQF,eAAO,MAAM,OAAO,6GAAoB,CAAC;AAUzC,eAAO,MAAM,SAAS,6GAAoB,CAAC;AAO3C,eAAO,MAAM,cAAc,6GAAoB,CAAC;AAOhD,eAAO,MAAM,QAAQ,6GAAoB,CAAC;AAO1C,eAAO,MAAM,QAAQ,6GAAoB,CAAC;AAO1C,eAAe,KAAK,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { BKJTheme, BKJThemeProvider } from '../../providers/BKJThemeProvider/index.js';
3
- import { BKJTextArea } from './BKJTextArea.js';
2
+ import { BKJTextArea } from '../index.js';
3
+ import { BKJTheme, BKJThemeProvider } from '../../providers/index.js';
4
4
  const Setup = {
5
5
  title: 'Input Elements/BKJTextArea',
6
6
  component: BKJTextArea,
@@ -54,5 +54,25 @@ Default.args = {
54
54
  width: '',
55
55
  height: '',
56
56
  };
57
+ export const WithError = Template.bind({});
58
+ WithError.args = {
59
+ ...Default.args,
60
+ error: 'This field is required',
61
+ };
62
+ export const WithArrayError = Template.bind({});
63
+ WithArrayError.args = {
64
+ ...Default.args,
65
+ error: ['Must not be empty', 'Must be at least 10 characters'],
66
+ };
67
+ export const Required = Template.bind({});
68
+ Required.args = {
69
+ ...Default.args,
70
+ required: true,
71
+ };
72
+ export const Disabled = Template.bind({});
73
+ Disabled.args = {
74
+ ...Default.args,
75
+ disabled: true,
76
+ };
57
77
  export default Setup;
58
78
  //# sourceMappingURL=BKJTextArea.stories.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BKJTextArea.stories.js","sourceRoot":"","sources":["../../../src/components/BKJTextArea/BKJTextArea.stories.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAC9E,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C,MAAM,KAAK,GAAG;IACZ,KAAK,EAAE,4BAA4B;IACnC,SAAS,EAAE,WAAW;IAEtB,QAAQ,EAAE;QACR,KAAK,EAAE;YACL,IAAI,EAAE,YAAY;SACnB;QACD,KAAK,EAAE;YACL,IAAI,EAAE,eAAe;YACrB,OAAO,EAAE;gBACP,IAAI,EAAE,MAAM;aACb;SACF;QACD,QAAQ,EAAE;YACR,IAAI,EAAE,gBAAgB;SACvB;QACD,WAAW,EAAE;YACX,IAAI,EAAE,aAAa;SACpB;QACD,SAAS,EAAE;YACT,IAAI,EAAE,0BAA0B;SACjC;QACD,QAAQ,EAAE;YACR,IAAI,EAAE,UAAU;SACjB;QACD,KAAK,EAAE;YACL,IAAI,EAAE,OAAO;YACb,OAAO,EAAE;gBACP,IAAI,EAAE,MAAM;aACb;SACF;QACD,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE;gBACP,IAAI,EAAE,MAAM;aACb;SACF;QACD,KAAK,EAAE;YACL,KAAK,EAAE;gBACL,OAAO,EAAE,IAAI;aACd;SACF;KACF;CACF,CAAC;AAEF,MAAM,QAAQ,GAA+B,CAAC,IAAI,EAAE,EAAE,CAAC,CACrD,KAAC,gBAAgB,IAAC,KAAK,EAAE,QAAQ,YAC/B,KAAC,WAAW,OAAK,IAAI,GAAI,GACR,CACpB,CAAC;AAEF,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAEzC,OAAO,CAAC,IAAI,GAAG;IACb,KAAK,EAAE,6BAA6B;IACpC,QAAQ,EAAE,KAAK;IACf,WAAW,EAAE,wBAAwB;IACrC,KAAK,EAAE,EAAE;IACT,MAAM,EAAE,EAAE;CACX,CAAC;AAEF,eAAe,KAAK,CAAC"}
1
+ {"version":3,"file":"BKJTextArea.stories.js","sourceRoot":"","sources":["../../../src/components/BKJTextArea/BKJTextArea.stories.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAEvD,MAAM,KAAK,GAAG;IACZ,KAAK,EAAE,4BAA4B;IACnC,SAAS,EAAE,WAAW;IAEtB,QAAQ,EAAE;QACR,KAAK,EAAE;YACL,IAAI,EAAE,YAAY;SACnB;QACD,KAAK,EAAE;YACL,IAAI,EAAE,eAAe;YACrB,OAAO,EAAE;gBACP,IAAI,EAAE,MAAM;aACb;SACF;QACD,QAAQ,EAAE;YACR,IAAI,EAAE,gBAAgB;SACvB;QACD,WAAW,EAAE;YACX,IAAI,EAAE,aAAa;SACpB;QACD,SAAS,EAAE;YACT,IAAI,EAAE,0BAA0B;SACjC;QACD,QAAQ,EAAE;YACR,IAAI,EAAE,UAAU;SACjB;QACD,KAAK,EAAE;YACL,IAAI,EAAE,OAAO;YACb,OAAO,EAAE;gBACP,IAAI,EAAE,MAAM;aACb;SACF;QACD,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE;gBACP,IAAI,EAAE,MAAM;aACb;SACF;QACD,KAAK,EAAE;YACL,KAAK,EAAE;gBACL,OAAO,EAAE,IAAI;aACd;SACF;KACF;CACF,CAAC;AAEF,MAAM,QAAQ,GAA+B,CAAC,IAAI,EAAE,EAAE,CAAC,CACrD,KAAC,gBAAgB,IAAC,KAAK,EAAE,QAAQ,YAC/B,KAAC,WAAW,OAAK,IAAI,GAAI,GACR,CACpB,CAAC;AAEF,MAAM,CAAC,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AAC;AAEF,eAAO,MAAM,KAAK,kFAmBjB,CAAC;AAEF,UAAU,eAAe;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,eAAO,MAAM,SAAS,gQAerB,CAAC;AAEF,eAAO,MAAM,gBAAgB,6NAE5B,CAAC;AAEF,eAAO,MAAM,iBAAiB,+NAM7B,CAAC"}
1
+ {"version":3,"file":"BKJTextArea.styled.d.ts","sourceRoot":"","sources":["../../../src/components/BKJTextArea/BKJTextArea.styled.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,eAAO,MAAM,UAAU,6PAEtB,CAAC;AAEF,eAAO,MAAM,gBAAgB;;mBAE5B,CAAC;AAEF,eAAO,MAAM,KAAK,kFAmBjB,CAAC;AAEF,UAAU,eAAe;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,eAAO,MAAM,SAAS,gQAerB,CAAC;AAEF,eAAO,MAAM,gBAAgB,6NAE5B,CAAC;AAEF,eAAO,MAAM,iBAAiB,+NAO7B,CAAC"}
@@ -7,7 +7,7 @@ export const RequiredAsterisk = styled(InputLabel) `
7
7
  ${InputRequiredAsteriskCSS}
8
8
  `;
9
9
  export const Input = styled.textarea `
10
- ${InputBaseCSS}
10
+ ${InputBaseCSS};
11
11
  padding: 10px 12px;
12
12
  height: 120px;
13
13
  resize: none;
@@ -44,6 +44,7 @@ export const TextInputWrapper = styled.div `
44
44
  export const InputErrorMessage = styled.span `
45
45
  ${({ theme }) => theme.fonts.PoppinsText};
46
46
  font-size: 14px;
47
+ padding-left: 5px;
47
48
  line-height: 21px;
48
49
  margin-top: 8px;
49
50
  color: ${({ theme }) => theme.colors.ErrorDefault};
@@ -1 +1 @@
1
- {"version":3,"file":"BKJTextArea.styled.js","sourceRoot":"","sources":["../../../src/components/BKJTextArea/B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K,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO;WAChC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,YAAY;;WAExC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,YAAY;IAC/C,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,CACxB,QAAQ;IACR,GAAG,CAAA;eACQ,KAAK,CAAC,MAAM,CAAC,YAAY;KACnC;IACD,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,CACrB,KAAK;IACL,GAAG,CAAA;eACQ,KAAK,CAAC,MAAM,CAAC,YAAY;KACnC;CACJ,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,GAAG,CAAA;IACtC,eAAe;CAClB,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,IAAI,CAAA;IACxC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,WAAW;;;;;WAK/B,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,YAAY;CAClD,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=BKJTextArea.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BKJTextArea.test.d.ts","sourceRoot":"","sources":["../../../src/components/BKJTextArea/BKJTextArea.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,117 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { screen } from '@testing-library/react';
3
+ import { renderAndCheckA11y, renderWithTheme } from '../../test-utils/index.js';
4
+ import { BKJThemeProvider } from '../../providers/BKJThemeProvider/index.js';
5
+ import { BKJTextArea } from '../index.js';
6
+ const noop = () => { };
7
+ describe('BKJTextArea', () => {
8
+ describe('Accessibility', () => {
9
+ it('default (labelled) has no a11y violations', async () => {
10
+ const { axeResults } = await renderAndCheckA11y(_jsx(BKJTextArea, { label: "Notes", onChange: noop }));
11
+ expect(axeResults).toHaveNoViolations();
12
+ });
13
+ it('required has no a11y violations', async () => {
14
+ const { axeResults } = await renderAndCheckA11y(_jsx(BKJTextArea, { label: "Notes", required: true, onChange: noop }));
15
+ expect(axeResults).toHaveNoViolations();
16
+ });
17
+ it('with string error has no a11y violations', async () => {
18
+ const { axeResults } = await renderAndCheckA11y(_jsx(BKJTextArea, { label: "Notes", error: "This field is required", onChange: noop }));
19
+ expect(axeResults).toHaveNoViolations();
20
+ });
21
+ it('with array of errors has no a11y violations', async () => {
22
+ const { axeResults } = await renderAndCheckA11y(_jsx(BKJTextArea, { label: "Notes", error: ['Must not be empty', 'Must be at least 10 characters'], onChange: noop }));
23
+ expect(axeResults).toHaveNoViolations();
24
+ });
25
+ it('disabled has no a11y violations', async () => {
26
+ const { axeResults } = await renderAndCheckA11y(_jsx(BKJTextArea, { label: "Notes", disabled: true, onChange: noop }));
27
+ expect(axeResults).toHaveNoViolations();
28
+ });
29
+ it('renders a single error element when error is an array of strings', () => {
30
+ const { container } = renderWithTheme(_jsx(BKJTextArea, { label: "Notes", error: ['Must not be empty', 'Must be at least 10 characters'], onChange: noop }));
31
+ const textarea = screen.getByRole('textbox', { name: 'Notes' });
32
+ const describedBy = textarea.getAttribute('aria-describedby');
33
+ expect(describedBy).toBeTruthy();
34
+ const errorIds = (describedBy ?? '').split(/\s+/).filter(Boolean);
35
+ errorIds.forEach((id) => {
36
+ const matches = container.querySelectorAll(`[id="${id}"]`);
37
+ expect(matches.length).toBe(1);
38
+ });
39
+ });
40
+ it('does not render an error element when error is boolean true', () => {
41
+ renderWithTheme(_jsx(BKJTextArea, { label: "Notes", error: true, onChange: noop }));
42
+ const textarea = screen.getByRole('textbox', { name: 'Notes' });
43
+ expect(textarea).toHaveAttribute('aria-invalid', 'true');
44
+ const describedBy = textarea.getAttribute('aria-describedby');
45
+ if (describedBy) {
46
+ const referenced = describedBy
47
+ .split(/\s+/)
48
+ .filter(Boolean)
49
+ .map((id) => document.getElementById(id))
50
+ .filter((el) => el !== null);
51
+ referenced.forEach((el) => {
52
+ expect(el.textContent?.trim().length ?? 0).toBeGreaterThan(0);
53
+ });
54
+ }
55
+ });
56
+ });
57
+ describe('ARIA attributes', () => {
58
+ it('label htmlFor matches textarea id', () => {
59
+ const { container } = renderWithTheme(_jsx(BKJTextArea, { label: "Notes", onChange: noop }));
60
+ const textarea = screen.getByRole('textbox', { name: 'Notes' });
61
+ const textareaId = textarea.getAttribute('id');
62
+ expect(textareaId).toBeTruthy();
63
+ const label = container.querySelector('label');
64
+ expect(label).not.toBeNull();
65
+ expect(label.getAttribute('for')).toBe(textareaId);
66
+ });
67
+ it('textarea has aria-invalid="true" when error is a string', () => {
68
+ renderWithTheme(_jsx(BKJTextArea, { label: "Notes", error: "Required", onChange: noop }));
69
+ const textarea = screen.getByRole('textbox', { name: 'Notes' });
70
+ expect(textarea).toHaveAttribute('aria-invalid', 'true');
71
+ });
72
+ it('textarea aria-describedby references the error element id when error is a string', () => {
73
+ renderWithTheme(_jsx(BKJTextArea, { label: "Notes", error: "Required", onChange: noop }));
74
+ const textarea = screen.getByRole('textbox', { name: 'Notes' });
75
+ const describedBy = textarea.getAttribute('aria-describedby');
76
+ expect(describedBy).toBeTruthy();
77
+ const errorEl = document.getElementById(describedBy.split(/\s+/)[0]);
78
+ expect(errorEl).not.toBeNull();
79
+ expect(errorEl.textContent).toContain('Required');
80
+ });
81
+ it('textarea has no aria-invalid when error is falsy', () => {
82
+ renderWithTheme(_jsx(BKJTextArea, { label: "Notes", onChange: noop }));
83
+ const textarea = screen.getByRole('textbox', { name: 'Notes' });
84
+ expect(textarea).not.toHaveAttribute('aria-invalid', 'true');
85
+ });
86
+ it('textarea has aria-required="true" when required is true', () => {
87
+ renderWithTheme(_jsx(BKJTextArea, { label: "Notes", required: true, onChange: noop }));
88
+ const textarea = screen.getByRole('textbox', { name: /Notes/ });
89
+ expect(textarea).toHaveAttribute('aria-required', 'true');
90
+ });
91
+ it('textarea has no aria-required when required is absent', () => {
92
+ renderWithTheme(_jsx(BKJTextArea, { label: "Notes", onChange: noop }));
93
+ const textarea = screen.getByRole('textbox', { name: 'Notes' });
94
+ expect(textarea).not.toHaveAttribute('aria-required');
95
+ });
96
+ });
97
+ describe('State transitions', () => {
98
+ it('clears aria-invalid and error linkage when string error is cleared', () => {
99
+ const { rerender } = renderWithTheme(_jsx(BKJTextArea, { label: "Notes", error: "Required", onChange: noop }));
100
+ const textareaWithError = screen.getByRole('textbox', { name: 'Notes' });
101
+ expect(textareaWithError).toHaveAttribute('aria-invalid', 'true');
102
+ const describedByWithError = textareaWithError.getAttribute('aria-describedby');
103
+ expect(describedByWithError).toBeTruthy();
104
+ rerender(_jsx(BKJThemeProvider, { children: _jsx(BKJTextArea, { label: "Notes", onChange: noop }) }));
105
+ const textareaCleared = screen.getByRole('textbox', { name: 'Notes' });
106
+ expect(textareaCleared).not.toHaveAttribute('aria-invalid', 'true');
107
+ const describedByCleared = textareaCleared.getAttribute('aria-describedby');
108
+ if (describedByCleared) {
109
+ const referencedIds = describedByCleared.split(/\s+/).filter(Boolean);
110
+ referencedIds.forEach((id) => {
111
+ expect(document.getElementById(id)).not.toBeNull();
112
+ });
113
+ }
114
+ });
115
+ });
116
+ });
117
+ //# sourceMappingURL=BKJTextArea.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BKJTextArea.test.js","sourceRoot":"","sources":["../../../src/components/BKJTextArea/BKJTextArea.test.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAA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EAAE;oBAC3B,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;gBACrD,CAAC,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bookjane2/bookjane-design-library",
3
- "version": "9.0.8",
3
+ "version": "9.0.10",
4
4
  "main": "./lib/index.js",
5
5
  "typings": "./lib/index.d.ts",
6
6
  "engines": {