@adobe-commerce/aio-experience-kit 1.0.0 → 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 (51) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +284 -19
  3. package/dist/cjs/components/DataForm/FieldBuilder/index.js +180 -35
  4. package/dist/cjs/components/DataForm/FieldBuilder/index.js.map +1 -1
  5. package/dist/cjs/components/DataForm/FormBuilder/index.js +9 -7
  6. package/dist/cjs/components/DataForm/FormBuilder/index.js.map +1 -1
  7. package/dist/cjs/components/DataForm/FormBuilder/types.js +2 -0
  8. package/dist/cjs/components/DataForm/FormBuilder/types.js.map +1 -1
  9. package/dist/cjs/components/DataForm/index.js +4 -1
  10. package/dist/cjs/components/DataForm/index.js.map +1 -1
  11. package/dist/cjs/components/DataTable/index.js +4 -1
  12. package/dist/cjs/components/DataTable/index.js.map +1 -1
  13. package/dist/cjs/components/ShippingCarrierForm/index.js +137 -0
  14. package/dist/cjs/components/ShippingCarrierForm/index.js.map +1 -0
  15. package/dist/cjs/index.js +6 -4
  16. package/dist/cjs/index.js.map +1 -1
  17. package/dist/cjs/utils/AdminUiSdk/index.js +171 -66
  18. package/dist/cjs/utils/AdminUiSdk/index.js.map +1 -1
  19. package/dist/esm/components/DataForm/FieldBuilder/index.js +181 -36
  20. package/dist/esm/components/DataForm/FieldBuilder/index.js.map +1 -1
  21. package/dist/esm/components/DataForm/FormBuilder/index.js +9 -7
  22. package/dist/esm/components/DataForm/FormBuilder/index.js.map +1 -1
  23. package/dist/esm/components/DataForm/FormBuilder/types.js +2 -0
  24. package/dist/esm/components/DataForm/FormBuilder/types.js.map +1 -1
  25. package/dist/esm/components/DataForm/index.js +5 -2
  26. package/dist/esm/components/DataForm/index.js.map +1 -1
  27. package/dist/esm/components/DataTable/index.js +5 -2
  28. package/dist/esm/components/DataTable/index.js.map +1 -1
  29. package/dist/esm/components/ShippingCarrierForm/index.js +133 -0
  30. package/dist/esm/components/ShippingCarrierForm/index.js.map +1 -0
  31. package/dist/esm/index.js +1 -0
  32. package/dist/esm/index.js.map +1 -1
  33. package/dist/esm/types/components/DataForm/FieldBuilder/index.d.ts.map +1 -1
  34. package/dist/esm/types/components/DataForm/FormBuilder/index.d.ts.map +1 -1
  35. package/dist/esm/types/components/DataForm/FormBuilder/types.d.ts +2 -0
  36. package/dist/esm/types/components/DataForm/FormBuilder/types.d.ts.map +1 -1
  37. package/dist/esm/types/components/DataForm/index.d.ts.map +1 -1
  38. package/dist/esm/types/components/DataTable/index.d.ts.map +1 -1
  39. package/dist/esm/types/components/ShippingCarrierForm/index.d.ts +12 -0
  40. package/dist/esm/types/components/ShippingCarrierForm/index.d.ts.map +1 -0
  41. package/dist/esm/types/components/ShippingCarrierForm/types.d.ts +50 -0
  42. package/dist/esm/types/components/ShippingCarrierForm/types.d.ts.map +1 -0
  43. package/dist/esm/types/components/index.d.ts +2 -0
  44. package/dist/esm/types/components/index.d.ts.map +1 -1
  45. package/dist/esm/types/utils/AdminUiSdk/index.d.ts +48 -22
  46. package/dist/esm/types/utils/AdminUiSdk/index.d.ts.map +1 -1
  47. package/dist/esm/types/utils/AdminUiSdk/types.d.ts +28 -23
  48. package/dist/esm/types/utils/AdminUiSdk/types.d.ts.map +1 -1
  49. package/dist/esm/utils/AdminUiSdk/index.js +172 -67
  50. package/dist/esm/utils/AdminUiSdk/index.js.map +1 -1
  51. package/package.json +36 -35
