@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,218 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Building2, ChevronDown, User, X } 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 { IconButton } from "@open-mercato/ui/primitives/icon-button";
|
|
9
|
+
import { Input } from "@open-mercato/ui/primitives/input";
|
|
10
|
+
import {
|
|
11
|
+
fetchDealsForEntity,
|
|
12
|
+
searchRelatedEntities
|
|
13
|
+
} from "./lookups.js";
|
|
14
|
+
import { CONTROL_BORDER, DROPDOWN_PANEL_CLASS, PersonChip, UppercaseBadge } from "./inputs.js";
|
|
15
|
+
const OPTION_ROW_CLASS = "h-auto w-full justify-start gap-2 whitespace-normal px-2 py-1.5 text-left text-sm font-normal text-foreground";
|
|
16
|
+
function RelatedToField({
|
|
17
|
+
label,
|
|
18
|
+
value,
|
|
19
|
+
deal,
|
|
20
|
+
onChange,
|
|
21
|
+
onDealChange,
|
|
22
|
+
error
|
|
23
|
+
}) {
|
|
24
|
+
const t = useT();
|
|
25
|
+
const [open, setOpen] = React.useState(false);
|
|
26
|
+
const [query, setQuery] = React.useState("");
|
|
27
|
+
const [options, setOptions] = React.useState([]);
|
|
28
|
+
const [deals, setDeals] = React.useState([]);
|
|
29
|
+
const [loading, setLoading] = React.useState(false);
|
|
30
|
+
React.useEffect(() => {
|
|
31
|
+
if (!open) return;
|
|
32
|
+
const controller = new AbortController();
|
|
33
|
+
let cancelled = false;
|
|
34
|
+
const timer = window.setTimeout(async () => {
|
|
35
|
+
setLoading(true);
|
|
36
|
+
try {
|
|
37
|
+
const trimmed = query.trim();
|
|
38
|
+
const [people, companies] = await Promise.all([
|
|
39
|
+
searchRelatedEntities("person", trimmed, controller.signal),
|
|
40
|
+
searchRelatedEntities("company", trimmed, controller.signal)
|
|
41
|
+
]);
|
|
42
|
+
if (cancelled) return;
|
|
43
|
+
setOptions([...people, ...companies]);
|
|
44
|
+
} catch {
|
|
45
|
+
if (!cancelled) setOptions([]);
|
|
46
|
+
} finally {
|
|
47
|
+
if (!cancelled) setLoading(false);
|
|
48
|
+
}
|
|
49
|
+
}, 200);
|
|
50
|
+
return () => {
|
|
51
|
+
cancelled = true;
|
|
52
|
+
controller.abort();
|
|
53
|
+
window.clearTimeout(timer);
|
|
54
|
+
};
|
|
55
|
+
}, [open, query]);
|
|
56
|
+
React.useEffect(() => {
|
|
57
|
+
if (!open || !value || value.kind === "unknown") {
|
|
58
|
+
setDeals([]);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const controller = new AbortController();
|
|
62
|
+
let cancelled = false;
|
|
63
|
+
fetchDealsForEntity({ id: value.id, kind: value.kind }, controller.signal).then((items) => {
|
|
64
|
+
if (!cancelled) setDeals(items);
|
|
65
|
+
}).catch(() => {
|
|
66
|
+
if (!cancelled) setDeals([]);
|
|
67
|
+
});
|
|
68
|
+
return () => {
|
|
69
|
+
cancelled = true;
|
|
70
|
+
controller.abort();
|
|
71
|
+
};
|
|
72
|
+
}, [open, value]);
|
|
73
|
+
const kindLabel = (kind) => kind === "person" ? t("customers.deals.detail.tabs.peopleSingular", "Person") : t("customers.deals.detail.tabs.companySingular", "Company");
|
|
74
|
+
return /* @__PURE__ */ jsxs(
|
|
75
|
+
"div",
|
|
76
|
+
{
|
|
77
|
+
className: "relative w-full",
|
|
78
|
+
onBlur: (event) => {
|
|
79
|
+
if (!event.currentTarget.contains(event.relatedTarget)) setOpen(false);
|
|
80
|
+
},
|
|
81
|
+
children: [
|
|
82
|
+
/* @__PURE__ */ jsxs(
|
|
83
|
+
"div",
|
|
84
|
+
{
|
|
85
|
+
className: cn(
|
|
86
|
+
"flex h-10 w-full items-center rounded-md bg-background pl-2.5 pr-3",
|
|
87
|
+
error ? "border border-status-error-border" : CONTROL_BORDER
|
|
88
|
+
),
|
|
89
|
+
children: [
|
|
90
|
+
/* @__PURE__ */ jsxs(
|
|
91
|
+
Button,
|
|
92
|
+
{
|
|
93
|
+
type: "button",
|
|
94
|
+
variant: "ghost",
|
|
95
|
+
"aria-haspopup": "listbox",
|
|
96
|
+
"aria-expanded": open,
|
|
97
|
+
"aria-label": label,
|
|
98
|
+
onClick: () => setOpen((previous) => !previous),
|
|
99
|
+
className: "h-full min-w-0 flex-1 justify-between rounded-none bg-transparent p-0 text-left shadow-none hover:bg-transparent",
|
|
100
|
+
children: [
|
|
101
|
+
/* @__PURE__ */ jsx("span", { className: "flex min-w-0 items-center gap-2", children: value ? /* @__PURE__ */ jsx(
|
|
102
|
+
PersonChip,
|
|
103
|
+
{
|
|
104
|
+
compact: true,
|
|
105
|
+
name: value.label || value.id
|
|
106
|
+
}
|
|
107
|
+
) : /* @__PURE__ */ jsx("span", { className: "truncate text-sm text-muted-foreground", children: t("customers.calendar.editor.relatedToPlaceholder", "Search people or companies\u2026") }) }),
|
|
108
|
+
/* @__PURE__ */ jsxs("span", { className: "flex shrink-0 items-center", children: [
|
|
109
|
+
deal ? /* @__PURE__ */ jsx(UppercaseBadge, { className: "h-7 bg-status-info-bg text-status-info-text", children: t("customers.calendar.editor.dealBadge", "{name} \xB7 Deal", { name: deal.label }) }) : null,
|
|
110
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "h-px w-2" }),
|
|
111
|
+
/* @__PURE__ */ jsx(ChevronDown, { "aria-hidden": true, className: "size-4 opacity-60" })
|
|
112
|
+
] })
|
|
113
|
+
]
|
|
114
|
+
}
|
|
115
|
+
),
|
|
116
|
+
value ? /* @__PURE__ */ jsx(
|
|
117
|
+
IconButton,
|
|
118
|
+
{
|
|
119
|
+
variant: "ghost",
|
|
120
|
+
size: "xs",
|
|
121
|
+
onClick: () => {
|
|
122
|
+
onChange(null);
|
|
123
|
+
onDealChange(null);
|
|
124
|
+
},
|
|
125
|
+
"aria-label": t("customers.calendar.editor.removeRelated", "Clear related record"),
|
|
126
|
+
className: "ms-1 shrink-0 text-muted-foreground",
|
|
127
|
+
children: /* @__PURE__ */ jsx(X, { "aria-hidden": true, className: "size-3.5" })
|
|
128
|
+
}
|
|
129
|
+
) : null
|
|
130
|
+
]
|
|
131
|
+
}
|
|
132
|
+
),
|
|
133
|
+
open ? /* @__PURE__ */ jsxs("div", { role: "listbox", "aria-label": label, className: DROPDOWN_PANEL_CLASS, children: [
|
|
134
|
+
/* @__PURE__ */ jsx(
|
|
135
|
+
Input,
|
|
136
|
+
{
|
|
137
|
+
type: "text",
|
|
138
|
+
value: query,
|
|
139
|
+
onChange: (event) => setQuery(event.target.value),
|
|
140
|
+
placeholder: t("customers.calendar.editor.relatedToPlaceholder", "Search people or companies\u2026"),
|
|
141
|
+
"aria-label": t("customers.calendar.editor.relatedToPlaceholder", "Search people or companies\u2026"),
|
|
142
|
+
autoFocus: true,
|
|
143
|
+
size: "sm",
|
|
144
|
+
className: "mb-1"
|
|
145
|
+
}
|
|
146
|
+
),
|
|
147
|
+
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,
|
|
148
|
+
!loading && 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,
|
|
149
|
+
!loading ? options.map((option) => /* @__PURE__ */ jsxs(
|
|
150
|
+
Button,
|
|
151
|
+
{
|
|
152
|
+
type: "button",
|
|
153
|
+
variant: "ghost",
|
|
154
|
+
role: "option",
|
|
155
|
+
"aria-selected": value?.id === option.id,
|
|
156
|
+
onClick: () => {
|
|
157
|
+
onChange({ id: option.id, kind: option.kind, label: option.label });
|
|
158
|
+
if (value?.id !== option.id) onDealChange(null);
|
|
159
|
+
setQuery("");
|
|
160
|
+
},
|
|
161
|
+
className: OPTION_ROW_CLASS,
|
|
162
|
+
children: [
|
|
163
|
+
option.kind === "company" ? /* @__PURE__ */ jsx(Building2, { "aria-hidden": true, className: "size-3.5 shrink-0 text-muted-foreground" }) : /* @__PURE__ */ jsx(User, { "aria-hidden": true, className: "size-3.5 shrink-0 text-muted-foreground" }),
|
|
164
|
+
/* @__PURE__ */ jsxs("span", { className: "min-w-0 flex-1 truncate", children: [
|
|
165
|
+
option.label,
|
|
166
|
+
option.subtitle ? /* @__PURE__ */ jsx("span", { className: "ml-1.5 text-xs text-muted-foreground", children: option.subtitle }) : null
|
|
167
|
+
] }),
|
|
168
|
+
/* @__PURE__ */ jsx("span", { className: "shrink-0 text-xs text-muted-foreground", children: kindLabel(option.kind) })
|
|
169
|
+
]
|
|
170
|
+
},
|
|
171
|
+
`${option.kind}:${option.id}`
|
|
172
|
+
)) : null,
|
|
173
|
+
value && deals.length > 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
174
|
+
/* @__PURE__ */ jsx("p", { className: "px-2 pb-1 pt-2 text-overline font-medium uppercase text-muted-foreground", children: t("customers.calendar.editor.dealsSection", "Deals") }),
|
|
175
|
+
/* @__PURE__ */ jsx(
|
|
176
|
+
Button,
|
|
177
|
+
{
|
|
178
|
+
type: "button",
|
|
179
|
+
variant: "ghost",
|
|
180
|
+
role: "option",
|
|
181
|
+
"aria-selected": deal === null,
|
|
182
|
+
onClick: () => {
|
|
183
|
+
onDealChange(null);
|
|
184
|
+
setOpen(false);
|
|
185
|
+
},
|
|
186
|
+
className: OPTION_ROW_CLASS,
|
|
187
|
+
children: t("customers.calendar.editor.dealNone", "No deal")
|
|
188
|
+
}
|
|
189
|
+
),
|
|
190
|
+
deals.map((option) => /* @__PURE__ */ jsxs(
|
|
191
|
+
Button,
|
|
192
|
+
{
|
|
193
|
+
type: "button",
|
|
194
|
+
variant: "ghost",
|
|
195
|
+
role: "option",
|
|
196
|
+
"aria-selected": deal?.id === option.id,
|
|
197
|
+
onClick: () => {
|
|
198
|
+
onDealChange(option);
|
|
199
|
+
setOpen(false);
|
|
200
|
+
},
|
|
201
|
+
className: OPTION_ROW_CLASS,
|
|
202
|
+
children: [
|
|
203
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate", children: option.label }),
|
|
204
|
+
/* @__PURE__ */ jsx(UppercaseBadge, { className: "bg-status-info-bg text-status-info-text", children: t("customers.calendar.editor.dealBadgeSuffix", "Deal") })
|
|
205
|
+
]
|
|
206
|
+
},
|
|
207
|
+
option.id
|
|
208
|
+
))
|
|
209
|
+
] }) : null
|
|
210
|
+
] }) : null
|
|
211
|
+
]
|
|
212
|
+
}
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
export {
|
|
216
|
+
RelatedToField
|
|
217
|
+
};
|
|
218
|
+
//# sourceMappingURL=RelatedToField.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../src/modules/customers/components/calendar/editor/RelatedToField.tsx"],
|
|
4
|
+
"sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport { Building2, ChevronDown, User, X } 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 { IconButton } from '@open-mercato/ui/primitives/icon-button'\nimport { Input } from '@open-mercato/ui/primitives/input'\nimport type { EditorRelatedTo } from '../../../lib/calendar/editorPayload'\nimport {\n fetchDealsForEntity,\n searchRelatedEntities,\n type DealOption,\n type RelatedEntityOption,\n} from './lookups'\nimport { CONTROL_BORDER, DROPDOWN_PANEL_CLASS, PersonChip, UppercaseBadge } from './inputs'\n\nconst OPTION_ROW_CLASS =\n 'h-auto w-full justify-start gap-2 whitespace-normal px-2 py-1.5 text-left text-sm font-normal text-foreground'\n\nexport function RelatedToField({\n label,\n value,\n deal,\n onChange,\n onDealChange,\n error,\n}: {\n label: string\n value: EditorRelatedTo | null\n deal: DealOption | null\n onChange(next: EditorRelatedTo | null): void\n onDealChange(next: DealOption | null): void\n error?: string | null\n}) {\n const t = useT()\n const [open, setOpen] = React.useState(false)\n const [query, setQuery] = React.useState('')\n const [options, setOptions] = React.useState<RelatedEntityOption[]>([])\n const [deals, setDeals] = React.useState<DealOption[]>([])\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 trimmed = query.trim()\n const [people, companies] = await Promise.all([\n searchRelatedEntities('person', trimmed, controller.signal),\n searchRelatedEntities('company', trimmed, controller.signal),\n ])\n if (cancelled) return\n setOptions([...people, ...companies])\n } catch {\n if (!cancelled) setOptions([])\n } finally {\n if (!cancelled) setLoading(false)\n }\n }, 200)\n return () => {\n cancelled = true\n controller.abort()\n window.clearTimeout(timer)\n }\n }, [open, query])\n\n React.useEffect(() => {\n if (!open || !value || value.kind === 'unknown') {\n setDeals([])\n return\n }\n const controller = new AbortController()\n let cancelled = false\n fetchDealsForEntity({ id: value.id, kind: value.kind }, controller.signal)\n .then((items) => { if (!cancelled) setDeals(items) })\n .catch(() => { if (!cancelled) setDeals([]) })\n return () => {\n cancelled = true\n controller.abort()\n }\n }, [open, value])\n\n const kindLabel = (kind: RelatedEntityOption['kind']) =>\n kind === 'person'\n ? t('customers.deals.detail.tabs.peopleSingular', 'Person')\n : t('customers.deals.detail.tabs.companySingular', 'Company')\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 h-10 w-full items-center rounded-md bg-background pl-2.5 pr-3',\n error ? 'border border-status-error-border' : CONTROL_BORDER,\n )}\n >\n <Button\n type=\"button\"\n variant=\"ghost\"\n aria-haspopup=\"listbox\"\n aria-expanded={open}\n aria-label={label}\n onClick={() => setOpen((previous) => !previous)}\n className=\"h-full min-w-0 flex-1 justify-between rounded-none bg-transparent p-0 text-left shadow-none hover:bg-transparent\"\n >\n <span className=\"flex min-w-0 items-center gap-2\">\n {value ? (\n <PersonChip\n compact\n name={value.label || value.id}\n />\n ) : (\n <span className=\"truncate text-sm text-muted-foreground\">\n {t('customers.calendar.editor.relatedToPlaceholder', 'Search people or companies\u2026')}\n </span>\n )}\n </span>\n <span className=\"flex shrink-0 items-center\">\n {deal ? (\n <UppercaseBadge className=\"h-7 bg-status-info-bg text-status-info-text\">\n {t('customers.calendar.editor.dealBadge', '{name} \u00B7 Deal', { name: deal.label })}\n </UppercaseBadge>\n ) : null}\n <span aria-hidden className=\"h-px w-2\" />\n <ChevronDown aria-hidden className=\"size-4 opacity-60\" />\n </span>\n </Button>\n {value ? (\n <IconButton\n variant=\"ghost\"\n size=\"xs\"\n onClick={() => {\n onChange(null)\n onDealChange(null)\n }}\n aria-label={t('customers.calendar.editor.removeRelated', 'Clear related record')}\n className=\"ms-1 shrink-0 text-muted-foreground\"\n >\n <X aria-hidden className=\"size-3.5\" />\n </IconButton>\n ) : null}\n </div>\n {open ? (\n <div role=\"listbox\" aria-label={label} className={DROPDOWN_PANEL_CLASS}>\n <Input\n type=\"text\"\n value={query}\n onChange={(event) => setQuery(event.target.value)}\n placeholder={t('customers.calendar.editor.relatedToPlaceholder', 'Search people or companies\u2026')}\n aria-label={t('customers.calendar.editor.relatedToPlaceholder', 'Search people or companies\u2026')}\n autoFocus\n size=\"sm\"\n className=\"mb-1\"\n />\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 && 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 {!loading\n ? options.map((option) => (\n <Button\n key={`${option.kind}:${option.id}`}\n type=\"button\"\n variant=\"ghost\"\n role=\"option\"\n aria-selected={value?.id === option.id}\n onClick={() => {\n onChange({ id: option.id, kind: option.kind, label: option.label })\n if (value?.id !== option.id) onDealChange(null)\n setQuery('')\n }}\n className={OPTION_ROW_CLASS}\n >\n {option.kind === 'company'\n ? <Building2 aria-hidden className=\"size-3.5 shrink-0 text-muted-foreground\" />\n : <User aria-hidden className=\"size-3.5 shrink-0 text-muted-foreground\" />}\n <span className=\"min-w-0 flex-1 truncate\">\n {option.label}\n {option.subtitle ? <span className=\"ml-1.5 text-xs text-muted-foreground\">{option.subtitle}</span> : null}\n </span>\n <span className=\"shrink-0 text-xs text-muted-foreground\">{kindLabel(option.kind)}</span>\n </Button>\n ))\n : null}\n {value && deals.length > 0 ? (\n <>\n <p className=\"px-2 pb-1 pt-2 text-overline font-medium uppercase text-muted-foreground\">\n {t('customers.calendar.editor.dealsSection', 'Deals')}\n </p>\n <Button\n type=\"button\"\n variant=\"ghost\"\n role=\"option\"\n aria-selected={deal === null}\n onClick={() => {\n onDealChange(null)\n setOpen(false)\n }}\n className={OPTION_ROW_CLASS}\n >\n {t('customers.calendar.editor.dealNone', 'No deal')}\n </Button>\n {deals.map((option) => (\n <Button\n key={option.id}\n type=\"button\"\n variant=\"ghost\"\n role=\"option\"\n aria-selected={deal?.id === option.id}\n onClick={() => {\n onDealChange(option)\n setOpen(false)\n }}\n className={OPTION_ROW_CLASS}\n >\n <span className=\"min-w-0 flex-1 truncate\">{option.label}</span>\n <UppercaseBadge className=\"bg-status-info-bg text-status-info-text\">\n {t('customers.calendar.editor.dealBadgeSuffix', 'Deal')}\n </UppercaseBadge>\n </Button>\n ))}\n </>\n ) : null}\n </div>\n ) : null}\n </div>\n )\n}\n"],
|
|
5
|
+
"mappings": ";AAmHc,SAoFF,UApFE,KAUJ,YAVI;AAjHd,YAAY,WAAW;AACvB,SAAS,WAAW,aAAa,MAAM,SAAS;AAChD,SAAS,UAAU;AACnB,SAAS,YAAY;AAC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,+BAAa,MAAM;AACnB,0BAAQ,KAAK;AAAA,gBACf;AAAA,gBACA,WAAW;AAAA,gBAEX;AAAA,sCAAC,UAAK,WAAU,2BAA2B,iBAAO,OAAM;AAAA,kBACxD,oBAAC,kBAAe,WAAU,2CACvB,YAAE,6CAA6C,MAAM,GACxD;AAAA;AAAA;AAAA,cAdK,OAAO;AAAA,YAed,CACD;AAAA,aACH,IACE;AAAA,WACN,IACE;AAAA;AAAA;AAAA,EACN;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cn } from "@open-mercato/shared/lib/utils";
|
|
4
|
+
import { useT } from "@open-mercato/shared/lib/i18n/context";
|
|
5
|
+
import { Button } from "@open-mercato/ui/primitives/button";
|
|
6
|
+
import { Input } from "@open-mercato/ui/primitives/input";
|
|
7
|
+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@open-mercato/ui/primitives/select";
|
|
8
|
+
import { DateControl, LABEL_CLASS } from "./inputs.js";
|
|
9
|
+
import { SegmentGroup } from "./SegmentGroup.js";
|
|
10
|
+
const DAY_LABEL_KEYS = [
|
|
11
|
+
{ letterKey: "customers.calendar.editor.repeat.days.mon", letterFallback: "M", ariaKey: "customers.calendar.day.mon", ariaFallback: "MON" },
|
|
12
|
+
{ letterKey: "customers.calendar.editor.repeat.days.tue", letterFallback: "T", ariaKey: "customers.calendar.day.tue", ariaFallback: "TUE" },
|
|
13
|
+
{ letterKey: "customers.calendar.editor.repeat.days.wed", letterFallback: "W", ariaKey: "customers.calendar.day.wed", ariaFallback: "WED" },
|
|
14
|
+
{ letterKey: "customers.calendar.editor.repeat.days.thu", letterFallback: "T", ariaKey: "customers.calendar.day.thu", ariaFallback: "THU" },
|
|
15
|
+
{ letterKey: "customers.calendar.editor.repeat.days.fri", letterFallback: "F", ariaKey: "customers.calendar.day.fri", ariaFallback: "FRI" },
|
|
16
|
+
{ letterKey: "customers.calendar.editor.repeat.days.sat", letterFallback: "S", ariaKey: "customers.calendar.day.sat", ariaFallback: "SAT" },
|
|
17
|
+
{ letterKey: "customers.calendar.editor.repeat.days.sun", letterFallback: "S", ariaKey: "customers.calendar.day.sun", ariaFallback: "SUN" }
|
|
18
|
+
];
|
|
19
|
+
function RepeatField({
|
|
20
|
+
freq,
|
|
21
|
+
days,
|
|
22
|
+
endType,
|
|
23
|
+
count,
|
|
24
|
+
untilDate,
|
|
25
|
+
locale,
|
|
26
|
+
onFreqChange,
|
|
27
|
+
onToggleDay,
|
|
28
|
+
onEndTypeChange,
|
|
29
|
+
onCountChange,
|
|
30
|
+
onUntilDateChange
|
|
31
|
+
}) {
|
|
32
|
+
const t = useT();
|
|
33
|
+
const freqLabel = t("customers.calendar.editor.repeat.label", "Repeat");
|
|
34
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col gap-2.5", children: [
|
|
35
|
+
/* @__PURE__ */ jsx("span", { className: LABEL_CLASS, children: freqLabel }),
|
|
36
|
+
/* @__PURE__ */ jsxs(
|
|
37
|
+
Select,
|
|
38
|
+
{
|
|
39
|
+
value: freq,
|
|
40
|
+
onValueChange: (value) => onFreqChange(value),
|
|
41
|
+
children: [
|
|
42
|
+
/* @__PURE__ */ jsx(SelectTrigger, { "aria-label": freqLabel, children: /* @__PURE__ */ jsx(SelectValue, {}) }),
|
|
43
|
+
/* @__PURE__ */ jsxs(SelectContent, { children: [
|
|
44
|
+
/* @__PURE__ */ jsx(SelectItem, { value: "none", children: t("customers.calendar.editor.repeat.freq.none", "Does not repeat") }),
|
|
45
|
+
/* @__PURE__ */ jsx(SelectItem, { value: "daily", children: t("customers.calendar.editor.repeat.freq.daily", "Daily") }),
|
|
46
|
+
/* @__PURE__ */ jsx(SelectItem, { value: "weekly", children: t("customers.calendar.editor.repeat.freq.weekly", "Weekly") })
|
|
47
|
+
] })
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
),
|
|
51
|
+
freq === "weekly" ? /* @__PURE__ */ jsx("div", { className: "flex items-start gap-1.5", children: DAY_LABEL_KEYS.map((day, index) => {
|
|
52
|
+
const isActive = Boolean(days[index]);
|
|
53
|
+
return /* @__PURE__ */ jsx(
|
|
54
|
+
Button,
|
|
55
|
+
{
|
|
56
|
+
type: "button",
|
|
57
|
+
variant: isActive ? "default" : "outline",
|
|
58
|
+
"aria-pressed": isActive,
|
|
59
|
+
"aria-label": t(day.ariaKey, day.ariaFallback),
|
|
60
|
+
onClick: () => onToggleDay(index),
|
|
61
|
+
className: cn(
|
|
62
|
+
"size-9 px-0 text-xs font-medium",
|
|
63
|
+
!isActive && "text-muted-foreground"
|
|
64
|
+
),
|
|
65
|
+
children: t(day.letterKey, day.letterFallback)
|
|
66
|
+
},
|
|
67
|
+
day.ariaKey
|
|
68
|
+
);
|
|
69
|
+
}) }) : null,
|
|
70
|
+
freq !== "none" ? /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
71
|
+
/* @__PURE__ */ jsx("span", { className: LABEL_CLASS, children: t("customers.calendar.editor.repeat.ends", "Ends") }),
|
|
72
|
+
/* @__PURE__ */ jsx(
|
|
73
|
+
SegmentGroup,
|
|
74
|
+
{
|
|
75
|
+
ariaLabel: t("customers.calendar.editor.repeat.ends", "Ends"),
|
|
76
|
+
value: endType,
|
|
77
|
+
onChange: onEndTypeChange,
|
|
78
|
+
options: [
|
|
79
|
+
{ value: "never", label: t("customers.calendar.editor.repeat.never", "Never") },
|
|
80
|
+
{ value: "date", label: t("customers.calendar.editor.repeat.onDate", "On date") },
|
|
81
|
+
{ value: "count", label: t("customers.calendar.editor.repeat.after", "After") }
|
|
82
|
+
]
|
|
83
|
+
}
|
|
84
|
+
),
|
|
85
|
+
endType === "date" ? /* @__PURE__ */ jsx(
|
|
86
|
+
DateControl,
|
|
87
|
+
{
|
|
88
|
+
className: "w-44",
|
|
89
|
+
value: untilDate || "",
|
|
90
|
+
onChange: onUntilDateChange,
|
|
91
|
+
ariaLabel: t("customers.calendar.editor.repeat.onDate", "On date"),
|
|
92
|
+
locale
|
|
93
|
+
}
|
|
94
|
+
) : null,
|
|
95
|
+
endType === "count" ? /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
|
|
96
|
+
/* @__PURE__ */ jsx(
|
|
97
|
+
Input,
|
|
98
|
+
{
|
|
99
|
+
type: "number",
|
|
100
|
+
min: 1,
|
|
101
|
+
max: 365,
|
|
102
|
+
value: count,
|
|
103
|
+
onChange: (event) => {
|
|
104
|
+
const next = Number(event.target.value);
|
|
105
|
+
if (Number.isInteger(next) && next >= 1) onCountChange(next);
|
|
106
|
+
},
|
|
107
|
+
"aria-label": t("customers.calendar.editor.repeat.after", "After"),
|
|
108
|
+
className: "h-9 w-20"
|
|
109
|
+
}
|
|
110
|
+
),
|
|
111
|
+
/* @__PURE__ */ jsx("span", { className: LABEL_CLASS, children: t("customers.calendar.editor.repeat.times", "times") })
|
|
112
|
+
] }) : null
|
|
113
|
+
] }) : null
|
|
114
|
+
] });
|
|
115
|
+
}
|
|
116
|
+
export {
|
|
117
|
+
RepeatField
|
|
118
|
+
};
|
|
119
|
+
//# sourceMappingURL=RepeatField.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../src/modules/customers/components/calendar/editor/RepeatField.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 { Button } from '@open-mercato/ui/primitives/button'\nimport { Input } from '@open-mercato/ui/primitives/input'\nimport { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@open-mercato/ui/primitives/select'\nimport type { EditorRepeatEndType, EditorRepeatFreq } from '../../../lib/calendar/editorPayload'\nimport { DateControl, LABEL_CLASS } from './inputs'\nimport { SegmentGroup } from './SegmentGroup'\n\nconst DAY_LABEL_KEYS = [\n { letterKey: 'customers.calendar.editor.repeat.days.mon', letterFallback: 'M', ariaKey: 'customers.calendar.day.mon', ariaFallback: 'MON' },\n { letterKey: 'customers.calendar.editor.repeat.days.tue', letterFallback: 'T', ariaKey: 'customers.calendar.day.tue', ariaFallback: 'TUE' },\n { letterKey: 'customers.calendar.editor.repeat.days.wed', letterFallback: 'W', ariaKey: 'customers.calendar.day.wed', ariaFallback: 'WED' },\n { letterKey: 'customers.calendar.editor.repeat.days.thu', letterFallback: 'T', ariaKey: 'customers.calendar.day.thu', ariaFallback: 'THU' },\n { letterKey: 'customers.calendar.editor.repeat.days.fri', letterFallback: 'F', ariaKey: 'customers.calendar.day.fri', ariaFallback: 'FRI' },\n { letterKey: 'customers.calendar.editor.repeat.days.sat', letterFallback: 'S', ariaKey: 'customers.calendar.day.sat', ariaFallback: 'SAT' },\n { letterKey: 'customers.calendar.editor.repeat.days.sun', letterFallback: 'S', ariaKey: 'customers.calendar.day.sun', ariaFallback: 'SUN' },\n]\n\nexport function RepeatField({\n freq,\n days,\n endType,\n count,\n untilDate,\n locale,\n onFreqChange,\n onToggleDay,\n onEndTypeChange,\n onCountChange,\n onUntilDateChange,\n}: {\n freq: EditorRepeatFreq\n days: boolean[]\n endType: EditorRepeatEndType\n count: number\n untilDate: string\n locale: string\n onFreqChange(next: EditorRepeatFreq): void\n onToggleDay(index: number): void\n onEndTypeChange(next: EditorRepeatEndType): void\n onCountChange(next: number): void\n onUntilDateChange(next: string): void\n}) {\n const t = useT()\n const freqLabel = t('customers.calendar.editor.repeat.label', 'Repeat')\n return (\n <div className=\"flex w-full flex-col gap-2.5\">\n <span className={LABEL_CLASS}>{freqLabel}</span>\n <Select\n value={freq}\n onValueChange={(value) => onFreqChange(value as EditorRepeatFreq)}\n >\n <SelectTrigger aria-label={freqLabel}>\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n <SelectItem value=\"none\">{t('customers.calendar.editor.repeat.freq.none', 'Does not repeat')}</SelectItem>\n <SelectItem value=\"daily\">{t('customers.calendar.editor.repeat.freq.daily', 'Daily')}</SelectItem>\n <SelectItem value=\"weekly\">{t('customers.calendar.editor.repeat.freq.weekly', 'Weekly')}</SelectItem>\n </SelectContent>\n </Select>\n {freq === 'weekly' ? (\n <div className=\"flex items-start gap-1.5\">\n {DAY_LABEL_KEYS.map((day, index) => {\n const isActive = Boolean(days[index])\n return (\n <Button\n key={day.ariaKey}\n type=\"button\"\n variant={isActive ? 'default' : 'outline'}\n aria-pressed={isActive}\n aria-label={t(day.ariaKey, day.ariaFallback)}\n onClick={() => onToggleDay(index)}\n className={cn(\n 'size-9 px-0 text-xs font-medium',\n !isActive && 'text-muted-foreground',\n )}\n >\n {t(day.letterKey, day.letterFallback)}\n </Button>\n )\n })}\n </div>\n ) : null}\n {freq !== 'none' ? (\n <div className=\"flex flex-wrap items-center gap-2\">\n <span className={LABEL_CLASS}>{t('customers.calendar.editor.repeat.ends', 'Ends')}</span>\n <SegmentGroup\n ariaLabel={t('customers.calendar.editor.repeat.ends', 'Ends')}\n value={endType}\n onChange={onEndTypeChange}\n options={[\n { value: 'never', label: t('customers.calendar.editor.repeat.never', 'Never') },\n { value: 'date', label: t('customers.calendar.editor.repeat.onDate', 'On date') },\n { value: 'count', label: t('customers.calendar.editor.repeat.after', 'After') },\n ]}\n />\n {endType === 'date' ? (\n <DateControl\n className=\"w-44\"\n value={untilDate || ''}\n onChange={onUntilDateChange}\n ariaLabel={t('customers.calendar.editor.repeat.onDate', 'On date')}\n locale={locale}\n />\n ) : null}\n {endType === 'count' ? (\n <span className=\"flex items-center gap-2\">\n <Input\n type=\"number\"\n min={1}\n max={365}\n value={count}\n onChange={(event) => {\n const next = Number(event.target.value)\n if (Number.isInteger(next) && next >= 1) onCountChange(next)\n }}\n aria-label={t('customers.calendar.editor.repeat.after', 'After')}\n className=\"h-9 w-20\"\n />\n <span className={LABEL_CLASS}>{t('customers.calendar.editor.repe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AAAA,UACC,WAAU;AAAA,UACV,OAAO,aAAa;AAAA,UACpB,UAAU;AAAA,UACV,WAAW,EAAE,2CAA2C,SAAS;AAAA,UACjE;AAAA;AAAA,MACF,IACE;AAAA,MACH,YAAY,UACX,qBAAC,UAAK,WAAU,2BACd;AAAA;AAAA,UAAC;AAAA;AAAA,YACC,MAAK;AAAA,YACL,KAAK;AAAA,YACL,KAAK;AAAA,YACL,OAAO;AAAA,YACP,UAAU,CAAC,UAAU;AACnB,oBAAM,OAAO,OAAO,MAAM,OAAO,KAAK;AACtC,kBAAI,OAAO,UAAU,IAAI,KAAK,QAAQ,EAAG,eAAc,IAAI;AAAA,YAC7D;AAAA,YACA,cAAY,EAAE,0CAA0C,OAAO;AAAA,YAC/D,WAAU;AAAA;AAAA,QACZ;AAAA,QACA,oBAAC,UAAK,WAAW,aAAc,YAAE,0CAA0C,OAAO,GAAE;AAAA,SACtF,IACE;AAAA,OACN,IACE;AAAA,KACN;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useT } from "@open-mercato/shared/lib/i18n/context";
|
|
4
|
+
import { AllDayToggle, DateControl, LABEL_CLASS, TimeControl } from "./inputs.js";
|
|
5
|
+
const DATE_LABEL_TEXT = {
|
|
6
|
+
starts: { key: "customers.calendar.editor.dates.starts", fallback: "Starts" },
|
|
7
|
+
when: { key: "customers.calendar.editor.dates.when", fallback: "When" },
|
|
8
|
+
sent: { key: "customers.calendar.editor.dates.sent", fallback: "Sent" },
|
|
9
|
+
logged: { key: "customers.calendar.editor.dates.logged", fallback: "Logged" },
|
|
10
|
+
due: { key: "customers.calendar.editor.dates.due", fallback: "Due" }
|
|
11
|
+
};
|
|
12
|
+
function DateTimeRow({
|
|
13
|
+
label,
|
|
14
|
+
date,
|
|
15
|
+
time,
|
|
16
|
+
showTime,
|
|
17
|
+
locale,
|
|
18
|
+
onDateChange,
|
|
19
|
+
onTimeChange
|
|
20
|
+
}) {
|
|
21
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex w-full items-end gap-2.5", children: [
|
|
22
|
+
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-1.5", children: [
|
|
23
|
+
/* @__PURE__ */ jsx("span", { className: LABEL_CLASS, children: label }),
|
|
24
|
+
/* @__PURE__ */ jsx(DateControl, { value: date, onChange: onDateChange, ariaLabel: label, locale })
|
|
25
|
+
] }),
|
|
26
|
+
showTime ? /* @__PURE__ */ jsx(TimeControl, { value: time, onChange: onTimeChange, ariaLabel: label }) : null
|
|
27
|
+
] });
|
|
28
|
+
}
|
|
29
|
+
function ScheduleSection({
|
|
30
|
+
dateLabel,
|
|
31
|
+
hasAllDay,
|
|
32
|
+
hasEnd,
|
|
33
|
+
allDay,
|
|
34
|
+
date,
|
|
35
|
+
startTime,
|
|
36
|
+
endDate,
|
|
37
|
+
endTime,
|
|
38
|
+
locale,
|
|
39
|
+
endsError,
|
|
40
|
+
onAllDayChange,
|
|
41
|
+
onDateChange,
|
|
42
|
+
onStartTimeChange,
|
|
43
|
+
onEndDateChange,
|
|
44
|
+
onEndTimeChange
|
|
45
|
+
}) {
|
|
46
|
+
const t = useT();
|
|
47
|
+
const showTime = !(hasAllDay && allDay);
|
|
48
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col gap-2.5", children: [
|
|
49
|
+
hasAllDay ? /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between", children: [
|
|
50
|
+
/* @__PURE__ */ jsx("span", { className: LABEL_CLASS, children: t("customers.calendar.editor.allDay", "All day") }),
|
|
51
|
+
/* @__PURE__ */ jsx(AllDayToggle, { checked: allDay, onCheckedChange: onAllDayChange, label: t("customers.calendar.editor.allDay", "All day") })
|
|
52
|
+
] }) : null,
|
|
53
|
+
/* @__PURE__ */ jsx(
|
|
54
|
+
DateTimeRow,
|
|
55
|
+
{
|
|
56
|
+
label: t(DATE_LABEL_TEXT[dateLabel].key, DATE_LABEL_TEXT[dateLabel].fallback),
|
|
57
|
+
date,
|
|
58
|
+
time: startTime,
|
|
59
|
+
showTime,
|
|
60
|
+
locale,
|
|
61
|
+
onDateChange,
|
|
62
|
+
onTimeChange: onStartTimeChange
|
|
63
|
+
}
|
|
64
|
+
),
|
|
65
|
+
hasEnd ? /* @__PURE__ */ jsx(
|
|
66
|
+
DateTimeRow,
|
|
67
|
+
{
|
|
68
|
+
label: t("customers.calendar.editor.dates.ends", "Ends"),
|
|
69
|
+
date: endDate,
|
|
70
|
+
time: endTime,
|
|
71
|
+
showTime,
|
|
72
|
+
locale,
|
|
73
|
+
onDateChange: onEndDateChange,
|
|
74
|
+
onTimeChange: onEndTimeChange
|
|
75
|
+
}
|
|
76
|
+
) : null,
|
|
77
|
+
endsError ? /* @__PURE__ */ jsx("p", { className: "text-xs text-status-error-text", children: endsError }) : null
|
|
78
|
+
] });
|
|
79
|
+
}
|
|
80
|
+
export {
|
|
81
|
+
ScheduleSection
|
|
82
|
+
};
|
|
83
|
+
//# sourceMappingURL=ScheduleSection.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../src/modules/customers/components/calendar/editor/ScheduleSection.tsx"],
|
|
4
|
+
"sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport type { EditorDateLabel } from '../../../lib/calendar/editorPayload'\nimport { AllDayToggle, DateControl, LABEL_CLASS, TimeControl } from './inputs'\n\nconst DATE_LABEL_TEXT: Record<EditorDateLabel, { key: string; fallback: string }> = {\n starts: { key: 'customers.calendar.editor.dates.starts', fallback: 'Starts' },\n when: { key: 'customers.calendar.editor.dates.when', fallback: 'When' },\n sent: { key: 'customers.calendar.editor.dates.sent', fallback: 'Sent' },\n logged: { key: 'customers.calendar.editor.dates.logged', fallback: 'Logged' },\n due: { key: 'customers.calendar.editor.dates.due', fallback: 'Due' },\n}\n\nfunction DateTimeRow({\n label,\n date,\n time,\n showTime,\n locale,\n onDateChange,\n onTimeChange,\n}: {\n label: string\n date: string\n time: string\n showTime: boolean\n locale: string\n onDateChange(next: string): void\n onTimeChange(next: string): void\n}) {\n return (\n <div className=\"flex w-full items-end gap-2.5\">\n <div className=\"flex min-w-0 flex-1 flex-col gap-1.5\">\n <span className={LABEL_CLASS}>{label}</span>\n <DateControl value={date} onChange={onDateChange} ariaLabel={label} locale={locale} />\n </div>\n {showTime ? <TimeControl value={time} onChange={onTimeChange} ariaLabel={label} /> : null}\n </div>\n )\n}\n\nexport function ScheduleSection({\n dateLabel,\n hasAllDay,\n hasEnd,\n allDay,\n date,\n startTime,\n endDate,\n endTime,\n locale,\n endsError,\n onAllDayChange,\n onDateChange,\n onStartTimeChange,\n onEndDateChange,\n onEndTimeChange,\n}: {\n dateLabel: EditorDateLabel\n hasAllDay: boolean\n hasEnd: boolean\n allDay: boolean\n date: string\n startTime: string\n endDate: string\n endTime: string\n locale: string\n endsError?: string | null\n onAllDayChange(next: boolean): void\n onDateChange(next: string): void\n onStartTimeChange(next: string): void\n onEndDateChange(next: string): void\n onEndTimeChange(next: string): void\n}) {\n const t = useT()\n const showTime = !(hasAllDay && allDay)\n return (\n <div className=\"flex w-full flex-col gap-2.5\">\n {hasAllDay ? (\n <div className=\"flex w-full items-center justify-between\">\n <span className={LABEL_CLASS}>{t('customers.calendar.editor.allDay', 'All day')}</span>\n <AllDayToggle checked={allDay} onCheckedChange={onAllDayChange} label={t('customers.calendar.editor.allDay', 'All day')} />\n </div>\n ) : null}\n <DateTimeRow\n label={t(DATE_LABEL_TEXT[dateLabel].key, DATE_LABEL_TEXT[dateLabel].fallback)}\n date={date}\n time={startTime}\n showTime={showTime}\n locale={locale}\n onDateChange={onDateChange}\n onTimeChange={onStartTimeChange}\n />\n {hasEnd ? (\n <DateTimeRow\n label={t('customers.calendar.editor.dates.ends', 'Ends')}\n date={endDate}\n time={endTime}\n showTime={showTime}\n locale={locale}\n onDateChange={onEndDateChange}\n onTimeChange={onEndTimeChange}\n />\n ) : null}\n {endsError ? <p className=\"text-xs text-status-error-text\">{endsError}</p> : null}\n </div>\n )\n}\n"],
|
|
5
|
+
"mappings": ";AAkCM,SACE,KADF;AA/BN,SAAS,YAAY;AAErB,SAAS,cAAc,aAAa,aAAa,mBAAmB;AAEpE,MAAM,kBAA8E;AAAA,EAClF,QAAQ,EAAE,KAAK,0CAA0C,UAAU,SAAS;AAAA,EAC5E,MAAM,EAAE,KAAK,wCAAwC,UAAU,OAAO;AAAA,EACtE,MAAM,EAAE,KAAK,wCAAwC,UAAU,OAAO;AAAA,EACtE,QAAQ,EAAE,KAAK,0CAA0C,UAAU,SAAS;AAAA,EAC5E,KAAK,EAAE,KAAK,uCAAuC,UAAU,MAAM;AACrE;AAEA,SAAS,YAAY;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAQG;AACD,SACE,qBAAC,SAAI,WAAU,iCACb;AAAA,yBAAC,SAAI,WAAU,wCACb;AAAA,0BAAC,UAAK,WAAW,aAAc,iBAAM;AAAA,MACrC,oBAAC,eAAY,OAAO,MAAM,UAAU,cAAc,WAAW,OAAO,QAAgB;AAAA,OACtF;AAAA,IACC,WAAW,oBAAC,eAAY,OAAO,MAAM,UAAU,cAAc,WAAW,OAAO,IAAK;AAAA,KACvF;AAEJ;AAEO,SAAS,gBAAgB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAgBG;AACD,QAAM,IAAI,KAAK;AACf,QAAM,WAAW,EAAE,aAAa;AAChC,SACE,qBAAC,SAAI,WAAU,gCACZ;AAAA,gBACC,qBAAC,SAAI,WAAU,4CACb;AAAA,0BAAC,UAAK,WAAW,aAAc,YAAE,oCAAoC,SAAS,GAAE;AAAA,MAChF,oBAAC,gBAAa,SAAS,QAAQ,iBAAiB,gBAAgB,OAAO,EAAE,oCAAoC,SAAS,GAAG;AAAA,OAC3H,IACE;AAAA,IACJ;AAAA,MAAC;AAAA;AAAA,QACC,OAAO,EAAE,gBAAgB,SAAS,EAAE,KAAK,gBAAgB,SAAS,EAAE,QAAQ;AAAA,QAC5E;AAAA,QACA,MAAM;AAAA,QACN;AAAA,QACA;AAAA,QACA;AAAA,QACA,cAAc;AAAA;AAAA,IAChB;AAAA,IACC,SACC;AAAA,MAAC;AAAA;AAAA,QACC,OAAO,EAAE,wCAAwC,MAAM;AAAA,QACvD,MAAM;AAAA,QACN,MAAM;AAAA,QACN;AAAA,QACA;AAAA,QACA,cAAc;AAAA,QACd,cAAc;AAAA;AAAA,IAChB,IACE;AAAA,IACH,YAAY,oBAAC,OAAE,WAAU,kCAAkC,qBAAU,IAAO;AAAA,KAC/E;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { cn } from "@open-mercato/shared/lib/utils";
|
|
4
|
+
import { Button } from "@open-mercato/ui/primitives/button";
|
|
5
|
+
function SegmentGroup({
|
|
6
|
+
options,
|
|
7
|
+
value,
|
|
8
|
+
onChange,
|
|
9
|
+
size = "sm",
|
|
10
|
+
ariaLabel
|
|
11
|
+
}) {
|
|
12
|
+
return /* @__PURE__ */ jsx(
|
|
13
|
+
"div",
|
|
14
|
+
{
|
|
15
|
+
role: "group",
|
|
16
|
+
"aria-label": ariaLabel,
|
|
17
|
+
className: "inline-flex max-w-full items-start overflow-x-auto rounded-md border border-border bg-background",
|
|
18
|
+
children: options.map((option, index) => {
|
|
19
|
+
const isActive = option.value === value;
|
|
20
|
+
return /* @__PURE__ */ jsx(
|
|
21
|
+
Button,
|
|
22
|
+
{
|
|
23
|
+
type: "button",
|
|
24
|
+
variant: "ghost",
|
|
25
|
+
"aria-pressed": isActive,
|
|
26
|
+
onClick: () => onChange(option.value),
|
|
27
|
+
className: cn(
|
|
28
|
+
"h-auto rounded-none border-0 text-sm font-medium leading-5 shadow-none",
|
|
29
|
+
size === "md" ? "px-4 py-2" : "px-3.5 py-1.5",
|
|
30
|
+
index > 0 && "border-l border-border",
|
|
31
|
+
isActive ? "bg-muted text-foreground hover:bg-muted" : "bg-background text-muted-foreground"
|
|
32
|
+
),
|
|
33
|
+
children: option.label
|
|
34
|
+
},
|
|
35
|
+
option.value
|
|
36
|
+
);
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
export {
|
|
42
|
+
SegmentGroup
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=SegmentGroup.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../src/modules/customers/components/calendar/editor/SegmentGroup.tsx"],
|
|
4
|
+
"sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport { cn } from '@open-mercato/shared/lib/utils'\nimport { Button } from '@open-mercato/ui/primitives/button'\n\nexport type SegmentOption<T extends string> = { value: T; label: string }\n\nexport function SegmentGroup<T extends string>({\n options,\n value,\n onChange,\n size = 'sm',\n ariaLabel,\n}: {\n options: Array<SegmentOption<T>>\n value: T\n onChange(next: T): void\n size?: 'sm' | 'md'\n ariaLabel: string\n}) {\n return (\n <div\n role=\"group\"\n aria-label={ariaLabel}\n className=\"inline-flex max-w-full items-start overflow-x-auto rounded-md border border-border bg-background\"\n >\n {options.map((option, index) => {\n const isActive = option.value === value\n return (\n <Button\n key={option.value}\n type=\"button\"\n variant=\"ghost\"\n aria-pressed={isActive}\n onClick={() => onChange(option.value)}\n className={cn(\n 'h-auto rounded-none border-0 text-sm font-medium leading-5 shadow-none',\n size === 'md' ? 'px-4 py-2' : 'px-3.5 py-1.5',\n index > 0 && 'border-l border-border',\n isActive ? 'bg-muted text-foreground hover:bg-muted' : 'bg-background text-muted-foreground',\n )}\n >\n {option.label}\n </Button>\n )\n })}\n </div>\n )\n}\n"],
|
|
5
|
+
"mappings": ";AA8BU;AA3BV,SAAS,UAAU;AACnB,SAAS,cAAc;AAIhB,SAAS,aAA+B;AAAA,EAC7C;AAAA,EACA;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP;AACF,GAMG;AACD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL,cAAY;AAAA,MACZ,WAAU;AAAA,MAET,kBAAQ,IAAI,CAAC,QAAQ,UAAU;AAC9B,cAAM,WAAW,OAAO,UAAU;AAClC,eACE;AAAA,UAAC;AAAA;AAAA,YAEC,MAAK;AAAA,YACL,SAAQ;AAAA,YACR,gBAAc;AAAA,YACd,SAAS,MAAM,SAAS,OAAO,KAAK;AAAA,YACpC,WAAW;AAAA,cACT;AAAA,cACA,SAAS,OAAO,cAAc;AAAA,cAC9B,QAAQ,KAAK;AAAA,cACb,WAAW,4CAA4C;AAAA,YACzD;AAAA,YAEC,iBAAO;AAAA;AAAA,UAZH,OAAO;AAAA,QAad;AAAA,MAEJ,CAAC;AAAA;AAAA,EACH;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|