@open-mercato/core 0.6.6-develop.6094.1.28b081ea16 → 0.6.6-develop.6121.1.5797a901b3
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/.turbo/turbo-build.log +1 -1
- package/dist/generated/entities/catalog_product/index.js +52 -0
- package/dist/generated/entities/catalog_product/index.js.map +2 -2
- package/dist/generated/entities/catalog_product_variant/index.js +4 -0
- package/dist/generated/entities/catalog_product_variant/index.js.map +2 -2
- package/dist/generated/entity-fields-registry.js +28 -0
- package/dist/generated/entity-fields-registry.js.map +2 -2
- package/dist/modules/catalog/api/products/route.js +103 -33
- package/dist/modules/catalog/api/products/route.js.map +2 -2
- package/dist/modules/catalog/api/variants/route.js +4 -0
- package/dist/modules/catalog/api/variants/route.js.map +2 -2
- package/dist/modules/catalog/backend/catalog/products/[id]/page.js +46 -2
- package/dist/modules/catalog/backend/catalog/products/[id]/page.js.map +2 -2
- package/dist/modules/catalog/backend/catalog/products/[productId]/variants/[variantId]/page.js +4 -0
- package/dist/modules/catalog/backend/catalog/products/[productId]/variants/[variantId]/page.js.map +2 -2
- package/dist/modules/catalog/backend/catalog/products/[productId]/variants/create/page.js +2 -0
- package/dist/modules/catalog/backend/catalog/products/[productId]/variants/create/page.js.map +2 -2
- package/dist/modules/catalog/backend/catalog/products/create/page.js +42 -2
- package/dist/modules/catalog/backend/catalog/products/create/page.js.map +2 -2
- package/dist/modules/catalog/commands/products.js +251 -14
- package/dist/modules/catalog/commands/products.js.map +2 -2
- package/dist/modules/catalog/commands/variants.js +72 -1
- package/dist/modules/catalog/commands/variants.js.map +2 -2
- package/dist/modules/catalog/components/products/ProductComplianceSection.js +500 -0
- package/dist/modules/catalog/components/products/ProductComplianceSection.js.map +7 -0
- package/dist/modules/catalog/components/products/VariantBuilder.js +39 -1
- package/dist/modules/catalog/components/products/VariantBuilder.js.map +2 -2
- package/dist/modules/catalog/components/products/productForm.js +164 -2
- package/dist/modules/catalog/components/products/productForm.js.map +2 -2
- package/dist/modules/catalog/components/products/variantForm.js +2 -0
- package/dist/modules/catalog/components/products/variantForm.js.map +2 -2
- package/dist/modules/catalog/data/entities.js +93 -0
- package/dist/modules/catalog/data/entities.js.map +2 -2
- package/dist/modules/catalog/data/types.js +28 -0
- package/dist/modules/catalog/data/types.js.map +2 -2
- package/dist/modules/catalog/data/validators.js +100 -5
- package/dist/modules/catalog/data/validators.js.map +2 -2
- package/dist/modules/catalog/lib/gtin.js +61 -0
- package/dist/modules/catalog/lib/gtin.js.map +7 -0
- package/dist/modules/catalog/migrations/Migration20260611090000.js +17 -0
- package/dist/modules/catalog/migrations/Migration20260611090000.js.map +7 -0
- package/dist/modules/catalog/translations.js +1 -1
- package/dist/modules/catalog/translations.js.map +2 -2
- package/dist/modules/configs/api/cache/route.js +60 -10
- package/dist/modules/configs/api/cache/route.js.map +3 -3
- package/dist/modules/configs/components/CachePanel.js +52 -29
- package/dist/modules/configs/components/CachePanel.js.map +2 -2
- package/dist/modules/currencies/api/currencies/options/route.js +18 -4
- package/dist/modules/currencies/api/currencies/options/route.js.map +2 -2
- package/dist/modules/currencies/services/rateFetchingService.js +35 -18
- package/dist/modules/currencies/services/rateFetchingService.js.map +2 -2
- package/dist/modules/customer_accounts/backend/customer_accounts/users/[id]/page.js +16 -16
- package/dist/modules/customer_accounts/backend/customer_accounts/users/[id]/page.js.map +2 -2
- package/dist/modules/customer_accounts/backend/customer_accounts/users/page.js +1 -1
- package/dist/modules/customer_accounts/backend/customer_accounts/users/page.js.map +2 -2
- package/dist/modules/customers/backend/calendar/page.js +10 -0
- package/dist/modules/customers/backend/calendar/page.js.map +7 -0
- package/dist/modules/customers/backend/calendar/page.meta.js +25 -0
- package/dist/modules/customers/backend/calendar/page.meta.js.map +7 -0
- package/dist/modules/customers/cli.js +1 -0
- package/dist/modules/customers/cli.js.map +2 -2
- package/dist/modules/customers/components/calendar/AgendaList.js +182 -0
- package/dist/modules/customers/components/calendar/AgendaList.js.map +7 -0
- package/dist/modules/customers/components/calendar/CalendarEventEditor.js +331 -0
- package/dist/modules/customers/components/calendar/CalendarEventEditor.js.map +7 -0
- package/dist/modules/customers/components/calendar/CalendarFooter.js +48 -0
- package/dist/modules/customers/components/calendar/CalendarFooter.js.map +7 -0
- package/dist/modules/customers/components/calendar/CalendarHeader.js +36 -0
- package/dist/modules/customers/components/calendar/CalendarHeader.js.map +7 -0
- package/dist/modules/customers/components/calendar/CalendarScreen.js +516 -0
- package/dist/modules/customers/components/calendar/CalendarScreen.js.map +7 -0
- package/dist/modules/customers/components/calendar/CalendarSettingsModal.js +163 -0
- package/dist/modules/customers/components/calendar/CalendarSettingsModal.js.map +7 -0
- package/dist/modules/customers/components/calendar/CalendarTabs.js +60 -0
- package/dist/modules/customers/components/calendar/CalendarTabs.js.map +7 -0
- package/dist/modules/customers/components/calendar/CalendarToolbar.js +262 -0
- package/dist/modules/customers/components/calendar/CalendarToolbar.js.map +7 -0
- package/dist/modules/customers/components/calendar/EventBlock.js +149 -0
- package/dist/modules/customers/components/calendar/EventBlock.js.map +7 -0
- package/dist/modules/customers/components/calendar/EventPeekPopover.js +72 -0
- package/dist/modules/customers/components/calendar/EventPeekPopover.js.map +7 -0
- package/dist/modules/customers/components/calendar/MonthGrid.js +214 -0
- package/dist/modules/customers/components/calendar/MonthGrid.js.map +7 -0
- package/dist/modules/customers/components/calendar/ShortcutsDialog.js +44 -0
- package/dist/modules/customers/components/calendar/ShortcutsDialog.js.map +7 -0
- package/dist/modules/customers/components/calendar/TimeGrid.js +410 -0
- package/dist/modules/customers/components/calendar/TimeGrid.js.map +7 -0
- package/dist/modules/customers/components/calendar/UpcomingCards.js +175 -0
- package/dist/modules/customers/components/calendar/UpcomingCards.js.map +7 -0
- package/dist/modules/customers/components/calendar/editor/CategoryField.js +75 -0
- package/dist/modules/customers/components/calendar/editor/CategoryField.js.map +7 -0
- package/dist/modules/customers/components/calendar/editor/LocationField.js +30 -0
- package/dist/modules/customers/components/calendar/editor/LocationField.js.map +7 -0
- package/dist/modules/customers/components/calendar/editor/PeopleField.js +135 -0
- package/dist/modules/customers/components/calendar/editor/PeopleField.js.map +7 -0
- package/dist/modules/customers/components/calendar/editor/RelatedToField.js +218 -0
- package/dist/modules/customers/components/calendar/editor/RelatedToField.js.map +7 -0
- package/dist/modules/customers/components/calendar/editor/RepeatField.js +119 -0
- package/dist/modules/customers/components/calendar/editor/RepeatField.js.map +7 -0
- package/dist/modules/customers/components/calendar/editor/ScheduleSection.js +83 -0
- package/dist/modules/customers/components/calendar/editor/ScheduleSection.js.map +7 -0
- package/dist/modules/customers/components/calendar/editor/SegmentGroup.js +44 -0
- package/dist/modules/customers/components/calendar/editor/SegmentGroup.js.map +7 -0
- package/dist/modules/customers/components/calendar/editor/hooks.js +132 -0
- package/dist/modules/customers/components/calendar/editor/hooks.js.map +7 -0
- package/dist/modules/customers/components/calendar/editor/inputs.js +160 -0
- package/dist/modules/customers/components/calendar/editor/inputs.js.map +7 -0
- package/dist/modules/customers/components/calendar/editor/lookups.js +107 -0
- package/dist/modules/customers/components/calendar/editor/lookups.js.map +7 -0
- package/dist/modules/customers/components/calendar/types.js +30 -0
- package/dist/modules/customers/components/calendar/types.js.map +7 -0
- package/dist/modules/customers/components/calendar/useCalendarItems.js +131 -0
- package/dist/modules/customers/components/calendar/useCalendarItems.js.map +7 -0
- package/dist/modules/customers/components/calendar/useCalendarPreferences.js +41 -0
- package/dist/modules/customers/components/calendar/useCalendarPreferences.js.map +7 -0
- package/dist/modules/customers/lib/calendar/categories.js +28 -0
- package/dist/modules/customers/lib/calendar/categories.js.map +7 -0
- package/dist/modules/customers/lib/calendar/conflicts.js +72 -0
- package/dist/modules/customers/lib/calendar/conflicts.js.map +7 -0
- package/dist/modules/customers/lib/calendar/editorPayload.js +271 -0
- package/dist/modules/customers/lib/calendar/editorPayload.js.map +7 -0
- package/dist/modules/customers/lib/calendar/grid.js +48 -0
- package/dist/modules/customers/lib/calendar/grid.js.map +7 -0
- package/dist/modules/customers/lib/calendar/layout.js +39 -0
- package/dist/modules/customers/lib/calendar/layout.js.map +7 -0
- package/dist/modules/customers/lib/calendar/mapItem.js +79 -0
- package/dist/modules/customers/lib/calendar/mapItem.js.map +7 -0
- package/dist/modules/customers/lib/calendar/preferences.js +71 -0
- package/dist/modules/customers/lib/calendar/preferences.js.map +7 -0
- package/dist/modules/customers/lib/calendar/range.js +46 -0
- package/dist/modules/customers/lib/calendar/range.js.map +7 -0
- package/dist/modules/customers/lib/calendar/recurrence.js +113 -0
- package/dist/modules/customers/lib/calendar/recurrence.js.map +7 -0
- package/dist/modules/dashboards/services/widgetDataService.js +5 -5
- package/dist/modules/dashboards/services/widgetDataService.js.map +2 -2
- package/dist/modules/dictionaries/api/[dictionaryId]/entries/[entryId]/route.js +61 -1
- package/dist/modules/dictionaries/api/[dictionaryId]/entries/[entryId]/route.js.map +2 -2
- package/dist/modules/dictionaries/api/[dictionaryId]/entries/route.js +33 -1
- package/dist/modules/dictionaries/api/[dictionaryId]/entries/route.js.map +2 -2
- package/dist/modules/dictionaries/api/[dictionaryId]/route.js +61 -1
- package/dist/modules/dictionaries/api/[dictionaryId]/route.js.map +2 -2
- package/dist/modules/dictionaries/api/route.js +33 -1
- package/dist/modules/dictionaries/api/route.js.map +2 -2
- package/dist/modules/feature_toggles/lib/queries.js +36 -52
- package/dist/modules/feature_toggles/lib/queries.js.map +2 -2
- package/dist/modules/perspectives/api/[tableId]/[perspectiveId]/route.js +32 -1
- package/dist/modules/perspectives/api/[tableId]/[perspectiveId]/route.js.map +2 -2
- package/dist/modules/perspectives/api/[tableId]/roles/[roleId]/route.js +32 -1
- package/dist/modules/perspectives/api/[tableId]/roles/[roleId]/route.js.map +2 -2
- package/dist/modules/perspectives/api/[tableId]/route.js +73 -2
- package/dist/modules/perspectives/api/[tableId]/route.js.map +2 -2
- package/dist/modules/perspectives/services/perspectiveService.js +5 -3
- package/dist/modules/perspectives/services/perspectiveService.js.map +2 -2
- package/dist/modules/planner/api/access.js +9 -0
- package/dist/modules/planner/api/access.js.map +2 -2
- package/dist/modules/planner/api/availability-date-specific.js +22 -1
- package/dist/modules/planner/api/availability-date-specific.js.map +2 -2
- package/dist/modules/planner/api/availability-weekly.js +22 -1
- package/dist/modules/planner/api/availability-weekly.js.map +2 -2
- package/dist/modules/resources/api/resources/tags/assign/route.js +39 -0
- package/dist/modules/resources/api/resources/tags/assign/route.js.map +2 -2
- package/dist/modules/resources/api/resources/tags/unassign/route.js +39 -0
- package/dist/modules/resources/api/resources/tags/unassign/route.js.map +2 -2
- package/dist/modules/sales/api/settings/document-numbers/route.js +33 -1
- package/dist/modules/sales/api/settings/document-numbers/route.js.map +2 -2
- package/dist/modules/sales/api/settings/order-editing/route.js +35 -3
- package/dist/modules/sales/api/settings/order-editing/route.js.map +2 -2
- package/dist/modules/staff/api/leave-requests/accept/route.js +41 -0
- package/dist/modules/staff/api/leave-requests/accept/route.js.map +2 -2
- package/dist/modules/staff/api/leave-requests/reject/route.js +41 -0
- package/dist/modules/staff/api/leave-requests/reject/route.js.map +2 -2
- package/dist/modules/staff/api/team-members/self/route.js +40 -0
- package/dist/modules/staff/api/team-members/self/route.js.map +2 -2
- package/dist/modules/staff/api/team-members/tags/assign/route.js +41 -0
- package/dist/modules/staff/api/team-members/tags/assign/route.js.map +2 -2
- package/dist/modules/staff/api/team-members/tags/unassign/route.js +41 -0
- package/dist/modules/staff/api/team-members/tags/unassign/route.js.map +2 -2
- package/dist/modules/translations/api/[entityType]/[entityId]/route.js +61 -1
- package/dist/modules/translations/api/[entityType]/[entityId]/route.js.map +2 -2
- package/dist/modules/translations/api/context.js +7 -0
- package/dist/modules/translations/api/context.js.map +2 -2
- package/dist/modules/translations/api/put/locales.js +33 -1
- package/dist/modules/translations/api/put/locales.js.map +2 -2
- package/dist/modules/workflows/backend/definitions/visual-editor/page.js +6 -7
- package/dist/modules/workflows/backend/definitions/visual-editor/page.js.map +2 -2
- package/dist/modules/workflows/backend/instances/[id]/page.js.map +1 -1
- package/dist/modules/workflows/components/EdgeEditDialog.js.map +1 -1
- package/dist/modules/workflows/components/EdgeEditDialogCrudForm.js.map +1 -1
- package/dist/modules/workflows/components/NodeEditDialog.js.map +1 -1
- package/dist/modules/workflows/components/NodeEditDialogCrudForm.js.map +1 -1
- package/dist/modules/workflows/components/WorkflowGraph.js.map +1 -1
- package/dist/modules/workflows/components/WorkflowGraphImpl.js +17 -9
- package/dist/modules/workflows/components/WorkflowGraphImpl.js.map +2 -2
- package/dist/modules/workflows/components/mobile/MobileVisualEditor.js.map +1 -1
- package/dist/modules/workflows/frontend/checkout-demo/deriveCurrentStep.js +8 -0
- package/dist/modules/workflows/frontend/checkout-demo/deriveCurrentStep.js.map +7 -0
- package/dist/modules/workflows/frontend/checkout-demo/page.js +2 -20
- package/dist/modules/workflows/frontend/checkout-demo/page.js.map +2 -2
- package/dist/modules/workflows/lib/graph-utils.js +8 -0
- package/dist/modules/workflows/lib/graph-utils.js.map +2 -2
- package/generated/entities/catalog_product/index.ts +26 -0
- package/generated/entities/catalog_product_variant/index.ts +2 -0
- package/generated/entity-fields-registry.ts +28 -0
- package/package.json +7 -7
- package/src/modules/catalog/api/products/route.ts +123 -39
- package/src/modules/catalog/api/variants/route.ts +4 -0
- package/src/modules/catalog/backend/catalog/products/[id]/page.tsx +43 -0
- package/src/modules/catalog/backend/catalog/products/[productId]/variants/[variantId]/page.tsx +14 -0
- package/src/modules/catalog/backend/catalog/products/[productId]/variants/create/page.tsx +2 -0
- package/src/modules/catalog/backend/catalog/products/create/page.tsx +41 -0
- package/src/modules/catalog/commands/products.ts +307 -2
- package/src/modules/catalog/commands/variants.ts +90 -1
- package/src/modules/catalog/components/products/ProductComplianceSection.tsx +497 -0
- package/src/modules/catalog/components/products/VariantBuilder.tsx +43 -0
- package/src/modules/catalog/components/products/productForm.ts +262 -0
- package/src/modules/catalog/components/products/variantForm.ts +4 -0
- package/src/modules/catalog/data/entities.ts +97 -0
- package/src/modules/catalog/data/types.ts +36 -0
- package/src/modules/catalog/data/validators.ts +159 -3
- package/src/modules/catalog/i18n/de.json +64 -0
- package/src/modules/catalog/i18n/en.json +64 -0
- package/src/modules/catalog/i18n/es.json +64 -0
- package/src/modules/catalog/i18n/pl.json +64 -0
- package/src/modules/catalog/lib/gtin.ts +66 -0
- package/src/modules/catalog/migrations/.snapshot-open-mercato.json +457 -0
- package/src/modules/catalog/migrations/Migration20260611090000.ts +17 -0
- package/src/modules/catalog/translations.ts +1 -1
- package/src/modules/configs/api/cache/route.ts +72 -10
- package/src/modules/configs/components/CachePanel.tsx +59 -29
- package/src/modules/currencies/api/currencies/options/route.ts +22 -4
- package/src/modules/currencies/services/rateFetchingService.ts +63 -26
- package/src/modules/customer_accounts/backend/customer_accounts/users/[id]/page.tsx +18 -18
- package/src/modules/customer_accounts/backend/customer_accounts/users/page.tsx +1 -1
- package/src/modules/customer_accounts/i18n/de.json +1 -1
- package/src/modules/customer_accounts/i18n/en.json +1 -1
- package/src/modules/customer_accounts/i18n/es.json +1 -1
- package/src/modules/customer_accounts/i18n/pl.json +1 -1
- package/src/modules/customers/backend/calendar/page.meta.ts +23 -0
- package/src/modules/customers/backend/calendar/page.tsx +12 -0
- package/src/modules/customers/cli.ts +1 -0
- package/src/modules/customers/components/calendar/AgendaList.tsx +219 -0
- package/src/modules/customers/components/calendar/CalendarEventEditor.tsx +386 -0
- package/src/modules/customers/components/calendar/CalendarFooter.tsx +61 -0
- package/src/modules/customers/components/calendar/CalendarHeader.tsx +40 -0
- package/src/modules/customers/components/calendar/CalendarScreen.tsx +590 -0
- package/src/modules/customers/components/calendar/CalendarSettingsModal.tsx +207 -0
- package/src/modules/customers/components/calendar/CalendarTabs.tsx +63 -0
- package/src/modules/customers/components/calendar/CalendarToolbar.tsx +295 -0
- package/src/modules/customers/components/calendar/EventBlock.tsx +205 -0
- package/src/modules/customers/components/calendar/EventPeekPopover.tsx +100 -0
- package/src/modules/customers/components/calendar/MonthGrid.tsx +236 -0
- package/src/modules/customers/components/calendar/ShortcutsDialog.tsx +57 -0
- package/src/modules/customers/components/calendar/TimeGrid.tsx +510 -0
- package/src/modules/customers/components/calendar/UpcomingCards.tsx +220 -0
- package/src/modules/customers/components/calendar/editor/CategoryField.tsx +79 -0
- package/src/modules/customers/components/calendar/editor/LocationField.tsx +37 -0
- package/src/modules/customers/components/calendar/editor/PeopleField.tsx +148 -0
- package/src/modules/customers/components/calendar/editor/RelatedToField.tsx +242 -0
- package/src/modules/customers/components/calendar/editor/RepeatField.tsx +132 -0
- package/src/modules/customers/components/calendar/editor/ScheduleSection.tsx +110 -0
- package/src/modules/customers/components/calendar/editor/SegmentGroup.tsx +50 -0
- package/src/modules/customers/components/calendar/editor/hooks.ts +162 -0
- package/src/modules/customers/components/calendar/editor/inputs.tsx +158 -0
- package/src/modules/customers/components/calendar/editor/lookups.ts +160 -0
- package/src/modules/customers/components/calendar/types.ts +163 -0
- package/src/modules/customers/components/calendar/useCalendarItems.ts +162 -0
- package/src/modules/customers/components/calendar/useCalendarPreferences.ts +52 -0
- package/src/modules/customers/i18n/de.json +195 -0
- package/src/modules/customers/i18n/en.json +195 -0
- package/src/modules/customers/i18n/es.json +195 -0
- package/src/modules/customers/i18n/pl.json +195 -0
- package/src/modules/customers/lib/calendar/categories.ts +26 -0
- package/src/modules/customers/lib/calendar/conflicts.ts +117 -0
- package/src/modules/customers/lib/calendar/editorPayload.ts +388 -0
- package/src/modules/customers/lib/calendar/grid.ts +50 -0
- package/src/modules/customers/lib/calendar/layout.ts +47 -0
- package/src/modules/customers/lib/calendar/mapItem.ts +94 -0
- package/src/modules/customers/lib/calendar/preferences.ts +95 -0
- package/src/modules/customers/lib/calendar/range.ts +45 -0
- package/src/modules/customers/lib/calendar/recurrence.ts +137 -0
- package/src/modules/dashboards/services/widgetDataService.ts +8 -6
- package/src/modules/dictionaries/api/[dictionaryId]/entries/[entryId]/route.ts +61 -1
- package/src/modules/dictionaries/api/[dictionaryId]/entries/route.ts +33 -1
- package/src/modules/dictionaries/api/[dictionaryId]/route.ts +65 -1
- package/src/modules/dictionaries/api/route.ts +36 -1
- package/src/modules/feature_toggles/lib/queries.ts +41 -60
- package/src/modules/perspectives/api/[tableId]/[perspectiveId]/route.ts +34 -1
- package/src/modules/perspectives/api/[tableId]/roles/[roleId]/route.ts +34 -1
- package/src/modules/perspectives/api/[tableId]/route.ts +107 -32
- package/src/modules/perspectives/services/perspectiveService.ts +9 -5
- package/src/modules/planner/api/access.ts +9 -0
- package/src/modules/planner/api/availability-date-specific.ts +22 -1
- package/src/modules/planner/api/availability-weekly.ts +22 -1
- package/src/modules/resources/api/resources/tags/assign/route.ts +42 -0
- package/src/modules/resources/api/resources/tags/unassign/route.ts +42 -0
- package/src/modules/sales/api/settings/document-numbers/route.ts +35 -1
- package/src/modules/sales/api/settings/order-editing/route.ts +37 -3
- package/src/modules/staff/api/leave-requests/accept/route.ts +45 -0
- package/src/modules/staff/api/leave-requests/reject/route.ts +45 -0
- package/src/modules/staff/api/team-members/self/route.ts +43 -0
- package/src/modules/staff/api/team-members/tags/assign/route.ts +45 -0
- package/src/modules/staff/api/team-members/tags/unassign/route.ts +45 -0
- package/src/modules/translations/api/[entityType]/[entityId]/route.ts +65 -1
- package/src/modules/translations/api/context.ts +7 -0
- package/src/modules/translations/api/put/locales.ts +35 -1
- package/src/modules/workflows/backend/definitions/visual-editor/page.tsx +11 -9
- package/src/modules/workflows/backend/instances/[id]/page.tsx +1 -1
- package/src/modules/workflows/components/EdgeEditDialog.tsx +1 -1
- package/src/modules/workflows/components/EdgeEditDialogCrudForm.tsx +1 -1
- package/src/modules/workflows/components/NodeEditDialog.tsx +1 -1
- package/src/modules/workflows/components/NodeEditDialogCrudForm.tsx +1 -1
- package/src/modules/workflows/components/WorkflowGraph.tsx +2 -2
- package/src/modules/workflows/components/WorkflowGraphImpl.tsx +27 -13
- package/src/modules/workflows/components/mobile/MobileVisualEditor.tsx +3 -3
- package/src/modules/workflows/frontend/checkout-demo/deriveCurrentStep.ts +12 -0
- package/src/modules/workflows/frontend/checkout-demo/page.tsx +3 -23
- package/src/modules/workflows/lib/graph-utils.ts +21 -1
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { differenceInCalendarDays } from "date-fns/differenceInCalendarDays";
|
|
4
|
+
import { format } from "date-fns/format";
|
|
5
|
+
import { AlertTriangle, ChevronDown, Clock } from "lucide-react";
|
|
6
|
+
import { Button } from "@open-mercato/ui/primitives/button";
|
|
7
|
+
import { IconButton } from "@open-mercato/ui/primitives/icon-button";
|
|
8
|
+
import { LinkButton } from "@open-mercato/ui/primitives/link-button";
|
|
9
|
+
import {
|
|
10
|
+
Popover,
|
|
11
|
+
PopoverClose,
|
|
12
|
+
PopoverContent,
|
|
13
|
+
PopoverTrigger
|
|
14
|
+
} from "@open-mercato/ui/primitives/popover";
|
|
15
|
+
import { useT } from "@open-mercato/shared/lib/i18n/context";
|
|
16
|
+
function formatTimeRange(item, allDayLabel) {
|
|
17
|
+
if (item.allDay) return allDayLabel;
|
|
18
|
+
return `${format(item.start, "h:mm a")} \u2013 ${format(item.end, "h:mm a")}`;
|
|
19
|
+
}
|
|
20
|
+
function canJoin(item) {
|
|
21
|
+
return item.locationKind === "url" || item.locationKind === "platform";
|
|
22
|
+
}
|
|
23
|
+
function UpcomingCardStatus({
|
|
24
|
+
card,
|
|
25
|
+
onJoin,
|
|
26
|
+
onSeeConflict
|
|
27
|
+
}) {
|
|
28
|
+
const t = useT();
|
|
29
|
+
const { item, kind, conflictCount } = card;
|
|
30
|
+
if (kind === "today") {
|
|
31
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center gap-1.5 rounded-lg bg-status-success-bg py-2 pl-2 pr-3", children: [
|
|
32
|
+
/* @__PURE__ */ jsx(Clock, { className: "size-4 shrink-0 text-status-success-icon", "aria-hidden": "true" }),
|
|
33
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate text-xs font-medium text-foreground", children: t("customers.calendar.cards.today", "Today") }),
|
|
34
|
+
canJoin(item) ? /* @__PURE__ */ jsx(
|
|
35
|
+
LinkButton,
|
|
36
|
+
{
|
|
37
|
+
variant: "gray",
|
|
38
|
+
size: "sm",
|
|
39
|
+
underline: "always",
|
|
40
|
+
onClick: () => onJoin(item),
|
|
41
|
+
className: "shrink-0",
|
|
42
|
+
children: t("customers.calendar.cards.join", "Join Meeting")
|
|
43
|
+
}
|
|
44
|
+
) : null
|
|
45
|
+
] });
|
|
46
|
+
}
|
|
47
|
+
if (kind === "conflicted") {
|
|
48
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center gap-1.5 rounded-lg bg-status-warning-bg py-2 pl-2 pr-3", children: [
|
|
49
|
+
/* @__PURE__ */ jsx(AlertTriangle, { className: "size-4 shrink-0 text-status-warning-icon", "aria-hidden": "true" }),
|
|
50
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate text-xs font-medium text-foreground", children: t("customers.calendar.cards.conflictedCount", "{count} Conflicted", {
|
|
51
|
+
count: conflictCount
|
|
52
|
+
}) }),
|
|
53
|
+
/* @__PURE__ */ jsx(
|
|
54
|
+
LinkButton,
|
|
55
|
+
{
|
|
56
|
+
variant: "gray",
|
|
57
|
+
size: "sm",
|
|
58
|
+
underline: "always",
|
|
59
|
+
onClick: () => onSeeConflict(item),
|
|
60
|
+
className: "shrink-0",
|
|
61
|
+
children: t("customers.calendar.cards.seeConflict", "See Conflict")
|
|
62
|
+
}
|
|
63
|
+
)
|
|
64
|
+
] });
|
|
65
|
+
}
|
|
66
|
+
if (kind === "cancelled") {
|
|
67
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center gap-1.5 rounded-lg bg-status-error-bg py-2 pl-2 pr-3", children: [
|
|
68
|
+
/* @__PURE__ */ jsx(Clock, { className: "size-4 shrink-0 text-status-error-icon", "aria-hidden": "true" }),
|
|
69
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate text-xs font-medium text-foreground", children: t("customers.calendar.cards.cancelled", "Cancelled") }),
|
|
70
|
+
/* @__PURE__ */ jsx("span", { className: "shrink-0 text-xs text-muted-foreground", children: format(item.start, "MMM dd, yyyy") })
|
|
71
|
+
] });
|
|
72
|
+
}
|
|
73
|
+
const daysLater = Math.max(0, differenceInCalendarDays(item.start, /* @__PURE__ */ new Date()));
|
|
74
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center gap-1.5 rounded-lg bg-muted py-2 pl-2 pr-3", children: [
|
|
75
|
+
/* @__PURE__ */ jsx(Clock, { className: "size-4 shrink-0 text-muted-foreground", "aria-hidden": "true" }),
|
|
76
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate text-xs text-muted-foreground", children: daysLater === 1 ? t("customers.calendar.cards.dayLater", "1 day later") : t("customers.calendar.cards.daysLater", "{days} days later", { days: daysLater }) }),
|
|
77
|
+
/* @__PURE__ */ jsx("span", { className: "shrink-0 text-xs text-muted-foreground", children: format(item.start, "MMM dd, yyyy") })
|
|
78
|
+
] });
|
|
79
|
+
}
|
|
80
|
+
function UpcomingCardItem({
|
|
81
|
+
card,
|
|
82
|
+
canManage,
|
|
83
|
+
onJoin,
|
|
84
|
+
onSeeConflict,
|
|
85
|
+
onOpen,
|
|
86
|
+
onEdit,
|
|
87
|
+
onCancel
|
|
88
|
+
}) {
|
|
89
|
+
const t = useT();
|
|
90
|
+
const { item } = card;
|
|
91
|
+
return /* @__PURE__ */ jsxs("article", { className: "flex w-[260px] shrink-0 snap-start flex-col gap-3 rounded-xl border bg-card px-2 pb-2 pt-4 shadow-xs sm:w-auto sm:shrink", children: [
|
|
92
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2 px-2", children: [
|
|
93
|
+
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
|
|
94
|
+
/* @__PURE__ */ jsx("p", { className: "truncate text-sm font-medium text-foreground", children: item.title }),
|
|
95
|
+
/* @__PURE__ */ jsx("p", { className: "truncate text-xs text-muted-foreground", children: formatTimeRange(item, t("customers.calendar.cards.allDay", "All day")) })
|
|
96
|
+
] }),
|
|
97
|
+
/* @__PURE__ */ jsxs(Popover, { children: [
|
|
98
|
+
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
99
|
+
IconButton,
|
|
100
|
+
{
|
|
101
|
+
variant: "outline",
|
|
102
|
+
size: "xs",
|
|
103
|
+
fullRadius: true,
|
|
104
|
+
"aria-label": t("customers.calendar.cards.menu.label", "Event actions"),
|
|
105
|
+
children: /* @__PURE__ */ jsx(ChevronDown, { "aria-hidden": "true" })
|
|
106
|
+
}
|
|
107
|
+
) }),
|
|
108
|
+
/* @__PURE__ */ jsxs(PopoverContent, { align: "end", className: "w-40 min-w-0 p-1", children: [
|
|
109
|
+
/* @__PURE__ */ jsx(PopoverClose, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
110
|
+
Button,
|
|
111
|
+
{
|
|
112
|
+
type: "button",
|
|
113
|
+
variant: "ghost",
|
|
114
|
+
size: "sm",
|
|
115
|
+
className: "w-full justify-start",
|
|
116
|
+
onClick: () => onOpen(item),
|
|
117
|
+
children: t("customers.calendar.cards.menu.open", "Open")
|
|
118
|
+
}
|
|
119
|
+
) }),
|
|
120
|
+
canManage ? /* @__PURE__ */ jsx(PopoverClose, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
121
|
+
Button,
|
|
122
|
+
{
|
|
123
|
+
type: "button",
|
|
124
|
+
variant: "ghost",
|
|
125
|
+
size: "sm",
|
|
126
|
+
className: "w-full justify-start",
|
|
127
|
+
onClick: () => onEdit(item),
|
|
128
|
+
children: t("customers.calendar.cards.menu.edit", "Edit")
|
|
129
|
+
}
|
|
130
|
+
) }) : null,
|
|
131
|
+
canManage ? /* @__PURE__ */ jsx(PopoverClose, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
132
|
+
Button,
|
|
133
|
+
{
|
|
134
|
+
type: "button",
|
|
135
|
+
variant: "destructive-ghost",
|
|
136
|
+
size: "sm",
|
|
137
|
+
className: "w-full justify-start",
|
|
138
|
+
onClick: () => onCancel(item),
|
|
139
|
+
children: t("customers.calendar.cards.menu.cancel", "Cancel")
|
|
140
|
+
}
|
|
141
|
+
) }) : null
|
|
142
|
+
] })
|
|
143
|
+
] })
|
|
144
|
+
] }),
|
|
145
|
+
/* @__PURE__ */ jsx(UpcomingCardStatus, { card, onJoin, onSeeConflict })
|
|
146
|
+
] });
|
|
147
|
+
}
|
|
148
|
+
function UpcomingCards({
|
|
149
|
+
cards,
|
|
150
|
+
canManage = true,
|
|
151
|
+
onJoin,
|
|
152
|
+
onSeeConflict,
|
|
153
|
+
onOpen,
|
|
154
|
+
onEdit,
|
|
155
|
+
onCancel
|
|
156
|
+
}) {
|
|
157
|
+
if (cards.length === 0) return null;
|
|
158
|
+
return /* @__PURE__ */ jsx("div", { className: "flex snap-x snap-mandatory gap-3 overflow-x-auto pb-1 sm:grid sm:snap-none sm:grid-cols-2 sm:gap-4 sm:overflow-visible sm:pb-0 xl:grid-cols-4", children: cards.map((card) => /* @__PURE__ */ jsx(
|
|
159
|
+
UpcomingCardItem,
|
|
160
|
+
{
|
|
161
|
+
card,
|
|
162
|
+
canManage,
|
|
163
|
+
onJoin,
|
|
164
|
+
onSeeConflict,
|
|
165
|
+
onOpen,
|
|
166
|
+
onEdit,
|
|
167
|
+
onCancel
|
|
168
|
+
},
|
|
169
|
+
card.item.id
|
|
170
|
+
)) });
|
|
171
|
+
}
|
|
172
|
+
export {
|
|
173
|
+
UpcomingCards
|
|
174
|
+
};
|
|
175
|
+
//# sourceMappingURL=UpcomingCards.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/modules/customers/components/calendar/UpcomingCards.tsx"],
|
|
4
|
+
"sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport { differenceInCalendarDays } from 'date-fns/differenceInCalendarDays'\nimport { format } from 'date-fns/format'\nimport { AlertTriangle, ChevronDown, Clock } from 'lucide-react'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { IconButton } from '@open-mercato/ui/primitives/icon-button'\nimport { LinkButton } from '@open-mercato/ui/primitives/link-button'\nimport {\n Popover,\n PopoverClose,\n PopoverContent,\n PopoverTrigger,\n} from '@open-mercato/ui/primitives/popover'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport type { CalendarItem, UpcomingCard, UpcomingCardsProps } from './types'\n\nfunction formatTimeRange(item: CalendarItem, allDayLabel: string): string {\n if (item.allDay) return allDayLabel\n return `${format(item.start, 'h:mm a')} \u2013 ${format(item.end, 'h:mm a')}`\n}\n\nfunction canJoin(item: CalendarItem): boolean {\n return item.locationKind === 'url' || item.locationKind === 'platform'\n}\n\ntype CardCallbacks = Pick<UpcomingCardsProps, 'canManage' | 'onJoin' | 'onSeeConflict' | 'onOpen' | 'onEdit' | 'onCancel'>\n\nfunction UpcomingCardStatus({\n card,\n onJoin,\n onSeeConflict,\n}: {\n card: UpcomingCard\n onJoin: UpcomingCardsProps['onJoin']\n onSeeConflict: UpcomingCardsProps['onSeeConflict']\n}) {\n const t = useT()\n const { item, kind, conflictCount } = card\n\n if (kind === 'today') {\n return (\n <div className=\"flex w-full items-center gap-1.5 rounded-lg bg-status-success-bg py-2 pl-2 pr-3\">\n <Clock className=\"size-4 shrink-0 text-status-success-icon\" aria-hidden=\"true\" />\n <span className=\"min-w-0 flex-1 truncate text-xs font-medium text-foreground\">\n {t('customers.calendar.cards.today', 'Today')}\n </span>\n {canJoin(item) ? (\n <LinkButton\n variant=\"gray\"\n size=\"sm\"\n underline=\"always\"\n onClick={() => onJoin(item)}\n className=\"shrink-0\"\n >\n {t('customers.calendar.cards.join', 'Join Meeting')}\n </LinkButton>\n ) : null}\n </div>\n )\n }\n\n if (kind === 'conflicted') {\n return (\n <div className=\"flex w-full items-center gap-1.5 rounded-lg bg-status-warning-bg py-2 pl-2 pr-3\">\n <AlertTriangle className=\"size-4 shrink-0 text-status-warning-icon\" aria-hidden=\"true\" />\n <span className=\"min-w-0 flex-1 truncate text-xs font-medium text-foreground\">\n {t('customers.calendar.cards.conflictedCount', '{count} Conflicted', {\n count: conflictCount,\n })}\n </span>\n <LinkButton\n variant=\"gray\"\n size=\"sm\"\n underline=\"always\"\n onClick={() => onSeeConflict(item)}\n className=\"shrink-0\"\n >\n {t('customers.calendar.cards.seeConflict', 'See Conflict')}\n </LinkButton>\n </div>\n )\n }\n\n if (kind === 'cancelled') {\n return (\n <div className=\"flex w-full items-center gap-1.5 rounded-lg bg-status-error-bg py-2 pl-2 pr-3\">\n <Clock className=\"size-4 shrink-0 text-status-error-icon\" aria-hidden=\"true\" />\n <span className=\"min-w-0 flex-1 truncate text-xs font-medium text-foreground\">\n {t('customers.calendar.cards.cancelled', 'Cancelled')}\n </span>\n <span className=\"shrink-0 text-xs text-muted-foreground\">\n {format(item.start, 'MMM dd, yyyy')}\n </span>\n </div>\n )\n }\n\n const daysLater = Math.max(0, differenceInCalendarDays(item.start, new Date()))\n return (\n <div className=\"flex w-full items-center gap-1.5 rounded-lg bg-muted py-2 pl-2 pr-3\">\n <Clock className=\"size-4 shrink-0 text-muted-foreground\" aria-hidden=\"true\" />\n <span className=\"min-w-0 flex-1 truncate text-xs text-muted-foreground\">\n {daysLater === 1\n ? t('customers.calendar.cards.dayLater', '1 day later')\n : t('customers.calendar.cards.daysLater', '{days} days later', { days: daysLater })}\n </span>\n <span className=\"shrink-0 text-xs text-muted-foreground\">\n {format(item.start, 'MMM dd, yyyy')}\n </span>\n </div>\n )\n}\n\nfunction UpcomingCardItem({\n card,\n canManage,\n onJoin,\n onSeeConflict,\n onOpen,\n onEdit,\n onCancel,\n}: { card: UpcomingCard } & CardCallbacks) {\n const t = useT()\n const { item } = card\n\n return (\n <article className=\"flex w-[260px] shrink-0 snap-start flex-col gap-3 rounded-xl border bg-card px-2 pb-2 pt-4 shadow-xs sm:w-auto sm:shrink\">\n <div className=\"flex items-start gap-2 px-2\">\n <div className=\"flex min-w-0 flex-1 flex-col gap-1\">\n <p className=\"truncate text-sm font-medium text-foreground\">{item.title}</p>\n <p className=\"truncate text-xs text-muted-foreground\">\n {formatTimeRange(item, t('customers.calendar.cards.allDay', 'All day'))}\n </p>\n </div>\n <Popover>\n <PopoverTrigger asChild>\n <IconButton\n variant=\"outline\"\n size=\"xs\"\n fullRadius\n aria-label={t('customers.calendar.cards.menu.label', 'Event actions')}\n >\n <ChevronDown aria-hidden=\"true\" />\n </IconButton>\n </PopoverTrigger>\n <PopoverContent align=\"end\" className=\"w-40 min-w-0 p-1\">\n <PopoverClose asChild>\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n className=\"w-full justify-start\"\n onClick={() => onOpen(item)}\n >\n {t('customers.calendar.cards.menu.open', 'Open')}\n </Button>\n </PopoverClose>\n {canManage ? (\n <PopoverClose asChild>\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n className=\"w-full justify-start\"\n onClick={() => onEdit(item)}\n >\n {t('customers.calendar.cards.menu.edit', 'Edit')}\n </Button>\n </PopoverClose>\n ) : null}\n {canManage ? (\n <PopoverClose asChild>\n <Button\n type=\"button\"\n variant=\"destructive-ghost\"\n size=\"sm\"\n className=\"w-full justify-start\"\n onClick={() => onCancel(item)}\n >\n {t('customers.calendar.cards.menu.cancel', 'Cancel')}\n </Button>\n </PopoverClose>\n ) : null}\n </PopoverContent>\n </Popover>\n </div>\n <UpcomingCardStatus card={card} onJoin={onJoin} onSeeConflict={onSeeConflict} />\n </article>\n )\n}\n\nexport function UpcomingCards({\n cards,\n canManage = true,\n onJoin,\n onSeeConflict,\n onOpen,\n onEdit,\n onCancel,\n}: UpcomingCardsProps) {\n if (cards.length === 0) return null\n return (\n <div className=\"flex snap-x snap-mandatory gap-3 overflow-x-auto pb-1 sm:grid sm:snap-none sm:grid-cols-2 sm:gap-4 sm:overflow-visible sm:pb-0 xl:grid-cols-4\">\n {cards.map((card) => (\n <UpcomingCardItem\n key={card.item.id}\n card={card}\n canManage={canManage}\n onJoin={onJoin}\n onSeeConflict={onSeeConflict}\n onOpen={onOpen}\n onEdit={onEdit}\n onCancel={onCancel}\n />\n ))}\n </div>\n )\n}\n"],
|
|
5
|
+
"mappings": ";AA2CM,SACE,KADF;AAxCN,SAAS,gCAAgC;AACzC,SAAS,cAAc;AACvB,SAAS,eAAe,aAAa,aAAa;AAClD,SAAS,cAAc;AACvB,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB;AAC3B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,YAAY;AAGrB,SAAS,gBAAgB,MAAoB,aAA6B;AACxE,MAAI,KAAK,OAAQ,QAAO;AACxB,SAAO,GAAG,OAAO,KAAK,OAAO,QAAQ,CAAC,WAAM,OAAO,KAAK,KAAK,QAAQ,CAAC;AACxE;AAEA,SAAS,QAAQ,MAA6B;AAC5C,SAAO,KAAK,iBAAiB,SAAS,KAAK,iBAAiB;AAC9D;AAIA,SAAS,mBAAmB;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AACF,GAIG;AACD,QAAM,IAAI,KAAK;AACf,QAAM,EAAE,MAAM,MAAM,cAAc,IAAI;AAEtC,MAAI,SAAS,SAAS;AACpB,WACE,qBAAC,SAAI,WAAU,mFACb;AAAA,0BAAC,SAAM,WAAU,4CAA2C,eAAY,QAAO;AAAA,MAC/E,oBAAC,UAAK,WAAU,+DACb,YAAE,kCAAkC,OAAO,GAC9C;AAAA,MACC,QAAQ,IAAI,IACX;AAAA,QAAC;AAAA;AAAA,UACC,SAAQ;AAAA,UACR,MAAK;AAAA,UACL,WAAU;AAAA,UACV,SAAS,MAAM,OAAO,IAAI;AAAA,UAC1B,WAAU;AAAA,UAET,YAAE,iCAAiC,cAAc;AAAA;AAAA,MACpD,IACE;AAAA,OACN;AAAA,EAEJ;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QAAgB,eAA8B;AAAA,KAChF;AAEJ;AAEO,SAAS,cAAc;AAAA,EAC5B;AAAA,EACA,YAAY;AAAA,EACZ;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAuB;AACrB,MAAI,MAAM,WAAW,EAAG,QAAO;AAC/B,SACE,oBAAC,SAAI,WAAU,iJACZ,gBAAM,IAAI,CAAC,SACV;AAAA,IAAC;AAAA;AAAA,MAEC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,IAPK,KAAK,KAAK;AAAA,EAQjB,CACD,GACH;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { ChevronDown } from "lucide-react";
|
|
5
|
+
import { cn } from "@open-mercato/shared/lib/utils";
|
|
6
|
+
import { useT } from "@open-mercato/shared/lib/i18n/context";
|
|
7
|
+
import { Button } from "@open-mercato/ui/primitives/button";
|
|
8
|
+
import { categoryPillStyle, CONTROL_BORDER, DROPDOWN_PANEL_CLASS, UppercaseBadge } from "./inputs.js";
|
|
9
|
+
function CategoryField({
|
|
10
|
+
label,
|
|
11
|
+
value,
|
|
12
|
+
options,
|
|
13
|
+
colors,
|
|
14
|
+
onChange
|
|
15
|
+
}) {
|
|
16
|
+
const t = useT();
|
|
17
|
+
const [open, setOpen] = React.useState(false);
|
|
18
|
+
const selected = options.find((option) => option.value === value) ?? { value, label: value };
|
|
19
|
+
return /* @__PURE__ */ jsxs(
|
|
20
|
+
"div",
|
|
21
|
+
{
|
|
22
|
+
className: "relative w-full",
|
|
23
|
+
onBlur: (event) => {
|
|
24
|
+
if (!event.currentTarget.contains(event.relatedTarget)) setOpen(false);
|
|
25
|
+
},
|
|
26
|
+
children: [
|
|
27
|
+
/* @__PURE__ */ jsxs(
|
|
28
|
+
Button,
|
|
29
|
+
{
|
|
30
|
+
type: "button",
|
|
31
|
+
variant: "outline",
|
|
32
|
+
"aria-haspopup": "listbox",
|
|
33
|
+
"aria-expanded": open,
|
|
34
|
+
"aria-label": label,
|
|
35
|
+
onClick: () => setOpen((previous) => !previous),
|
|
36
|
+
className: cn(
|
|
37
|
+
"h-9 w-full justify-between bg-background px-3 shadow-none",
|
|
38
|
+
CONTROL_BORDER
|
|
39
|
+
),
|
|
40
|
+
children: [
|
|
41
|
+
/* @__PURE__ */ jsx(UppercaseBadge, { style: categoryPillStyle(colors[selected.value] ?? null), children: selected.label }),
|
|
42
|
+
/* @__PURE__ */ jsxs("span", { className: "flex shrink-0 items-center", children: [
|
|
43
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "h-px w-2" }),
|
|
44
|
+
/* @__PURE__ */ jsx(ChevronDown, { "aria-hidden": true, className: "size-4 opacity-60" })
|
|
45
|
+
] })
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
),
|
|
49
|
+
open ? /* @__PURE__ */ jsxs("div", { role: "listbox", "aria-label": label, className: DROPDOWN_PANEL_CLASS, children: [
|
|
50
|
+
options.length === 0 ? /* @__PURE__ */ jsx("p", { className: "px-2 py-3 text-center text-xs text-muted-foreground", children: t("customers.calendar.editor.noResults", "No results") }) : null,
|
|
51
|
+
options.map((option) => /* @__PURE__ */ jsx(
|
|
52
|
+
Button,
|
|
53
|
+
{
|
|
54
|
+
type: "button",
|
|
55
|
+
variant: "ghost",
|
|
56
|
+
role: "option",
|
|
57
|
+
"aria-selected": option.value === value,
|
|
58
|
+
onClick: () => {
|
|
59
|
+
onChange(option.value);
|
|
60
|
+
setOpen(false);
|
|
61
|
+
},
|
|
62
|
+
className: "h-auto w-full justify-start px-2 py-1.5 text-left",
|
|
63
|
+
children: /* @__PURE__ */ jsx(UppercaseBadge, { style: categoryPillStyle(colors[option.value] ?? null), children: option.label })
|
|
64
|
+
},
|
|
65
|
+
option.value
|
|
66
|
+
))
|
|
67
|
+
] }) : null
|
|
68
|
+
]
|
|
69
|
+
}
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
export {
|
|
73
|
+
CategoryField
|
|
74
|
+
};
|
|
75
|
+
//# sourceMappingURL=CategoryField.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../src/modules/customers/components/calendar/editor/CategoryField.tsx"],
|
|
4
|
+
"sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport { ChevronDown } from 'lucide-react'\nimport { cn } from '@open-mercato/shared/lib/utils'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { categoryPillStyle, CONTROL_BORDER, DROPDOWN_PANEL_CLASS, UppercaseBadge } from './inputs'\n\nexport function CategoryField({\n label,\n value,\n options,\n colors,\n onChange,\n}: {\n label: string\n value: string\n options: Array<{ value: string; label: string }>\n colors: Record<string, string | null>\n onChange(next: string): void\n}) {\n const t = useT()\n const [open, setOpen] = React.useState(false)\n const selected = options.find((option) => option.value === value) ?? { value, label: value }\n\n return (\n <div\n className=\"relative w-full\"\n onBlur={(event) => {\n if (!event.currentTarget.contains(event.relatedTarget as Node | null)) setOpen(false)\n }}\n >\n <Button\n type=\"button\"\n variant=\"outline\"\n aria-haspopup=\"listbox\"\n aria-expanded={open}\n aria-label={label}\n onClick={() => setOpen((previous) => !previous)}\n className={cn(\n 'h-9 w-full justify-between bg-background px-3 shadow-none',\n CONTROL_BORDER,\n )}\n >\n <UppercaseBadge style={categoryPillStyle(colors[selected.value] ?? null)}>{selected.label}</UppercaseBadge>\n <span className=\"flex shrink-0 items-center\">\n <span aria-hidden className=\"h-px w-2\" />\n <ChevronDown aria-hidden className=\"size-4 opacity-60\" />\n </span>\n </Button>\n {open ? (\n <div role=\"listbox\" aria-label={label} className={DROPDOWN_PANEL_CLASS}>\n {options.length === 0 ? (\n <p className=\"px-2 py-3 text-center text-xs text-muted-foreground\">\n {t('customers.calendar.editor.noResults', 'No results')}\n </p>\n ) : null}\n {options.map((option) => (\n <Button\n key={option.value}\n type=\"button\"\n variant=\"ghost\"\n role=\"option\"\n aria-selected={option.value === value}\n onClick={() => {\n onChange(option.value)\n setOpen(false)\n }}\n className=\"h-auto w-full justify-start px-2 py-1.5 text-left\"\n >\n <UppercaseBadge style={categoryPillStyle(colors[option.value] ?? null)}>{option.label}</UppercaseBadge>\n </Button>\n ))}\n </div>\n ) : null}\n </div>\n )\n}\n"],
|
|
5
|
+
"mappings": ";AA6CQ,cACA,YADA;AA3CR,YAAY,WAAW;AACvB,SAAS,mBAAmB;AAC5B,SAAS,UAAU;AACnB,SAAS,YAAY;AACrB,SAAS,cAAc;AACvB,SAAS,mBAAmB,gBAAgB,sBAAsB,sBAAsB;AAEjF,SAAS,cAAc;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAMG;AACD,QAAM,IAAI,KAAK;AACf,QAAM,CAAC,MAAM,OAAO,IAAI,MAAM,SAAS,KAAK;AAC5C,QAAM,WAAW,QAAQ,KAAK,CAAC,WAAW,OAAO,UAAU,KAAK,KAAK,EAAE,OAAO,OAAO,MAAM;AAE3F,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAU;AAAA,MACV,QAAQ,CAAC,UAAU;AACjB,YAAI,CAAC,MAAM,cAAc,SAAS,MAAM,aAA4B,EAAG,SAAQ,KAAK;AAAA,MACtF;AAAA,MAEA;AAAA;AAAA,UAAC;AAAA;AAAA,YACC,MAAK;AAAA,YACL,SAAQ;AAAA,YACR,iBAAc;AAAA,YACd,iBAAe;AAAA,YACf,cAAY;AAAA,YACZ,SAAS,MAAM,QAAQ,CAAC,aAAa,CAAC,QAAQ;AAAA,YAC9C,WAAW;AAAA,cACT;AAAA,cACA;AAAA,YACF;AAAA,YAEA;AAAA,kCAAC,kBAAe,OAAO,kBAAkB,OAAO,SAAS,KAAK,KAAK,IAAI,GAAI,mBAAS,OAAM;AAAA,cAC1F,qBAAC,UAAK,WAAU,8BACd;AAAA,oCAAC,UAAK,eAAW,MAAC,WAAU,YAAW;AAAA,gBACvC,oBAAC,eAAY,eAAW,MAAC,WAAU,qBAAoB;AAAA,iBACzD;AAAA;AAAA;AAAA,QACF;AAAA,QACC,OACC,qBAAC,SAAI,MAAK,WAAU,cAAY,OAAO,WAAW,sBAC/C;AAAA,kBAAQ,WAAW,IAClB,oBAAC,OAAE,WAAU,uDACV,YAAE,uCAAuC,YAAY,GACxD,IACE;AAAA,UACH,QAAQ,IAAI,CAAC,WACZ;AAAA,YAAC;AAAA;AAAA,cAEC,MAAK;AAAA,cACL,SAAQ;AAAA,cACR,MAAK;AAAA,cACL,iBAAe,OAAO,UAAU;AAAA,cAChC,SAAS,MAAM;AACb,yBAAS,OAAO,KAAK;AACrB,wBAAQ,KAAK;AAAA,cACf;AAAA,cACA,WAAU;AAAA,cAEV,8BAAC,kBAAe,OAAO,kBAAkB,OAAO,OAAO,KAAK,KAAK,IAAI,GAAI,iBAAO,OAAM;AAAA;AAAA,YAXjF,OAAO;AAAA,UAYd,CACD;AAAA,WACH,IACE;AAAA;AAAA;AAAA,EACN;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { MapPin } from "lucide-react";
|
|
4
|
+
import { useT } from "@open-mercato/shared/lib/i18n/context";
|
|
5
|
+
import { Input } from "@open-mercato/ui/primitives/input";
|
|
6
|
+
import { Field } from "./inputs.js";
|
|
7
|
+
function LocationField({
|
|
8
|
+
variant,
|
|
9
|
+
value,
|
|
10
|
+
onChange
|
|
11
|
+
}) {
|
|
12
|
+
const t = useT();
|
|
13
|
+
const label = variant === "phoneLink" ? t("customers.calendar.editor.phoneLink", "Phone / link") : t("customers.calendar.editor.location", "Location");
|
|
14
|
+
const placeholder = variant === "phoneLink" ? t("customers.calendar.editor.phoneLinkPlaceholder", "Add a phone number or link\u2026") : t("customers.calendar.editor.locationPlaceholder", "Add a location or link\u2026");
|
|
15
|
+
return /* @__PURE__ */ jsx(Field, { label, children: /* @__PURE__ */ jsx(
|
|
16
|
+
Input,
|
|
17
|
+
{
|
|
18
|
+
type: "text",
|
|
19
|
+
value,
|
|
20
|
+
onChange: (event) => onChange(event.target.value),
|
|
21
|
+
placeholder,
|
|
22
|
+
"aria-label": label,
|
|
23
|
+
leftIcon: /* @__PURE__ */ jsx(MapPin, {})
|
|
24
|
+
}
|
|
25
|
+
) });
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
LocationField
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=LocationField.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../src/modules/customers/components/calendar/editor/LocationField.tsx"],
|
|
4
|
+
"sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport { MapPin } from 'lucide-react'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { Input } from '@open-mercato/ui/primitives/input'\nimport { Field } from './inputs'\n\nexport function LocationField({\n variant,\n value,\n onChange,\n}: {\n variant: 'location' | 'phoneLink'\n value: string\n onChange(next: string): void\n}) {\n const t = useT()\n const label = variant === 'phoneLink'\n ? t('customers.calendar.editor.phoneLink', 'Phone / link')\n : t('customers.calendar.editor.location', 'Location')\n const placeholder = variant === 'phoneLink'\n ? t('customers.calendar.editor.phoneLinkPlaceholder', 'Add a phone number or link\u2026')\n : t('customers.calendar.editor.locationPlaceholder', 'Add a location or link\u2026')\n return (\n <Field label={label}>\n <Input\n type=\"text\"\n value={value}\n onChange={(event) => onChange(event.target.value)}\n placeholder={placeholder}\n aria-label={label}\n leftIcon={<MapPin />}\n />\n </Field>\n )\n}\n"],
|
|
5
|
+
"mappings": ";AAgCkB;AA7BlB,SAAS,cAAc;AACvB,SAAS,YAAY;AACrB,SAAS,aAAa;AACtB,SAAS,aAAa;AAEf,SAAS,cAAc;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AACF,GAIG;AACD,QAAM,IAAI,KAAK;AACf,QAAM,QAAQ,YAAY,cACtB,EAAE,uCAAuC,cAAc,IACvD,EAAE,sCAAsC,UAAU;AACtD,QAAM,cAAc,YAAY,cAC5B,EAAE,kDAAkD,kCAA6B,IACjF,EAAE,iDAAiD,8BAAyB;AAChF,SACE,oBAAC,SAAM,OACL;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL;AAAA,MACA,UAAU,CAAC,UAAU,SAAS,MAAM,OAAO,KAAK;AAAA,MAChD;AAAA,MACA,cAAY;AAAA,MACZ,UAAU,oBAAC,UAAO;AAAA;AAAA,EACpB,GACF;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { cn } from "@open-mercato/shared/lib/utils";
|
|
5
|
+
import { useT } from "@open-mercato/shared/lib/i18n/context";
|
|
6
|
+
import { Avatar } from "@open-mercato/ui/primitives/avatar";
|
|
7
|
+
import { Button } from "@open-mercato/ui/primitives/button";
|
|
8
|
+
import { Input } from "@open-mercato/ui/primitives/input";
|
|
9
|
+
import { searchPeopleOptions } from "./lookups.js";
|
|
10
|
+
import { CONTROL_BORDER, DROPDOWN_PANEL_CLASS, PersonChip, UppercaseBadge } from "./inputs.js";
|
|
11
|
+
function PeopleField({
|
|
12
|
+
mode,
|
|
13
|
+
placeholder,
|
|
14
|
+
ariaLabel,
|
|
15
|
+
value,
|
|
16
|
+
onChange,
|
|
17
|
+
includeCustomers
|
|
18
|
+
}) {
|
|
19
|
+
const t = useT();
|
|
20
|
+
const [query, setQuery] = React.useState("");
|
|
21
|
+
const [open, setOpen] = React.useState(false);
|
|
22
|
+
const [options, setOptions] = React.useState([]);
|
|
23
|
+
const [loading, setLoading] = React.useState(false);
|
|
24
|
+
React.useEffect(() => {
|
|
25
|
+
if (!open) return;
|
|
26
|
+
const controller = new AbortController();
|
|
27
|
+
let cancelled = false;
|
|
28
|
+
const timer = window.setTimeout(async () => {
|
|
29
|
+
setLoading(true);
|
|
30
|
+
try {
|
|
31
|
+
const results = await searchPeopleOptions(query.trim(), { includeCustomers, signal: controller.signal });
|
|
32
|
+
if (cancelled) return;
|
|
33
|
+
setOptions(results);
|
|
34
|
+
} catch {
|
|
35
|
+
if (!cancelled) setOptions([]);
|
|
36
|
+
} finally {
|
|
37
|
+
if (!cancelled) setLoading(false);
|
|
38
|
+
}
|
|
39
|
+
}, 250);
|
|
40
|
+
return () => {
|
|
41
|
+
cancelled = true;
|
|
42
|
+
controller.abort();
|
|
43
|
+
window.clearTimeout(timer);
|
|
44
|
+
};
|
|
45
|
+
}, [open, query, includeCustomers]);
|
|
46
|
+
const selectedIds = new Set(value.map((participant) => participant.userId));
|
|
47
|
+
const visibleOptions = options.filter((option) => !selectedIds.has(option.userId));
|
|
48
|
+
const customerBadge = /* @__PURE__ */ jsx(UppercaseBadge, { className: "bg-status-info-bg text-status-info-text", children: t("customers.calendar.editor.customerBadge", "Customer") });
|
|
49
|
+
return /* @__PURE__ */ jsxs(
|
|
50
|
+
"div",
|
|
51
|
+
{
|
|
52
|
+
className: "relative w-full",
|
|
53
|
+
onBlur: (event) => {
|
|
54
|
+
if (!event.currentTarget.contains(event.relatedTarget)) setOpen(false);
|
|
55
|
+
},
|
|
56
|
+
children: [
|
|
57
|
+
/* @__PURE__ */ jsxs(
|
|
58
|
+
"div",
|
|
59
|
+
{
|
|
60
|
+
className: cn(
|
|
61
|
+
"flex w-full flex-wrap content-center items-center gap-2 rounded-md bg-background px-2.5 py-2",
|
|
62
|
+
mode === "multi" ? "min-h-24" : "min-h-14",
|
|
63
|
+
CONTROL_BORDER
|
|
64
|
+
),
|
|
65
|
+
children: [
|
|
66
|
+
value.map((participant) => /* @__PURE__ */ jsx(
|
|
67
|
+
PersonChip,
|
|
68
|
+
{
|
|
69
|
+
name: participant.name,
|
|
70
|
+
badge: participant.isCustomer ? customerBadge : void 0,
|
|
71
|
+
onRemove: () => onChange(value.filter((entry) => entry.userId !== participant.userId)),
|
|
72
|
+
removeLabel: t("customers.calendar.editor.removePerson", "Remove {name}", { name: participant.name })
|
|
73
|
+
},
|
|
74
|
+
participant.userId
|
|
75
|
+
)),
|
|
76
|
+
/* @__PURE__ */ jsx(
|
|
77
|
+
Input,
|
|
78
|
+
{
|
|
79
|
+
type: "text",
|
|
80
|
+
value: query,
|
|
81
|
+
onChange: (event) => setQuery(event.target.value),
|
|
82
|
+
onFocus: () => setOpen(true),
|
|
83
|
+
placeholder,
|
|
84
|
+
"aria-label": ariaLabel,
|
|
85
|
+
role: "combobox",
|
|
86
|
+
"aria-expanded": open,
|
|
87
|
+
className: "min-w-36 flex-1 border-0 bg-transparent px-0 shadow-none hover:bg-transparent focus-within:border-transparent focus-within:shadow-none",
|
|
88
|
+
inputClassName: "text-sm text-foreground placeholder:text-muted-foreground"
|
|
89
|
+
}
|
|
90
|
+
)
|
|
91
|
+
]
|
|
92
|
+
}
|
|
93
|
+
),
|
|
94
|
+
open ? /* @__PURE__ */ jsxs("div", { role: "listbox", "aria-label": ariaLabel, className: DROPDOWN_PANEL_CLASS, children: [
|
|
95
|
+
loading ? /* @__PURE__ */ jsx("p", { className: "px-2 py-3 text-center text-xs text-muted-foreground", children: t("customers.calendar.editor.searching", "Searching\u2026") }) : null,
|
|
96
|
+
!loading && visibleOptions.length === 0 ? /* @__PURE__ */ jsx("p", { className: "px-2 py-3 text-center text-xs text-muted-foreground", children: t("customers.calendar.editor.noResults", "No results") }) : null,
|
|
97
|
+
!loading ? visibleOptions.map((option) => /* @__PURE__ */ jsxs(
|
|
98
|
+
Button,
|
|
99
|
+
{
|
|
100
|
+
type: "button",
|
|
101
|
+
variant: "ghost",
|
|
102
|
+
role: "option",
|
|
103
|
+
"aria-selected": false,
|
|
104
|
+
onClick: () => {
|
|
105
|
+
const participant = {
|
|
106
|
+
userId: option.userId,
|
|
107
|
+
name: option.name,
|
|
108
|
+
email: option.email ?? void 0,
|
|
109
|
+
isCustomer: option.isCustomer
|
|
110
|
+
};
|
|
111
|
+
onChange(mode === "single" ? [participant] : [...value, participant]);
|
|
112
|
+
setQuery("");
|
|
113
|
+
if (mode === "single") setOpen(false);
|
|
114
|
+
},
|
|
115
|
+
className: "h-auto w-full justify-start gap-2 whitespace-normal px-2 py-1.5 text-left text-sm font-normal text-foreground",
|
|
116
|
+
children: [
|
|
117
|
+
/* @__PURE__ */ jsx(Avatar, { size: "xs", label: option.name }),
|
|
118
|
+
/* @__PURE__ */ jsxs("span", { className: "min-w-0 flex-1 truncate", children: [
|
|
119
|
+
option.name,
|
|
120
|
+
option.email ? /* @__PURE__ */ jsx("span", { className: "ml-1.5 text-xs text-muted-foreground", children: option.email }) : null
|
|
121
|
+
] }),
|
|
122
|
+
option.isCustomer ? customerBadge : null
|
|
123
|
+
]
|
|
124
|
+
},
|
|
125
|
+
`${option.isCustomer ? "customer" : "staff"}:${option.userId}`
|
|
126
|
+
)) : null
|
|
127
|
+
] }) : null
|
|
128
|
+
]
|
|
129
|
+
}
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
export {
|
|
133
|
+
PeopleField
|
|
134
|
+
};
|
|
135
|
+
//# sourceMappingURL=PeopleField.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../src/modules/customers/components/calendar/editor/PeopleField.tsx"],
|
|
4
|
+
"sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport { cn } from '@open-mercato/shared/lib/utils'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { Avatar } from '@open-mercato/ui/primitives/avatar'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { Input } from '@open-mercato/ui/primitives/input'\nimport type { EditorParticipant } from '../../../lib/calendar/editorPayload'\nimport { searchPeopleOptions, type PersonOption } from './lookups'\nimport { CONTROL_BORDER, DROPDOWN_PANEL_CLASS, PersonChip, UppercaseBadge } from './inputs'\n\nexport function PeopleField({\n mode,\n placeholder,\n ariaLabel,\n value,\n onChange,\n includeCustomers,\n}: {\n mode: 'multi' | 'single'\n placeholder: string\n ariaLabel: string\n value: EditorParticipant[]\n onChange(next: EditorParticipant[]): void\n includeCustomers: boolean\n}) {\n const t = useT()\n const [query, setQuery] = React.useState('')\n const [open, setOpen] = React.useState(false)\n const [options, setOptions] = React.useState<PersonOption[]>([])\n const [loading, setLoading] = React.useState(false)\n\n React.useEffect(() => {\n if (!open) return\n const controller = new AbortController()\n let cancelled = false\n const timer = window.setTimeout(async () => {\n setLoading(true)\n try {\n const results = await searchPeopleOptions(query.trim(), { includeCustomers, signal: controller.signal })\n if (cancelled) return\n setOptions(results)\n } catch {\n if (!cancelled) setOptions([])\n } finally {\n if (!cancelled) setLoading(false)\n }\n }, 250)\n return () => {\n cancelled = true\n controller.abort()\n window.clearTimeout(timer)\n }\n }, [open, query, includeCustomers])\n\n const selectedIds = new Set(value.map((participant) => participant.userId))\n const visibleOptions = options.filter((option) => !selectedIds.has(option.userId))\n\n const customerBadge = (\n <UppercaseBadge className=\"bg-status-info-bg text-status-info-text\">\n {t('customers.calendar.editor.customerBadge', 'Customer')}\n </UppercaseBadge>\n )\n\n return (\n <div\n className=\"relative w-full\"\n onBlur={(event) => {\n if (!event.currentTarget.contains(event.relatedTarget as Node | null)) setOpen(false)\n }}\n >\n <div\n className={cn(\n 'flex w-full flex-wrap content-center items-center gap-2 rounded-md bg-background px-2.5 py-2',\n mode === 'multi' ? 'min-h-24' : 'min-h-14',\n CONTROL_BORDER,\n )}\n >\n {value.map((participant) => (\n <PersonChip\n key={participant.userId}\n name={participant.name}\n badge={participant.isCustomer ? customerBadge : undefined}\n onRemove={() => onChange(value.filter((entry) => entry.userId !== participant.userId))}\n removeLabel={t('customers.calendar.editor.removePerson', 'Remove {name}', { name: participant.name })}\n />\n ))}\n <Input\n type=\"text\"\n value={query}\n onChange={(event) => setQuery(event.target.value)}\n onFocus={() => setOpen(true)}\n placeholder={placeholder}\n aria-label={ariaLabel}\n role=\"combobox\"\n aria-expanded={open}\n className=\"min-w-36 flex-1 border-0 bg-transparent px-0 shadow-none hover:bg-transparent focus-within:border-transparent focus-within:shadow-none\"\n inputClassName=\"text-sm text-foreground placeholder:text-muted-foreground\"\n />\n </div>\n {open ? (\n <div role=\"listbox\" aria-label={ariaLabel} className={DROPDOWN_PANEL_CLASS}>\n {loading ? (\n <p className=\"px-2 py-3 text-center text-xs text-muted-foreground\">\n {t('customers.calendar.editor.searching', 'Searching\u2026')}\n </p>\n ) : null}\n {!loading && visibleOptions.length === 0 ? (\n <p className=\"px-2 py-3 text-center text-xs text-muted-foreground\">\n {t('customers.calendar.editor.noResults', 'No results')}\n </p>\n ) : null}\n {!loading\n ? visibleOptions.map((option) => (\n <Button\n key={`${option.isCustomer ? 'customer' : 'staff'}:${option.userId}`}\n type=\"button\"\n variant=\"ghost\"\n role=\"option\"\n aria-selected={false}\n onClick={() => {\n const participant: EditorParticipant = {\n userId: option.userId,\n name: option.name,\n email: option.email ?? undefined,\n isCustomer: option.isCustomer,\n }\n onChange(mode === 'single' ? [participant] : [...value, participant])\n setQuery('')\n if (mode === 'single') setOpen(false)\n }}\n className=\"h-auto w-full justify-start gap-2 whitespace-normal px-2 py-1.5 text-left text-sm font-normal text-foreground\"\n >\n <Avatar size=\"xs\" label={option.name} />\n <span className=\"min-w-0 flex-1 truncate\">\n {option.name}\n {option.email ? <span className=\"ml-1.5 text-xs text-muted-foreground\">{option.email}</span> : null}\n </span>\n {option.isCustomer ? customerBadge : null}\n </Button>\n ))\n : null}\n </div>\n ) : null}\n </div>\n )\n}\n"],
|
|
5
|
+
"mappings": ";AA4DI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