@abstraks-dev/ui-library 1.0.1

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 (158) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +708 -0
  3. package/dist/__tests__/Anchor.test.js +145 -0
  4. package/dist/__tests__/ArrowRight.test.js +91 -0
  5. package/dist/__tests__/Avatar.test.js +123 -0
  6. package/dist/__tests__/Button.test.js +82 -0
  7. package/dist/__tests__/Card.test.js +198 -0
  8. package/dist/__tests__/CheckCircle.test.js +98 -0
  9. package/dist/__tests__/Checkbox.test.js +161 -0
  10. package/dist/__tests__/ChevronDown.test.js +73 -0
  11. package/dist/__tests__/Close.test.js +98 -0
  12. package/dist/__tests__/EditSquare.test.js +99 -0
  13. package/dist/__tests__/Error.test.js +74 -0
  14. package/dist/__tests__/Footer.test.js +66 -0
  15. package/dist/__tests__/Heading.test.js +227 -0
  16. package/dist/__tests__/Hero.test.js +74 -0
  17. package/dist/__tests__/Label.test.js +123 -0
  18. package/dist/__tests__/Loader.test.js +115 -0
  19. package/dist/__tests__/MenuHover.test.js +137 -0
  20. package/dist/__tests__/Paragraph.test.js +93 -0
  21. package/dist/__tests__/PlusCircle.test.js +99 -0
  22. package/dist/__tests__/Radio.test.js +153 -0
  23. package/dist/__tests__/Select.test.js +187 -0
  24. package/dist/__tests__/Tabs.test.js +162 -0
  25. package/dist/__tests__/TextArea.test.js +127 -0
  26. package/dist/__tests__/TextInput.test.js +181 -0
  27. package/dist/__tests__/Toggle.test.js +120 -0
  28. package/dist/__tests__/TrashX.test.js +99 -0
  29. package/dist/__tests__/useHeadingAccessibility.test.js +144 -0
  30. package/dist/components/Anchor.js +131 -0
  31. package/dist/components/Animation.js +129 -0
  32. package/dist/components/AnimationGroup.js +207 -0
  33. package/dist/components/AnimationToggle.js +216 -0
  34. package/dist/components/Avatar.js +153 -0
  35. package/dist/components/Button.js +218 -0
  36. package/dist/components/Card.js +222 -0
  37. package/dist/components/Checkbox.js +305 -0
  38. package/dist/components/Crud.js +564 -0
  39. package/dist/components/DragAndDrop.js +337 -0
  40. package/dist/components/Error.js +206 -0
  41. package/dist/components/Footer.js +99 -0
  42. package/dist/components/Form.js +412 -0
  43. package/dist/components/Header.js +372 -0
  44. package/dist/components/Heading.js +134 -0
  45. package/dist/components/Hero.js +181 -0
  46. package/dist/components/Label.js +256 -0
  47. package/dist/components/Loader.js +302 -0
  48. package/dist/components/MenuHover.js +114 -0
  49. package/dist/components/Paragraph.js +128 -0
  50. package/dist/components/Prompt.js +61 -0
  51. package/dist/components/Radio.js +254 -0
  52. package/dist/components/Select.js +422 -0
  53. package/dist/components/SideMenu.js +313 -0
  54. package/dist/components/Tabs.js +297 -0
  55. package/dist/components/TextArea.js +370 -0
  56. package/dist/components/TextInput.js +286 -0
  57. package/dist/components/Toggle.js +186 -0
  58. package/dist/components/crudFiles/CrudEditBase.js +150 -0
  59. package/dist/components/crudFiles/CrudViewBase.js +39 -0
  60. package/dist/components/crudFiles/crudDevelopment.js +118 -0
  61. package/dist/components/crudFiles/crudEditHandlers.js +50 -0
  62. package/dist/constants/animation.js +30 -0
  63. package/dist/icons/ArrowIcon.js +32 -0
  64. package/dist/icons/ArrowRight.js +33 -0
  65. package/dist/icons/CheckCircle.js +33 -0
  66. package/dist/icons/ChevronDown.js +28 -0
  67. package/dist/icons/Close.js +33 -0
  68. package/dist/icons/EditSquare.js +33 -0
  69. package/dist/icons/Ellipses.js +34 -0
  70. package/dist/icons/Hamburger.js +39 -0
  71. package/dist/icons/LoadingSpinner.js +42 -0
  72. package/dist/icons/PlusCircle.js +33 -0
  73. package/dist/icons/SaveIcon.js +32 -0
  74. package/dist/icons/TrashX.js +33 -0
  75. package/dist/icons/__tests__/CheckCircle.test.js +9 -0
  76. package/dist/icons/__tests__/ChevronDown.test.js +9 -0
  77. package/dist/icons/__tests__/Close.test.js +9 -0
  78. package/dist/icons/__tests__/EditSquare.test.js +9 -0
  79. package/dist/icons/__tests__/PlusCircle.test.js +9 -0
  80. package/dist/icons/__tests__/TrashX.test.js +9 -0
  81. package/dist/icons/index.js +89 -0
  82. package/dist/index.js +332 -0
  83. package/dist/setupTests.js +3 -0
  84. package/dist/styles/_variables.scss +286 -0
  85. package/dist/styles/anchor.scss +40 -0
  86. package/dist/styles/animation-accessibility.scss +96 -0
  87. package/dist/styles/animation-toggle.scss +233 -0
  88. package/dist/styles/animation.scss +3781 -0
  89. package/dist/styles/avatar.scss +285 -0
  90. package/dist/styles/button.scss +430 -0
  91. package/dist/styles/card.scss +210 -0
  92. package/dist/styles/checkbox.scss +160 -0
  93. package/dist/styles/crud.scss +474 -0
  94. package/dist/styles/dragAndDrop.scss +312 -0
  95. package/dist/styles/error.scss +232 -0
  96. package/dist/styles/footer.scss +58 -0
  97. package/dist/styles/form.scss +420 -0
  98. package/dist/styles/grid.scss +29 -0
  99. package/dist/styles/header.scss +276 -0
  100. package/dist/styles/heading.scss +118 -0
  101. package/dist/styles/hero.scss +185 -0
  102. package/dist/styles/htmlElements.scss +20 -0
  103. package/dist/styles/image.scss +9 -0
  104. package/dist/styles/label.scss +340 -0
  105. package/dist/styles/list-item.scss +5 -0
  106. package/dist/styles/loader.scss +354 -0
  107. package/dist/styles/logo.scss +19 -0
  108. package/dist/styles/main.css +9056 -0
  109. package/dist/styles/main.css.map +1 -0
  110. package/dist/styles/main.scss +0 -0
  111. package/dist/styles/menu-hover.scss +30 -0
  112. package/dist/styles/paragraph.scss +88 -0
  113. package/dist/styles/prompt.scss +51 -0
  114. package/dist/styles/radio.scss +202 -0
  115. package/dist/styles/select.scss +363 -0
  116. package/dist/styles/side-menu.scss +334 -0
  117. package/dist/styles/tabs.scss +540 -0
  118. package/dist/styles/text-area.scss +388 -0
  119. package/dist/styles/text-input.scss +171 -0
  120. package/dist/styles/toggle.scss +0 -0
  121. package/dist/styles/unordered-list.scss +8 -0
  122. package/dist/utils/ScrollHandler.js +30 -0
  123. package/dist/utils/accessibility.js +128 -0
  124. package/dist/utils/heroUtils.js +316 -0
  125. package/dist/utils/index.js +104 -0
  126. package/dist/utils/inputValidation.js +29 -0
  127. package/dist/utils/keyboardNavigation.js +536 -0
  128. package/dist/utils/labelUtils.js +708 -0
  129. package/dist/utils/loaderUtils.js +387 -0
  130. package/dist/utils/menuUtils.js +575 -0
  131. package/dist/utils/useHeadingAccessibility.js +298 -0
  132. package/dist/utils/useRadioGroup.js +260 -0
  133. package/dist/utils/useSelectAccessibility.js +426 -0
  134. package/dist/utils/useTabsAccessibility.js +278 -0
  135. package/dist/utils/useTextAreaAccessibility.js +255 -0
  136. package/dist/utils/useTextInputAccessibility.js +295 -0
  137. package/dist/utils/useTypographyAccessibility.js +168 -0
  138. package/dist/utils/useWindowSize.js +32 -0
  139. package/dist/utils/utils/ScrollHandler.js +26 -0
  140. package/dist/utils/utils/accessibility.js +133 -0
  141. package/dist/utils/utils/heroUtils.js +348 -0
  142. package/dist/utils/utils/index.js +9 -0
  143. package/dist/utils/utils/inputValidation.js +22 -0
  144. package/dist/utils/utils/keyboardNavigation.js +664 -0
  145. package/dist/utils/utils/labelUtils.js +772 -0
  146. package/dist/utils/utils/loaderUtils.js +436 -0
  147. package/dist/utils/utils/menuUtils.js +651 -0
  148. package/dist/utils/utils/useHeadingAccessibility.js +334 -0
  149. package/dist/utils/utils/useRadioGroup.js +311 -0
  150. package/dist/utils/utils/useSelectAccessibility.js +498 -0
  151. package/dist/utils/utils/useTabsAccessibility.js +316 -0
  152. package/dist/utils/utils/useTextAreaAccessibility.js +303 -0
  153. package/dist/utils/utils/useTextInputAccessibility.js +338 -0
  154. package/dist/utils/utils/useTypographyAccessibility.js +180 -0
  155. package/dist/utils/utils/useWindowSize.js +26 -0
  156. package/dist/utils/utils/validation.js +131 -0
  157. package/dist/utils/validation.js +139 -0
  158. package/package.json +90 -0