package/CHANGELOG.md CHANGED
@@ -5,6 +5,47 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.0.1] - 2025-10-14
9
+
10
+ ### ✨ Added
11
+
12
+ - **[ShippingCarrierForm](./src/components/ShippingCarrierForm/index.tsx)** - New specialized form component for shipping carrier configuration
13
+ - Pre-configured fields for common shipping carrier attributes (code, title, active status)
14
+ - Multi-select support for stores and countries with scrollable option lists
15
+ - Toggle fields for tracking and shipping labels availability
16
+ - Built on top of DataForm with consistent validation and user experience
17
+ - Async-friendly API with loading states and lifecycle callbacks
18
+ - Type-safe props with comprehensive TypeScript interfaces
19
+
20
+ ### 🐛 Fixed
21
+
22
+ - **FormBuilder**: Resolved race condition when handling multiple toggle fields simultaneously
23
+ - **ESLint**: Resolved React hooks linting warnings across components
24
+
25
+ ### 🔧 Changed
26
+
27
+ - **[DataForm](./src/components/DataForm/index.tsx)** - Enhanced with new field types for richer form capabilities
28
+ - Added MULTISELECT field type with React Spectrum CheckboxGroup implementation
29
+ - Added TOGGLE field type with React Spectrum Switch component
30
+ - Array value handling for MULTISELECT with proper storage and retrieval
31
+ - Automatic '1'/'0' value handling for TOGGLE fields with backend compatibility
32
+ - Scrollable containers for multi-select options with automatic overflow handling
33
+ - Enhanced styling with proper spacing and visual hierarchy for new field types
34
+ - Full accessibility support with keyboard navigation for all field types
35
+ - Environment variable mode support for TOGGLE fields
36
+
37
+ - **[AdminUiSdk](./src/utils/AdminUiSdk/index.ts)** - Refactored to use registration-based approach for improved flexibility
38
+ - **ESLint**: Migrated to ESLint 9 flat config format for modern JavaScript tooling
39
+ - **FieldBuilder**: Improved import formatting and code spacing for better readability
40
+
41
+ ### 📚 Documentation
42
+
43
+ - Added comprehensive documentation for MULTISELECT and TOGGLE field types
44
+ - Updated README with ShippingCarrierForm component usage examples
45
+ - Enhanced field type documentation with code examples and use cases
46
+
47
+ ---
48
+
8
49
  ## [1.0.0] - 2024-12-19
9
50
 
10
51
  ### 🎉 Initial Release
package/README.md CHANGED
@@ -287,6 +287,46 @@ class EntityModel {
287
287
  label: 'Disabled'
288
288
  }
289
289
  ]
290
+ },
291
+ {
292
+ label: 'Categories',
293
+ code: 'categories',
294
+ db_field: 'categories',
295
+ type: FieldType.MULTISELECT,
296
+ required: false,
297
+ options: [
298
+ {
299
+ value: 'electronics',
300
+ label: 'Electronics'
301
+ },
302
+ {
303
+ value: 'clothing',
304
+ label: 'Clothing'
305
+ },
306
+ {
307
+ value: 'books',
308
+ label: 'Books'
309
+ },
310
+ {
311
+ value: 'home',
312
+ label: 'Home & Garden'
313
+ }
314
+ ]
315
+ },
316
+ {
317
+ label: 'Featured Product',
318
+ code: 'featured',
319
+ db_field: 'featured',
320
+ type: FieldType.TOGGLE,
321
+ required: false
322
+ },
323
+ {
324
+ label: 'Notifications',
325
+ code: 'notifications',
326
+ db_field: 'notifications',
327
+ type: FieldType.TOGGLE,
328
+ required: false,
329
+ use_env_var: true
290
330
  }
291
331
  ]
292
332
  }
@@ -296,9 +336,74 @@ class EntityModel {
296
336
  }
