@ayasofyazilim/ui 0.0.0 → 0.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.
- package/dist/aria/index.js +2 -0
- package/dist/aria/index.js.map +1 -0
- package/dist/aria/number-field.js +46 -0
- package/dist/aria/number-field.js.map +1 -0
- package/dist/components/accordion.js +66 -0
- package/dist/components/accordion.js.map +1 -0
- package/dist/components/alert-dialog.js +148 -0
- package/dist/components/alert-dialog.js.map +1 -0
- package/dist/components/alert.js +69 -0
- package/dist/components/alert.js.map +1 -0
- package/dist/components/aspect-ratio.js +12 -0
- package/dist/components/aspect-ratio.js.map +1 -0
- package/dist/components/avatar.js +55 -0
- package/dist/components/avatar.js.map +1 -0
- package/dist/components/badge.js +62 -0
- package/dist/components/badge.js.map +1 -0
- package/dist/components/breadcrumb.js +104 -0
- package/dist/components/breadcrumb.js.map +1 -0
- package/dist/components/button-group.js +77 -0
- package/dist/components/button-group.js.map +1 -0
- package/dist/components/button.js +56 -0
- package/dist/components/button.js.map +1 -0
- package/dist/components/calendar.js +196 -0
- package/dist/components/calendar.js.map +1 -0
- package/dist/components/card.js +91 -0
- package/dist/components/card.js.map +1 -0
- package/dist/components/carousel.js +200 -0
- package/dist/components/carousel.js.map +1 -0
- package/dist/components/chart.js +250 -0
- package/dist/components/chart.js.map +1 -0
- package/dist/components/checkbox.js +33 -0
- package/dist/components/checkbox.js.map +1 -0
- package/dist/components/collapsible.js +36 -0
- package/dist/components/collapsible.js.map +1 -0
- package/dist/components/command.js +178 -0
- package/dist/components/command.js.map +1 -0
- package/dist/components/context-menu.js +225 -0
- package/dist/components/context-menu.js.map +1 -0
- package/dist/components/dialog.js +139 -0
- package/dist/components/dialog.js.map +1 -0
- package/dist/components/drawer.js +130 -0
- package/dist/components/drawer.js.map +1 -0
- package/dist/components/dropdown-menu.js +234 -0
- package/dist/components/dropdown-menu.js.map +1 -0
- package/dist/components/empty.js +100 -0
- package/dist/components/empty.js.map +1 -0
- package/dist/components/field.js +231 -0
- package/dist/components/field.js.map +1 -0
- package/dist/components/form.js +124 -0
- package/dist/components/form.js.map +1 -0
- package/dist/components/hover-card.js +40 -0
- package/dist/components/hover-card.js.map +1 -0
- package/dist/components/input-group.js +156 -0
- package/dist/components/input-group.js.map +1 -0
- package/dist/components/input-otp.js +68 -0
- package/dist/components/input-otp.js.map +1 -0
- package/dist/components/input.js +22 -0
- package/dist/components/input.js.map +1 -0
- package/dist/components/item.js +188 -0
- package/dist/components/item.js.map +1 -0
- package/dist/components/kbd.js +32 -0
- package/dist/components/kbd.js.map +1 -0
- package/dist/components/label.js +24 -0
- package/dist/components/label.js.map +1 -0
- package/dist/components/menubar.js +253 -0
- package/dist/components/menubar.js.map +1 -0
- package/dist/components/navigation-menu.js +171 -0
- package/dist/components/navigation-menu.js.map +1 -0
- package/dist/components/pagination.js +125 -0
- package/dist/components/pagination.js.map +1 -0
- package/dist/components/popover.js +82 -0
- package/dist/components/popover.js.map +1 -0
- package/dist/components/progress.js +33 -0
- package/dist/components/progress.js.map +1 -0
- package/dist/components/radio-group.js +47 -0
- package/dist/components/radio-group.js.map +1 -0
- package/dist/components/resizable.js +50 -0
- package/dist/components/resizable.js.map +1 -0
- package/dist/components/scroll-area.js +62 -0
- package/dist/components/scroll-area.js.map +1 -0
- package/dist/components/select.js +173 -0
- package/dist/components/select.js.map +1 -0
- package/dist/components/separator.js +28 -0
- package/dist/components/separator.js.map +1 -0
- package/dist/components/sheet.js +129 -0
- package/dist/components/sheet.js.map +1 -0
- package/dist/components/sidebar.js +759 -0
- package/dist/components/sidebar.js.map +1 -0
- package/dist/components/skeleton.js +16 -0
- package/dist/components/skeleton.js.map +1 -0
- package/dist/components/slider.js +65 -0
- package/dist/components/slider.js.map +1 -0
- package/dist/components/sonner.js +40 -0
- package/dist/components/sonner.js.map +1 -0
- package/dist/components/spinner.js +18 -0
- package/dist/components/spinner.js.map +1 -0
- package/dist/components/stepper.js +220 -0
- package/dist/components/stepper.js.map +1 -0
- package/dist/components/switch.js +33 -0
- package/dist/components/switch.js.map +1 -0
- package/dist/components/table.js +131 -0
- package/dist/components/table.js.map +1 -0
- package/dist/components/tabs.js +69 -0
- package/dist/components/tabs.js.map +1 -0
- package/dist/components/textarea.js +19 -0
- package/dist/components/textarea.js.map +1 -0
- package/dist/components/toggle-group.js +70 -0
- package/dist/components/toggle-group.js.map +1 -0
- package/dist/components/toggle.js +45 -0
- package/dist/components/toggle.js.map +1 -0
- package/dist/components/tooltip.js +65 -0
- package/dist/components/tooltip.js.map +1 -0
- package/dist/custom/action-button.js +38 -0
- package/dist/custom/action-button.js.map +1 -0
- package/dist/custom/async-select.js +249 -0
- package/dist/custom/async-select.js.map +1 -0
- package/dist/custom/awesome-not-found.js +113 -0
- package/dist/custom/awesome-not-found.js.map +1 -0
- package/dist/custom/charts/area-chart.js +125 -0
- package/dist/custom/charts/area-chart.js.map +1 -0
- package/dist/custom/charts/bar-chart.js +232 -0
- package/dist/custom/charts/bar-chart.js.map +1 -0
- package/dist/custom/charts/chart-card.js +71 -0
- package/dist/custom/charts/chart-card.js.map +1 -0
- package/dist/custom/charts/index.js +5 -0
- package/dist/custom/charts/index.js.map +1 -0
- package/dist/custom/charts/pie-chart.js +153 -0
- package/dist/custom/charts/pie-chart.js.map +1 -0
- package/dist/custom/charts/radar-chart.js +112 -0
- package/dist/custom/charts/radar-chart.js.map +1 -0
- package/dist/custom/checkbox-tree.js +70 -0
- package/dist/custom/checkbox-tree.js.map +1 -0
- package/dist/custom/combobox.js +233 -0
- package/dist/custom/combobox.js.map +1 -0
- package/dist/custom/confirm-dialog.js +90 -0
- package/dist/custom/confirm-dialog.js.map +1 -0
- package/dist/custom/country-selector.js +151 -0
- package/dist/custom/country-selector.js.map +1 -0
- package/dist/custom/date-picker/calendar-rac.js +91 -0
- package/dist/custom/date-picker/calendar-rac.js.map +1 -0
- package/dist/custom/date-picker/datefield-rac.js +77 -0
- package/dist/custom/date-picker/datefield-rac.js.map +1 -0
- package/dist/custom/date-picker/index.js +251 -0
- package/dist/custom/date-picker/index.js.map +1 -0
- package/dist/custom/date-picker/types/index.js +1 -0
- package/dist/custom/date-picker/types/index.js.map +1 -0
- package/dist/custom/date-picker/utils/index.js +30 -0
- package/dist/custom/date-picker/utils/index.js.map +1 -0
- package/dist/custom/date-picker-old.js +46 -0
- package/dist/custom/date-picker-old.js.map +1 -0
- package/dist/custom/date-tooltip.js +89 -0
- package/dist/custom/date-tooltip.js.map +1 -0
- package/dist/custom/document-scanner/consts.js +13 -0
- package/dist/custom/document-scanner/consts.js.map +1 -0
- package/dist/custom/document-scanner/corner-adjustment/action-buttons.js +24 -0
- package/dist/custom/document-scanner/corner-adjustment/action-buttons.js.map +1 -0
- package/dist/custom/document-scanner/corner-adjustment/corner-handle.js +44 -0
- package/dist/custom/document-scanner/corner-adjustment/corner-handle.js.map +1 -0
- package/dist/custom/document-scanner/corner-adjustment/hooks/use-corner-drag.js +60 -0
- package/dist/custom/document-scanner/corner-adjustment/hooks/use-corner-drag.js.map +1 -0
- package/dist/custom/document-scanner/corner-adjustment/index.js +124 -0
- package/dist/custom/document-scanner/corner-adjustment/index.js.map +1 -0
- package/dist/custom/document-scanner/corner-adjustment/types.js +1 -0
- package/dist/custom/document-scanner/corner-adjustment/types.js.map +1 -0
- package/dist/custom/document-scanner/corner-adjustment/utils/clip-path.js +16 -0
- package/dist/custom/document-scanner/corner-adjustment/utils/clip-path.js.map +1 -0
- package/dist/custom/document-scanner/corner-adjustment/zoom-magnifier.js +85 -0
- package/dist/custom/document-scanner/corner-adjustment/zoom-magnifier.js.map +1 -0
- package/dist/custom/document-scanner/hooks/use-document-capture.js +61 -0
- package/dist/custom/document-scanner/hooks/use-document-capture.js.map +1 -0
- package/dist/custom/document-scanner/hooks/use-document-scanner.js +59 -0
- package/dist/custom/document-scanner/hooks/use-document-scanner.js.map +1 -0
- package/dist/custom/document-scanner/hooks/use-perspective-crop.js +31 -0
- package/dist/custom/document-scanner/hooks/use-perspective-crop.js.map +1 -0
- package/dist/custom/document-scanner/index.js +229 -0
- package/dist/custom/document-scanner/index.js.map +1 -0
- package/dist/custom/document-scanner/lib.js +289 -0
- package/dist/custom/document-scanner/lib.js.map +1 -0
- package/dist/custom/document-scanner/types.js +1 -0
- package/dist/custom/document-scanner/types.js.map +1 -0
- package/dist/custom/document-scanner/utils/perspective-correction.js +100 -0
- package/dist/custom/document-scanner/utils/perspective-correction.js.map +1 -0
- package/dist/custom/document-viewer/controllers.js +76 -0
- package/dist/custom/document-viewer/controllers.js.map +1 -0
- package/dist/custom/document-viewer/index.js +36 -0
- package/dist/custom/document-viewer/index.js.map +1 -0
- package/dist/custom/document-viewer/renderers/image.js +40 -0
- package/dist/custom/document-viewer/renderers/image.js.map +1 -0
- package/dist/custom/document-viewer/renderers/index.js +3 -0
- package/dist/custom/document-viewer/renderers/index.js.map +1 -0
- package/dist/custom/document-viewer/renderers/pdf.js +95 -0
- package/dist/custom/document-viewer/renderers/pdf.js.map +1 -0
- package/dist/custom/email-input/email.js +184 -0
- package/dist/custom/email-input/email.js.map +1 -0
- package/dist/custom/email-input/index.js +8 -0
- package/dist/custom/email-input/index.js.map +1 -0
- package/dist/custom/email-input/types.js +13 -0
- package/dist/custom/email-input/types.js.map +1 -0
- package/dist/custom/file-uploader.js +389 -0
- package/dist/custom/file-uploader.js.map +1 -0
- package/dist/custom/filter-component/fields/async-select.js +31 -0
- package/dist/custom/filter-component/fields/async-select.js.map +1 -0
- package/dist/custom/filter-component/fields/date.js +56 -0
- package/dist/custom/filter-component/fields/date.js.map +1 -0
- package/dist/custom/filter-component/fields/multi-select.js +28 -0
- package/dist/custom/filter-component/fields/multi-select.js.map +1 -0
- package/dist/custom/filter-component/index.js +149 -0
- package/dist/custom/filter-component/index.js.map +1 -0
- package/dist/custom/image-canvas.js +193 -0
- package/dist/custom/image-canvas.js.map +1 -0
- package/dist/custom/json-editor.js +30 -0
- package/dist/custom/json-editor.js.map +1 -0
- package/dist/custom/master-data-grid/components/dialogs/column-settings-dialog.js +84 -0
- package/dist/custom/master-data-grid/components/dialogs/column-settings-dialog.js.map +1 -0
- package/dist/custom/master-data-grid/components/dialogs/index.js +5 -0
- package/dist/custom/master-data-grid/components/dialogs/index.js.map +1 -0
- package/dist/custom/master-data-grid/components/filters/client-filter.js +310 -0
- package/dist/custom/master-data-grid/components/filters/client-filter.js.map +1 -0
- package/dist/custom/master-data-grid/components/filters/filter-input.js +209 -0
- package/dist/custom/master-data-grid/components/filters/filter-input.js.map +1 -0
- package/dist/custom/master-data-grid/components/filters/index.js +9 -0
- package/dist/custom/master-data-grid/components/filters/index.js.map +1 -0
- package/dist/custom/master-data-grid/components/filters/inline-column-filter.js +188 -0
- package/dist/custom/master-data-grid/components/filters/inline-column-filter.js.map +1 -0
- package/dist/custom/master-data-grid/components/filters/multi-filter-dialog.js +65 -0
- package/dist/custom/master-data-grid/components/filters/multi-filter-dialog.js.map +1 -0
- package/dist/custom/master-data-grid/components/filters/server-filter.js +213 -0
- package/dist/custom/master-data-grid/components/filters/server-filter.js.map +1 -0
- package/dist/custom/master-data-grid/components/master-data-grid.js +421 -0
- package/dist/custom/master-data-grid/components/master-data-grid.js.map +1 -0
- package/dist/custom/master-data-grid/components/pagination/index.js +5 -0
- package/dist/custom/master-data-grid/components/pagination/index.js.map +1 -0
- package/dist/custom/master-data-grid/components/pagination/pagination.js +159 -0
- package/dist/custom/master-data-grid/components/pagination/pagination.js.map +1 -0
- package/dist/custom/master-data-grid/components/table/cell-renderer.js +442 -0
- package/dist/custom/master-data-grid/components/table/cell-renderer.js.map +1 -0
- package/dist/custom/master-data-grid/components/table/header-cell.js +116 -0
- package/dist/custom/master-data-grid/components/table/header-cell.js.map +1 -0
- package/dist/custom/master-data-grid/components/table/index.js +5 -0
- package/dist/custom/master-data-grid/components/table/index.js.map +1 -0
- package/dist/custom/master-data-grid/components/table/table-body-renderer.js +79 -0
- package/dist/custom/master-data-grid/components/table/table-body-renderer.js.map +1 -0
- package/dist/custom/master-data-grid/components/table/virtual-body.js +86 -0
- package/dist/custom/master-data-grid/components/table/virtual-body.js.map +1 -0
- package/dist/custom/master-data-grid/components/toolbar/index.js +5 -0
- package/dist/custom/master-data-grid/components/toolbar/index.js.map +1 -0
- package/dist/custom/master-data-grid/components/toolbar/toolbar.js +238 -0
- package/dist/custom/master-data-grid/components/toolbar/toolbar.js.map +1 -0
- package/dist/custom/master-data-grid/hooks/index.js +7 -0
- package/dist/custom/master-data-grid/hooks/index.js.map +1 -0
- package/dist/custom/master-data-grid/hooks/use-columns.js +278 -0
- package/dist/custom/master-data-grid/hooks/use-columns.js.map +1 -0
- package/dist/custom/master-data-grid/hooks/use-editing.js +75 -0
- package/dist/custom/master-data-grid/hooks/use-editing.js.map +1 -0
- package/dist/custom/master-data-grid/hooks/use-table-state-reducer.js +96 -0
- package/dist/custom/master-data-grid/hooks/use-table-state-reducer.js.map +1 -0
- package/dist/custom/master-data-grid/hooks/use-table-state.js +25 -0
- package/dist/custom/master-data-grid/hooks/use-table-state.js.map +1 -0
- package/dist/custom/master-data-grid/index.js +5 -0
- package/dist/custom/master-data-grid/index.js.map +1 -0
- package/dist/custom/master-data-grid/types.js +1 -0
- package/dist/custom/master-data-grid/types.js.map +1 -0
- package/dist/custom/master-data-grid/utils/column-generator.js +203 -0
- package/dist/custom/master-data-grid/utils/column-generator.js.map +1 -0
- package/dist/custom/master-data-grid/utils/export-utils.js +46 -0
- package/dist/custom/master-data-grid/utils/export-utils.js.map +1 -0
- package/dist/custom/master-data-grid/utils/filter-fns.js +218 -0
- package/dist/custom/master-data-grid/utils/filter-fns.js.map +1 -0
- package/dist/custom/master-data-grid/utils/index.js +16 -0
- package/dist/custom/master-data-grid/utils/index.js.map +1 -0
- package/dist/custom/master-data-grid/utils/pinning-utils.js +70 -0
- package/dist/custom/master-data-grid/utils/pinning-utils.js.map +1 -0
- package/dist/custom/master-data-grid/utils/translation-utils.js +33 -0
- package/dist/custom/master-data-grid/utils/translation-utils.js.map +1 -0
- package/dist/custom/multi-select.js +339 -0
- package/dist/custom/multi-select.js.map +1 -0
- package/dist/custom/password-input.js +158 -0
- package/dist/custom/password-input.js.map +1 -0
- package/dist/custom/phone-input.js +127 -0
- package/dist/custom/phone-input.js.map +1 -0
- package/dist/custom/schema-form/custom/index.js +2 -0
- package/dist/custom/schema-form/custom/index.js.map +1 -0
- package/dist/custom/schema-form/custom/label.js +39 -0
- package/dist/custom/schema-form/custom/label.js.map +1 -0
- package/dist/custom/schema-form/fields/base-input-field.js +73 -0
- package/dist/custom/schema-form/fields/base-input-field.js.map +1 -0
- package/dist/custom/schema-form/fields/field.js +72 -0
- package/dist/custom/schema-form/fields/field.js.map +1 -0
- package/dist/custom/schema-form/fields/index.js +6 -0
- package/dist/custom/schema-form/fields/index.js.map +1 -0
- package/dist/custom/schema-form/fields/object.js +9 -0
- package/dist/custom/schema-form/fields/object.js.map +1 -0
- package/dist/custom/schema-form/fields/table-array/array-field-item.js +58 -0
- package/dist/custom/schema-form/fields/table-array/array-field-item.js.map +1 -0
- package/dist/custom/schema-form/fields/table-array/array-field-template.js +104 -0
- package/dist/custom/schema-form/fields/table-array/array-field-template.js.map +1 -0
- package/dist/custom/schema-form/index.js +219 -0
- package/dist/custom/schema-form/index.js.map +1 -0
- package/dist/custom/schema-form/templates/description.js +19 -0
- package/dist/custom/schema-form/templates/description.js.map +1 -0
- package/dist/custom/schema-form/templates/index.js +3 -0
- package/dist/custom/schema-form/templates/index.js.map +1 -0
- package/dist/custom/schema-form/templates/submit.js +31 -0
- package/dist/custom/schema-form/templates/submit.js.map +1 -0
- package/dist/custom/schema-form/types.js +1 -0
- package/dist/custom/schema-form/types.js.map +1 -0
- package/dist/custom/schema-form/utils/index.js +10 -0
- package/dist/custom/schema-form/utils/index.js.map +1 -0
- package/dist/custom/schema-form/utils/schema-dependency.js +349 -0
- package/dist/custom/schema-form/utils/schema-dependency.js.map +1 -0
- package/dist/custom/schema-form/utils/schemas.js +190 -0
- package/dist/custom/schema-form/utils/schemas.js.map +1 -0
- package/dist/custom/schema-form/utils/validation.js +19 -0
- package/dist/custom/schema-form/utils/validation.js.map +1 -0
- package/dist/custom/schema-form/widgets/boolean.js +73 -0
- package/dist/custom/schema-form/widgets/boolean.js.map +1 -0
- package/dist/custom/schema-form/widgets/combobox.js +222 -0
- package/dist/custom/schema-form/widgets/combobox.js.map +1 -0
- package/dist/custom/schema-form/widgets/date.js +56 -0
- package/dist/custom/schema-form/widgets/date.js.map +1 -0
- package/dist/custom/schema-form/widgets/email.js +37 -0
- package/dist/custom/schema-form/widgets/email.js.map +1 -0
- package/dist/custom/schema-form/widgets/index.js +11 -0
- package/dist/custom/schema-form/widgets/index.js.map +1 -0
- package/dist/custom/schema-form/widgets/password.js +42 -0
- package/dist/custom/schema-form/widgets/password.js.map +1 -0
- package/dist/custom/schema-form/widgets/phone.js +39 -0
- package/dist/custom/schema-form/widgets/phone.js.map +1 -0
- package/dist/custom/schema-form/widgets/select.js +78 -0
- package/dist/custom/schema-form/widgets/select.js.map +1 -0
- package/dist/custom/schema-form/widgets/selectable.js +25 -0
- package/dist/custom/schema-form/widgets/selectable.js.map +1 -0
- package/dist/custom/schema-form/widgets/string-array.js +237 -0
- package/dist/custom/schema-form/widgets/string-array.js.map +1 -0
- package/dist/custom/schema-form/widgets/url.js +53 -0
- package/dist/custom/schema-form/widgets/url.js.map +1 -0
- package/dist/custom/section-layout-v2.js +150 -0
- package/dist/custom/section-layout-v2.js.map +1 -0
- package/dist/custom/select-tabs.js +66 -0
- package/dist/custom/select-tabs.js.map +1 -0
- package/dist/custom/selectable.js +231 -0
- package/dist/custom/selectable.js.map +1 -0
- package/dist/custom/stepper.js +166 -0
- package/dist/custom/stepper.js.map +1 -0
- package/dist/custom/tab-layout.js +182 -0
- package/dist/custom/tab-layout.js.map +1 -0
- package/dist/custom/tanstack-table/fields/index.js +13 -0
- package/dist/custom/tanstack-table/fields/index.js.map +1 -0
- package/dist/custom/tanstack-table/fields/tanstack-table-action-dialogs.js +76 -0
- package/dist/custom/tanstack-table/fields/tanstack-table-action-dialogs.js.map +1 -0
- package/dist/custom/tanstack-table/fields/tanstack-table-column-header.js +47 -0
- package/dist/custom/tanstack-table/fields/tanstack-table-column-header.js.map +1 -0
- package/dist/custom/tanstack-table/fields/tanstack-table-filter-date.js +132 -0
- package/dist/custom/tanstack-table/fields/tanstack-table-filter-date.js.map +1 -0
- package/dist/custom/tanstack-table/fields/tanstack-table-filter-faceted.js +131 -0
- package/dist/custom/tanstack-table/fields/tanstack-table-filter-faceted.js.map +1 -0
- package/dist/custom/tanstack-table/fields/tanstack-table-filter-text.js +64 -0
- package/dist/custom/tanstack-table/fields/tanstack-table-filter-text.js.map +1 -0
- package/dist/custom/tanstack-table/fields/tanstack-table-pagination.js +135 -0
- package/dist/custom/tanstack-table/fields/tanstack-table-pagination.js.map +1 -0
- package/dist/custom/tanstack-table/fields/tanstack-table-plain-table.js +111 -0
- package/dist/custom/tanstack-table/fields/tanstack-table-plain-table.js.map +1 -0
- package/dist/custom/tanstack-table/fields/tanstack-table-row-actions-confirmation.js +65 -0
- package/dist/custom/tanstack-table/fields/tanstack-table-row-actions-confirmation.js.map +1 -0
- package/dist/custom/tanstack-table/fields/tanstack-table-row-actions-custom-dialog.js +69 -0
- package/dist/custom/tanstack-table/fields/tanstack-table-row-actions-custom-dialog.js.map +1 -0
- package/dist/custom/tanstack-table/fields/tanstack-table-row-actions.js +119 -0
- package/dist/custom/tanstack-table/fields/tanstack-table-row-actions.js.map +1 -0
- package/dist/custom/tanstack-table/fields/tanstack-table-table-actions-custom-dialog.js +75 -0
- package/dist/custom/tanstack-table/fields/tanstack-table-table-actions-custom-dialog.js.map +1 -0
- package/dist/custom/tanstack-table/fields/tanstack-table-table-actions-schemaform-dialog.js +41 -0
- package/dist/custom/tanstack-table/fields/tanstack-table-table-actions-schemaform-dialog.js.map +1 -0
- package/dist/custom/tanstack-table/fields/tanstack-table-toolbar.js +106 -0
- package/dist/custom/tanstack-table/fields/tanstack-table-toolbar.js.map +1 -0
- package/dist/custom/tanstack-table/fields/tanstack-table-view-options.js +132 -0
- package/dist/custom/tanstack-table/fields/tanstack-table-view-options.js.map +1 -0
- package/dist/custom/tanstack-table/index.js +217 -0
- package/dist/custom/tanstack-table/index.js.map +1 -0
- package/dist/custom/tanstack-table/types/index.js +1 -0
- package/dist/custom/tanstack-table/types/index.js.map +1 -0
- package/dist/custom/tanstack-table/utils/cell-with-actions.js +16 -0
- package/dist/custom/tanstack-table/utils/cell-with-actions.js.map +1 -0
- package/dist/custom/tanstack-table/utils/column-names.js +15 -0
- package/dist/custom/tanstack-table/utils/column-names.js.map +1 -0
- package/dist/custom/tanstack-table/utils/columns-by-row-data.js +246 -0
- package/dist/custom/tanstack-table/utils/columns-by-row-data.js.map +1 -0
- package/dist/custom/tanstack-table/utils/editable-columns-by-row-data.js +187 -0
- package/dist/custom/tanstack-table/utils/editable-columns-by-row-data.js.map +1 -0
- package/dist/custom/tanstack-table/utils/faceted-boolean-options.js +25 -0
- package/dist/custom/tanstack-table/utils/faceted-boolean-options.js.map +1 -0
- package/dist/custom/tanstack-table/utils/index.js +10 -0
- package/dist/custom/tanstack-table/utils/index.js.map +1 -0
- package/dist/custom/tanstack-table/utils/pinning-styles.js +38 -0
- package/dist/custom/tanstack-table/utils/pinning-styles.js.map +1 -0
- package/dist/custom/tanstack-table/utils/table.js +66 -0
- package/dist/custom/tanstack-table/utils/table.js.map +1 -0
- package/dist/custom/tanstack-table/utils/test-conditions.js +10 -0
- package/dist/custom/tanstack-table/utils/test-conditions.js.map +1 -0
- package/dist/custom/timeline.js +165 -0
- package/dist/custom/timeline.js.map +1 -0
- package/dist/custom/tree.js +130 -0
- package/dist/custom/tree.js.map +1 -0
- package/dist/custom/tscanify/browser.js +36 -0
- package/dist/custom/tscanify/browser.js.map +1 -0
- package/dist/custom/tscanify/index.js +34 -0
- package/dist/custom/tscanify/index.js.map +1 -0
- package/dist/custom/tscanify/tscanify-browser.js +363 -0
- package/dist/custom/tscanify/tscanify-browser.js.map +1 -0
- package/dist/custom/tscanify/tscanify.js +197 -0
- package/dist/custom/tscanify/tscanify.js.map +1 -0
- package/dist/custom/tscanify/types.js +1 -0
- package/dist/custom/tscanify/types.js.map +1 -0
- package/dist/custom/webcam.js +519 -0
- package/dist/custom/webcam.js.map +1 -0
- package/dist/hooks/use-callback-ref.js +15 -0
- package/dist/hooks/use-callback-ref.js.map +1 -0
- package/dist/hooks/use-controllable-state.js +49 -0
- package/dist/hooks/use-controllable-state.js.map +1 -0
- package/dist/hooks/use-debounce.js +18 -0
- package/dist/hooks/use-debounce.js.map +1 -0
- package/dist/hooks/use-is-visible.js +22 -0
- package/dist/hooks/use-is-visible.js.map +1 -0
- package/dist/hooks/use-media-query.js +19 -0
- package/dist/hooks/use-media-query.js.map +1 -0
- package/dist/hooks/use-mobile.js +21 -0
- package/dist/hooks/use-mobile.js.map +1 -0
- package/dist/hooks/use-on-window-resize.js +15 -0
- package/dist/hooks/use-on-window-resize.js.map +1 -0
- package/dist/hooks/use-scroll.js +20 -0
- package/dist/hooks/use-scroll.js.map +1 -0
- package/dist/lib/utils.js +48 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/lib/zod.js +7 -0
- package/dist/lib/zod.js.map +1 -0
- package/package.json +34 -8
- package/src/aria/index.tsx +1 -1
- package/src/aria/number-field.tsx +41 -41
- package/src/components/accordion.tsx +66 -66
- package/src/components/alert-dialog.tsx +157 -157
- package/src/components/alert.tsx +70 -70
- package/src/components/aspect-ratio.tsx +11 -11
- package/src/components/avatar.tsx +53 -53
- package/src/components/badge.tsx +74 -67
- package/src/components/breadcrumb.tsx +109 -109
- package/src/components/button-group.tsx +83 -83
- package/src/components/button.tsx +68 -68
- package/src/components/calendar.tsx +219 -219
- package/src/components/card.tsx +92 -92
- package/src/components/carousel.tsx +241 -241
- package/src/components/chart.tsx +363 -363
- package/src/components/checkbox.tsx +32 -32
- package/src/components/collapsible.tsx +33 -33
- package/src/components/command.tsx +184 -184
- package/src/components/context-menu.tsx +252 -252
- package/src/components/dialog.tsx +144 -144
- package/src/components/drawer.tsx +135 -135
- package/src/components/dropdown-menu.tsx +258 -258
- package/src/components/empty.tsx +100 -100
- package/src/components/field.tsx +248 -248
- package/src/components/form.tsx +169 -169
- package/src/components/hover-card.tsx +44 -44
- package/src/components/input-group.tsx +170 -170
- package/src/components/input-otp.tsx +77 -77
- package/src/components/input.tsx +21 -21
- package/src/components/item.tsx +193 -193
- package/src/components/kbd.tsx +28 -28
- package/src/components/label.tsx +24 -24
- package/src/components/menubar.tsx +276 -276
- package/src/components/navigation-menu.tsx +168 -168
- package/src/components/pagination.tsx +130 -130
- package/src/components/popover.tsx +88 -88
- package/src/components/progress.tsx +31 -31
- package/src/components/radio-group.tsx +45 -45
- package/src/components/resizable.tsx +56 -56
- package/src/components/scroll-area.tsx +58 -58
- package/src/components/select.tsx +189 -189
- package/src/components/separator.tsx +28 -28
- package/src/components/sheet.tsx +140 -140
- package/src/components/sidebar.tsx +862 -862
- package/src/components/skeleton.tsx +13 -13
- package/src/components/slider.tsx +63 -63
- package/src/components/sonner.tsx +40 -40
- package/src/components/spinner.tsx +16 -16
- package/src/components/stepper.tsx +291 -291
- package/src/components/switch.tsx +31 -31
- package/src/components/table.tsx +133 -133
- package/src/components/tabs.tsx +66 -66
- package/src/components/textarea.tsx +18 -18
- package/src/components/toggle-group.tsx +83 -83
- package/src/components/toggle.tsx +47 -47
- package/src/components/tooltip.tsx +66 -66
- package/src/custom/action-button.tsx +48 -48
- package/src/custom/async-select.tsx +287 -287
- package/src/custom/awesome-not-found.tsx +116 -116
- package/src/custom/charts/area-chart.tsx +147 -147
- package/src/custom/charts/bar-chart.tsx +233 -233
- package/src/custom/charts/chart-card.tsx +103 -103
- package/src/custom/charts/index.tsx +16 -16
- package/src/custom/charts/pie-chart.tsx +168 -168
- package/src/custom/charts/radar-chart.tsx +126 -126
- package/src/custom/checkbox-tree.tsx +100 -100
- package/src/custom/combobox.tsx +296 -296
- package/src/custom/confirm-dialog.tsx +114 -102
- package/src/custom/country-selector.tsx +204 -204
- package/src/custom/date-picker/calendar-rac.tsx +109 -109
- package/src/custom/date-picker/datefield-rac.tsx +84 -84
- package/src/custom/date-picker/index.tsx +273 -273
- package/src/custom/date-picker/types/index.ts +4 -4
- package/src/custom/date-picker/utils/index.ts +42 -42
- package/src/custom/date-picker-old.tsx +50 -50
- package/src/custom/date-tooltip.tsx +98 -98
- package/src/custom/document-scanner/consts.ts +5 -5
- package/src/custom/document-scanner/corner-adjustment/action-buttons.tsx +33 -33
- package/src/custom/document-scanner/corner-adjustment/corner-handle.tsx +43 -43
- package/src/custom/document-scanner/corner-adjustment/hooks/use-corner-drag.ts +85 -85
- package/src/custom/document-scanner/corner-adjustment/index.tsx +125 -125
- package/src/custom/document-scanner/corner-adjustment/types.ts +53 -53
- package/src/custom/document-scanner/corner-adjustment/utils/clip-path.ts +22 -22
- package/src/custom/document-scanner/corner-adjustment/zoom-magnifier.tsx +115 -115
- package/src/custom/document-scanner/hooks/use-document-capture.ts +81 -81
- package/src/custom/document-scanner/hooks/use-document-scanner.ts +80 -80
- package/src/custom/document-scanner/hooks/use-perspective-crop.ts +38 -38
- package/src/custom/document-scanner/index.tsx +255 -255
- package/src/custom/document-scanner/lib.ts +407 -407
- package/src/custom/document-scanner/types.ts +205 -205
- package/src/custom/document-scanner/utils/perspective-correction.ts +139 -139
- package/src/custom/document-viewer/controllers.tsx +98 -98
- package/src/custom/document-viewer/index.tsx +43 -43
- package/src/custom/document-viewer/renderers/image.tsx +37 -37
- package/src/custom/document-viewer/renderers/index.tsx +2 -2
- package/src/custom/document-viewer/renderers/pdf.tsx +105 -105
- package/src/custom/email-input/domains.json +159 -159
- package/src/custom/email-input/email.tsx +229 -229
- package/src/custom/email-input/index.tsx +4 -4
- package/src/custom/email-input/types.ts +104 -104
- package/src/custom/file-uploader.tsx +541 -541
- package/src/custom/filter-component/fields/async-select.tsx +33 -33
- package/src/custom/filter-component/fields/date.tsx +60 -60
- package/src/custom/filter-component/fields/multi-select.tsx +30 -30
- package/src/custom/filter-component/index.tsx +217 -217
- package/src/custom/image-canvas.tsx +260 -260
- package/src/custom/json-editor.tsx +22 -22
- package/src/custom/master-data-grid/components/dialogs/column-settings-dialog.tsx +100 -100
- package/src/custom/master-data-grid/components/dialogs/index.ts +1 -1
- package/src/custom/master-data-grid/components/filters/client-filter.tsx +368 -368
- package/src/custom/master-data-grid/components/filters/filter-input.tsx +256 -256
- package/src/custom/master-data-grid/components/filters/index.ts +3 -3
- package/src/custom/master-data-grid/components/filters/inline-column-filter.tsx +233 -233
- package/src/custom/master-data-grid/components/filters/multi-filter-dialog.tsx +90 -90
- package/src/custom/master-data-grid/components/filters/server-filter.tsx +264 -255
- package/src/custom/master-data-grid/components/master-data-grid.tsx +472 -472
- package/src/custom/master-data-grid/components/pagination/index.ts +1 -1
- package/src/custom/master-data-grid/components/pagination/pagination.tsx +178 -178
- package/src/custom/master-data-grid/components/table/cell-renderer.tsx +621 -634
- package/src/custom/master-data-grid/components/table/header-cell.tsx +162 -162
- package/src/custom/master-data-grid/components/table/index.ts +4 -4
- package/src/custom/master-data-grid/components/table/table-body-renderer.tsx +113 -113
- package/src/custom/master-data-grid/components/table/virtual-body.tsx +138 -138
- package/src/custom/master-data-grid/components/toolbar/index.ts +1 -1
- package/src/custom/master-data-grid/components/toolbar/toolbar.tsx +314 -314
- package/src/custom/master-data-grid/hooks/index.ts +3 -3
- package/src/custom/master-data-grid/hooks/use-columns.tsx +353 -332
- package/src/custom/master-data-grid/hooks/use-editing.ts +106 -106
- package/src/custom/master-data-grid/hooks/use-table-state-reducer.ts +157 -157
- package/src/custom/master-data-grid/hooks/use-table-state.ts +31 -31
- package/src/custom/master-data-grid/index.ts +16 -16
- package/src/custom/master-data-grid/types.ts +486 -466
- package/src/custom/master-data-grid/utils/column-generator.tsx +324 -306
- package/src/custom/master-data-grid/utils/export-utils.ts +67 -67
- package/src/custom/master-data-grid/utils/filter-fns.ts +310 -290
- package/src/custom/master-data-grid/utils/index.ts +8 -8
- package/src/custom/master-data-grid/utils/pinning-utils.ts +88 -88
- package/src/custom/master-data-grid/utils/translation-utils.ts +42 -42
- package/src/custom/multi-select.tsx +432 -432
- package/src/custom/password-input.tsx +194 -194
- package/src/custom/phone-input.tsx +172 -172
- package/src/custom/schema-form/custom/index.tsx +1 -1
- package/src/custom/schema-form/custom/label.tsx +53 -53
- package/src/custom/schema-form/fields/base-input-field.tsx +82 -82
- package/src/custom/schema-form/fields/field.tsx +67 -67
- package/src/custom/schema-form/fields/index.tsx +5 -5
- package/src/custom/schema-form/fields/object.tsx +12 -12
- package/src/custom/schema-form/fields/table-array/array-field-item.tsx +90 -90
- package/src/custom/schema-form/fields/table-array/array-field-template.tsx +115 -115
- package/src/custom/schema-form/index.tsx +259 -259
- package/src/custom/schema-form/templates/description.tsx +20 -20
- package/src/custom/schema-form/templates/index.tsx +2 -2
- package/src/custom/schema-form/templates/submit.tsx +32 -32
- package/src/custom/schema-form/types.ts +64 -64
- package/src/custom/schema-form/utils/index.ts +4 -4
- package/src/custom/schema-form/utils/schema-dependency.ts +655 -655
- package/src/custom/schema-form/utils/schemas.ts +289 -289
- package/src/custom/schema-form/utils/validation.ts +23 -23
- package/src/custom/schema-form/widgets/boolean.tsx +77 -77
- package/src/custom/schema-form/widgets/combobox.tsx +274 -274
- package/src/custom/schema-form/widgets/date.tsx +59 -59
- package/src/custom/schema-form/widgets/email.tsx +34 -34
- package/src/custom/schema-form/widgets/index.tsx +10 -10
- package/src/custom/schema-form/widgets/password.tsx +40 -40
- package/src/custom/schema-form/widgets/phone.tsx +40 -40
- package/src/custom/schema-form/widgets/select.tsx +105 -105
- package/src/custom/schema-form/widgets/selectable.tsx +25 -25
- package/src/custom/schema-form/widgets/string-array.tsx +296 -296
- package/src/custom/schema-form/widgets/url.tsx +56 -56
- package/src/custom/section-layout-v2.tsx +212 -212
- package/src/custom/select-tabs.tsx +109 -109
- package/src/custom/selectable.tsx +316 -316
- package/src/custom/stepper.tsx +236 -236
- package/src/custom/tab-layout.tsx +213 -213
- package/src/custom/tanstack-table/fields/index.tsx +12 -12
- package/src/custom/tanstack-table/fields/tanstack-table-action-dialogs.tsx +89 -89
- package/src/custom/tanstack-table/fields/tanstack-table-column-header.tsx +66 -66
- package/src/custom/tanstack-table/fields/tanstack-table-filter-date.tsx +180 -180
- package/src/custom/tanstack-table/fields/tanstack-table-filter-faceted.tsx +158 -158
- package/src/custom/tanstack-table/fields/tanstack-table-filter-text.tsx +76 -76
- package/src/custom/tanstack-table/fields/tanstack-table-pagination.tsx +136 -136
- package/src/custom/tanstack-table/fields/tanstack-table-plain-table.tsx +142 -142
- package/src/custom/tanstack-table/fields/tanstack-table-row-actions-confirmation.tsx +77 -77
- package/src/custom/tanstack-table/fields/tanstack-table-row-actions-custom-dialog.tsx +87 -87
- package/src/custom/tanstack-table/fields/tanstack-table-row-actions.tsx +151 -151
- package/src/custom/tanstack-table/fields/tanstack-table-table-actions-custom-dialog.tsx +88 -88
- package/src/custom/tanstack-table/fields/tanstack-table-table-actions-schemaform-dialog.tsx +47 -47
- package/src/custom/tanstack-table/fields/tanstack-table-toolbar.tsx +143 -143
- package/src/custom/tanstack-table/fields/tanstack-table-view-options.tsx +171 -171
- package/src/custom/tanstack-table/index.tsx +244 -244
- package/src/custom/tanstack-table/types/index.ts +328 -328
- package/src/custom/tanstack-table/utils/cell-with-actions.tsx +21 -21
- package/src/custom/tanstack-table/utils/column-names.ts +26 -26
- package/src/custom/tanstack-table/utils/columns-by-row-data.tsx +312 -312
- package/src/custom/tanstack-table/utils/editable-columns-by-row-data.tsx +219 -219
- package/src/custom/tanstack-table/utils/faceted-boolean-options.tsx +22 -22
- package/src/custom/tanstack-table/utils/index.tsx +10 -10
- package/src/custom/tanstack-table/utils/pinning-styles.ts +57 -57
- package/src/custom/tanstack-table/utils/table.tsx +83 -83
- package/src/custom/tanstack-table/utils/test-conditions.ts +17 -17
- package/src/custom/timeline.tsx +208 -208
- package/src/custom/tree.tsx +200 -200
- package/src/custom/tscanify/browser.ts +66 -66
- package/src/custom/tscanify/index.ts +51 -51
- package/src/custom/tscanify/tscanify-browser.ts +522 -522
- package/src/custom/tscanify/tscanify.ts +262 -262
- package/src/custom/tscanify/types.ts +22 -22
- package/src/custom/webcam.tsx +737 -737
- package/src/hooks/use-callback-ref.ts +27 -27
- package/src/hooks/use-controllable-state.ts +67 -67
- package/src/hooks/use-debounce.ts +19 -19
- package/src/hooks/use-is-visible.ts +23 -23
- package/src/hooks/use-media-query.ts +21 -21
- package/src/hooks/use-mobile.ts +21 -21
- package/src/hooks/use-on-window-resize.ts +15 -15
- package/src/hooks/use-scroll.tsx +22 -22
- package/src/lib/utils.ts +61 -61
- package/src/lib/zod.ts +2 -2
- package/src/styles/core.css +57 -57
- package/src/test/email-input.test.tsx +217 -217
- package/src/test/password-input.test.tsx +92 -92
- package/src/test/select-tabs.test.tsx +302 -302
- package/src/test/selectable.test.tsx +1093 -1093
- package/__mocks__/canvas.ts +0 -8
- package/components.json +0 -21
- package/eslint.config.js +0 -4
- package/jest-environment.js +0 -37
- package/jest.config.ts +0 -47
- package/jest.setup.ts +0 -69
- package/postcss.config.mjs +0 -6
- package/tsconfig.json +0 -13
- package/tsconfig.lint.json +0 -8
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
function getTranslations(key, t, replacements) {
|
|
2
|
+
let text = t?.[key] ?? key;
|
|
3
|
+
if (replacements) {
|
|
4
|
+
Object.entries(replacements).forEach(([placeholder, value]) => {
|
|
5
|
+
text = text.replace(`{${placeholder}}`, value);
|
|
6
|
+
});
|
|
7
|
+
}
|
|
8
|
+
return text;
|
|
9
|
+
}
|
|
10
|
+
function getColumnName(column, t, fallback) {
|
|
11
|
+
if (typeof column === "string") {
|
|
12
|
+
const translationKey2 = `column.${column}`;
|
|
13
|
+
const translated = getTranslations(translationKey2, t);
|
|
14
|
+
if (translated !== translationKey2) {
|
|
15
|
+
return translated;
|
|
16
|
+
}
|
|
17
|
+
return fallback ?? column;
|
|
18
|
+
}
|
|
19
|
+
const translationKey = `column.${column.id}`;
|
|
20
|
+
if (t?.[translationKey]) {
|
|
21
|
+
return t[translationKey];
|
|
22
|
+
}
|
|
23
|
+
const header = column.columnDef.header;
|
|
24
|
+
if (typeof header === "string") {
|
|
25
|
+
return header;
|
|
26
|
+
}
|
|
27
|
+
return column.id;
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
getColumnName,
|
|
31
|
+
getTranslations
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=translation-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/custom/master-data-grid/utils/translation-utils.ts"],"sourcesContent":["import type { Column } from \"@tanstack/react-table\";\r\nimport type { MasterDataGridResources } from \"../types\";\r\n\r\nexport function getTranslations(\r\n key: string,\r\n t?: MasterDataGridResources,\r\n replacements?: Record<string, string>\r\n): string {\r\n let text = t?.[key] ?? key;\r\n\r\n if (replacements) {\r\n Object.entries(replacements).forEach(([placeholder, value]) => {\r\n text = text.replace(`{${placeholder}}`, value);\r\n });\r\n }\r\n\r\n return text;\r\n}\r\n\r\nexport function getColumnName<TData>(\r\n column: Column<TData> | string,\r\n t?: MasterDataGridResources,\r\n fallback?: string\r\n): string {\r\n if (typeof column === \"string\") {\r\n const translationKey = `column.${column}`;\r\n const translated = getTranslations(translationKey, t);\r\n if (translated !== translationKey) {\r\n return translated;\r\n }\r\n return fallback ?? column;\r\n }\r\n const translationKey = `column.${column.id}`;\r\n if (t?.[translationKey]) {\r\n return t[translationKey];\r\n }\r\n const header = column.columnDef.header;\r\n if (typeof header === \"string\") {\r\n return header;\r\n }\r\n return column.id;\r\n}\r\n"],"mappings":"AAGO,SAAS,gBACd,KACA,GACA,cACQ;AACR,MAAI,OAAO,IAAI,GAAG,KAAK;AAEvB,MAAI,cAAc;AAChB,WAAO,QAAQ,YAAY,EAAE,QAAQ,CAAC,CAAC,aAAa,KAAK,MAAM;AAC7D,aAAO,KAAK,QAAQ,IAAI,WAAW,KAAK,KAAK;AAAA,IAC/C,CAAC;AAAA,EACH;AAEA,SAAO;AACT;AAEO,SAAS,cACd,QACA,GACA,UACQ;AACR,MAAI,OAAO,WAAW,UAAU;AAC9B,UAAMA,kBAAiB,UAAU,MAAM;AACvC,UAAM,aAAa,gBAAgBA,iBAAgB,CAAC;AACpD,QAAI,eAAeA,iBAAgB;AACjC,aAAO;AAAA,IACT;AACA,WAAO,YAAY;AAAA,EACrB;AACA,QAAM,iBAAiB,UAAU,OAAO,EAAE;AAC1C,MAAI,IAAI,cAAc,GAAG;AACvB,WAAO,EAAE,cAAc;AAAA,EACzB;AACA,QAAM,SAAS,OAAO,UAAU;AAChC,MAAI,OAAO,WAAW,UAAU;AAC9B,WAAO;AAAA,EACT;AACA,SAAO,OAAO;AAChB;","names":["translationKey"]}
|
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { cva } from "class-variance-authority";
|
|
5
|
+
import {
|
|
6
|
+
CheckIcon,
|
|
7
|
+
XCircle,
|
|
8
|
+
ChevronDown,
|
|
9
|
+
XIcon,
|
|
10
|
+
WandSparkles
|
|
11
|
+
} from "lucide-react";
|
|
12
|
+
import { cn } from "@repo/ayasofyazilim-ui/lib/utils";
|
|
13
|
+
import { Separator } from "@repo/ayasofyazilim-ui/components/separator";
|
|
14
|
+
import { Button } from "@repo/ayasofyazilim-ui/components/button";
|
|
15
|
+
import { Badge } from "@repo/ayasofyazilim-ui/components/badge";
|
|
16
|
+
import {
|
|
17
|
+
Popover,
|
|
18
|
+
PopoverContent,
|
|
19
|
+
PopoverTrigger
|
|
20
|
+
} from "@repo/ayasofyazilim-ui/components/popover";
|
|
21
|
+
import {
|
|
22
|
+
Command,
|
|
23
|
+
CommandEmpty,
|
|
24
|
+
CommandGroup,
|
|
25
|
+
CommandInput,
|
|
26
|
+
CommandItem,
|
|
27
|
+
CommandList,
|
|
28
|
+
CommandSeparator
|
|
29
|
+
} from "@repo/ayasofyazilim-ui/components/command";
|
|
30
|
+
const multiSelectVariants = cva(
|
|
31
|
+
"m-1 transition ease-in-out delay-150 hover:-translate-y-1 hover:scale-110 duration-300",
|
|
32
|
+
{
|
|
33
|
+
variants: {
|
|
34
|
+
variant: {
|
|
35
|
+
default: "border-foreground/10 text-foreground bg-card hover:bg-card/80",
|
|
36
|
+
secondary: "border-foreground/10 bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
37
|
+
destructive: "border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",
|
|
38
|
+
inverted: "inverted"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
defaultVariants: {
|
|
42
|
+
variant: "default"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
const MultiSelect = React.forwardRef(
|
|
47
|
+
({
|
|
48
|
+
options,
|
|
49
|
+
onValueChange,
|
|
50
|
+
variant,
|
|
51
|
+
defaultValue = [],
|
|
52
|
+
placeholder = "Select options",
|
|
53
|
+
selectAllLabel = "Select all",
|
|
54
|
+
animation = 0,
|
|
55
|
+
maxCount = 3,
|
|
56
|
+
modalPopover = false,
|
|
57
|
+
className,
|
|
58
|
+
disabled,
|
|
59
|
+
...props
|
|
60
|
+
}, ref) => {
|
|
61
|
+
const [selectedValues, setSelectedValues] = React.useState(defaultValue);
|
|
62
|
+
const previousDefaultValue = React.useRef(defaultValue);
|
|
63
|
+
React.useEffect(() => {
|
|
64
|
+
if (JSON.stringify(previousDefaultValue.current) !== JSON.stringify(defaultValue)) {
|
|
65
|
+
setSelectedValues(defaultValue);
|
|
66
|
+
previousDefaultValue.current = defaultValue;
|
|
67
|
+
}
|
|
68
|
+
}, [defaultValue]);
|
|
69
|
+
const [isPopoverOpen, setIsPopoverOpen] = React.useState(false);
|
|
70
|
+
const [isAnimating, setIsAnimating] = React.useState(false);
|
|
71
|
+
const handleInputKeyDown = (event) => {
|
|
72
|
+
if (event.key === "Enter") {
|
|
73
|
+
setIsPopoverOpen(true);
|
|
74
|
+
} else if (event.key === "Backspace" && !event.currentTarget.value) {
|
|
75
|
+
const newSelectedValues = [...selectedValues];
|
|
76
|
+
newSelectedValues.pop();
|
|
77
|
+
setSelectedValues(newSelectedValues);
|
|
78
|
+
if (onValueChange) onValueChange(newSelectedValues);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
const toggleOption = (option) => {
|
|
82
|
+
const newSelectedValues = selectedValues.includes(option) ? selectedValues.filter((value) => value !== option) : [...selectedValues, option];
|
|
83
|
+
setSelectedValues(newSelectedValues);
|
|
84
|
+
if (onValueChange) onValueChange(newSelectedValues);
|
|
85
|
+
};
|
|
86
|
+
const handleClear = () => {
|
|
87
|
+
setSelectedValues(
|
|
88
|
+
selectedValues.filter(
|
|
89
|
+
(value) => !options.map((o) => !o.disabled && o.value).includes(value)
|
|
90
|
+
)
|
|
91
|
+
);
|
|
92
|
+
if (onValueChange) onValueChange([]);
|
|
93
|
+
};
|
|
94
|
+
const handleTogglePopover = () => {
|
|
95
|
+
setIsPopoverOpen((prev) => !prev);
|
|
96
|
+
};
|
|
97
|
+
const clearExtraOptions = () => {
|
|
98
|
+
const newSelectedValues = selectedValues.slice(0, maxCount);
|
|
99
|
+
setSelectedValues(newSelectedValues);
|
|
100
|
+
if (onValueChange) onValueChange(newSelectedValues);
|
|
101
|
+
};
|
|
102
|
+
const toggleAll = () => {
|
|
103
|
+
if (selectedValues.length === options.length) {
|
|
104
|
+
handleClear();
|
|
105
|
+
} else {
|
|
106
|
+
const allValues = options.map((option) => option.value);
|
|
107
|
+
setSelectedValues(allValues);
|
|
108
|
+
if (onValueChange) onValueChange(allValues);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
return /* @__PURE__ */ jsxs(
|
|
112
|
+
Popover,
|
|
113
|
+
{
|
|
114
|
+
open: isPopoverOpen,
|
|
115
|
+
onOpenChange: setIsPopoverOpen,
|
|
116
|
+
modal: modalPopover,
|
|
117
|
+
children: [
|
|
118
|
+
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, className: "w-full", children: /* @__PURE__ */ jsx(
|
|
119
|
+
Button,
|
|
120
|
+
{
|
|
121
|
+
ref,
|
|
122
|
+
"data-testid": props.id,
|
|
123
|
+
type: "button",
|
|
124
|
+
disabled,
|
|
125
|
+
onClick: handleTogglePopover,
|
|
126
|
+
className: cn(
|
|
127
|
+
"flex w-full p-1 rounded-md border min-h-9 h-auto items-center justify-between bg-inherit hover:bg-inherit",
|
|
128
|
+
className
|
|
129
|
+
),
|
|
130
|
+
children: selectedValues.length > 0 ? /* @__PURE__ */ jsxs("div", { className: "flex justify-between items-center w-full", children: [
|
|
131
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center", children: [
|
|
132
|
+
selectedValues.slice(0, maxCount).map((value) => {
|
|
133
|
+
const option = options.find((o) => o.value === value);
|
|
134
|
+
const IconComponent = option?.icon;
|
|
135
|
+
return /* @__PURE__ */ jsxs(
|
|
136
|
+
Badge,
|
|
137
|
+
{
|
|
138
|
+
className: cn(
|
|
139
|
+
isAnimating ? "animate-bounce" : "",
|
|
140
|
+
multiSelectVariants({ variant })
|
|
141
|
+
),
|
|
142
|
+
style: { animationDuration: `${animation}s` },
|
|
143
|
+
children: [
|
|
144
|
+
IconComponent && /* @__PURE__ */ jsx(IconComponent, { className: "h-4 w-4 mr-2" }),
|
|
145
|
+
option?.label,
|
|
146
|
+
!option?.disabled && /* @__PURE__ */ jsx(
|
|
147
|
+
XCircle,
|
|
148
|
+
{
|
|
149
|
+
className: "ml-2 h-4 w-4 cursor-pointer",
|
|
150
|
+
onClick: (event) => {
|
|
151
|
+
event.stopPropagation();
|
|
152
|
+
toggleOption(value);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
)
|
|
156
|
+
]
|
|
157
|
+
},
|
|
158
|
+
value
|
|
159
|
+
);
|
|
160
|
+
}),
|
|
161
|
+
selectedValues.length > maxCount && /* @__PURE__ */ jsxs(
|
|
162
|
+
Badge,
|
|
163
|
+
{
|
|
164
|
+
className: cn(
|
|
165
|
+
"bg-transparent text-foreground border-foreground/1 hover:bg-transparent",
|
|
166
|
+
isAnimating ? "animate-bounce" : "",
|
|
167
|
+
multiSelectVariants({ variant })
|
|
168
|
+
),
|
|
169
|
+
style: { animationDuration: `${animation}s` },
|
|
170
|
+
children: [
|
|
171
|
+
`+ ${selectedValues.length - maxCount} more`,
|
|
172
|
+
/* @__PURE__ */ jsx(
|
|
173
|
+
XCircle,
|
|
174
|
+
{
|
|
175
|
+
className: "ml-2 h-4 w-4 cursor-pointer",
|
|
176
|
+
onClick: (event) => {
|
|
177
|
+
event.stopPropagation();
|
|
178
|
+
clearExtraOptions();
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
)
|
|
182
|
+
]
|
|
183
|
+
}
|
|
184
|
+
)
|
|
185
|
+
] }),
|
|
186
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
187
|
+
options.filter((x) => x.disabled).length !== options.length && /* @__PURE__ */ jsx(
|
|
188
|
+
XIcon,
|
|
189
|
+
{
|
|
190
|
+
className: "h-4 mx-2 cursor-pointer text-muted-foreground",
|
|
191
|
+
onClick: (event) => {
|
|
192
|
+
event.stopPropagation();
|
|
193
|
+
handleClear();
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
),
|
|
197
|
+
/* @__PURE__ */ jsx(
|
|
198
|
+
Separator,
|
|
199
|
+
{
|
|
200
|
+
orientation: "vertical",
|
|
201
|
+
className: "flex min-h-6 h-full"
|
|
202
|
+
}
|
|
203
|
+
),
|
|
204
|
+
/* @__PURE__ */ jsx(ChevronDown, { className: "h-4 mx-2 cursor-pointer text-muted-foreground" })
|
|
205
|
+
] })
|
|
206
|
+
] }) : /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between w-full mx-auto", children: [
|
|
207
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm text-black mx-3 font-normal", children: placeholder }),
|
|
208
|
+
/* @__PURE__ */ jsx(ChevronDown, { className: "h-4 cursor-pointer text-muted-foreground mx-2" })
|
|
209
|
+
] })
|
|
210
|
+
}
|
|
211
|
+
) }),
|
|
212
|
+
/* @__PURE__ */ jsx(
|
|
213
|
+
PopoverContent,
|
|
214
|
+
{
|
|
215
|
+
className: "p-0",
|
|
216
|
+
onEscapeKeyDown: () => setIsPopoverOpen(false),
|
|
217
|
+
children: /* @__PURE__ */ jsxs(Command, { className: "w-full", children: [
|
|
218
|
+
/* @__PURE__ */ jsx(
|
|
219
|
+
CommandInput,
|
|
220
|
+
{
|
|
221
|
+
"data-testid": `${props.id}_search`,
|
|
222
|
+
placeholder: "Search...",
|
|
223
|
+
onKeyDown: handleInputKeyDown
|
|
224
|
+
}
|
|
225
|
+
),
|
|
226
|
+
/* @__PURE__ */ jsxs(CommandList, { children: [
|
|
227
|
+
/* @__PURE__ */ jsx(CommandEmpty, { children: "No results found." }),
|
|
228
|
+
/* @__PURE__ */ jsxs(CommandGroup, { children: [
|
|
229
|
+
/* @__PURE__ */ jsxs(
|
|
230
|
+
CommandItem,
|
|
231
|
+
{
|
|
232
|
+
"data-testid": `${props.id}_select_all`,
|
|
233
|
+
onSelect: toggleAll,
|
|
234
|
+
className: "cursor-pointer",
|
|
235
|
+
disabled: options.filter((x) => x.disabled).length === options.length,
|
|
236
|
+
children: [
|
|
237
|
+
/* @__PURE__ */ jsx(
|
|
238
|
+
"div",
|
|
239
|
+
{
|
|
240
|
+
className: cn(
|
|
241
|
+
"mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",
|
|
242
|
+
selectedValues.length === options.length ? "bg-primary text-primary-foreground" : "opacity-50 [&_svg]:invisible"
|
|
243
|
+
),
|
|
244
|
+
children: /* @__PURE__ */ jsx(CheckIcon, { className: "h-4 w-4" })
|
|
245
|
+
}
|
|
246
|
+
),
|
|
247
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
248
|
+
"(",
|
|
249
|
+
selectAllLabel,
|
|
250
|
+
")"
|
|
251
|
+
] })
|
|
252
|
+
]
|
|
253
|
+
},
|
|
254
|
+
"all"
|
|
255
|
+
),
|
|
256
|
+
options.map((option) => {
|
|
257
|
+
const isSelected = selectedValues.includes(option.value);
|
|
258
|
+
return /* @__PURE__ */ jsxs(
|
|
259
|
+
CommandItem,
|
|
260
|
+
{
|
|
261
|
+
"data-testid": `${props.id}_${option.value}`,
|
|
262
|
+
onSelect: () => toggleOption(option.value),
|
|
263
|
+
className: "cursor-pointer",
|
|
264
|
+
disabled: option.disabled,
|
|
265
|
+
children: [
|
|
266
|
+
/* @__PURE__ */ jsx(
|
|
267
|
+
"div",
|
|
268
|
+
{
|
|
269
|
+
className: cn(
|
|
270
|
+
"mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",
|
|
271
|
+
isSelected ? "bg-primary text-primary-foreground" : "opacity-50 [&_svg]:invisible"
|
|
272
|
+
),
|
|
273
|
+
children: /* @__PURE__ */ jsx(CheckIcon, { className: "h-4 w-4" })
|
|
274
|
+
}
|
|
275
|
+
),
|
|
276
|
+
option.icon && /* @__PURE__ */ jsx(option.icon, { className: "mr-2 h-4 w-4 text-muted-foreground" }),
|
|
277
|
+
/* @__PURE__ */ jsx("span", { children: option.label }),
|
|
278
|
+
option.children
|
|
279
|
+
]
|
|
280
|
+
},
|
|
281
|
+
option.value
|
|
282
|
+
);
|
|
283
|
+
})
|
|
284
|
+
] }),
|
|
285
|
+
/* @__PURE__ */ jsx(CommandSeparator, {}),
|
|
286
|
+
/* @__PURE__ */ jsx(CommandGroup, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
287
|
+
selectedValues.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
288
|
+
/* @__PURE__ */ jsx(
|
|
289
|
+
CommandItem,
|
|
290
|
+
{
|
|
291
|
+
"data-testid": `${props.id}_clear`,
|
|
292
|
+
onSelect: handleClear,
|
|
293
|
+
className: "flex-1 justify-center cursor-pointer",
|
|
294
|
+
disabled: options.filter((x) => x.disabled).length === options.length,
|
|
295
|
+
children: "Clear"
|
|
296
|
+
}
|
|
297
|
+
),
|
|
298
|
+
/* @__PURE__ */ jsx(
|
|
299
|
+
Separator,
|
|
300
|
+
{
|
|
301
|
+
orientation: "vertical",
|
|
302
|
+
className: "flex min-h-6 h-full"
|
|
303
|
+
}
|
|
304
|
+
)
|
|
305
|
+
] }),
|
|
306
|
+
/* @__PURE__ */ jsx(
|
|
307
|
+
CommandItem,
|
|
308
|
+
{
|
|
309
|
+
"data-testid": `${props.id}_close`,
|
|
310
|
+
onSelect: () => setIsPopoverOpen(false),
|
|
311
|
+
className: "flex-1 justify-center cursor-pointer max-w-full",
|
|
312
|
+
children: "Close"
|
|
313
|
+
}
|
|
314
|
+
)
|
|
315
|
+
] }) })
|
|
316
|
+
] })
|
|
317
|
+
] })
|
|
318
|
+
}
|
|
319
|
+
),
|
|
320
|
+
animation > 0 && selectedValues.length > 0 && /* @__PURE__ */ jsx(
|
|
321
|
+
WandSparkles,
|
|
322
|
+
{
|
|
323
|
+
className: cn(
|
|
324
|
+
"cursor-pointer my-2 text-foreground bg-background w-3 h-3",
|
|
325
|
+
isAnimating ? "" : "text-muted-foreground"
|
|
326
|
+
),
|
|
327
|
+
onClick: () => setIsAnimating(!isAnimating)
|
|
328
|
+
}
|
|
329
|
+
)
|
|
330
|
+
]
|
|
331
|
+
}
|
|
332
|
+
);
|
|
333
|
+
}
|
|
334
|
+
);
|
|
335
|
+
MultiSelect.displayName = "MultiSelect";
|
|
336
|
+
export {
|
|
337
|
+
MultiSelect
|
|
338
|
+
};
|
|
339
|
+
//# sourceMappingURL=multi-select.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/custom/multi-select.tsx"],"sourcesContent":["\"use client\";\r\n\r\n// src/components/multi-select.tsx\r\nimport * as React from \"react\";\r\nimport { cva, type VariantProps } from \"class-variance-authority\";\r\nimport {\r\n CheckIcon,\r\n XCircle,\r\n ChevronDown,\r\n XIcon,\r\n WandSparkles,\r\n} from \"lucide-react\";\r\n\r\nimport { cn } from \"@repo/ayasofyazilim-ui/lib/utils\";\r\nimport { Separator } from \"@repo/ayasofyazilim-ui/components/separator\";\r\nimport { Button } from \"@repo/ayasofyazilim-ui/components/button\";\r\nimport { Badge } from \"@repo/ayasofyazilim-ui/components/badge\";\r\nimport {\r\n Popover,\r\n PopoverContent,\r\n PopoverTrigger,\r\n} from \"@repo/ayasofyazilim-ui/components/popover\";\r\nimport {\r\n Command,\r\n CommandEmpty,\r\n CommandGroup,\r\n CommandInput,\r\n CommandItem,\r\n CommandList,\r\n CommandSeparator,\r\n} from \"@repo/ayasofyazilim-ui/components/command\";\r\n\r\n/**\r\n * Variants for the multi-select component to handle different styles.\r\n * Uses class-variance-authority (cva) to define different styles based on \"variant\" prop.\r\n */\r\nconst multiSelectVariants = cva(\r\n \"m-1 transition ease-in-out delay-150 hover:-translate-y-1 hover:scale-110 duration-300\",\r\n {\r\n variants: {\r\n variant: {\r\n default:\r\n \"border-foreground/10 text-foreground bg-card hover:bg-card/80\",\r\n secondary:\r\n \"border-foreground/10 bg-secondary text-secondary-foreground hover:bg-secondary/80\",\r\n destructive:\r\n \"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80\",\r\n inverted: \"inverted\",\r\n },\r\n },\r\n defaultVariants: {\r\n variant: \"default\",\r\n },\r\n }\r\n);\r\n\r\n/**\r\n * Props for MultiSelect component\r\n */\r\nexport interface MultiSelectProps\r\n extends React.ButtonHTMLAttributes<HTMLButtonElement>,\r\n VariantProps<typeof multiSelectVariants> {\r\n /**\r\n * Animation duration in seconds for the visual effects (e.g., bouncing badges).\r\n * Optional, defaults to 0 (no animation).\r\n */\r\n animation?: number;\r\n\r\n /**\r\n * If true, renders the multi-select component as a child of another component.\r\n * Optional, defaults to false.\r\n */\r\n asChild?: boolean;\r\n\r\n /**\r\n * Additional class names to apply custom styles to the multi-select component.\r\n * Optional, can be used to add custom styles.\r\n */\r\n className?: string;\r\n\r\n /** The default selected values when the component mounts. */\r\n defaultValue?: string[];\r\n\r\n /**\r\n * Maximum number of items to display. Extra selected items will be summarized.\r\n * Optional, defaults to 3.\r\n */\r\n maxCount?: number;\r\n\r\n /**\r\n * The modality of the popover. When set to true, interaction with outside elements\r\n * will be disabled and only popover content will be visible to screen readers.\r\n * Optional, defaults to false.\r\n */\r\n modalPopover?: boolean;\r\n\r\n /**\r\n * Callback function triggered when the selected values change.\r\n * Receives an array of the new selected values.\r\n */\r\n onValueChange?: (value: string[]) => void;\r\n\r\n /**\r\n * An array of option objects to be displayed in the multi-select component.\r\n * Each option object has a label, value, and an optional icon.\r\n */\r\n options: {\r\n /** Optional icon component to display alongside the option. */\r\n icon?: React.ComponentType<{ className?: string }>;\r\n /** The text to display for the option. */\r\n label: string;\r\n /** The unique value associated with the option. */\r\n value: string;\r\n /** Optional badge component to display alongside the option. */\r\n children?: React.ReactNode;\r\n disabled?: boolean;\r\n }[];\r\n\r\n /**\r\n * Placeholder text to be displayed when no values are selected.\r\n * Optional, defaults to \"Select options\".\r\n */\r\n placeholder?: string;\r\n\r\n /**\r\n * selectAllLabel text to be displayed for select all option.\r\n * Optional, defaults to \"Select all\".\r\n */\r\n selectAllLabel?: string;\r\n\r\n /**\r\n * If true, the multi-select component will be disabled.\r\n * Optional, defaults to false.\r\n */\r\n disabled?: boolean;\r\n}\r\n\r\nexport const MultiSelect = React.forwardRef<\r\n HTMLButtonElement,\r\n MultiSelectProps\r\n>(\r\n (\r\n {\r\n options,\r\n onValueChange,\r\n variant,\r\n defaultValue = [],\r\n placeholder = \"Select options\",\r\n selectAllLabel = \"Select all\",\r\n animation = 0,\r\n maxCount = 3,\r\n modalPopover = false,\r\n className,\r\n disabled,\r\n ...props\r\n },\r\n ref\r\n ) => {\r\n const [selectedValues, setSelectedValues] =\r\n React.useState<string[]>(defaultValue);\r\n const previousDefaultValue = React.useRef<string[]>(defaultValue);\r\n React.useEffect(() => {\r\n if (\r\n JSON.stringify(previousDefaultValue.current) !==\r\n JSON.stringify(defaultValue)\r\n ) {\r\n setSelectedValues(defaultValue);\r\n previousDefaultValue.current = defaultValue;\r\n }\r\n }, [defaultValue]);\r\n const [isPopoverOpen, setIsPopoverOpen] = React.useState(false);\r\n const [isAnimating, setIsAnimating] = React.useState(false);\r\n\r\n const handleInputKeyDown = (\r\n event: React.KeyboardEvent<HTMLInputElement>\r\n ) => {\r\n if (event.key === \"Enter\") {\r\n setIsPopoverOpen(true);\r\n } else if (event.key === \"Backspace\" && !event.currentTarget.value) {\r\n const newSelectedValues = [...selectedValues];\r\n newSelectedValues.pop();\r\n setSelectedValues(newSelectedValues);\r\n if (onValueChange) onValueChange(newSelectedValues);\r\n }\r\n };\r\n\r\n const toggleOption = (option: string) => {\r\n const newSelectedValues = selectedValues.includes(option)\r\n ? selectedValues.filter((value) => value !== option)\r\n : [...selectedValues, option];\r\n setSelectedValues(newSelectedValues);\r\n if (onValueChange) onValueChange(newSelectedValues);\r\n };\r\n\r\n const handleClear = () => {\r\n setSelectedValues(\r\n selectedValues.filter(\r\n (value) => !options.map((o) => !o.disabled && o.value).includes(value)\r\n )\r\n );\r\n if (onValueChange) onValueChange([]);\r\n };\r\n\r\n const handleTogglePopover = () => {\r\n setIsPopoverOpen((prev) => !prev);\r\n };\r\n\r\n const clearExtraOptions = () => {\r\n const newSelectedValues = selectedValues.slice(0, maxCount);\r\n setSelectedValues(newSelectedValues);\r\n if (onValueChange) onValueChange(newSelectedValues);\r\n };\r\n\r\n const toggleAll = () => {\r\n if (selectedValues.length === options.length) {\r\n handleClear();\r\n } else {\r\n const allValues = options.map((option) => option.value);\r\n setSelectedValues(allValues);\r\n if (onValueChange) onValueChange(allValues);\r\n }\r\n };\r\n\r\n return (\r\n <Popover\r\n open={isPopoverOpen}\r\n onOpenChange={setIsPopoverOpen}\r\n modal={modalPopover}\r\n >\r\n <PopoverTrigger asChild className=\"w-full\">\r\n <Button\r\n ref={ref}\r\n data-testid={props.id}\r\n type=\"button\"\r\n disabled={disabled}\r\n onClick={handleTogglePopover}\r\n className={cn(\r\n \"flex w-full p-1 rounded-md border min-h-9 h-auto items-center justify-between bg-inherit hover:bg-inherit\",\r\n className\r\n )}\r\n >\r\n {selectedValues.length > 0 ? (\r\n <div className=\"flex justify-between items-center w-full\">\r\n <div className=\"flex flex-wrap items-center\">\r\n {selectedValues.slice(0, maxCount).map((value) => {\r\n const option = options.find((o) => o.value === value);\r\n const IconComponent = option?.icon;\r\n return (\r\n <Badge\r\n key={value}\r\n className={cn(\r\n isAnimating ? \"animate-bounce\" : \"\",\r\n multiSelectVariants({ variant })\r\n )}\r\n style={{ animationDuration: `${animation}s` }}\r\n >\r\n {IconComponent && (\r\n <IconComponent className=\"h-4 w-4 mr-2\" />\r\n )}\r\n {option?.label}\r\n {!option?.disabled && (\r\n <XCircle\r\n className=\"ml-2 h-4 w-4 cursor-pointer\"\r\n onClick={(event) => {\r\n event.stopPropagation();\r\n toggleOption(value);\r\n }}\r\n />\r\n )}\r\n </Badge>\r\n );\r\n })}\r\n {selectedValues.length > maxCount && (\r\n <Badge\r\n className={cn(\r\n \"bg-transparent text-foreground border-foreground/1 hover:bg-transparent\",\r\n isAnimating ? \"animate-bounce\" : \"\",\r\n multiSelectVariants({ variant })\r\n )}\r\n style={{ animationDuration: `${animation}s` }}\r\n >\r\n {`+ ${selectedValues.length - maxCount} more`}\r\n <XCircle\r\n className=\"ml-2 h-4 w-4 cursor-pointer\"\r\n onClick={(event) => {\r\n event.stopPropagation();\r\n clearExtraOptions();\r\n }}\r\n />\r\n </Badge>\r\n )}\r\n </div>\r\n <div className=\"flex items-center justify-between\">\r\n {options.filter((x) => x.disabled).length !==\r\n options.length && (\r\n <XIcon\r\n className=\"h-4 mx-2 cursor-pointer text-muted-foreground\"\r\n onClick={(event) => {\r\n event.stopPropagation();\r\n handleClear();\r\n }}\r\n />\r\n )}\r\n <Separator\r\n orientation=\"vertical\"\r\n className=\"flex min-h-6 h-full\"\r\n />\r\n <ChevronDown className=\"h-4 mx-2 cursor-pointer text-muted-foreground\" />\r\n </div>\r\n </div>\r\n ) : (\r\n <div className=\"flex items-center justify-between w-full mx-auto\">\r\n <span className=\"text-sm text-black mx-3 font-normal\">\r\n {placeholder}\r\n </span>\r\n <ChevronDown className=\"h-4 cursor-pointer text-muted-foreground mx-2\" />\r\n </div>\r\n )}\r\n </Button>\r\n </PopoverTrigger>\r\n <PopoverContent\r\n className=\"p-0\"\r\n onEscapeKeyDown={() => setIsPopoverOpen(false)}\r\n >\r\n <Command className=\"w-full\">\r\n <CommandInput\r\n data-testid={`${props.id}_search`}\r\n placeholder=\"Search...\"\r\n onKeyDown={handleInputKeyDown}\r\n />\r\n <CommandList>\r\n <CommandEmpty>No results found.</CommandEmpty>\r\n <CommandGroup>\r\n <CommandItem\r\n data-testid={`${props.id}_select_all`}\r\n key=\"all\"\r\n onSelect={toggleAll}\r\n className=\"cursor-pointer\"\r\n disabled={\r\n options.filter((x) => x.disabled).length === options.length\r\n }\r\n >\r\n <div\r\n className={cn(\r\n \"mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary\",\r\n selectedValues.length === options.length\r\n ? \"bg-primary text-primary-foreground\"\r\n : \"opacity-50 [&_svg]:invisible\"\r\n )}\r\n >\r\n <CheckIcon className=\"h-4 w-4\" />\r\n </div>\r\n <span>({selectAllLabel})</span>\r\n </CommandItem>\r\n {options.map((option) => {\r\n const isSelected = selectedValues.includes(option.value);\r\n return (\r\n <CommandItem\r\n data-testid={`${props.id}_${option.value}`}\r\n key={option.value}\r\n onSelect={() => toggleOption(option.value)}\r\n className=\"cursor-pointer\"\r\n disabled={option.disabled}\r\n >\r\n <div\r\n className={cn(\r\n \"mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary\",\r\n isSelected\r\n ? \"bg-primary text-primary-foreground\"\r\n : \"opacity-50 [&_svg]:invisible\"\r\n )}\r\n >\r\n <CheckIcon className=\"h-4 w-4\" />\r\n </div>\r\n {option.icon && (\r\n <option.icon className=\"mr-2 h-4 w-4 text-muted-foreground\" />\r\n )}\r\n <span>{option.label}</span>\r\n {option.children}\r\n </CommandItem>\r\n );\r\n })}\r\n </CommandGroup>\r\n <CommandSeparator />\r\n <CommandGroup>\r\n <div className=\"flex items-center justify-between\">\r\n {selectedValues.length > 0 && (\r\n <>\r\n <CommandItem\r\n data-testid={`${props.id}_clear`}\r\n onSelect={handleClear}\r\n className=\"flex-1 justify-center cursor-pointer\"\r\n disabled={\r\n options.filter((x) => x.disabled).length ===\r\n options.length\r\n }\r\n >\r\n Clear\r\n </CommandItem>\r\n <Separator\r\n orientation=\"vertical\"\r\n className=\"flex min-h-6 h-full\"\r\n />\r\n </>\r\n )}\r\n <CommandItem\r\n data-testid={`${props.id}_close`}\r\n onSelect={() => setIsPopoverOpen(false)}\r\n className=\"flex-1 justify-center cursor-pointer max-w-full\"\r\n >\r\n Close\r\n </CommandItem>\r\n </div>\r\n </CommandGroup>\r\n </CommandList>\r\n </Command>\r\n </PopoverContent>\r\n {animation > 0 && selectedValues.length > 0 && (\r\n <WandSparkles\r\n className={cn(\r\n \"cursor-pointer my-2 text-foreground bg-background w-3 h-3\",\r\n isAnimating ? \"\" : \"text-muted-foreground\"\r\n )}\r\n onClick={() => setIsAnimating(!isAnimating)}\r\n />\r\n )}\r\n </Popover>\r\n );\r\n }\r\n);\r\n\r\nMultiSelect.displayName = \"MultiSelect\";\r\n"],"mappings":";AAwPsB,SA2IF,UAlIM,KATJ;AArPtB,YAAY,WAAW;AACvB,SAAS,WAA8B;AACvC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,UAAU;AACnB,SAAS,iBAAiB;AAC1B,SAAS,cAAc;AACvB,SAAS,aAAa;AACtB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;A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YAAY,KAAK,eAAe,SAAS,KACxC;AAAA,YAAC;AAAA;AAAA,cACC,WAAW;AAAA,gBACT;AAAA,gBACA,cAAc,KAAK;AAAA,cACrB;AAAA,cACA,SAAS,MAAM,eAAe,CAAC,WAAW;AAAA;AAAA,UAC5C;AAAA;AAAA;AAAA,IAEJ;AAAA,EAEJ;AACF;AAEA,YAAY,cAAc;","names":[]}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cn } from "@repo/ayasofyazilim-ui/lib/utils";
|
|
4
|
+
import { EyeIcon, EyeOffIcon, RotateCcwKey } from "lucide-react";
|
|
5
|
+
import {
|
|
6
|
+
forwardRef,
|
|
7
|
+
useCallback,
|
|
8
|
+
useImperativeHandle,
|
|
9
|
+
useMemo,
|
|
10
|
+
useRef,
|
|
11
|
+
useState
|
|
12
|
+
} from "react";
|
|
13
|
+
import {
|
|
14
|
+
InputGroup,
|
|
15
|
+
InputGroupAddon,
|
|
16
|
+
InputGroupButton,
|
|
17
|
+
InputGroupInput
|
|
18
|
+
} from "../components/input-group";
|
|
19
|
+
const PasswordInput = forwardRef(
|
|
20
|
+
({ className, showGenerator = false, passwordLength = 10, ...props }, ref) => {
|
|
21
|
+
const [showPassword, setShowPassword] = useState(false);
|
|
22
|
+
const internalRef = useRef(null);
|
|
23
|
+
const { disabled } = props;
|
|
24
|
+
useImperativeHandle(ref, () => internalRef.current, []);
|
|
25
|
+
const characterSets = useMemo(() => {
|
|
26
|
+
const sets = {
|
|
27
|
+
lowercase: "abcdefghijklmnopqrstuvwxyz",
|
|
28
|
+
uppercase: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
|
29
|
+
numbers: "0123456789",
|
|
30
|
+
symbols: "!@#$%^&*()_+-=[]{}|;:,.<>?"
|
|
31
|
+
};
|
|
32
|
+
return {
|
|
33
|
+
...sets,
|
|
34
|
+
all: sets.lowercase + sets.uppercase + sets.numbers + sets.symbols
|
|
35
|
+
};
|
|
36
|
+
}, []);
|
|
37
|
+
const inputClassName = useMemo(
|
|
38
|
+
() => cn(
|
|
39
|
+
"hide-password-toggle",
|
|
40
|
+
showGenerator ? "pr-20" : "pr-10",
|
|
41
|
+
className
|
|
42
|
+
),
|
|
43
|
+
[showGenerator, className]
|
|
44
|
+
);
|
|
45
|
+
const getRandomInt = useCallback((max) => {
|
|
46
|
+
if (typeof window !== "undefined" && window.crypto?.getRandomValues) {
|
|
47
|
+
const array = new Uint32Array(1);
|
|
48
|
+
window.crypto.getRandomValues(array);
|
|
49
|
+
return (array[0] ?? 0) % max;
|
|
50
|
+
}
|
|
51
|
+
return Math.floor(Math.random() * max);
|
|
52
|
+
}, []);
|
|
53
|
+
const shuffleArray = useCallback(
|
|
54
|
+
(array) => {
|
|
55
|
+
const shuffled = [...array];
|
|
56
|
+
for (let i = shuffled.length - 1; i > 0; i--) {
|
|
57
|
+
const j = getRandomInt(i + 1);
|
|
58
|
+
const elemI = shuffled[i];
|
|
59
|
+
const elemJ = shuffled[j];
|
|
60
|
+
if (elemI !== void 0 && elemJ !== void 0) {
|
|
61
|
+
[shuffled[i], shuffled[j]] = [elemJ, elemI];
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return shuffled;
|
|
65
|
+
},
|
|
66
|
+
[getRandomInt]
|
|
67
|
+
);
|
|
68
|
+
const generatePassword = useCallback(
|
|
69
|
+
(length = passwordLength) => {
|
|
70
|
+
const { lowercase, uppercase, numbers, symbols, all } = characterSets;
|
|
71
|
+
const requiredChars = [
|
|
72
|
+
lowercase[getRandomInt(lowercase.length)],
|
|
73
|
+
uppercase[getRandomInt(uppercase.length)],
|
|
74
|
+
numbers[getRandomInt(numbers.length)],
|
|
75
|
+
symbols[getRandomInt(symbols.length)]
|
|
76
|
+
];
|
|
77
|
+
const remainingLength = Math.max(0, length - requiredChars.length);
|
|
78
|
+
const additionalChars = Array.from(
|
|
79
|
+
{ length: remainingLength },
|
|
80
|
+
() => all[getRandomInt(all.length)]
|
|
81
|
+
);
|
|
82
|
+
const allChars = [...requiredChars, ...additionalChars];
|
|
83
|
+
return shuffleArray(allChars).join("");
|
|
84
|
+
},
|
|
85
|
+
[passwordLength, characterSets, getRandomInt, shuffleArray]
|
|
86
|
+
);
|
|
87
|
+
const dispatchInputEvents = useCallback(
|
|
88
|
+
(input, value) => {
|
|
89
|
+
const _input = input;
|
|
90
|
+
const descriptor = Object.getOwnPropertyDescriptor(
|
|
91
|
+
HTMLInputElement.prototype,
|
|
92
|
+
"value"
|
|
93
|
+
);
|
|
94
|
+
if (descriptor?.set) {
|
|
95
|
+
descriptor.set.call(_input, value);
|
|
96
|
+
} else {
|
|
97
|
+
_input.value = value;
|
|
98
|
+
}
|
|
99
|
+
const inputEvent = new Event("input", { bubbles: true });
|
|
100
|
+
const changeEvent = new Event("change", { bubbles: true });
|
|
101
|
+
_input.dispatchEvent(inputEvent);
|
|
102
|
+
_input.dispatchEvent(changeEvent);
|
|
103
|
+
},
|
|
104
|
+
[]
|
|
105
|
+
);
|
|
106
|
+
const handleGeneratePassword = useCallback(() => {
|
|
107
|
+
if (disabled || !internalRef.current) return;
|
|
108
|
+
const newPassword = generatePassword(passwordLength);
|
|
109
|
+
dispatchInputEvents(internalRef.current, newPassword);
|
|
110
|
+
}, [disabled, generatePassword, passwordLength, dispatchInputEvents]);
|
|
111
|
+
const togglePasswordVisibility = useCallback(() => {
|
|
112
|
+
setShowPassword((prev) => !prev);
|
|
113
|
+
}, []);
|
|
114
|
+
return /* @__PURE__ */ jsxs(InputGroup, { children: [
|
|
115
|
+
/* @__PURE__ */ jsx(
|
|
116
|
+
InputGroupInput,
|
|
117
|
+
{
|
|
118
|
+
placeholder: props.placeholder,
|
|
119
|
+
className: inputClassName,
|
|
120
|
+
ref: internalRef,
|
|
121
|
+
...props,
|
|
122
|
+
type: showPassword ? "text" : "password"
|
|
123
|
+
}
|
|
124
|
+
),
|
|
125
|
+
/* @__PURE__ */ jsx(InputGroupAddon, { align: "inline-end", children: /* @__PURE__ */ jsx(
|
|
126
|
+
InputGroupButton,
|
|
127
|
+
{
|
|
128
|
+
id: "toggle-password-visibility-button",
|
|
129
|
+
variant: "ghost",
|
|
130
|
+
"aria-label": showPassword ? "Hide password" : "Show password",
|
|
131
|
+
size: "icon-xs",
|
|
132
|
+
onClick: togglePasswordVisibility,
|
|
133
|
+
disabled,
|
|
134
|
+
children: showPassword ? /* @__PURE__ */ jsx(EyeOffIcon, {}) : /* @__PURE__ */ jsx(EyeIcon, {})
|
|
135
|
+
}
|
|
136
|
+
) }),
|
|
137
|
+
showGenerator && /* @__PURE__ */ jsx(InputGroupAddon, { align: "inline-start", children: /* @__PURE__ */ jsxs(
|
|
138
|
+
InputGroupButton,
|
|
139
|
+
{
|
|
140
|
+
id: "generate-password-button",
|
|
141
|
+
variant: "ghost",
|
|
142
|
+
size: "icon-xs",
|
|
143
|
+
onClick: handleGeneratePassword,
|
|
144
|
+
disabled,
|
|
145
|
+
children: [
|
|
146
|
+
/* @__PURE__ */ jsx(RotateCcwKey, {}),
|
|
147
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: "Generate password" })
|
|
148
|
+
]
|
|
149
|
+
}
|
|
150
|
+
) })
|
|
151
|
+
] });
|
|
152
|
+
}
|
|
153
|
+
);
|
|
154
|
+
PasswordInput.displayName = "PasswordInput";
|
|
155
|
+
export {
|
|
156
|
+
PasswordInput
|
|
157
|
+
};
|
|
158
|
+
//# sourceMappingURL=password-input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/custom/password-input.tsx"],"sourcesContent":["\"use client\";\r\n\r\nimport { InputProps } from \"@repo/ayasofyazilim-ui/components/input\";\r\nimport { cn } from \"@repo/ayasofyazilim-ui/lib/utils\";\r\nimport { EyeIcon, EyeOffIcon, RotateCcwKey } from \"lucide-react\";\r\nimport {\r\n forwardRef,\r\n useCallback,\r\n useImperativeHandle,\r\n useMemo,\r\n useRef,\r\n useState,\r\n} from \"react\";\r\nimport {\r\n InputGroup,\r\n InputGroupAddon,\r\n InputGroupButton,\r\n InputGroupInput,\r\n} from \"../components/input-group\";\r\n\r\ninterface PasswordInputProps extends InputProps {\r\n passwordLength?: number;\r\n showGenerator?: boolean;\r\n}\r\n\r\nconst PasswordInput = forwardRef<HTMLInputElement, PasswordInputProps>(\r\n (\r\n { className, showGenerator = false, passwordLength = 10, ...props },\r\n ref\r\n ) => {\r\n const [showPassword, setShowPassword] = useState(false);\r\n const internalRef = useRef<HTMLInputElement>(null);\r\n const { disabled } = props;\r\n\r\n useImperativeHandle(ref, () => internalRef.current!, []);\r\n\r\n // Memoize character sets to avoid recreation on every render\r\n const characterSets = useMemo(() => {\r\n const sets = {\r\n lowercase: \"abcdefghijklmnopqrstuvwxyz\",\r\n uppercase: \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\",\r\n numbers: \"0123456789\",\r\n symbols: \"!@#$%^&*()_+-=[]{}|;:,.<>?\",\r\n };\r\n\r\n return {\r\n ...sets,\r\n all: sets.lowercase + sets.uppercase + sets.numbers + sets.symbols,\r\n };\r\n }, []);\r\n // Memoize class names to prevent unnecessary re-renders\r\n const inputClassName = useMemo(\r\n () =>\r\n cn(\r\n \"hide-password-toggle\",\r\n showGenerator ? \"pr-20\" : \"pr-10\",\r\n className\r\n ),\r\n [showGenerator, className]\r\n );\r\n\r\n // Use crypto.getRandomValues for better randomness when available\r\n const getRandomInt = useCallback((max: number): number => {\r\n if (typeof window !== \"undefined\" && window.crypto?.getRandomValues) {\r\n const array = new Uint32Array(1);\r\n window.crypto.getRandomValues(array);\r\n return (array[0] ?? 0) % max;\r\n }\r\n return Math.floor(Math.random() * max);\r\n }, []);\r\n\r\n // Fisher-Yates shuffle algorithm for better randomization\r\n const shuffleArray = useCallback(\r\n (array: string[]): string[] => {\r\n const shuffled = [...array];\r\n for (let i = shuffled.length - 1; i > 0; i--) {\r\n const j = getRandomInt(i + 1);\r\n const elemI = shuffled[i];\r\n const elemJ = shuffled[j];\r\n if (elemI !== undefined && elemJ !== undefined) {\r\n [shuffled[i], shuffled[j]] = [elemJ, elemI];\r\n }\r\n }\r\n return shuffled;\r\n },\r\n [getRandomInt]\r\n );\r\n\r\n const generatePassword = useCallback(\r\n (length: number = passwordLength): string => {\r\n const { lowercase, uppercase, numbers, symbols, all } = characterSets;\r\n\r\n // Ensure minimum requirements\r\n const requiredChars = [\r\n lowercase[getRandomInt(lowercase.length)],\r\n uppercase[getRandomInt(uppercase.length)],\r\n numbers[getRandomInt(numbers.length)],\r\n symbols[getRandomInt(symbols.length)],\r\n ];\r\n\r\n // Fill remaining positions\r\n const remainingLength = Math.max(0, length - requiredChars.length);\r\n const additionalChars = Array.from(\r\n { length: remainingLength },\r\n () => all[getRandomInt(all.length)]\r\n );\r\n\r\n // Combine and shuffle\r\n const allChars = [...requiredChars, ...additionalChars] as string[];\r\n return shuffleArray(allChars).join(\"\");\r\n },\r\n [passwordLength, characterSets, getRandomInt, shuffleArray]\r\n );\r\n\r\n // Optimized event dispatching\r\n const dispatchInputEvents = useCallback(\r\n (input: HTMLInputElement, value: string) => {\r\n const _input = input;\r\n // Use React's internal event system when possible\r\n const descriptor = Object.getOwnPropertyDescriptor(\r\n HTMLInputElement.prototype,\r\n \"value\"\r\n );\r\n if (descriptor?.set) {\r\n descriptor.set.call(_input, value);\r\n } else {\r\n _input.value = value;\r\n }\r\n\r\n // Dispatch events in the correct order\r\n const inputEvent = new Event(\"input\", { bubbles: true });\r\n const changeEvent = new Event(\"change\", { bubbles: true });\r\n\r\n _input.dispatchEvent(inputEvent);\r\n _input.dispatchEvent(changeEvent);\r\n },\r\n []\r\n );\r\n\r\n const handleGeneratePassword = useCallback(() => {\r\n if (disabled || !internalRef.current) return;\r\n\r\n const newPassword = generatePassword(passwordLength);\r\n dispatchInputEvents(internalRef.current, newPassword);\r\n }, [disabled, generatePassword, passwordLength, dispatchInputEvents]);\r\n\r\n const togglePasswordVisibility = useCallback(() => {\r\n setShowPassword((prev) => !prev);\r\n }, []);\r\n\r\n return (\r\n <InputGroup>\r\n <InputGroupInput\r\n placeholder={props.placeholder}\r\n className={inputClassName}\r\n ref={internalRef}\r\n {...props}\r\n type={showPassword ? \"text\" : \"password\"}\r\n />\r\n <InputGroupAddon align=\"inline-end\">\r\n <InputGroupButton\r\n id=\"toggle-password-visibility-button\"\r\n variant=\"ghost\"\r\n aria-label={showPassword ? \"Hide password\" : \"Show password\"}\r\n size=\"icon-xs\"\r\n onClick={togglePasswordVisibility}\r\n disabled={disabled}\r\n >\r\n {showPassword ? <EyeOffIcon /> : <EyeIcon />}\r\n </InputGroupButton>\r\n </InputGroupAddon>\r\n {showGenerator && (\r\n <InputGroupAddon align=\"inline-start\">\r\n <InputGroupButton\r\n id=\"generate-password-button\"\r\n variant=\"ghost\"\r\n size=\"icon-xs\"\r\n onClick={handleGeneratePassword}\r\n disabled={disabled}\r\n >\r\n <RotateCcwKey />\r\n <span className=\"sr-only\">Generate password</span>\r\n </InputGroupButton>\r\n </InputGroupAddon>\r\n )}\r\n </InputGroup>\r\n );\r\n }\r\n);\r\n\r\nPasswordInput.displayName = \"PasswordInput\";\r\n\r\nexport { PasswordInput };\r\nexport type { PasswordInputProps };\r\n"],"mappings":";AAwJQ,cAqBI,YArBJ;AArJR,SAAS,UAAU;AACnB,SAAS,SAAS,YAAY,oBAAoB;AAClD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAOP,MAAM,gBAAgB;AAAA,EACpB,CACE,EAAE,WAAW,gBAAgB,OAAO,iBAAiB,IAAI,GAAG,MAAM,GAClE,QACG;AACH,UAAM,CAAC,cAAc,eAAe,IAAI,SAAS,KAAK;AACtD,UAAM,cAAc,OAAyB,IAAI;AACjD,UAAM,EAAE,SAAS,IAAI;AAErB,wBAAoB,KAAK,MAAM,YAAY,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