@@ -0,0 +1,305 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Checkbox = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _propTypes = require("prop-types");
9
+ var _Label = require("./Label");
10
+ var _Error = require("./Error");
11
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
12
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); } /*eslint-disable no-unused-vars*/ // components
13
+ /**
14
+ * Checkbox Component
15
+ *
16
+ * A fully accessible, modern checkbox component following WCAG 2.1 AA guidelines.
17
+ * Features keyboard navigation, screen reader support, and proper form integration.
18
+ *
19
+ * This is a stateless component - state management should be handled externally.
20
+ *
21
+ * @component
22
+ * @example
23
+ * <Checkbox
24
+ * id="agreement"
25
+ * name="agreement"
26
+ * checked={agreed}
27
+ * onChange={handleAgreementChange}
28
+ * required
29
+ * >
30
+ * I agree to the terms and conditions
31
+ * </Checkbox>
32
+ */
33
+ const Checkbox = exports.Checkbox = /*#__PURE__*/(0, _react.forwardRef)(({
34
+ // Core props
35
+ id,
36
+ name,
37
+ checked = false,
38
+ onChange,
39
+ onFocus,
40
+ onBlur,
41
+ // Content props
42
+ children,
43
+ label,
44
+ // Validation props
45
+ required = false,
46
+ disabled = false,
47
+ error = false,
48
+ errorText = '',
49
+ // Layout props
50
+ className = '',
51
+ variant = 'default',
52
+ size = 'medium',
53
+ // Accessibility props
54
+ 'aria-label': ariaLabel,
55
+ 'aria-labelledby': ariaLabelledby,
56
+ 'aria-describedby': ariaDescribedby,
57
+ 'aria-invalid': ariaInvalid,
58
+ // Legacy props (for backward compatibility - internal use only)
59
+ componentName = 'checkbox',
60
+ additionalClassName = '',
61
+ labelText = '',
62
+ noLabel = false,
63
+ setName,
64
+ handleChecked,
65
+ setField,
66
+ ...restProps
67
+ }, ref) => {
68
+ // Handle legacy prop mapping
69
+ const finalId = id || setName || `checkbox-${Math.random().toString(36).substr(2, 9)}`;
70
+ const finalName = name || setName || finalId;
71
+ const finalLabel = children || label || labelText;
72
+ const finalOnChange = onChange || handleChecked;
73
+ const finalClassName = className || additionalClassName;
74
+ const showLabel = !noLabel && finalLabel;
75
+
76
+ // Generate unique IDs for accessibility
77
+ const checkboxId = finalId;
78
+ const errorId = `${checkboxId}-error`;
79
+
80
+ // Build aria-describedby
81
+ const describedByIds = [];
82
+ if (ariaDescribedby) describedByIds.push(ariaDescribedby);
83
+ if (error && errorText) describedByIds.push(errorId);
84
+ const finalAriaDescribedby = describedByIds.length > 0 ? describedByIds.join(' ') : undefined;
85
+
86
+ // Determine aria-invalid
87
+ const finalAriaInvalid = ariaInvalid || (error ? 'true' : undefined);
88
+
89
+ // Build CSS classes
90
+ const wrapperClasses = [`${componentName}-wrapper`, finalClassName, `${componentName}-wrapper--${variant}`, `${componentName}-wrapper--${size}`, error && `${componentName}-wrapper--error`, disabled && `${componentName}-wrapper--disabled`].filter(Boolean).join(' ');
91
+ const checkboxClasses = [componentName, `${componentName}--${variant}`, `${componentName}--${size}`, error && `${componentName}--error`, disabled && `${componentName}--disabled`].filter(Boolean).join(' ');
92
+ return /*#__PURE__*/_react.default.createElement("div", {
93
+ className: wrapperClasses,
94
+ "data-testid": `${componentName}-wrapper`
95
+ }, showLabel ? /*#__PURE__*/_react.default.createElement(_Label.Label, {
96
+ htmlFor: checkboxId,
97
+ required: false // Prevent Label from rendering its own required indicator
98
+ ,
99
+ className: `${componentName}__label`
100
+ }, /*#__PURE__*/_react.default.createElement("input", _extends({
101
+ ref: ref,
102
+ id: checkboxId,
103
+ name: finalName,
104
+ type: "checkbox",
105
+ checked: checked,
106
+ onChange: finalOnChange,
107
+ onFocus: onFocus,
108
+ onBlur: onBlur,
109
+ className: checkboxClasses,
110
+ disabled: disabled,
111
+ "data-testid": `${componentName}-input`
112
+ // Accessibility attributes
113
+ ,
114
+ "aria-label": !showLabel ? ariaLabel : undefined,
115
+ "aria-labelledby": !showLabel ? ariaLabelledby : undefined,
116
+ "aria-describedby": finalAriaDescribedby,
117
+ "aria-invalid": finalAriaInvalid,
118
+ "aria-required": required || undefined
119
+ }, restProps)), /*#__PURE__*/_react.default.createElement("span", {
120
+ className: "custom-checkbox"
121
+ }), /*#__PURE__*/_react.default.createElement("span", {
122
+ className: "label-text"
123
+ }, finalLabel, required && /*#__PURE__*/_react.default.createElement("span", {
124
+ className: "required",
125
+ "aria-label": "required"
126
+ }, "*"))) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("input", _extends({
127
+ ref: ref,
128
+ id: checkboxId,
129
+ name: finalName,
130
+ type: "checkbox",
131
+ checked: checked,
132
+ onChange: finalOnChange,
133
+ onFocus: onFocus,
134
+ onBlur: onBlur,
135
+ className: checkboxClasses,
136
+ disabled: disabled,
137
+ "data-testid": `${componentName}-input`
138
+ // Accessibility attributes
139
+ ,
140
+ "aria-label": ariaLabel,
141
+ "aria-labelledby": ariaLabelledby,
142
+ "aria-describedby": finalAriaDescribedby,
143
+ "aria-invalid": finalAriaInvalid,
144
+ "aria-required": required || undefined
145
+ }, restProps)), /*#__PURE__*/_react.default.createElement("span", {
146
+ className: "custom-checkbox"
147
+ })), error && errorText && /*#__PURE__*/_react.default.createElement(_Error.Error, {
148
+ id: errorId,
149
+ className: `${componentName}__error`,
150
+ role: "alert",
151
+ "aria-live": "polite"
152
+ }, errorText));
153
+ });
154
+
155
+ // Set display name for debugging
156
+ Checkbox.displayName = 'Checkbox';
157
+ Checkbox.propTypes = {
158
+ // ====================
159
+ // Core Props
160
+ // ====================
161
+
162
+ /**
163
+ * Unique identifier for the checkbox
164
+ */
165
+ id: _propTypes.string,
166
+ /**
167
+ * Additional CSS classes to apply to the component
168
+ */
169
+ className: _propTypes.string,
170
+ /**
171
+ * Name attribute for the checkbox (used for form submission)
172
+ */
173
+ name: _propTypes.string,
174
+ // ====================
175
+ // Content Props
176
+ // ====================
177
+
178
+ /**
179
+ * Label content (can be string or JSX)
180
+ */
181
+ children: _propTypes.node,
182
+ /**
183
+ * Alternative label prop
184
+ */
185
+ label: _propTypes.string,
186
+ // ====================
187
+ // Appearance Props
188
+ // ====================
189
+
190
+ /**
191
+ * Visual style variant
192
+ * @default 'default'
193
+ */
194
+ variant: _propTypes.string,
195
+ /**
196
+ * Size of the checkbox
197
+ * @default 'medium'
198
+ */
199
+ size: _propTypes.string,
200
+ // ====================
201
+ // Behavior Props
202
+ // ====================
203
+
204
+ /**
205
+ * Whether the checkbox is checked
206
+ */
207
+ checked: _propTypes.bool,
208
+ /**
209
+ * Whether the checkbox is required
210
+ * @default false
211
+ */
212
+ required: _propTypes.bool,
213
+ /**
214
+ * Whether the checkbox is disabled
215
+ * @default false
216
+ */
217
+ disabled: _propTypes.bool,
218
+ // ====================
219
+ // Validation Props
220
+ // ====================
221
+
222
+ /**
223
+ * Whether the field has an error
224
+ * @default false
225
+ */
226
+ error: _propTypes.bool,
227
+ /**
228
+ * Error message to display when error is true
229
+ */
230
+ errorText: _propTypes.string,
231
+ // ====================
232
+ // Event Props
233
+ // ====================
234
+
235
+ /**
236
+ * Change handler function - called when checkbox is toggled
237
+ * @param {Event} event - The change event
238
+ */
239
+ onChange: _propTypes.func.isRequired,
240
+ /**
241
+ * Focus handler function
242
+ * @param {Event} event - The focus event
243
+ */
244
+ onFocus: _propTypes.func,
245
+ /**
246
+ * Blur handler function
247
+ * @param {Event} event - The blur event
248
+ */
249
+ onBlur: _propTypes.func,
250
+ // ====================
251
+ // Accessibility Props
252
+ // ====================
253
+
254
+ /**
255
+ * Accessible label (alternative to children/label prop)
256
+ */
257
+ 'aria-label': _propTypes.string,
258
+ /**
259
+ * ID of element that labels this checkbox
260
+ */
261
+ 'aria-labelledby': _propTypes.string,
262
+ /**
263
+ * ID(s) of elements that describe this checkbox
264
+ */
265
+ 'aria-describedby': _propTypes.string,
266
+ /**
267
+ * Whether the checkbox value is invalid
268
+ */
269
+ 'aria-invalid': _propTypes.string,
270
+ /**
271
+ * Use `className` instead
272
+ * Additional CSS classes
273
+ */
274
+ additionalClassName: _propTypes.string,
275
+ /**
276
+ * Use `children` or `label` instead
277
+ * Label text content
278
+ */
279
+ labelText: _propTypes.string,
280
+ /**
281
+ * Use external label management instead
282
+ * Whether to hide the label
283
+ */
284
+ noLabel: _propTypes.bool,
285
+ /**
286
+ * Use `id` and `name` instead
287
+ * Legacy name prop
288
+ */
289
+ setName: _propTypes.string,
290
+ /**
291
+ * Use `onChange` instead
292
+ * Legacy change handler
293
+ */
294
+ handleChecked: _propTypes.func,
295
+ /**
296
+ * Internal prop for field handling
297
+ * Legacy field setter
298
+ */
299
+ setField: _propTypes.func,
300
+ /**
301
+ * Internal prop for CSS class generation
302
+ * Base component name for CSS classes
303
+ */
304
+ componentName: _propTypes.string
305
+ };