297
337
  ```
298
338
 
339
+ ##### Field Types
340
+
341
+ The DataForm component supports various field types for different input scenarios:
342
+
343
+ **Basic Input Fields:**
344
+ - `FieldType.TEXT` - Standard text input
345
+ - `FieldType.EMAIL` - Email input with validation
346
+ - `FieldType.PASSWORD` - Password input with masking
347
+ - `FieldType.NUMBER` - Numeric input with validation
348
+ - `FieldType.URL` - URL input with validation
349
+ - `FieldType.TEL` - Telephone number input
350
+ - `FieldType.SEARCH` - Search input with appropriate styling
351
+
352
+ **Selection Fields:**
353
+ - `FieldType.SELECT` - Single selection dropdown with options
354
+ - `FieldType.MULTISELECT` - Multiple selection with checkboxes in a scrollable container
355
+ - `FieldType.TOGGLE` - Boolean toggle switch with '1'/'0' values
356
+
357
+ **Display Fields:**
358
+ - `FieldType.LABEL` - Read-only display field for showing values
359
+
360
+ **Field Configuration Examples:**
361
+
362
+ ```javascript
363
+ // MULTISELECT field with scrollable options
364
+ {
365
+ label: 'Product Categories',
366
+ code: 'categories',
367
+ db_field: 'categories',
368
+ type: FieldType.MULTISELECT,
369
+ required: false,
370
+ options: [
371
+ { value: 'electronics', label: 'Electronics' },
372
+ { value: 'clothing', label: 'Clothing' },
373
+ { value: 'books', label: 'Books' },
374
+ { value: 'home', label: 'Home & Garden' },
375
+ // ... more options (automatically scrollable when many)
376
+ ]
377
+ }
378
+
379
+ // TOGGLE field with automatic default value
380
+ {
381
+ label: 'Enable Feature',
382
+ code: 'feature_enabled',
383
+ db_field: 'feature_enabled',
384
+ type: FieldType.TOGGLE,
385
+ required: false
386
+ // Automatically defaults to '0' if no value provided
387
+ // Returns '1' when enabled, '0' when disabled
388
+ }
389
+
390
+ // Field with environment variable support
391
+ {
392
+ label: 'API Endpoint',
393
+ code: 'api_endpoint',
394
+ db_field: 'api_endpoint',
395
+ type: FieldType.TEXT,
396
+ required: true,
397
+ use_env_var: true // Adds checkbox to use as environment variable
398
+ }
399
+ ```
400
+
299
401
  **Features:**
300
402
  - **Dynamic Form Generation**: Create complex forms from simple configuration objects without manual field creation
301
- - **Rich Field Types**: Support for text, email, password, number, select, and specialized input types
403
+ - **Rich Field Types**: Support for text, email, password, number, select, multiselect, toggle, and specialized input types
404
+ - **Multi-Selection Support**: MULTISELECT field type with React Spectrum CheckboxGroup for selecting multiple options with scrollable overflow and accessibility support
405
+ - **Toggle Controls**: TOGGLE field type using React Spectrum Switch component with '1'/'0' value handling and automatic default value initialization
406
+ - **Environment Variable Support**: Built-in support for environment variable checkboxes on compatible field types (TEXT, SELECT, MULTISELECT, TOGGLE)
302
407
  - **Intelligent Validation**: Built-in validation with custom rules, real-time feedback, and error messaging
303
408
  - **Workflow Integration**: Loading states, processing indicators, and navigation controls for multi-step workflows
304
409
  - **Organized Layout**: Logical field grouping with collapsible sections and intuitive information hierarchy
@@ -386,42 +491,197 @@ class EntityModel {
386
491
  - **Accessibility Excellence**: Full screen reader support, proper ARIA labels, and focus trap implementation
387
492
  - **Design Consistency**: Follows Adobe Spectrum design patterns for familiar user interactions
388
493
 
494
+ #### `ShippingCarrierForm`
495
+
496
+ A specialized form component pre-configured for shipping carrier management. Built on top of DataForm, it provides a ready-to-use form with all the necessary fields for shipping carrier configuration.
497
+
498
+ ```javascript
499
+ import React, { useState } from 'react';
500
+ import { ShippingCarrierForm, useRouteParams } from '@adobe-commerce/aio-experience-kit';
501
+ import { ToastQueue } from '@react-spectrum/toast';
502
+
503
+ const CarrierForm = ({ actionCallHeaders, id = undefined }) => {
504
+ const { getNavigate } = useRouteParams();
505
+ const navigate = getNavigate();
506
+ const [isLoading, setLoading] = useState(false);
507
+ const [carrierData, setCarrierData] = useState({});
508
+
509
+ const carrierModel = new CarrierModel(actionCallHeaders);
510
+
511
+ const storeOptions = [
512
+ { value: '1', label: 'Main Store' },
513
+ { value: '2', label: 'EU Store' },
514
+ { value: '3', label: 'Asia Store' }
515
+ ];
516
+
517
+ const countryOptions = [
518
+ { value: 'US', label: 'United States' },
519
+ { value: 'CA', label: 'Canada' },
520
+ { value: 'GB', label: 'United Kingdom' },
521
+ { value: 'DE', label: 'Germany' },
522
+ { value: 'FR', label: 'France' }
523
+ ];
524
+
525
+ return (
526
+ <ShippingCarrierForm
527
+ countryOptions={countryOptions}
528
+ storeOptions={storeOptions}
529
+ defaults={carrierData}
530
+ isLoading={isLoading}
531
+ onFormSubmit={async (values) => {
532
+ try {
533
+ await carrierModel.save(values);
534
+ ToastQueue.positive('Carrier saved successfully', { timeout: 5000 });
535
+ } catch (e) {
536
+ ToastQueue.negative(e.message, { timeout: 5000 });
537
+ }
538
+ }}
539
+ onPostFormSubmit={async () => {
540
+ navigate('/carrier/grid');
541
+ }}
542
+ onBackPress={() => {
543
+ navigate('/carrier/grid');
544
+ }}
545
+ />
546
+ );
547
+ };
548
+
549
+ // Carrier Model
550
+ class CarrierModel {
551
+ constructor(actionCallHeaders) {
552
+ this.actionCallHeaders = actionCallHeaders;
553
+ }
554
+
555
+ async save(formValues) {
556
+ // Save carrier using API
557
+ return {};
558
+ }
559
+ }
560
+ ```
561
+
562
+ **Pre-configured Fields:**
563
+
564
+ The component includes the following built-in fields:
565
+ - **Active** (TOGGLE) - Enable/disable the shipping carrier
566
+ - **Code** (TEXT) - Unique identifier for the carrier
567
+ - **Title** (TEXT) - Display name of the carrier
568
+ - **Stores** (MULTISELECT) - Select which stores the carrier is available for
569
+ - **Countries** (MULTISELECT) - Select which countries the carrier ships to
570
+ - **Sort Order** (NUMBER) - Display order in the shipping methods list
571
+ - **Is Tracking Available?** (TOGGLE) - Whether tracking is supported
572
+ - **Is Shipping Labels Available?** (TOGGLE) - Whether shipping label generation is supported
573
+
574
+ **Features:**
575
+ - **Ready-to-Use**: Pre-configured form eliminates boilerplate code for common shipping carrier scenarios
576
+ - **Flexible Options**: Pass custom store and country options based on your store configuration
577
+ - **Data Persistence**: Support for loading existing carrier data via `defaults` prop
578
+ - **Loading States**: Built-in loading indicator while fetching carrier data
579
+ - **Type Safety**: Full TypeScript support with `ShippingCarrierFormProps` and `SelectOption` types
580
+ - **Workflow Integration**: Lifecycle callbacks for form submission, navigation, and error handling
581
+ - **Consistent UX**: Leverages DataForm for validation, error messaging, and user experience
582
+
389
583
  ### 🔧 Utils
390
584
 
391
585
  Utility functions and classes that simplify common tasks in Adobe Commerce extension development.
392
586
 
393
587
  #### `AdminUiSdk`
394
588
 
395
- A comprehensive utility class for registering Adobe Admin UI extensions with the Adobe UIX registry, managing menu items and page configurations.
589
+ A comprehensive utility class for registering Adobe Admin UI extensions with the Adobe UIX registry, managing menu items, page configurations, and credentials.
590
+
591
+ ##### Building Registration Configuration
592
+
593
+ Create menu structure and page configuration for your extension:
396
594
 
397
595
  ```typescript
398
596
  import { AdminUiSdk } from '@adobe-commerce/aio-experience-kit';
399
597
 
400
- // Initialize the SDK
401
- const extensionId = 'my_admin_extension';
402
- const sdk = new AdminUiSdk(extensionId);
598
+ // Initialize the SDK with your extension ID
599
+ const sdk = new AdminUiSdk('my_admin_extension');
600
+
601
+ // Add a menu section (appears as a parent menu)
602
+ sdk.addMenuSection('products', 'Product Management', 100);
403
603
 
404
- // Add menu items
405
- sdk.addMenu({
406
- id: `${extensionId}::products`,
407
- title: 'Product Manager',
408
- parent: 'Magento_Catalog::catalog',
409
- sortOrder: 10
410
- });
604
+ // Add menu items under the section
605
+ sdk.addMenuItem('product_list', 'Product List', 1, 'products');
411
606
 
412
- // Set page title
607
+ // Set the page title for your extension
413
608
  sdk.addPage('Product Management Dashboard');
414
609
 
415
- // Register with Adobe UIX
416
- await sdk.register();
610
+ // Get the complete registration configuration
611
+ const registration = sdk.getRegistration();
612
+ console.log(registration);
613
+ // Output: {
614
+ // registration: {
615
+ // menuItems: [
616
+ // {
617
+ // id: 'my_admin_extension::products',
618
+ // title: 'Product Management',
619
+ // sortOrder: 100,
620
+ // isSection: true
621
+ // },
622
+ // {
623
+ // id: 'my_admin_extension::product_list',
624
+ // title: 'Product List',
625
+ // parent: 'my_admin_extension::products',
626
+ // sortOrder: 1
627
+ // },
628
+ // page: {
629
+ // title: 'Product Management Dashboard'
630
+ // }
631
+ // }
632
+ // }
633
+ ```
634
+
635
+ ##### Registering Your Extension
636
+
637
+ Register your extension with Adobe UIX platform:
638
+
639
+ ```typescript
640
+ import { AdminUiSdk } from '@adobe-commerce/aio-experience-kit';
641
+
642
+ try {
643
+ const sdk = new AdminUiSdk('my_admin_extension');
644
+ // Register the extension with Adobe UIX
645
+ await sdk.registerExtension();
646
+ } catch (error) {
647
+ console.error('Registration failed:', error.message);
648
+ }
649
+ ```
650
+
651
+ ##### Getting Adobe IMS Credentials
652
+
653
+ Retrieve authentication credentials from the Adobe shared context:
654
+
655
+ ```typescript
656
+ import { AdminUiSdk } from '@adobe-commerce/aio-experience-kit';
657
+
658
+ try {
659
+ const sdk = new AdminUiSdk('my_admin_extension');
660
+
661
+ const credentials = await sdk.getCredentials();
662
+
663
+ if (credentials.imsToken && credentials.imsOrgId) {
664
+ // Use credentials for API calls
665
+ const apiHeaders = {
666
+ 'Authorization': `Bearer ${credentials.imsToken}`,
667
+ 'x-gw-ims-org-id': credentials.imsOrgId
668
+ };
669
+
670
+ // Make authenticated API requests
671
+ } else {
672
+ console.log('Credentials not available');
673
+ }
674
+ } catch (error) {
675
+ console.error('Failed to get credentials:', error.message);
676
+ }
417
677
  ```
418
678
 
419
679
  **Features:**
420
- - **Menu Management**: Add and organize menu items with validation, duplicate prevention, and proper hierarchy
421
- - **Page Configuration**: Set custom page titles for extension interfaces with automatic registration
680
+ - **Flexible Menu Management**: Create menu sections and items with automatic ID prefixing and validation
681
+ - **Optional Configuration**: Registration works with any combination of menu items and page configuration
682
+ - **Credential Management**: Secure access to Adobe IMS authentication tokens and organization IDs
422
683
  - **Adobe UIX Integration**: Seamless registration with Adobe's extensibility platform using official APIs
423
- - **Input Validation**: Built-in sanitization, trimming, and validation for all configuration parameters
424
- - **Error Prevention**: Comprehensive error handling with meaningful messages for invalid configurations
684
+ - **Input Validation**: Strict ID validation (alphanumeric + underscores only) and comprehensive error handling
425
685
  - **Type Safety**: Full TypeScript support with intelligent code completion and compile-time validation
426
686
  - **Production Ready**: Battle-tested utility used in real Adobe Commerce extensions with robust error handling
427
687
 
@@ -469,7 +729,12 @@ import type {
469
729
  DataTableProps,
470
730
  DataFormProps,
471
731
  ConfirmationDialogProps,
732
+ ShippingCarrierFormProps,
733
+ SelectOption,
734
+ FieldType,
472
735
  AdminUiSdkInterface,
736
+ AdminUiSdkCredentials,
737
+ AdminUiSdkRegistration,
473
738
  MenuItem
474
739
  } from '@adobe-commerce/aio-experience-kit';
475
740
  ```