@ahrowe/ui 0.41.2 → 0.43.0
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/CHANGELOG.md +934 -0
- package/README.md +11 -10
- package/dist/cjs-types/common/accordion/accordion.types.d.ts +17 -2
- package/dist/cjs-types/common/actionButtons/actionButtons.types.d.ts +7 -1
- package/dist/cjs-types/common/actionIcon/actionIcon.d.ts +1 -1
- package/dist/cjs-types/common/actionIcon/actionIcon.types.d.ts +7 -9
- package/dist/cjs-types/common/alert/alert.types.d.ts +6 -8
- package/dist/cjs-types/common/animatedLogo/animatedLogo.types.d.ts +3 -2
- package/dist/cjs-types/common/badge/badge.types.d.ts +10 -6
- package/dist/cjs-types/common/button/button.types.d.ts +14 -4
- package/dist/cjs-types/common/calendar/calendar.types.d.ts +25 -10
- package/dist/cjs-types/common/calendar/components/agendaList/agendaList.d.ts +1 -1
- package/dist/cjs-types/common/calendar/components/agendaList/agendaList.types.d.ts +3 -0
- package/dist/cjs-types/common/calendar/components/calendarHeader/calendarHeader.d.ts +1 -1
- package/dist/cjs-types/common/calendar/components/calendarHeader/calendarHeader.types.d.ts +2 -0
- package/dist/cjs-types/common/calendar/components/compactMonth/compactMonth.d.ts +1 -1
- package/dist/cjs-types/common/calendar/components/monthView/monthView.d.ts +1 -1
- package/dist/cjs-types/common/calendar/components/monthView/monthView.types.d.ts +3 -2
- package/dist/cjs-types/common/calendar/components/timeGrid/timeGrid.d.ts +1 -1
- package/dist/cjs-types/common/calendar/components/timeGrid/timeGrid.types.d.ts +9 -1
- package/dist/cjs-types/common/calendar/dates.d.ts +21 -5
- package/dist/cjs-types/common/calendar/format.d.ts +3 -2
- package/dist/cjs-types/common/calendar/layout.d.ts +5 -0
- package/dist/cjs-types/common/calendar/useNow.d.ts +4 -0
- package/dist/cjs-types/common/calendar/view.types.d.ts +9 -2
- package/dist/cjs-types/common/card/card.types.d.ts +16 -2
- package/dist/cjs-types/common/chip/chip.types.d.ts +10 -5
- package/dist/cjs-types/common/copyButton/copyButton.types.d.ts +5 -4
- package/dist/cjs-types/common/fab/components/fabBase/fabBase.d.ts +1 -1
- package/dist/cjs-types/common/fab/components/fabBase/fabBase.types.d.ts +2 -1
- package/dist/cjs-types/common/floorPlan/floorPlan.graph.d.ts +10 -3
- package/dist/cjs-types/common/floorPlan/floorPlan.plan.d.ts +5 -0
- package/dist/cjs-types/common/floorPlan/floorPlan.rooms.d.ts +6 -2
- package/dist/cjs-types/common/floorPlan/floorPlan.snap.d.ts +1 -3
- package/dist/cjs-types/common/floorPlan/index.d.ts +1 -3
- package/dist/cjs-types/common/planCanvas/planCanvas.types.d.ts +1 -1
- package/dist/cjs-types/common/progressBar/progressBar.d.ts +0 -1
- package/dist/cjs-types/common/progressBar/progressBar.types.d.ts +3 -1
- package/dist/cjs-types/common/roomDrawer/roomDrawer.types.d.ts +29 -8
- package/dist/cjs-types/common/roomViewer/roomViewer.types.d.ts +4 -2
- package/dist/cjs-types/common/splitButton/splitButton.types.d.ts +4 -1
- package/dist/cjs-types/common/styles/tone.d.ts +11 -0
- package/dist/cjs-types/common/themeProvider/color.types.d.ts +20 -0
- package/dist/cjs-types/common/themeProvider/index.d.ts +2 -0
- package/dist/cjs-types/common/themeProvider/theme.types.d.ts +3 -6
- package/dist/cjs-types/common/timeline/timeline.types.d.ts +3 -10
- package/dist/cjs-types/common/toast/index.d.ts +1 -1
- package/dist/cjs-types/common/toast/toast.types.d.ts +7 -3
- package/dist/cjs-types/common/types/actions.types.d.ts +1 -1
- package/dist/cjs-types/common/utils/dismissClick.d.ts +4 -0
- package/dist/cjs-types/common/utils/isDev.d.ts +1 -0
- package/dist/esm/common/accordion/accordion.mjs +1 -1
- package/dist/esm/common/accordion/accordion.mjs.map +1 -1
- package/dist/esm/common/accordion/accordion.module.mjs +1 -1
- package/dist/esm/common/accordion/accordion.module.mjs.map +1 -1
- package/dist/esm/common/accordion/accordion.types.mjs +1 -1
- package/dist/esm/common/accordion/accordion.types.mjs.map +1 -1
- package/dist/esm/common/actionButtons/actionButtons.mjs +1 -1
- package/dist/esm/common/actionButtons/actionButtons.mjs.map +1 -1
- package/dist/esm/common/actionIcon/actionIcon.mjs +1 -1
- package/dist/esm/common/actionIcon/actionIcon.mjs.map +1 -1
- package/dist/esm/common/actionIcon/actionIcon.module.mjs +1 -1
- package/dist/esm/common/actionIcon/actionIcon.module.mjs.map +1 -1
- package/dist/esm/common/alert/alert.mjs +1 -1
- package/dist/esm/common/alert/alert.mjs.map +1 -1
- package/dist/esm/common/alert/alert.module.mjs +1 -1
- package/dist/esm/common/alert/alert.module.mjs.map +1 -1
- package/dist/esm/common/animatedLogo/animatedLogo.mjs +1 -1
- package/dist/esm/common/animatedLogo/animatedLogo.mjs.map +1 -1
- package/dist/esm/common/avatar/avatar.mjs +1 -1
- package/dist/esm/common/avatar/avatar.mjs.map +1 -1
- package/dist/esm/common/badge/badge.mjs +1 -1
- package/dist/esm/common/badge/badge.mjs.map +1 -1
- package/dist/esm/common/badge/badge.module.mjs +1 -1
- package/dist/esm/common/badge/badge.module.mjs.map +1 -1
- package/dist/esm/common/badge/badge.types.mjs +1 -1
- package/dist/esm/common/badge/badge.types.mjs.map +1 -1
- package/dist/esm/common/bodyEnd/bodyEnd.mjs +1 -1
- package/dist/esm/common/bodyEnd/bodyEnd.mjs.map +1 -1
- package/dist/esm/common/breadcrumb/breadcrumb.mjs +1 -1
- package/dist/esm/common/breadcrumb/breadcrumb.mjs.map +1 -1
- package/dist/esm/common/breadcrumb/breadcrumb.module.mjs.map +1 -1
- package/dist/esm/common/button/button.mjs +1 -1
- package/dist/esm/common/button/button.mjs.map +1 -1
- package/dist/esm/common/button/button.module.mjs +1 -1
- package/dist/esm/common/button/button.module.mjs.map +1 -1
- package/dist/esm/common/button/button.types.mjs +1 -1
- package/dist/esm/common/button/button.types.mjs.map +1 -1
- package/dist/esm/common/calendar/calendar.mjs +1 -1
- package/dist/esm/common/calendar/calendar.mjs.map +1 -1
- package/dist/esm/common/calendar/calendar.module.mjs.map +1 -1
- package/dist/esm/common/calendar/calendar.types.mjs.map +1 -1
- package/dist/esm/common/calendar/components/agendaList/agendaList.mjs +1 -1
- package/dist/esm/common/calendar/components/agendaList/agendaList.mjs.map +1 -1
- package/dist/esm/common/calendar/components/agendaList/agendaList.module.mjs.map +1 -1
- package/dist/esm/common/calendar/components/calendarHeader/calendarHeader.mjs +1 -1
- package/dist/esm/common/calendar/components/calendarHeader/calendarHeader.mjs.map +1 -1
- package/dist/esm/common/calendar/components/calendarHeader/calendarHeader.module.mjs +1 -1
- package/dist/esm/common/calendar/components/calendarHeader/calendarHeader.module.mjs.map +1 -1
- package/dist/esm/common/calendar/components/compactMonth/compactMonth.mjs +1 -1
- package/dist/esm/common/calendar/components/compactMonth/compactMonth.mjs.map +1 -1
- package/dist/esm/common/calendar/components/compactMonth/compactMonth.module.mjs +1 -1
- package/dist/esm/common/calendar/components/compactMonth/compactMonth.module.mjs.map +1 -1
- package/dist/esm/common/calendar/components/monthView/monthView.mjs +1 -1
- package/dist/esm/common/calendar/components/monthView/monthView.mjs.map +1 -1
- package/dist/esm/common/calendar/components/monthView/monthView.module.mjs +1 -1
- package/dist/esm/common/calendar/components/monthView/monthView.module.mjs.map +1 -1
- package/dist/esm/common/calendar/components/timeGrid/timeGrid.mjs +1 -1
- package/dist/esm/common/calendar/components/timeGrid/timeGrid.mjs.map +1 -1
- package/dist/esm/common/calendar/components/timeGrid/timeGrid.module.mjs +1 -1
- package/dist/esm/common/calendar/components/timeGrid/timeGrid.module.mjs.map +1 -1
- package/dist/esm/common/calendar/dates.mjs +1 -1
- package/dist/esm/common/calendar/dates.mjs.map +1 -1
- package/dist/esm/common/calendar/format.mjs +1 -1
- package/dist/esm/common/calendar/format.mjs.map +1 -1
- package/dist/esm/common/calendar/layout.mjs +1 -1
- package/dist/esm/common/calendar/layout.mjs.map +1 -1
- package/dist/esm/common/calendar/useNow.mjs +2 -0
- package/dist/esm/common/calendar/useNow.mjs.map +1 -0
- package/dist/esm/common/card/Card.mjs +1 -1
- package/dist/esm/common/card/Card.mjs.map +1 -1
- package/dist/esm/common/card/CardActions.mjs +1 -1
- package/dist/esm/common/card/CardActions.mjs.map +1 -1
- package/dist/esm/common/card/CardHeader.mjs.map +1 -1
- package/dist/esm/common/card/card.module.mjs +1 -1
- package/dist/esm/common/card/card.module.mjs.map +1 -1
- package/dist/esm/common/card/card.types.mjs +1 -1
- package/dist/esm/common/card/card.types.mjs.map +1 -1
- package/dist/esm/common/carousel/carousel.mjs +1 -1
- package/dist/esm/common/carousel/carousel.mjs.map +1 -1
- package/dist/esm/common/carousel/carousel.module.mjs.map +1 -1
- package/dist/esm/common/chip/chip.mjs +1 -1
- package/dist/esm/common/chip/chip.mjs.map +1 -1
- package/dist/esm/common/chip/chip.module.mjs +1 -1
- package/dist/esm/common/chip/chip.module.mjs.map +1 -1
- package/dist/esm/common/chip/chip.types.mjs +1 -1
- package/dist/esm/common/chip/chip.types.mjs.map +1 -1
- package/dist/esm/common/colorPicker/colorPicker.mjs +1 -1
- package/dist/esm/common/colorPicker/colorPicker.mjs.map +1 -1
- package/dist/esm/common/colorPicker/colorPicker.module.mjs.map +1 -1
- package/dist/esm/common/confirmModal/confirmModal.mjs +1 -1
- package/dist/esm/common/confirmModal/confirmModal.mjs.map +1 -1
- package/dist/esm/common/copyButton/copyButton.mjs +1 -1
- package/dist/esm/common/copyButton/copyButton.mjs.map +1 -1
- package/dist/esm/common/copyButton/copyButton.module.mjs +1 -1
- package/dist/esm/common/copyButton/copyButton.module.mjs.map +1 -1
- package/dist/esm/common/errorBoundary/errorBoundary.mjs +2 -2
- package/dist/esm/common/errorBoundary/errorBoundary.mjs.map +1 -1
- package/dist/esm/common/fab/components/fabBase/fabBase.mjs +1 -1
- package/dist/esm/common/fab/components/fabBase/fabBase.mjs.map +1 -1
- package/dist/esm/common/fab/fab.mjs +1 -1
- package/dist/esm/common/fab/fab.mjs.map +1 -1
- package/dist/esm/common/flip/flip.mjs +1 -1
- package/dist/esm/common/flip/flip.mjs.map +1 -1
- package/dist/esm/common/floorPlan/floorPlan.faces.mjs +1 -1
- package/dist/esm/common/floorPlan/floorPlan.faces.mjs.map +1 -1
- package/dist/esm/common/floorPlan/floorPlan.geometry.mjs +1 -1
- package/dist/esm/common/floorPlan/floorPlan.geometry.mjs.map +1 -1
- package/dist/esm/common/floorPlan/floorPlan.graph.mjs +1 -1
- package/dist/esm/common/floorPlan/floorPlan.graph.mjs.map +1 -1
- package/dist/esm/common/floorPlan/floorPlan.hit.mjs +1 -1
- package/dist/esm/common/floorPlan/floorPlan.hit.mjs.map +1 -1
- package/dist/esm/common/floorPlan/floorPlan.json.mjs +1 -1
- package/dist/esm/common/floorPlan/floorPlan.json.mjs.map +1 -1
- package/dist/esm/common/floorPlan/floorPlan.mesh.mjs +1 -1
- package/dist/esm/common/floorPlan/floorPlan.mesh.mjs.map +1 -1
- package/dist/esm/common/floorPlan/floorPlan.path.mjs +1 -1
- package/dist/esm/common/floorPlan/floorPlan.path.mjs.map +1 -1
- package/dist/esm/common/floorPlan/floorPlan.plan.mjs +1 -1
- package/dist/esm/common/floorPlan/floorPlan.plan.mjs.map +1 -1
- package/dist/esm/common/floorPlan/floorPlan.rooms.mjs +1 -1
- package/dist/esm/common/floorPlan/floorPlan.rooms.mjs.map +1 -1
- package/dist/esm/common/floorPlan/floorPlan.snap.mjs +1 -1
- package/dist/esm/common/floorPlan/floorPlan.snap.mjs.map +1 -1
- package/dist/esm/common/floorPlan/floorPlan.triangulate.mjs +1 -1
- package/dist/esm/common/floorPlan/floorPlan.triangulate.mjs.map +1 -1
- package/dist/esm/common/floorPlan/floorPlan.types.mjs +1 -1
- package/dist/esm/common/floorPlan/floorPlan.types.mjs.map +1 -1
- package/dist/esm/common/klipyPicker/klipyPicker.mjs +1 -1
- package/dist/esm/common/klipyPicker/klipyPicker.mjs.map +1 -1
- package/dist/esm/common/modal/modal.mjs +1 -1
- package/dist/esm/common/modal/modal.mjs.map +1 -1
- package/dist/esm/common/modal/modal.module.mjs.map +1 -1
- package/dist/esm/common/numberInput/numberInput.mjs +1 -1
- package/dist/esm/common/numberInput/numberInput.mjs.map +1 -1
- package/dist/esm/common/numberInput/numberInput.module.mjs.map +1 -1
- package/dist/esm/common/planCanvas/planCanvas.mjs +1 -1
- package/dist/esm/common/planCanvas/planCanvas.mjs.map +1 -1
- package/dist/esm/common/popover/popover.mjs +1 -1
- package/dist/esm/common/popover/popover.mjs.map +1 -1
- package/dist/esm/common/progressBar/progressBar.mjs +1 -1
- package/dist/esm/common/progressBar/progressBar.mjs.map +1 -1
- package/dist/esm/common/progressBar/progressBar.module.mjs +1 -1
- package/dist/esm/common/progressBar/progressBar.module.mjs.map +1 -1
- package/dist/esm/common/roomDrawer/roomDrawer.mjs +1 -1
- package/dist/esm/common/roomDrawer/roomDrawer.mjs.map +1 -1
- package/dist/esm/common/roomDrawer/roomDrawer.module.mjs.map +1 -1
- package/dist/esm/common/roomViewer/roomViewer.mjs +1 -1
- package/dist/esm/common/roomViewer/roomViewer.mjs.map +1 -1
- package/dist/esm/common/sectionHeader/sectionHeader.mjs.map +1 -1
- package/dist/esm/common/splitButton/splitButton.mjs +1 -1
- package/dist/esm/common/splitButton/splitButton.mjs.map +1 -1
- package/dist/esm/common/styles/tone.mjs +4 -0
- package/dist/esm/common/styles/tone.mjs.map +1 -0
- package/dist/esm/common/styles/tone.module.mjs +2 -0
- package/dist/esm/common/styles/tone.module.mjs.map +1 -0
- package/dist/esm/common/themeProvider/color.types.mjs +2 -0
- package/dist/esm/common/themeProvider/color.types.mjs.map +1 -0
- package/dist/esm/common/themeProvider/defaultTheme.mjs +1 -1
- package/dist/esm/common/themeProvider/defaultTheme.mjs.map +1 -1
- package/dist/esm/common/tilt/tilt.mjs +1 -1
- package/dist/esm/common/tilt/tilt.mjs.map +1 -1
- package/dist/esm/common/timeInput/timeInput.mjs +1 -1
- package/dist/esm/common/timeInput/timeInput.mjs.map +1 -1
- package/dist/esm/common/timeline/timeline.mjs +1 -1
- package/dist/esm/common/timeline/timeline.mjs.map +1 -1
- package/dist/esm/common/timeline/timeline.module.mjs +1 -1
- package/dist/esm/common/timeline/timeline.module.mjs.map +1 -1
- package/dist/esm/common/timeline/timeline.types.mjs +1 -1
- package/dist/esm/common/timeline/timeline.types.mjs.map +1 -1
- package/dist/esm/common/timer/timer.mjs +1 -1
- package/dist/esm/common/timer/timer.mjs.map +1 -1
- package/dist/esm/common/timer/timer.module.mjs +1 -1
- package/dist/esm/common/timer/timer.module.mjs.map +1 -1
- package/dist/esm/common/toast/toast.mjs +1 -1
- package/dist/esm/common/toast/toast.mjs.map +1 -1
- package/dist/esm/common/toast/toast.module.mjs +1 -1
- package/dist/esm/common/toast/toast.module.mjs.map +1 -1
- package/dist/esm/common/toast/toastHost.mjs +1 -1
- package/dist/esm/common/toast/toastHost.mjs.map +1 -1
- package/dist/esm/common/utils/dismissClick.mjs +2 -0
- package/dist/esm/common/utils/dismissClick.mjs.map +1 -0
- package/dist/esm/common/utils/isDev.mjs +2 -0
- package/dist/esm/common/utils/isDev.mjs.map +1 -0
- package/dist/esm/floor-plan.mjs +1 -0
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/services/formValidation/FormValidatorGroupWithForm.mjs +1 -1
- package/dist/esm/services/formValidation/FormValidatorGroupWithForm.mjs.map +1 -1
- package/dist/floor-plan.cjs +1 -0
- package/dist/floorPlan-DLe5XAx6.cjs +2 -0
- package/dist/floorPlan-DLe5XAx6.cjs.map +1 -0
- package/dist/index.cjs +5 -3
- package/dist/index.cjs.map +1 -1
- package/dist/style.css +1 -1
- package/dist/types/common/accordion/accordion.types.d.ts +17 -2
- package/dist/types/common/actionButtons/actionButtons.types.d.ts +7 -1
- package/dist/types/common/actionIcon/actionIcon.d.ts +1 -1
- package/dist/types/common/actionIcon/actionIcon.types.d.ts +7 -9
- package/dist/types/common/alert/alert.types.d.ts +6 -8
- package/dist/types/common/animatedLogo/animatedLogo.types.d.ts +3 -2
- package/dist/types/common/badge/badge.types.d.ts +10 -6
- package/dist/types/common/button/button.types.d.ts +14 -4
- package/dist/types/common/calendar/calendar.types.d.ts +25 -10
- package/dist/types/common/calendar/components/agendaList/agendaList.d.ts +1 -1
- package/dist/types/common/calendar/components/agendaList/agendaList.types.d.ts +3 -0
- package/dist/types/common/calendar/components/calendarHeader/calendarHeader.d.ts +1 -1
- package/dist/types/common/calendar/components/calendarHeader/calendarHeader.types.d.ts +2 -0
- package/dist/types/common/calendar/components/compactMonth/compactMonth.d.ts +1 -1
- package/dist/types/common/calendar/components/monthView/monthView.d.ts +1 -1
- package/dist/types/common/calendar/components/monthView/monthView.types.d.ts +3 -2
- package/dist/types/common/calendar/components/timeGrid/timeGrid.d.ts +1 -1
- package/dist/types/common/calendar/components/timeGrid/timeGrid.types.d.ts +9 -1
- package/dist/types/common/calendar/dates.d.ts +21 -5
- package/dist/types/common/calendar/format.d.ts +3 -2
- package/dist/types/common/calendar/layout.d.ts +5 -0
- package/dist/types/common/calendar/useNow.d.ts +4 -0
- package/dist/types/common/calendar/view.types.d.ts +9 -2
- package/dist/types/common/card/card.types.d.ts +16 -2
- package/dist/types/common/chip/chip.types.d.ts +10 -5
- package/dist/types/common/copyButton/copyButton.types.d.ts +5 -4
- package/dist/types/common/fab/components/fabBase/fabBase.d.ts +1 -1
- package/dist/types/common/fab/components/fabBase/fabBase.types.d.ts +2 -1
- package/dist/types/common/floorPlan/floorPlan.graph.d.ts +10 -3
- package/dist/types/common/floorPlan/floorPlan.plan.d.ts +5 -0
- package/dist/types/common/floorPlan/floorPlan.rooms.d.ts +6 -2
- package/dist/types/common/floorPlan/floorPlan.snap.d.ts +1 -3
- package/dist/types/common/floorPlan/index.d.ts +1 -3
- package/dist/types/common/planCanvas/planCanvas.types.d.ts +1 -1
- package/dist/types/common/progressBar/progressBar.d.ts +0 -1
- package/dist/types/common/progressBar/progressBar.types.d.ts +3 -1
- package/dist/types/common/roomDrawer/roomDrawer.types.d.ts +29 -8
- package/dist/types/common/roomViewer/roomViewer.types.d.ts +4 -2
- package/dist/types/common/splitButton/splitButton.types.d.ts +4 -1
- package/dist/types/common/styles/tone.d.ts +11 -0
- package/dist/types/common/themeProvider/color.types.d.ts +20 -0
- package/dist/types/common/themeProvider/index.d.ts +2 -0
- package/dist/types/common/themeProvider/theme.types.d.ts +3 -6
- package/dist/types/common/timeline/timeline.types.d.ts +3 -10
- package/dist/types/common/toast/index.d.ts +1 -1
- package/dist/types/common/toast/toast.types.d.ts +7 -3
- package/dist/types/common/types/actions.types.d.ts +1 -1
- package/dist/types/common/utils/dismissClick.d.ts +4 -0
- package/dist/types/common/utils/isDev.d.ts +1 -0
- package/docs/Accordion.md +74 -5
- package/docs/ActionButtons.md +6 -3
- package/docs/ActionIcon.md +39 -14
- package/docs/Alert.md +27 -17
- package/docs/AnimatedLogo.md +1 -1
- package/docs/Badge.md +24 -7
- package/docs/Button.md +98 -40
- package/docs/ButtonGroup.md +18 -18
- package/docs/CLAUDE.md +24 -12
- package/docs/Calendar.md +35 -17
- package/docs/Card.md +53 -14
- package/docs/Chip.md +24 -9
- package/docs/ConfigProvider.md +3 -3
- package/docs/CopyButton.md +6 -5
- package/docs/FloorPlan.md +18 -14
- package/docs/ProgressBar.md +7 -4
- package/docs/RoomDrawer.md +42 -13
- package/docs/RoomViewer.md +1 -14
- package/docs/SectionHeader.md +1 -1
- package/docs/SplitButton.md +6 -5
- package/docs/ThemeColor.md +103 -0
- package/docs/ThemeProvider.md +5 -5
- package/docs/Timeline.md +18 -9
- package/docs/Toast.md +25 -11
- package/package.json +20 -2
- package/dist/cjs-types/common/floorPlan/legacySvg.d.ts +0 -27
- package/dist/esm/common/accordion/accordion.plain.module.mjs +0 -2
- package/dist/esm/common/accordion/accordion.plain.module.mjs.map +0 -1
- package/dist/esm/common/accordion/accordion.primary.module.mjs +0 -2
- package/dist/esm/common/accordion/accordion.primary.module.mjs.map +0 -1
- package/dist/esm/common/alert/alert.types.mjs +0 -2
- package/dist/esm/common/alert/alert.types.mjs.map +0 -1
- package/dist/esm/common/floorPlan/legacySvg.mjs +0 -2
- package/dist/esm/common/floorPlan/legacySvg.mjs.map +0 -1
- package/dist/types/common/floorPlan/legacySvg.d.ts +0 -27
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"floorPlan.snap.mjs","names":[],"sources":["../../../../package/common/floorPlan/floorPlan.snap.ts"],"sourcesContent":["/**\n * Snapping, and the screen-to-world conversion it depends on.\n *\n * Two things here are deliberately different from the previous implementation:\n *\n * 1. Conversion and snapping are separate. `clientToWorld` only converts; `resolveSnap`\n * is the only thing that decides. The old `clientToSVG` called `snapPt` internally,\n * which made grid snap unconditional and left no way to hold Alt to disable it.\n *\n * 2. Every tolerance is in SCREEN PIXELS, converted through the current zoom at the\n * point of use. A fixed world-unit tolerance (the old `WALL_TOLERANCE = 8`) means\n * snapping covers a smaller and smaller part of the screen as you zoom in, until it\n * stops working.\n */\n\nimport { dist, pointToSegment, projectOnSegment, segmentIntersection } from './floorPlan.geometry';\nimport type { PlanFloor, PlanPoint } from './floorPlan.types';\n\nexport enum SnapKind {\n None = 'none',\n Node = 'node',\n /** A point projected onto a wall's centreline. */\n Wall = 'wall',\n /** The crossing of two walls, or of a wall with the active angle ray. */\n Intersection = 'intersection',\n /** On the infinite line continuing an existing wall. */\n Extension = 'extension',\n /** Shares an x or y coordinate with an existing node. */\n Alignment = 'alignment',\n /** On a ray at a multiple of `angleStepDeg` from `origin`. */\n Angle = 'angle',\n Grid = 'grid',\n}\n\nexport interface SnapGuide {\n kind: SnapKind;\n a: PlanPoint;\n b: PlanPoint;\n /** Render as an unbounded construction line rather than a segment. */\n infinite?: boolean;\n}\n\nexport interface SnapOptions {\n /** Which snaps are active. Pass `[]` (Alt held) to disable snapping entirely. */\n enabled: SnapKind[];\n /** Millimetres. 0 disables grid snap. */\n gridSize: number;\n /** Degrees. 45 gives 0/45/90. 0 disables angle lock. */\n angleStepDeg: number;\n toleranceScreenPx: number;\n /** Nodes are the most valuable snap, so they get a little more room. */\n nodeToleranceScreenPx?: number;\n}\n\nexport const DEFAULT_SNAP_OPTIONS: SnapOptions = {\n enabled: [\n SnapKind.Node,\n SnapKind.Intersection,\n SnapKind.Wall,\n SnapKind.Angle,\n SnapKind.Extension,\n SnapKind.Alignment,\n SnapKind.Grid,\n ],\n gridSize: 100,\n angleStepDeg: 0,\n toleranceScreenPx: 10,\n nodeToleranceScreenPx: 12,\n};\n\nexport interface SnapContext {\n floor: PlanFloor;\n /** World units per screen pixel at the current zoom. See `screenScale`. */\n pxToWorld: number;\n /** The anchored point. Required for angle lock; also enables the length readout. */\n origin?: PlanPoint;\n /**\n * A direction in radians that angle lock measures from, in ADDITION to the world axes.\n *\n * Pass the direction of the wall being continued and the lock offers perpendicular and\n * parallel to that wall, not just to the world. Without it, angle lock is only useful\n * on a building that happens to be aligned to the page.\n */\n referenceAngle?: number;\n excludeWallIds?: ReadonlySet<string>;\n excludeNodeIds?: ReadonlySet<string>;\n options?: Partial<SnapOptions>;\n}\n\nexport interface SnapResult {\n point: PlanPoint;\n kind: SnapKind;\n nodeId?: string;\n wallId?: string;\n /** Parameter along `wallId`, for `SnapKind.Wall`. */\n t?: number;\n /** Everything an overlay needs to draw to explain the snap. */\n guides: SnapGuide[];\n /** Radians from `origin` to `point`, when an origin was given. */\n angle?: number;\n /** Distance from `origin` to `point`, when an origin was given. */\n distance?: number;\n /**\n * Set when angle lock produced the result, saying what it locked against: the world\n * axes, or the reference direction that was passed in.\n */\n angleRelativeTo?: 'world' | 'reference';\n}\n\n/** An infinite line as a point and a unit direction. */\ninterface Line {\n kind: SnapKind;\n point: PlanPoint;\n dir: PlanPoint;\n residual: number;\n /** Angle lock only: which basis the ray was measured from. */\n relativeTo?: 'world' | 'reference';\n}\n\n/** World units per screen pixel, from the element's current transform. */\nexport function screenScale(svg: SVGSVGElement): number {\n const ctm = svg.getScreenCTM();\n if (!ctm) return 1;\n // Measured rather than read off ctm.a, so a non-uniform or rotated transform still\n // gives a sensible scalar.\n const scale = Math.hypot(ctm.a, ctm.b);\n return scale === 0 ? 1 : 1 / scale;\n}\n\n/**\n * Client (screen) coordinates to world coordinates. Pure conversion, no snapping.\n *\n * Uses `getBoundingClientRect` arithmetic against an explicit viewport rather than\n * `getScreenCTM`, which returns `null` in jsdom and so makes anything built on it\n * untestable.\n */\nexport function clientToWorld(\n clientX: number,\n clientY: number,\n rect: { left: number; top: number },\n view: { x: number; y: number; zoom: number },\n): PlanPoint {\n return {\n x: view.x + (clientX - rect.left) / view.zoom,\n y: view.y + (clientY - rect.top) / view.zoom,\n };\n}\n\nfunction perpendicularDistanceToLine(p: PlanPoint, line: { point: PlanPoint; dir: PlanPoint }): number {\n const vx = p.x - line.point.x;\n const vy = p.y - line.point.y;\n return Math.abs(vx * line.dir.y - vy * line.dir.x);\n}\n\nfunction projectOnLine(p: PlanPoint, line: { point: PlanPoint; dir: PlanPoint }): PlanPoint {\n const vx = p.x - line.point.x;\n const vy = p.y - line.point.y;\n const along = vx * line.dir.x + vy * line.dir.y;\n return { x: line.point.x + line.dir.x * along, y: line.point.y + line.dir.y * along };\n}\n\nfunction intersectLines(l1: Line, l2: Line): PlanPoint | null {\n const denom = l1.dir.x * l2.dir.y - l1.dir.y * l2.dir.x;\n if (Math.abs(denom) < 1e-9) return null;\n const dx = l2.point.x - l1.point.x;\n const dy = l2.point.y - l1.point.y;\n const t = (dx * l2.dir.y - dy * l2.dir.x) / denom;\n return { x: l1.point.x + l1.dir.x * t, y: l1.point.y + l1.dir.y * t };\n}\n\nfunction angleBetween(l1: Line, l2: Line): number {\n const dot = Math.abs(l1.dir.x * l2.dir.x + l1.dir.y * l2.dir.y);\n return Math.acos(Math.min(1, dot));\n}\n\nfunction roundTo(value: number, step: number): number {\n return step > 0 ? Math.round(value / step) * step : value;\n}\n\n/**\n * Resolves a raw pointer position to the point the user meant.\n *\n * Two stages, because half of these snaps are constraints rather than points. A hard\n * snap (node, intersection, wall) fixes both degrees of freedom, so the first match\n * wins. A constraint (angle lock, extension, alignment) removes only one, so a flat\n * \"first match wins\" list would kick the point off the angle ray the moment an\n * alignment also matched. Two constraints intersect; one constraint is projected onto\n * and then slid ALONG to the nearest grid position, which is what lets angle lock and\n * grid coexist instead of fighting.\n */\nexport function resolveSnap(raw: PlanPoint, ctx: SnapContext): SnapResult {\n const options: SnapOptions = { ...DEFAULT_SNAP_OPTIONS, ...ctx.options };\n const enabled = new Set(options.enabled);\n\n /**\n * Measures the resolved point back against the origin, so every branch reports the\n * same angle and distance without each one having to compute them. Taking them from\n * the final point rather than from whichever branch produced it means they always\n * describe what the user actually gets.\n */\n const finish = (result: SnapResult): SnapResult => {\n if (!ctx.origin) return result;\n const dx = result.point.x - ctx.origin.x;\n const dy = result.point.y - ctx.origin.y;\n return { ...result, angle: Math.atan2(dy, dx), distance: Math.hypot(dx, dy) };\n };\n\n if (enabled.size === 0) return finish({ point: raw, kind: SnapKind.None, guides: [] });\n\n const tol = options.toleranceScreenPx * ctx.pxToWorld;\n const nodeTol = (options.nodeToleranceScreenPx ?? options.toleranceScreenPx) * ctx.pxToWorld;\n const { floor } = ctx;\n\n /**\n * Angle lock, when the caller has asked for it, is a HARD constraint rather than\n * another proximity snap: `angleStepDeg > 0` only happens because the user latched the\n * lock or held the modifier. Gating it by tolerance like the ambient snaps would mean\n * it silently stopped applying as soon as you dragged more than a few pixels off the\n * ray, which is the opposite of what a lock is for.\n */\n const lockedRay: Line | null = (() => {\n if (!enabled.has(SnapKind.Angle) || !ctx.origin || options.angleStepDeg <= 0) return null;\n const step = (options.angleStepDeg * Math.PI) / 180;\n const rawAngle = Math.atan2(raw.y - ctx.origin.y, raw.x - ctx.origin.x);\n\n // Measure from the world axes, and also from the reference direction when one was\n // given, so \"square to the wall I am continuing\" is available as well as \"square to\n // the page\". Whichever ray the pointer is closest to wins.\n const bases: Array<{ angle: number; relativeTo: 'world' | 'reference' }> = [{ angle: 0, relativeTo: 'world' }];\n if (ctx.referenceAngle !== undefined) {\n bases.push({ angle: ctx.referenceAngle, relativeTo: 'reference' });\n }\n\n let best: Line | null = null;\n for (const base of bases) {\n const snapped = base.angle + Math.round((rawAngle - base.angle) / step) * step;\n const dir = { x: Math.cos(snapped), y: Math.sin(snapped) };\n const line: Line = {\n kind: SnapKind.Angle,\n point: ctx.origin,\n dir,\n residual: 0,\n relativeTo: base.relativeTo,\n };\n line.residual = perpendicularDistanceToLine(raw, line);\n if (!best || line.residual < best.residual) best = line;\n }\n return best;\n })();\n\n /**\n * While the lock is on, a hard snap is only allowed to win if it sits ON the ray.\n * Otherwise \"hold the angle\" would be quietly overridden by any nearby corner, which\n * is exactly the case the lock exists to prevent.\n */\n const allowedByLock = (p: PlanPoint): boolean => !lockedRay || perpendicularDistanceToLine(p, lockedRay) <= tol;\n\n // ── Stage A: hard snaps ──────────────────────────────────────────────────────\n\n if (enabled.has(SnapKind.Node)) {\n let best: { id: string; point: PlanPoint; d: number } | null = null;\n for (const node of Object.values(floor.nodes)) {\n if (ctx.excludeNodeIds?.has(node.id)) continue;\n const d = dist(raw, node);\n if (d <= nodeTol && allowedByLock(node) && (!best || d < best.d)) {\n best = { id: node.id, point: { x: node.x, y: node.y }, d };\n }\n }\n if (best) {\n return finish({ point: best.point, kind: SnapKind.Node, nodeId: best.id, guides: [] });\n }\n }\n\n const walls = Object.values(floor.walls).filter((w) => !ctx.excludeWallIds?.has(w.id));\n\n if (enabled.has(SnapKind.Intersection)) {\n let best: { point: PlanPoint; d: number } | null = null;\n for (let i = 0; i < walls.length; i++) {\n for (let j = i + 1; j < walls.length; j++) {\n const a = floor.nodes[walls[i].a];\n const b = floor.nodes[walls[i].b];\n const c = floor.nodes[walls[j].a];\n const d2 = floor.nodes[walls[j].b];\n if (!a || !b || !c || !d2) continue;\n const hit = segmentIntersection(a, b, c, d2);\n if (!hit.point) continue;\n const d = dist(raw, hit.point);\n if (d <= tol && allowedByLock(hit.point) && (!best || d < best.d)) {\n best = { point: hit.point, d };\n }\n }\n }\n if (best) return finish({ point: best.point, kind: SnapKind.Intersection, guides: [] });\n }\n\n if (enabled.has(SnapKind.Wall)) {\n let best: { wallId: string; point: PlanPoint; t: number; d: number } | null = null;\n for (const wall of walls) {\n const a = floor.nodes[wall.a];\n const b = floor.nodes[wall.b];\n if (!a || !b) continue;\n const r = pointToSegment(raw, a, b);\n if (r.dist <= tol && allowedByLock(r.point) && (!best || r.dist < best.d)) {\n // Project exactly: intent is allowed to be approximate, the model is not.\n best = { wallId: wall.id, point: projectOnSegment(raw, a, b), t: r.t, d: r.dist };\n }\n }\n if (best) {\n return finish({\n point: best.point,\n kind: SnapKind.Wall,\n wallId: best.wallId,\n t: best.t,\n guides: [],\n });\n }\n }\n\n // ── Stage B: constraints ─────────────────────────────────────────────────────\n\n const constraints: Line[] = [];\n\n if (enabled.has(SnapKind.Extension)) {\n let best: Line | null = null;\n for (const wall of walls) {\n const a = floor.nodes[wall.a];\n const b = floor.nodes[wall.b];\n if (!a || !b) continue;\n const len = dist(a, b);\n if (len < 1e-6) continue;\n const dir = { x: (b.x - a.x) / len, y: (b.y - a.y) / len };\n const line: Line = { kind: SnapKind.Extension, point: { x: a.x, y: a.y }, dir, residual: 0 };\n line.residual = perpendicularDistanceToLine(raw, line);\n // Only beyond the segment itself; on the segment, the wall snap already applies.\n const onSegment = pointToSegment(raw, a, b).dist <= tol;\n if (line.residual <= tol && !onSegment && (!best || line.residual < best.residual)) {\n best = line;\n }\n }\n if (best) constraints.push(best);\n }\n\n if (enabled.has(SnapKind.Alignment)) {\n let bestV: Line | null = null;\n let bestH: Line | null = null;\n for (const node of Object.values(floor.nodes)) {\n if (ctx.excludeNodeIds?.has(node.id)) continue;\n const dx = Math.abs(raw.x - node.x);\n if (dx <= tol && (!bestV || dx < bestV.residual)) {\n bestV = {\n kind: SnapKind.Alignment,\n point: { x: node.x, y: node.y },\n dir: { x: 0, y: 1 },\n residual: dx,\n };\n }\n const dy = Math.abs(raw.y - node.y);\n if (dy <= tol && (!bestH || dy < bestH.residual)) {\n bestH = {\n kind: SnapKind.Alignment,\n point: { x: node.x, y: node.y },\n dir: { x: 1, y: 0 },\n residual: dy,\n };\n }\n }\n if (bestV) constraints.push(bestV);\n if (bestH) constraints.push(bestH);\n }\n\n const guideFor = (line: Line, through: PlanPoint): SnapGuide => ({\n kind: line.kind,\n a: { x: through.x - line.dir.x * 1e5, y: through.y - line.dir.y * 1e5 },\n b: { x: through.x + line.dir.x * 1e5, y: through.y + line.dir.y * 1e5 },\n infinite: true,\n });\n\n if (lockedRay) {\n // The ray is fixed; the only freedom left is where along it the point sits. Another\n // constraint that genuinely crosses it pins that down, which is the useful\n // \"45 degrees AND level with that corner\" case.\n const crossing = constraints\n .filter((c) => c.residual <= tol && angleBetween(lockedRay, c) > (15 * Math.PI) / 180)\n .sort((a, b) => a.residual - b.residual)[0];\n\n if (crossing) {\n const point = intersectLines(lockedRay, crossing);\n if (point && dist(point, raw) <= tol * 4) {\n return finish({\n point,\n kind: SnapKind.Angle,\n guides: [guideFor(lockedRay, point), guideFor(crossing, point)],\n angleRelativeTo: lockedRay.relativeTo,\n });\n }\n }\n\n let point = projectOnLine(raw, lockedRay);\n if (enabled.has(SnapKind.Grid) && options.gridSize > 0) {\n // Slide along the ray to a round length, rather than rounding both coordinates,\n // which would take the point straight back off it.\n const along = (point.x - lockedRay.point.x) * lockedRay.dir.x + (point.y - lockedRay.point.y) * lockedRay.dir.y;\n const snappedAlong = roundTo(along, options.gridSize);\n point = {\n x: lockedRay.point.x + lockedRay.dir.x * snappedAlong,\n y: lockedRay.point.y + lockedRay.dir.y * snappedAlong,\n };\n }\n return finish({\n point,\n kind: SnapKind.Angle,\n guides: [guideFor(lockedRay, point)],\n angleRelativeTo: lockedRay.relativeTo,\n });\n }\n\n if (constraints.length >= 2) {\n const sorted = [...constraints].sort((a, b) => a.residual - b.residual);\n const [l1, l2] = sorted;\n const point = intersectLines(l1, l2);\n // Two nearly parallel constraints intersect somewhere useless and far away.\n if (point && angleBetween(l1, l2) > (15 * Math.PI) / 180 && dist(point, raw) <= tol * 2) {\n return finish({\n point,\n kind: SnapKind.Intersection,\n guides: [guideFor(l1, point), guideFor(l2, point)],\n });\n }\n }\n\n if (constraints.length >= 1) {\n const line = [...constraints].sort((a, b) => a.residual - b.residual)[0];\n let point = projectOnLine(raw, line);\n if (enabled.has(SnapKind.Grid) && options.gridSize > 0) {\n // Slide along the constraint to a round distance, rather than rounding both\n // coordinates, which would take the point back off the line.\n const along = (point.x - line.point.x) * line.dir.x + (point.y - line.point.y) * line.dir.y;\n const snappedAlong = roundTo(along, options.gridSize);\n point = {\n x: line.point.x + line.dir.x * snappedAlong,\n y: line.point.y + line.dir.y * snappedAlong,\n };\n }\n return finish({\n point,\n kind: line.kind,\n guides: [guideFor(line, point)],\n angleRelativeTo: line.relativeTo,\n });\n }\n\n if (enabled.has(SnapKind.Grid) && options.gridSize > 0) {\n return finish({\n point: { x: roundTo(raw.x, options.gridSize), y: roundTo(raw.y, options.gridSize) },\n kind: SnapKind.Grid,\n guides: [],\n });\n }\n\n return finish({ point: raw, kind: SnapKind.None, guides: [] });\n}\n"],"mappings":"gIAkBA,IAAY,EAAL,SAAA,EAAA,OACL,GAAA,KAAA,OACA,EAAA,KAAA,OAEA,EAAA,KAAA,OAEA,EAAA,aAAA,eAEA,EAAA,UAAA,YAEA,EAAA,UAAA,YAEA,EAAA,MAAA,QACA,EAAA,KAAA,QACF,EAAA,CAAA,CAAA,EAsBa,EAAoC,CAC/C,QAAS,oEAQT,EACA,SAAU,IACV,aAAc,EACd,kBAAmB,GACnB,sBAAuB,EACzB,EAoDA,SAAgB,EAAY,EAA4B,CACtD,IAAM,EAAM,EAAI,aAAa,EAC7B,GAAI,CAAC,EAAK,MAAO,GAGjB,IAAM,EAAQ,KAAK,MAAM,EAAI,EAAG,EAAI,CAAC,EACrC,OAAO,IAAU,EAAI,EAAI,EAAI,CAC/B,CASA,SAAgB,EACd,EACA,EACA,EACA,EACW,CACX,MAAO,CACL,EAAG,EAAK,GAAK,EAAU,EAAK,M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nC,GAAI,GAAS,EAAa,EAAI,CAAE,EAAK,GAAK,KAAK,GAAM,KAAO,EAAK,EAAO,CAAG,GAAK,EAAM,EACpF,OAAO,EAAO,CACZ,QACA,KAAA,eACA,OAAQ,CAAC,EAAS,EAAI,CAAK,EAAG,EAAS,EAAI,CAAK,CAAC,CACnD,CAAC,CAEL,CAEA,GAAI,EAAY,QAAU,EAAG,CAC3B,IAAM,EAAO,CAAC,GAAG,CAAW,CAAC,CAAC,MAAM,EAAG,IAAM,EAAE,SAAW,EAAE,QAAQ,CAAC,CAAC,GAClE,EAAQ,EAAc,EAAK,CAAI,EACnC,GAAI,EAAQ,IAAA,MAAiB,GAAK,EAAQ,SAAW,EAAG,CAItD,IAAM,EAAe,GADN,EAAM,EAAI,EAAK,MAAM,GAAK,EAAK,IAAI,GAAK,EAAM,EAAI,EAAK,MAAM,GAAK,EAAK,IAAI,EACtD,EAAQ,QAAQ,EACpD,EAAQ,CACN,EAAG,EAAK,MAAM,EAAI,EAAK,IAAI,EAAI,EAC/B,EAAG,EAAK,MAAM,EAAI,EAAK,IAAI,EAAI,CACjC,CACF,CACA,OAAO,EAAO,CACZ,QACA,KAAM,EAAK,KACX,OAAQ,CAAC,EAAS,EAAM,CAAK,CAAC,EAC9B,gBAAiB,EAAK,UACxB,CAAC,CACH,CAUA,OARI,EAAQ,IAAA,MAAiB,GAAK,EAAQ,SAAW,EAC5C,EAAO,CACZ,MAAO,CAAE,EAAG,EAAQ,EAAI,EAAG,EAAQ,QAAQ,EAAG,EAAG,EAAQ,EAAI,EAAG,EAAQ,QAAQ,CAAE,EAClF,KAAA,OACA,OAAQ,CAAC,CACX,CAAC,EAGI,EAAO,CAAE,MAAO,EAAK,KAAA,OAAqB,OAAQ,CAAC,CAAE,CAAC,CAC/D"}
|
|
1
|
+
{"version":3,"file":"floorPlan.snap.mjs","names":[],"sources":["../../../../package/common/floorPlan/floorPlan.snap.ts"],"sourcesContent":["/**\n * Snapping, and the screen-to-world conversion it depends on.\n *\n * Two things here are deliberately different from the previous implementation:\n *\n * 1. Conversion and snapping are separate. `clientToWorld` only converts; `resolveSnap`\n * is the only thing that decides. The old `clientToSVG` called `snapPt` internally,\n * which made grid snap unconditional and left no way to hold Alt to disable it.\n *\n * 2. Every tolerance is in SCREEN PIXELS, converted through the current zoom at the\n * point of use. A fixed world-unit tolerance (the old `WALL_TOLERANCE = 8`) means\n * snapping covers a smaller and smaller part of the screen as you zoom in, until it\n * stops working.\n */\n\nimport { dist, pointToSegment, projectOnSegment, segmentIntersection } from './floorPlan.geometry';\nimport type { PlanFloor, PlanPoint } from './floorPlan.types';\n\nexport enum SnapKind {\n None = 'none',\n Node = 'node',\n /** A point projected onto a wall's centreline. */\n Wall = 'wall',\n /** The crossing of two walls, or of a wall with the active angle ray. */\n Intersection = 'intersection',\n /** On the infinite line continuing an existing wall. */\n Extension = 'extension',\n /** Shares an x or y coordinate with an existing node. */\n Alignment = 'alignment',\n /** On a ray at a multiple of `angleStepDeg` from `origin`. */\n Angle = 'angle',\n Grid = 'grid',\n}\n\nexport interface SnapGuide {\n kind: SnapKind;\n a: PlanPoint;\n b: PlanPoint;\n /** Render as an unbounded construction line rather than a segment. */\n infinite?: boolean;\n}\n\nexport interface SnapOptions {\n /** Which snaps are active. Pass `[]` (Alt held) to disable snapping entirely. */\n enabled: SnapKind[];\n /** Millimetres. 0 disables grid snap. */\n gridSize: number;\n /** Degrees. 45 gives 0/45/90. 0 disables angle lock. */\n angleStepDeg: number;\n toleranceScreenPx: number;\n /** Nodes are the most valuable snap, so they get a little more room. */\n nodeToleranceScreenPx?: number;\n}\n\nexport const DEFAULT_SNAP_OPTIONS: SnapOptions = {\n enabled: [\n SnapKind.Node,\n SnapKind.Intersection,\n SnapKind.Wall,\n SnapKind.Angle,\n SnapKind.Extension,\n SnapKind.Alignment,\n SnapKind.Grid,\n ],\n gridSize: 100,\n angleStepDeg: 0,\n toleranceScreenPx: 10,\n nodeToleranceScreenPx: 12,\n};\n\nexport interface SnapContext {\n floor: PlanFloor;\n /** World units per screen pixel at the current zoom: `1 / view.zoom`. */\n pxToWorld: number;\n /** The anchored point. Required for angle lock; also enables the length readout. */\n origin?: PlanPoint;\n /**\n * A direction in radians that angle lock measures from, in ADDITION to the world axes.\n *\n * Pass the direction of the wall being continued and the lock offers perpendicular and\n * parallel to that wall, not just to the world. Without it, angle lock is only useful\n * on a building that happens to be aligned to the page.\n */\n referenceAngle?: number;\n excludeWallIds?: ReadonlySet<string>;\n excludeNodeIds?: ReadonlySet<string>;\n options?: Partial<SnapOptions>;\n}\n\nexport interface SnapResult {\n point: PlanPoint;\n kind: SnapKind;\n nodeId?: string;\n wallId?: string;\n /** Parameter along `wallId`, for `SnapKind.Wall`. */\n t?: number;\n /** Everything an overlay needs to draw to explain the snap. */\n guides: SnapGuide[];\n /** Radians from `origin` to `point`, when an origin was given. */\n angle?: number;\n /** Distance from `origin` to `point`, when an origin was given. */\n distance?: number;\n /**\n * Set when angle lock produced the result, saying what it locked against: the world\n * axes, or the reference direction that was passed in.\n */\n angleRelativeTo?: 'world' | 'reference';\n}\n\n/** An infinite line as a point and a unit direction. */\ninterface Line {\n kind: SnapKind;\n point: PlanPoint;\n dir: PlanPoint;\n residual: number;\n /** Angle lock only: which basis the ray was measured from. */\n relativeTo?: 'world' | 'reference';\n}\n\n/**\n * Client (screen) coordinates to world coordinates. Pure conversion, no snapping.\n *\n * Uses `getBoundingClientRect` arithmetic against an explicit viewport rather than\n * `getScreenCTM`, which returns `null` in jsdom and so makes anything built on it\n * untestable.\n */\nexport function clientToWorld(\n clientX: number,\n clientY: number,\n rect: { left: number; top: number },\n view: { x: number; y: number; zoom: number },\n): PlanPoint {\n return {\n x: view.x + (clientX - rect.left) / view.zoom,\n y: view.y + (clientY - rect.top) / view.zoom,\n };\n}\n\nfunction perpendicularDistanceToLine(p: PlanPoint, line: { point: PlanPoint; dir: PlanPoint }): number {\n const vx = p.x - line.point.x;\n const vy = p.y - line.point.y;\n return Math.abs(vx * line.dir.y - vy * line.dir.x);\n}\n\nfunction projectOnLine(p: PlanPoint, line: { point: PlanPoint; dir: PlanPoint }): PlanPoint {\n const vx = p.x - line.point.x;\n const vy = p.y - line.point.y;\n const along = vx * line.dir.x + vy * line.dir.y;\n return { x: line.point.x + line.dir.x * along, y: line.point.y + line.dir.y * along };\n}\n\nfunction intersectLines(l1: Line, l2: Line): PlanPoint | null {\n const denom = l1.dir.x * l2.dir.y - l1.dir.y * l2.dir.x;\n if (Math.abs(denom) < 1e-9) return null;\n const dx = l2.point.x - l1.point.x;\n const dy = l2.point.y - l1.point.y;\n const t = (dx * l2.dir.y - dy * l2.dir.x) / denom;\n return { x: l1.point.x + l1.dir.x * t, y: l1.point.y + l1.dir.y * t };\n}\n\nfunction angleBetween(l1: Line, l2: Line): number {\n const dot = Math.abs(l1.dir.x * l2.dir.x + l1.dir.y * l2.dir.y);\n return Math.acos(Math.min(1, dot));\n}\n\nfunction roundTo(value: number, step: number): number {\n return step > 0 ? Math.round(value / step) * step : value;\n}\n\n/**\n * Resolves a raw pointer position to the point the user meant.\n *\n * Two stages, because half of these snaps are constraints rather than points. A hard\n * snap (node, intersection, wall) fixes both degrees of freedom, so the first match\n * wins. A constraint (angle lock, extension, alignment) removes only one, so a flat\n * \"first match wins\" list would kick the point off the angle ray the moment an\n * alignment also matched. Two constraints intersect; one constraint is projected onto\n * and then slid ALONG to the nearest grid position, which is what lets angle lock and\n * grid coexist instead of fighting.\n */\nexport function resolveSnap(raw: PlanPoint, ctx: SnapContext): SnapResult {\n const options: SnapOptions = { ...DEFAULT_SNAP_OPTIONS, ...ctx.options };\n const enabled = new Set(options.enabled);\n\n /**\n * Measures the resolved point back against the origin, so every branch reports the\n * same angle and distance without each one having to compute them. Taking them from\n * the final point rather than from whichever branch produced it means they always\n * describe what the user actually gets.\n */\n const finish = (result: SnapResult): SnapResult => {\n if (!ctx.origin) return result;\n const dx = result.point.x - ctx.origin.x;\n const dy = result.point.y - ctx.origin.y;\n return { ...result, angle: Math.atan2(dy, dx), distance: Math.hypot(dx, dy) };\n };\n\n if (enabled.size === 0) return finish({ point: raw, kind: SnapKind.None, guides: [] });\n\n const tol = options.toleranceScreenPx * ctx.pxToWorld;\n const nodeTol = (options.nodeToleranceScreenPx ?? options.toleranceScreenPx) * ctx.pxToWorld;\n const { floor } = ctx;\n\n /**\n * Angle lock, when the caller has asked for it, is a HARD constraint rather than\n * another proximity snap: `angleStepDeg > 0` only happens because the user latched the\n * lock or held the modifier. Gating it by tolerance like the ambient snaps would mean\n * it silently stopped applying as soon as you dragged more than a few pixels off the\n * ray, which is the opposite of what a lock is for.\n */\n const lockedRay: Line | null = (() => {\n if (!enabled.has(SnapKind.Angle) || !ctx.origin || options.angleStepDeg <= 0) return null;\n const step = (options.angleStepDeg * Math.PI) / 180;\n const rawAngle = Math.atan2(raw.y - ctx.origin.y, raw.x - ctx.origin.x);\n\n // Measure from the world axes, and also from the reference direction when one was\n // given, so \"square to the wall I am continuing\" is available as well as \"square to\n // the page\". Whichever ray the pointer is closest to wins.\n const bases: Array<{ angle: number; relativeTo: 'world' | 'reference' }> = [{ angle: 0, relativeTo: 'world' }];\n if (ctx.referenceAngle !== undefined) {\n bases.push({ angle: ctx.referenceAngle, relativeTo: 'reference' });\n }\n\n let best: Line | null = null;\n for (const base of bases) {\n const snapped = base.angle + Math.round((rawAngle - base.angle) / step) * step;\n const dir = { x: Math.cos(snapped), y: Math.sin(snapped) };\n const line: Line = {\n kind: SnapKind.Angle,\n point: ctx.origin,\n dir,\n residual: 0,\n relativeTo: base.relativeTo,\n };\n line.residual = perpendicularDistanceToLine(raw, line);\n if (!best || line.residual < best.residual) best = line;\n }\n return best;\n })();\n\n /**\n * While the lock is on, a hard snap is only allowed to win if it sits ON the ray.\n * Otherwise \"hold the angle\" would be quietly overridden by any nearby corner, which\n * is exactly the case the lock exists to prevent.\n */\n const allowedByLock = (p: PlanPoint): boolean => !lockedRay || perpendicularDistanceToLine(p, lockedRay) <= tol;\n\n // ── Stage A: hard snaps ──────────────────────────────────────────────────────\n\n if (enabled.has(SnapKind.Node)) {\n let best: { id: string; point: PlanPoint; d: number } | null = null;\n for (const node of Object.values(floor.nodes)) {\n if (ctx.excludeNodeIds?.has(node.id)) continue;\n const d = dist(raw, node);\n if (d <= nodeTol && allowedByLock(node) && (!best || d < best.d)) {\n best = { id: node.id, point: { x: node.x, y: node.y }, d };\n }\n }\n if (best) {\n return finish({ point: best.point, kind: SnapKind.Node, nodeId: best.id, guides: [] });\n }\n }\n\n const walls = Object.values(floor.walls).filter((w) => !ctx.excludeWallIds?.has(w.id));\n\n if (enabled.has(SnapKind.Intersection)) {\n let best: { point: PlanPoint; d: number } | null = null;\n for (let i = 0; i < walls.length; i++) {\n for (let j = i + 1; j < walls.length; j++) {\n const a = floor.nodes[walls[i].a];\n const b = floor.nodes[walls[i].b];\n const c = floor.nodes[walls[j].a];\n const d2 = floor.nodes[walls[j].b];\n if (!a || !b || !c || !d2) continue;\n const hit = segmentIntersection(a, b, c, d2);\n if (!hit.point) continue;\n const d = dist(raw, hit.point);\n if (d <= tol && allowedByLock(hit.point) && (!best || d < best.d)) {\n best = { point: hit.point, d };\n }\n }\n }\n if (best) return finish({ point: best.point, kind: SnapKind.Intersection, guides: [] });\n }\n\n if (enabled.has(SnapKind.Wall)) {\n let best: { wallId: string; point: PlanPoint; t: number; d: number } | null = null;\n for (const wall of walls) {\n const a = floor.nodes[wall.a];\n const b = floor.nodes[wall.b];\n if (!a || !b) continue;\n const r = pointToSegment(raw, a, b);\n if (r.dist <= tol && allowedByLock(r.point) && (!best || r.dist < best.d)) {\n // Project exactly: intent is allowed to be approximate, the model is not.\n best = { wallId: wall.id, point: projectOnSegment(raw, a, b), t: r.t, d: r.dist };\n }\n }\n if (best) {\n return finish({\n point: best.point,\n kind: SnapKind.Wall,\n wallId: best.wallId,\n t: best.t,\n guides: [],\n });\n }\n }\n\n // ── Stage B: constraints ─────────────────────────────────────────────────────\n\n const constraints: Line[] = [];\n\n if (enabled.has(SnapKind.Extension)) {\n let best: Line | null = null;\n for (const wall of walls) {\n const a = floor.nodes[wall.a];\n const b = floor.nodes[wall.b];\n if (!a || !b) continue;\n const len = dist(a, b);\n if (len < 1e-6) continue;\n const dir = { x: (b.x - a.x) / len, y: (b.y - a.y) / len };\n const line: Line = { kind: SnapKind.Extension, point: { x: a.x, y: a.y }, dir, residual: 0 };\n line.residual = perpendicularDistanceToLine(raw, line);\n // Only beyond the segment itself; on the segment, the wall snap already applies.\n const onSegment = pointToSegment(raw, a, b).dist <= tol;\n if (line.residual <= tol && !onSegment && (!best || line.residual < best.residual)) {\n best = line;\n }\n }\n if (best) constraints.push(best);\n }\n\n if (enabled.has(SnapKind.Alignment)) {\n let bestV: Line | null = null;\n let bestH: Line | null = null;\n for (const node of Object.values(floor.nodes)) {\n if (ctx.excludeNodeIds?.has(node.id)) continue;\n const dx = Math.abs(raw.x - node.x);\n if (dx <= tol && (!bestV || dx < bestV.residual)) {\n bestV = {\n kind: SnapKind.Alignment,\n point: { x: node.x, y: node.y },\n dir: { x: 0, y: 1 },\n residual: dx,\n };\n }\n const dy = Math.abs(raw.y - node.y);\n if (dy <= tol && (!bestH || dy < bestH.residual)) {\n bestH = {\n kind: SnapKind.Alignment,\n point: { x: node.x, y: node.y },\n dir: { x: 1, y: 0 },\n residual: dy,\n };\n }\n }\n if (bestV) constraints.push(bestV);\n if (bestH) constraints.push(bestH);\n }\n\n const guideFor = (line: Line, through: PlanPoint): SnapGuide => ({\n kind: line.kind,\n a: { x: through.x - line.dir.x * 1e5, y: through.y - line.dir.y * 1e5 },\n b: { x: through.x + line.dir.x * 1e5, y: through.y + line.dir.y * 1e5 },\n infinite: true,\n });\n\n if (lockedRay) {\n // The ray is fixed; the only freedom left is where along it the point sits. Another\n // constraint that genuinely crosses it pins that down, which is the useful\n // \"45 degrees AND level with that corner\" case.\n const crossing = constraints\n .filter((c) => c.residual <= tol && angleBetween(lockedRay, c) > (15 * Math.PI) / 180)\n .sort((a, b) => a.residual - b.residual)[0];\n\n if (crossing) {\n const point = intersectLines(lockedRay, crossing);\n if (point && dist(point, raw) <= tol * 4) {\n return finish({\n point,\n kind: SnapKind.Angle,\n guides: [guideFor(lockedRay, point), guideFor(crossing, point)],\n angleRelativeTo: lockedRay.relativeTo,\n });\n }\n }\n\n let point = projectOnLine(raw, lockedRay);\n if (enabled.has(SnapKind.Grid) && options.gridSize > 0) {\n // Slide along the ray to a round length, rather than rounding both coordinates,\n // which would take the point straight back off it.\n const along = (point.x - lockedRay.point.x) * lockedRay.dir.x + (point.y - lockedRay.point.y) * lockedRay.dir.y;\n const snappedAlong = roundTo(along, options.gridSize);\n point = {\n x: lockedRay.point.x + lockedRay.dir.x * snappedAlong,\n y: lockedRay.point.y + lockedRay.dir.y * snappedAlong,\n };\n }\n return finish({\n point,\n kind: SnapKind.Angle,\n guides: [guideFor(lockedRay, point)],\n angleRelativeTo: lockedRay.relativeTo,\n });\n }\n\n if (constraints.length >= 2) {\n const sorted = [...constraints].sort((a, b) => a.residual - b.residual);\n const [l1, l2] = sorted;\n const point = intersectLines(l1, l2);\n // Two nearly parallel constraints intersect somewhere useless and far away.\n if (point && angleBetween(l1, l2) > (15 * Math.PI) / 180 && dist(point, raw) <= tol * 2) {\n return finish({\n point,\n kind: SnapKind.Intersection,\n guides: [guideFor(l1, point), guideFor(l2, point)],\n });\n }\n }\n\n if (constraints.length >= 1) {\n const line = [...constraints].sort((a, b) => a.residual - b.residual)[0];\n let point = projectOnLine(raw, line);\n if (enabled.has(SnapKind.Grid) && options.gridSize > 0) {\n // Slide along the constraint to a round distance, rather than rounding both\n // coordinates, which would take the point back off the line.\n const along = (point.x - line.point.x) * line.dir.x + (point.y - line.point.y) * line.dir.y;\n const snappedAlong = roundTo(along, options.gridSize);\n point = {\n x: line.point.x + line.dir.x * snappedAlong,\n y: line.point.y + line.dir.y * snappedAlong,\n };\n }\n return finish({\n point,\n kind: line.kind,\n guides: [guideFor(line, point)],\n angleRelativeTo: line.relativeTo,\n });\n }\n\n if (enabled.has(SnapKind.Grid) && options.gridSize > 0) {\n return finish({\n point: { x: roundTo(raw.x, options.gridSize), y: roundTo(raw.y, options.gridSize) },\n kind: SnapKind.Grid,\n guides: [],\n });\n }\n\n return finish({ point: raw, kind: SnapKind.None, guides: [] });\n}\n"],"mappings":"mHAkBA,IAAY,EAAL,SAAA,EAAA,OACL,GAAA,KAAA,OACA,EAAA,KAAA,OAEA,EAAA,KAAA,OAEA,EAAA,aAAA,eAEA,EAAA,UAAA,YAEA,EAAA,UAAA,YAEA,EAAA,MAAA,QACA,EAAA,KAAA,QACF,EAAA,CAAA,CAAA,EAsBa,EAAoC,CAC/C,QAAS,oEAQT,EACA,SAAU,IACV,aAAc,EACd,kBAAmB,GACnB,sBAAuB,EACzB,EA0DA,SAAgB,EACd,EACA,EACA,EACA,EACW,CACX,MAAO,CACL,EAAG,EAAK,GAAK,EAAU,EAAK,MAAQ,EAAK,KACzC,EAAG,EAAK,GAAK,EAAU,EAAK,KAAO,EAAK,IAC1C,CACF,CAEA,SAAS,EAA4B,EAAc,EAAoD,CACrG,IAAM,EAAK,EAAE,EAAI,EAAK,MAAM,EACtB,EAAK,EAAE,EAAI,EAAK,MAAM,EAC5B,OAAO,KAAK,IAAI,EAAK,EAAK,IAAI,EAAI,EAAK,EAAK,IAAI,CAAC,CACnD,CAEA,SAAS,EAAc,EAAc,EAAuD,CAC1F,IAAM,EAAK,EAAE,EAAI,EAAK,MAAM,EACtB,EAAK,EAAE,EAAI,EAAK,MAAM,EACtB,EAAQ,EAAK,EAAK,IAAI,EAAI,EAAK,EAAK,IAAI,EAC9C,MAAO,CAAE,EAAG,EAAK,MAAM,EAAI,EAAK,IAAI,EAAI,EAAO,EAAG,EAAK,MAAM,EAAI,EAAK,IAAI,EAAI,CAAM,CACtF,CAEA,SAAS,EAAe,EAAU,EAA4B,CAC5D,IAAM,EAAQ,EAAG,IAAI,EAAI,EAAG,IAAI,EAAI,EAAG,IAAI,EAAI,EAAG,IAAI,EACtD,G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AAI,CACjC,CACF,CACA,OAAO,EAAO,CACZ,QACA,KAAM,EAAK,KACX,OAAQ,CAAC,EAAS,EAAM,CAAK,CAAC,EAC9B,gBAAiB,EAAK,UACxB,CAAC,CACH,CAUA,OARI,EAAQ,IAAA,MAAiB,GAAK,EAAQ,SAAW,EAC5C,EAAO,CACZ,MAAO,CAAE,EAAG,EAAQ,EAAI,EAAG,EAAQ,QAAQ,EAAG,EAAG,EAAQ,EAAI,EAAG,EAAQ,QAAQ,CAAE,EAClF,KAAA,OACA,OAAQ,CAAC,CACX,CAAC,EAGI,EAAO,CAAE,MAAO,EAAK,KAAA,OAAqB,OAAQ,CAAC,CAAE,CAAC,CAC/D"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import{signedArea as e,stripSpurs as t}from"./floorPlan.geometry.mjs";var n=1e-9;function r(e,t,n){return(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x)}function i(e,t){return Math.abs(e.x-t.x)<n&&Math.abs(e.y-t.y)<n}function a(e,t,i,a){let o=r(e,t,i),s=r(e,i,a),c=r(e,a,t);return!((o<-1e-9||s<-1e-9||c<-1e-9)&&(o>n||s>n||c>n))}function o(e,t){let n=e.slice(),r=t.filter(e=>e.length>=3).map(e=>({ring:e,index:e.reduce((t,n,r)=>n.x>e[t].x?r:t,0)})).sort((e,t)=>t.ring[t.index].x-e.ring[e.index].x);for(let e of r){let t=e.ring[e.index],r=-1,i=1/0;for(let a=0;a<n.length;a++){if(n[a].x<t.x)continue;let o=(n[a].x-t.x)**2+(n[a].y-t.y)**2;o<i&&s(t,n[a],n,e.ring)&&(i=o,r=a)}if(r<0)for(let e=0;e<n.length;e++){let a=(n[e].x-t.x)**2+(n[e].y-t.y)**2;a<i&&(i=a,r=e)}let a=[];for(let t=0;t<=e.ring.length;t++)a.push(e.ring[(e.index+t)%e.ring.length]);n=[...n.slice(0,r+1),...a,...n.slice(r)]}return n}function s(e,t,n,i){for(let a of[n,i])for(let n=0;n<a.length;n++){let i=a[n],o=a[(n+1)%a.length];if(i===e||o===e||i===t||o===t)continue;let s=r(e,t,i),c=r(e,t,o),l=r(i,o,e),u=r(i,o,t);if(s*c<0&&l*u<0)return!1}return!0}function c(s,c=[]){let l=t(s);if(l.length<3)return{vertices:[],indices:[]};let u=o(l,c.map(e=>t(e)).filter(e=>e.length>=3)),d=e(u)<0?u.slice().reverse():u.slice(),f=d.map((e,t)=>t),p=[],m=f.length*f.length;for(;f.length>3&&m-->0;){let e=!1;for(let t=0;t<f.length;t++){let o=f[(t+f.length-1)%f.length],s=f[t],c=f[(t+1)%f.length],l=d[o],u=d[s],m=d[c];if(r(l,u,m)<=n)continue;let h=!1;for(let e of f){if(e===o||e===s||e===c)continue;let t=d[e];if(!(i(t,l)||i(t,u)||i(t,m))&&a(t,l,u,m)){h=!0;break}}if(!h){p.push(o,s,c),f.splice(t,1),e=!0;break}}if(!e)break}return f.length===3&&p.push(f[0],f[1],f[2]),{vertices:d,indices:p}}export{c as triangulate};
|
|
2
2
|
//# sourceMappingURL=floorPlan.triangulate.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"floorPlan.triangulate.mjs","names":[],"sources":["../../../../package/common/floorPlan/floorPlan.triangulate.ts"],"sourcesContent":["/**\n * Ear clipping for simple polygons, with holes bridged into the outer ring first.\n *\n * Written out rather than pulled in: a floor slab is the only thing in this package that\n * needs a triangulator, and a dependency is a poor trade for one file.\n *\n * The rooms this runs on come from face extraction, so they are already closed, already\n * consistently wound, and free of self-intersections. That is what makes plain ear\n * clipping enough: it is O(n²) and it cannot cope with a self-intersecting ring, and\n * neither limit matters for a room with a few dozen corners.\n */\n\nimport { signedArea, stripSpurs } from './floorPlan.geometry';\nimport type { PlanPoint } from './floorPlan.types';\n\nconst EPS = 1e-9;\n\nfunction area2(a: PlanPoint, b: PlanPoint, c: PlanPoint): number {\n return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);\n}\n\nfunction samePoint(a: PlanPoint, b: PlanPoint): boolean {\n return Math.abs(a.x - b.x) < EPS && Math.abs(a.y - b.y) < EPS;\n}\n\n/** Inclusive of the edges: a vertex lying on one would still leave a sliver behind. */\nfunction inTriangle(p: PlanPoint, a: PlanPoint, b: PlanPoint, c: PlanPoint): boolean {\n const d1 = area2(p, a, b);\n const d2 = area2(p, b, c);\n const d3 = area2(p, c, a);\n const neg = d1 < -EPS || d2 < -EPS || d3 < -EPS;\n const pos = d1 > EPS || d2 > EPS || d3 > EPS;\n return !(neg && pos);\n}\n\n/**\n * Joins each hole to the outer ring with a pair of coincident edges, leaving one ring\n * that ear clipping can take. The bridge runs from the hole's rightmost vertex to a\n * visible vertex of the outer ring, which is the standard construction: going rightwards\n * from the extreme point of a hole must leave it, so the first outer edge hit is visible\n * from it.\n */\nfunction bridgeHoles(outer: PlanPoint[], holes: PlanPoint[][]): PlanPoint[] {\n let ring = outer.slice();\n\n // Rightmost hole first: bridging it cannot cross a hole further right.\n const queue = holes\n .filter((h) => h.length >= 3)\n .map((h) => ({ ring: h, index: h.reduce((best, p, i) => (p.x > h[best].x ? i : best), 0) }))\n .sort((a, b) => b.ring[b.index].x - a.ring[a.index].x);\n\n for (const hole of queue) {\n const from = hole.ring[hole.index];\n\n // The outer vertex to bridge to: the one that is visible and, among those, closest.\n let best = -1;\n let bestDist = Infinity;\n for (let i = 0; i < ring.length; i++) {\n if (ring[i].x < from.x) continue; // must lie to the right, or the bridge doubles back\n const d = (ring[i].x - from.x) ** 2 + (ring[i].y - from.y) ** 2;\n if (d < bestDist && visible(from, ring[i], ring, hole.ring)) {\n bestDist = d;\n best = i;\n }\n }\n // Nothing to the right was visible, so fall back to the nearest vertex anywhere. The\n // ring stays closed either way; at worst the slab gains a seam nobody can see.\n if (best < 0) {\n for (let i = 0; i < ring.length; i++) {\n const d = (ring[i].x - from.x) ** 2 + (ring[i].y - from.y) ** 2;\n if (d < bestDist) {\n bestDist = d;\n best = i;\n }\n }\n }\n\n // Walk the hole from its bridge vertex, then come back along the bridge.\n const woven: PlanPoint[] = [];\n for (let k = 0; k <= hole.ring.length; k++) {\n woven.push(hole.ring[(hole.index + k) % hole.ring.length]);\n }\n ring = [...ring.slice(0, best + 1), ...woven, ...ring.slice(best)];\n }\n\n return ring;\n}\n\n/** Whether the segment from `a` to `b` crosses any edge of the rings it has to avoid. */\nfunction visible(a: PlanPoint, b: PlanPoint, ring: PlanPoint[], hole: PlanPoint[]): boolean {\n for (const poly of [ring, hole]) {\n for (let i = 0; i < poly.length; i++) {\n const p = poly[i];\n const q = poly[(i + 1) % poly.length];\n if (p === a || q === a || p === b || q === b) continue;\n const d1 = area2(a, b, p);\n const d2 = area2(a, b, q);\n const d3 = area2(p, q, a);\n const d4 = area2(p, q, b);\n if (d1 * d2 < 0 && d3 * d4 < 0) return false;\n }\n }\n return true;\n}\n\n/**\n * Triangulates a ring and its holes into index triples over the returned vertex list.\n *\n * The vertices come back as well as the indices because bridging a hole duplicates the\n * two vertices it joins, so the caller cannot simply index into what it passed in.\n */\nexport function triangulate(\n outer: readonly PlanPoint[],\n holes: readonly (readonly PlanPoint[])[] = [],\n): { vertices: PlanPoint[]; indices: number[] } {\n // A dangling wall inside a room puts the same vertex in the ring twice, which is not a\n // simple polygon and would stall ear clipping on a zero-area ear.\n const cleanOuter = stripSpurs(outer);\n if (cleanOuter.length < 3) return { vertices: [], indices: [] };\n\n const ring = bridgeHoles(\n cleanOuter,\n holes.map((h) => stripSpurs(h)).filter((h) => h.length >= 3),\n );\n\n // Ear clipping wants a counter-clockwise ring under the usual maths convention.\n const vertices = signedArea(ring) < 0 ? ring.slice().reverse() : ring.slice();\n\n const live = vertices.map((_, i) => i);\n const indices: number[] = [];\n let guard = live.length * live.length;\n\n while (live.length > 3 && guard-- > 0) {\n let clipped = false;\n for (let i = 0; i < live.length; i++) {\n const ai = live[(i + live.length - 1) % live.length];\n const bi = live[i];\n const ci = live[(i + 1) % live.length];\n const a = vertices[ai];\n const b = vertices[bi];\n const c = vertices[ci];\n if (area2(a, b, c) <= EPS) continue; // reflex or degenerate: not an ear\n\n let blocked = false;\n for (const vi of live) {\n if (vi === ai || vi === bi || vi === ci) continue;\n const v = vertices[vi];\n // Bridging a hole duplicates the two vertices it joins, so a candidate can sit\n // exactly on a corner of the ear. Counting that as \"inside\" blocks every ear in\n // the ring and the triangulation comes back empty.\n if (samePoint(v, a) || samePoint(v, b) || samePoint(v, c)) continue;\n if (inTriangle(v, a, b, c)) {\n blocked = true;\n break;\n }\n }\n if (blocked) continue;\n\n indices.push(ai, bi, ci);\n live.splice(i, 1);\n clipped = true;\n break;\n }\n // No ear found: the ring is degenerate in a way this cannot reduce further. Stopping\n // beats spinning, and the caller gets whatever was triangulated so far.\n if (!clipped) break;\n }\n if (live.length === 3) indices.push(live[0], live[1], live[2]);\n\n return { vertices, indices };\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"floorPlan.triangulate.mjs","names":[],"sources":["../../../../package/common/floorPlan/floorPlan.triangulate.ts"],"sourcesContent":["/**\n * Ear clipping for simple polygons, with holes bridged into the outer ring first.\n *\n * Written out rather than pulled in: a floor slab is the only thing in this package that\n * needs a triangulator, and a dependency is a poor trade for one file.\n *\n * The rooms this runs on come from face extraction, so they are already closed, already\n * consistently wound, and free of self-intersections. That is what makes plain ear\n * clipping enough: it is O(n²) and it cannot cope with a self-intersecting ring, and\n * neither limit matters for a room with a few dozen corners.\n */\n\nimport { signedArea, stripSpurs } from './floorPlan.geometry';\nimport type { PlanPoint } from './floorPlan.types';\n\nconst EPS = 1e-9;\n\nfunction area2(a: PlanPoint, b: PlanPoint, c: PlanPoint): number {\n return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);\n}\n\nfunction samePoint(a: PlanPoint, b: PlanPoint): boolean {\n return Math.abs(a.x - b.x) < EPS && Math.abs(a.y - b.y) < EPS;\n}\n\n/** Inclusive of the edges: a vertex lying on one would still leave a sliver behind. */\nfunction inTriangle(p: PlanPoint, a: PlanPoint, b: PlanPoint, c: PlanPoint): boolean {\n const d1 = area2(p, a, b);\n const d2 = area2(p, b, c);\n const d3 = area2(p, c, a);\n const neg = d1 < -EPS || d2 < -EPS || d3 < -EPS;\n const pos = d1 > EPS || d2 > EPS || d3 > EPS;\n return !(neg && pos);\n}\n\n/**\n * Joins each hole to the outer ring with a pair of coincident edges, leaving one ring\n * that ear clipping can take. The bridge runs from the hole's rightmost vertex to a\n * visible vertex of the outer ring, which is the standard construction: going rightwards\n * from the extreme point of a hole must leave it, so the first outer edge hit is visible\n * from it.\n */\nfunction bridgeHoles(outer: PlanPoint[], holes: PlanPoint[][]): PlanPoint[] {\n let ring = outer.slice();\n\n // Rightmost hole first: bridging it cannot cross a hole further right.\n const queue = holes\n .filter((h) => h.length >= 3)\n .map((h) => ({ ring: h, index: h.reduce((best, p, i) => (p.x > h[best].x ? i : best), 0) }))\n .sort((a, b) => b.ring[b.index].x - a.ring[a.index].x);\n\n for (const hole of queue) {\n const from = hole.ring[hole.index];\n\n // The outer vertex to bridge to: the one that is visible and, among those, closest.\n let best = -1;\n let bestDist = Infinity;\n for (let i = 0; i < ring.length; i++) {\n if (ring[i].x < from.x) continue; // must lie to the right, or the bridge doubles back\n const d = (ring[i].x - from.x) ** 2 + (ring[i].y - from.y) ** 2;\n if (d < bestDist && visible(from, ring[i], ring, hole.ring)) {\n bestDist = d;\n best = i;\n }\n }\n // Nothing to the right was visible, so fall back to the nearest vertex anywhere. The\n // ring stays closed either way; at worst the slab gains a seam nobody can see.\n if (best < 0) {\n for (let i = 0; i < ring.length; i++) {\n const d = (ring[i].x - from.x) ** 2 + (ring[i].y - from.y) ** 2;\n if (d < bestDist) {\n bestDist = d;\n best = i;\n }\n }\n }\n\n // Walk the hole from its bridge vertex, then come back along the bridge.\n const woven: PlanPoint[] = [];\n for (let k = 0; k <= hole.ring.length; k++) {\n woven.push(hole.ring[(hole.index + k) % hole.ring.length]);\n }\n ring = [...ring.slice(0, best + 1), ...woven, ...ring.slice(best)];\n }\n\n return ring;\n}\n\n/** Whether the segment from `a` to `b` crosses any edge of the rings it has to avoid. */\nfunction visible(a: PlanPoint, b: PlanPoint, ring: PlanPoint[], hole: PlanPoint[]): boolean {\n for (const poly of [ring, hole]) {\n for (let i = 0; i < poly.length; i++) {\n const p = poly[i];\n const q = poly[(i + 1) % poly.length];\n if (p === a || q === a || p === b || q === b) continue;\n const d1 = area2(a, b, p);\n const d2 = area2(a, b, q);\n const d3 = area2(p, q, a);\n const d4 = area2(p, q, b);\n if (d1 * d2 < 0 && d3 * d4 < 0) return false;\n }\n }\n return true;\n}\n\n/**\n * Triangulates a ring and its holes into index triples over the returned vertex list.\n *\n * The vertices come back as well as the indices because bridging a hole duplicates the\n * two vertices it joins, so the caller cannot simply index into what it passed in.\n */\nexport function triangulate(\n outer: readonly PlanPoint[],\n holes: readonly (readonly PlanPoint[])[] = [],\n): { vertices: PlanPoint[]; indices: number[] } {\n // A dangling wall inside a room puts the same vertex in the ring twice, which is not a\n // simple polygon and would stall ear clipping on a zero-area ear.\n const cleanOuter = stripSpurs(outer);\n if (cleanOuter.length < 3) return { vertices: [], indices: [] };\n\n const ring = bridgeHoles(\n cleanOuter,\n holes.map((h) => stripSpurs(h)).filter((h) => h.length >= 3),\n );\n\n // Ear clipping wants a counter-clockwise ring under the usual maths convention.\n const vertices = signedArea(ring) < 0 ? ring.slice().reverse() : ring.slice();\n\n const live = vertices.map((_, i) => i);\n const indices: number[] = [];\n let guard = live.length * live.length;\n\n while (live.length > 3 && guard-- > 0) {\n let clipped = false;\n for (let i = 0; i < live.length; i++) {\n const ai = live[(i + live.length - 1) % live.length];\n const bi = live[i];\n const ci = live[(i + 1) % live.length];\n const a = vertices[ai];\n const b = vertices[bi];\n const c = vertices[ci];\n if (area2(a, b, c) <= EPS) continue; // reflex or degenerate: not an ear\n\n let blocked = false;\n for (const vi of live) {\n if (vi === ai || vi === bi || vi === ci) continue;\n const v = vertices[vi];\n // Bridging a hole duplicates the two vertices it joins, so a candidate can sit\n // exactly on a corner of the ear. Counting that as \"inside\" blocks every ear in\n // the ring and the triangulation comes back empty.\n if (samePoint(v, a) || samePoint(v, b) || samePoint(v, c)) continue;\n if (inTriangle(v, a, b, c)) {\n blocked = true;\n break;\n }\n }\n if (blocked) continue;\n\n indices.push(ai, bi, ci);\n live.splice(i, 1);\n clipped = true;\n break;\n }\n // No ear found: the ring is degenerate in a way this cannot reduce further. Stopping\n // beats spinning, and the caller gets whatever was triangulated so far.\n if (!clipped) break;\n }\n if (live.length === 3) indices.push(live[0], live[1], live[2]);\n\n return { vertices, indices };\n}\n"],"mappings":"sEAeA,IAAM,EAAM,KAEZ,SAAS,EAAM,EAAc,EAAc,EAAsB,CAC/D,OAAQ,EAAE,EAAI,EAAE,IAAM,EAAE,EAAI,EAAE,IAAM,EAAE,EAAI,EAAE,IAAM,EAAE,EAAI,EAAE,EAC5D,CAEA,SAAS,EAAU,EAAc,EAAuB,CACtD,OAAO,KAAK,IAAI,EAAE,EAAI,EAAE,CAAC,EAAI,GAAO,KAAK,IAAI,EAAE,EAAI,EAAE,CAAC,EAAI,CAC5D,CAGA,SAAS,EAAW,EAAc,EAAc,EAAc,EAAuB,CACnF,IAAM,EAAK,EAAM,EAAG,EAAG,CAAC,EAClB,EAAK,EAAM,EAAG,EAAG,CAAC,EAClB,EAAK,EAAM,EAAG,EAAG,CAAC,EAGxB,MAAO,GAFK,EAAK,OAAQ,EAAK,OAAQ,EAAK,SAC/B,EAAK,GAAO,EAAK,GAAO,EAAK,GAE3C,CASA,SAAS,EAAY,EAAoB,EAAmC,CAC1E,IAAI,EAAO,EAAM,MAAM,EAGjB,EAAQ,EACX,OAAQ,GAAM,EAAE,QAAU,CAAC,CAAC,CAC5B,IAAK,IAAO,CAAE,KAAM,EAAG,MAAO,EAAE,QAAQ,EAAM,EAAG,IAAO,EAAE,EAAI,EAAE,EAAK,CAAC,EAAI,EAAI,EAAO,CAAC,CAAE,EAAE,CAAC,CAC3F,MAAM,EAAG,IA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,CACF,CACI,MAIJ,CAFA,EAAQ,KAAK,EAAI,EAAI,CAAE,EACvB,EAAK,OAAO,EAAG,CAAC,EAChB,EAAU,GACV,KADU,CAEZ,CAGA,GAAI,CAAC,EAAS,KAChB,CAGA,OAFI,EAAK,SAAW,GAAG,EAAQ,KAAK,EAAK,GAAI,EAAK,GAAI,EAAK,EAAE,EAEtD,CAAE,WAAU,SAAQ,CAC7B"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
var e=function(e){return e.Metric=`metric`,e.Imperial=`imperial`,e}({}),t=function(e){return e.Exterior=`exterior`,e.Interior=`interior`,e.Partition=`partition`,e.Virtual=`virtual`,e}({}),n=function(e){return e.Door=`door`,e.Window=`window`,e.Archway=`archway`,e.Gap=`gap`,e}({}),r=function(e){return e.None=`none`,e.StartLeft=`startLeft`,e.StartRight=`startRight`,e.EndLeft=`endLeft`,e.EndRight=`endRight`,e.Double=`double`,e.Sliding=`sliding`,e}({}),i=function(e){return e.ZeroLengthWall=`zeroLengthWall`,e.SelfLoopWall=`selfLoopWall`,e.DuplicateWall=`duplicateWall`,e.CoincidentNodes=`coincidentNodes`,e.UnsplitCrossing=`unsplitCrossing`,e.UnsplitNodeOnWall=`unsplitNodeOnWall`,e.OverlappingWalls=`overlappingWalls`,e.OrphanNode=`orphanNode`,e.DanglingOpening=`danglingOpening`,e.UnmatchedRoom=`unmatchedRoom`,e.OpeningDropped=`openingDropped`,e}({});export{r as DoorSwing,n as OpeningKind,i as PlanIssueKind,e as PlanUnitSystem,t as WallType};
|
|
2
2
|
//# sourceMappingURL=floorPlan.types.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"floorPlan.types.mjs","names":[],"sources":["../../../../package/common/floorPlan/floorPlan.types.ts"],"sourcesContent":["/**\n * Floor plan model: a planar wall graph whose rooms are derived, not stored.\n *\n * Nodes and walls are first-class and shared, so the wall between two rooms is one\n * wall. An opening therefore cuts it exactly once, which is what the previous\n * room-polygon model could not express.\n *\n * GEOMETRY INVARIANT: every coordinate, length, thickness, offset and height in this\n * module is in MILLIMETRES. There is deliberately no per-plan scale factor: one would\n * have to be threaded through every geometry function, and a single missed call site\n * is a silent 1000x error that no type can catch. `unitSystem` below drives display\n * formatting only and is never read by geometry.\n */\n\n/** A point in plan space, in millimetres. y increases downwards, as in SVG. */\nexport interface PlanPoint {\n x: number;\n y: number;\n}\n\nexport enum PlanUnitSystem {\n /** Display as m / cm / mm. */\n Metric = 'metric',\n /** Display as feet and inches. Storage stays millimetres. */\n Imperial = 'imperial',\n}\n\nexport enum WallType {\n /** Load-bearing envelope wall. */\n Exterior = 'exterior',\n /** Load-bearing interior wall. */\n Interior = 'interior',\n /** Non-load-bearing partition. */\n Partition = 'partition',\n /**\n * A room boundary with no physical wall, for dividing open-plan space. It still\n * closes a face, so it produces two rooms, but renders as a thin dashed line and\n * extrudes to nothing in 3D.\n */\n Virtual = 'virtual',\n}\n\nexport enum OpeningKind {\n /** A real door leaf, with a swing and a threshold. */\n Door = 'door',\n /** Glazed opening with a sill above floor level. */\n Window = 'window',\n /** Structural opening with a head but no leaf. */\n Archway = 'archway',\n /**\n * A plain hole in the wall with no jamb detailing. Distinct from \"no wall at all\":\n * a Gap is a marked span of a wall that exists, which is what lets a gap-style\n * rendering stay unambiguous.\n */\n Gap = 'gap',\n}\n\nexport enum DoorSwing {\n None = 'none',\n /** Hinged at the opening's start, opening towards the wall's left normal. */\n StartLeft = 'startLeft',\n StartRight = 'startRight',\n EndLeft = 'endLeft',\n EndRight = 'endRight',\n /** Two leaves, hinged at both ends. */\n Double = 'double',\n Sliding = 'sliding',\n}\n\n/** A graph vertex. Structurally assignable to `PlanPoint`. */\nexport interface PlanNode {\n id: string;\n x: number;\n y: number;\n}\n\n/**\n * An undirected edge between two nodes. `a` and `b` define the wall's own direction,\n * which is what opening offsets and door swings are measured against.\n *\n * The wall is centred on the segment a..b, extending `thickness / 2` to each side.\n * There is no eccentric offset in this version.\n */\nexport interface PlanWall {\n id: string;\n a: string;\n b: string;\n /** Millimetres. Must be greater than 0. */\n thickness: number;\n /** Millimetres above this wall's base. Omit to inherit `PlanFloor.height`. */\n height?: number;\n /** Millimetres above the floor's finished level. Defaults to 0. */\n baseHeight?: number;\n type: WallType;\n}\n\n/**\n * An opening cut into exactly one wall. Because a shared wall is one wall, an opening\n * between two rooms exists exactly once and needs no de-duplication anywhere.\n */\nexport interface PlanOpening {\n id: string;\n wallId: string;\n kind: OpeningKind;\n /**\n * Distance in millimetres from the wall's node `a` to the opening's CENTRE, measured\n * along the centreline.\n *\n * Deliberately absolute rather than a 0..1 parameter: with a parameter, stretching a\n * wall by dragging one of its nodes would rescale every door on it. Absolute offsets\n * are clamped instead when a wall shortens.\n */\n offset: number;\n /** Millimetres, along the wall. */\n width: number;\n /**\n * Height of the opening's BOTTOM above the floor, in millimetres: 0 for a door, around\n * 900 for a window. Nothing in the 2D plan reads it, since a plan is a horizontal cut\n * and every opening looks the same from above. It is here so the same plan can drive a\n * 3D view later without the heights having to be invented or asked for again.\n */\n sill: number;\n /** Height of the opening's TOP above the floor, in millimetres. Typically 2100. */\n head: number;\n /** Only meaningful for `OpeningKind.Door`. */\n swing?: DoorSwing;\n}\n\n/**\n * Room METADATA. This is not a geometric object: the polygon comes from face\n * extraction. The trailing `wallIds` / `area` fields are a match cache maintained by\n * `derivePlan`, and are the reason a room's name survives edits.\n */\nexport interface PlanRoom {\n id: string;\n name: string;\n /** Any CSS colour. Omit to use the theme default. */\n colour?: string;\n /** Free-form usage tag (\"kitchen\", \"bath\"), for later fixture and 3D defaults. */\n usage?: string;\n /**\n * A point that lay inside the room's polygon when it was last written. Used as the\n * label position and as the secondary identity signal during matching.\n */\n anchor: PlanPoint;\n /** Set once the user drags the label; `derivePlan` then stops moving it. */\n anchorPinned: boolean;\n /** Monotonic creation counter, used as a deterministic tie-break when matching. */\n seq: number;\n /** Match cache: the wall ids on this room's boundary at the last successful match. */\n wallIds: string[];\n /** Match cache: area in mm² at the last successful match. */\n area: number;\n}\n\nexport interface PlanFloor {\n id: string;\n label: string;\n /** Finished floor level of this storey, millimetres above datum. */\n elevation: number;\n /** Default storey height in millimetres, used when a wall omits its own `height`. */\n height: number;\n /**\n * Keyed by id for O(1) lookup. Ids must not be numeric strings ('n_12', never '12'),\n * so that JavaScript preserves insertion order and iteration stays reproducible.\n */\n nodes: Record<string, PlanNode>;\n walls: Record<string, PlanWall>;\n openings: Record<string, PlanOpening>;\n rooms: Record<string, PlanRoom>;\n}\n\nexport interface FloorPlan {\n id: string;\n name?: string;\n /** Schema version, for future migrations. */\n version: 1;\n /** Display formatting only. Never read by geometry. */\n unitSystem: PlanUnitSystem;\n floors: PlanFloor[];\n /**\n * Bumped by every mutating operation. Use it as the memo key for `derivePlan`, so a\n * gesture that does not actually change the graph does not trigger a re-derive.\n */\n revision: number;\n}\n\n/**\n * A raw face from the planar walk, before room metadata is attached.\n *\n * WINDING: `outer` is positively wound under the shoelace formula, which in SVG's\n * y-down space means it reads as visually CLOCKWISE. Anything downstream that assumes\n * counter-clockwise (extruded slab normals, most triangulators) must flip it.\n */\nexport interface PlanFace {\n /**\n * Derived from the boundary itself, so it is stable across derives for as long as\n * the geometry is unchanged. Safe to use as a React key.\n */\n id: string;\n /** Outer ring, closed implicitly: the first vertex is not repeated at the end. */\n outer: PlanPoint[];\n /** Inner rings from nested components, wound opposite to `outer`. */\n holes: PlanPoint[][];\n /** mm², always positive, with holes already subtracted. */\n area: number;\n /** mm, outer ring only. */\n perimeter: number;\n /**\n * Wall ids on the boundary, in traversal order. A dangling wall inside this face\n * appears TWICE, once per direction, so consumers needing unique ids must dedupe.\n */\n wallIds: string[];\n nodeIds: string[];\n}\n\n/** A face with its matched metadata. This is what the components render. */\nexport interface DerivedRoom extends PlanFace {\n /** `null` when no `PlanRoom` matched this face during this derive. */\n roomId: string | null;\n meta: PlanRoom | null;\n /** Guaranteed inside `outer` and outside every hole. The label position. */\n anchor: PlanPoint;\n}\n\nexport enum PlanIssueKind {\n ZeroLengthWall = 'zeroLengthWall',\n SelfLoopWall = 'selfLoopWall',\n DuplicateWall = 'duplicateWall',\n CoincidentNodes = 'coincidentNodes',\n /** Two walls cross with no node at the intersection. Corrupts face extraction. */\n UnsplitCrossing = 'unsplitCrossing',\n /** A node sits on a wall's interior but that wall was never split there. */\n UnsplitNodeOnWall = 'unsplitNodeOnWall',\n /** Two walls leave a node in the same direction, tying the angular sort. */\n OverlappingWalls = 'overlappingWalls',\n OrphanNode = 'orphanNode',\n DanglingOpening = 'danglingOpening',\n /** A `PlanRoom` matched no face this derive. It is kept, never deleted. */\n UnmatchedRoom = 'unmatchedRoom',\n /** An opening was moved or dropped because its wall no longer has room for it. */\n OpeningDropped = 'openingDropped',\n}\n\nexport interface PlanIssue {\n kind: PlanIssueKind;\n message: string;\n nodeIds?: string[];\n wallIds?: string[];\n roomIds?: string[];\n openingIds?: string[];\n}\n\nexport interface PlanDerivation {\n /** The floor with room match caches and anchors refreshed. Pure: a new object. */\n floor: PlanFloor;\n rooms: DerivedRoom[];\n issues: PlanIssue[];\n}\n\n/** The uniform result of every graph mutation. All of them are pure. */\nexport interface PlanEdit<T = void> {\n floor: PlanFloor;\n result: T;\n issues: PlanIssue[];\n}\n\n/**\n * The viewport: which world point sits at the canvas's top-left corner, and how many\n * screen pixels one world millimetre occupies.\n *\n * A 6m plan filling a 600px canvas is `zoom: 0.1`. Note this is a transform on a group,\n * not an SVG `viewBox`: handles, labels and hit tolerances are then sized in screen\n * pixels and stay constant as you zoom, instead of scaling with the drawing.\n */\nexport interface PlanView {\n x: number;\n y: number;\n zoom: number;\n}\n\n/** What is currently selected or hovered. */\nexport type PlanSelection =\n | { type: 'room'; id: string }\n | { type: 'wall'; id: string }\n | { type: 'opening'; id: string }\n | { type: 'node'; id: string };\n"],"mappings":"aAoBA,IAAY,EAAL,SAAA,EAAA,OAEL,GAAA,OAAA,SAEA,EAAA,SAAA,YACF,EAAA,CAAA,CAAA,EAEY,EAAL,SAAA,EAAA,OAEL,GAAA,SAAA,WAEA,EAAA,SAAA,WAEA,EAAA,UAAA,YAMA,EAAA,QAAA,WACF,EAAA,CAAA,CAAA,EAEY,EAAL,SAAA,EAAA,OAEL,GAAA,KAAA,OAEA,EAAA,OAAA,SAEA,EAAA,QAAA,UAMA,EAAA,IAAA,OACF,EAAA,CAAA,CAAA,EAEY,EAAL,SAAA,EAAA,OACL,GAAA,KAAA,OAEA,EAAA,UAAA,YACA,EAAA,WAAA,aACA,EAAA,QAAA,UACA,EAAA,SAAA,WAEA,EAAA,OAAA,SACA,EAAA,QAAA,WACF,EAAA,CAAA,CAAA,EA8JY,EAAL,SAAA,EAAA,OACL,GAAA,eAAA,iBACA,EAAA,aAAA,eACA,EAAA,cAAA,gBACA,EAAA,gBAAA,kBAEA,EAAA,gBAAA,kBAEA,EAAA,kBAAA,oBAEA,EAAA,iBAAA,mBACA,EAAA,WAAA,aACA,EAAA,gBAAA,kBAEA,EAAA,cAAA,gBAEA,EAAA,eAAA,kBACF,EAAA,CAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"floorPlan.types.mjs","names":[],"sources":["../../../../package/common/floorPlan/floorPlan.types.ts"],"sourcesContent":["/**\n * Floor plan model: a planar wall graph whose rooms are derived, not stored.\n *\n * Nodes and walls are first-class and shared, so the wall between two rooms is one\n * wall. An opening therefore cuts it exactly once, which is what the previous\n * room-polygon model could not express.\n *\n * GEOMETRY INVARIANT: every coordinate, length, thickness, offset and height in this\n * module is in MILLIMETRES. There is deliberately no per-plan scale factor: one would\n * have to be threaded through every geometry function, and a single missed call site\n * is a silent 1000x error that no type can catch. `unitSystem` below drives display\n * formatting only and is never read by geometry.\n */\n\n/** A point in plan space, in millimetres. y increases downwards, as in SVG. */\nexport interface PlanPoint {\n x: number;\n y: number;\n}\n\nexport enum PlanUnitSystem {\n /** Display as m / cm / mm. */\n Metric = 'metric',\n /** Display as feet and inches. Storage stays millimetres. */\n Imperial = 'imperial',\n}\n\nexport enum WallType {\n /** Load-bearing envelope wall. */\n Exterior = 'exterior',\n /** Load-bearing interior wall. */\n Interior = 'interior',\n /** Non-load-bearing partition. */\n Partition = 'partition',\n /**\n * A room boundary with no physical wall, for dividing open-plan space. It still\n * closes a face, so it produces two rooms, but renders as a thin dashed line and\n * extrudes to nothing in 3D.\n */\n Virtual = 'virtual',\n}\n\nexport enum OpeningKind {\n /** A real door leaf, with a swing and a threshold. */\n Door = 'door',\n /** Glazed opening with a sill above floor level. */\n Window = 'window',\n /** Structural opening with a head but no leaf. */\n Archway = 'archway',\n /**\n * A plain hole in the wall with no jamb detailing. Distinct from \"no wall at all\":\n * a Gap is a marked span of a wall that exists, which is what lets a gap-style\n * rendering stay unambiguous.\n */\n Gap = 'gap',\n}\n\nexport enum DoorSwing {\n None = 'none',\n /** Hinged at the opening's start, opening towards the wall's left normal. */\n StartLeft = 'startLeft',\n StartRight = 'startRight',\n EndLeft = 'endLeft',\n EndRight = 'endRight',\n /** Two leaves, hinged at both ends. */\n Double = 'double',\n Sliding = 'sliding',\n}\n\n/** A graph vertex. Structurally assignable to `PlanPoint`. */\nexport interface PlanNode {\n id: string;\n x: number;\n y: number;\n}\n\n/**\n * An undirected edge between two nodes. `a` and `b` define the wall's own direction,\n * which is what opening offsets and door swings are measured against.\n *\n * The wall is centred on the segment a..b, extending `thickness / 2` to each side.\n * There is no eccentric offset in this version.\n */\nexport interface PlanWall {\n id: string;\n a: string;\n b: string;\n /** Millimetres. Must be greater than 0. */\n thickness: number;\n /** Millimetres above this wall's base. Omit to inherit `PlanFloor.height`. */\n height?: number;\n /** Millimetres above the floor's finished level. Defaults to 0. */\n baseHeight?: number;\n type: WallType;\n}\n\n/**\n * An opening cut into exactly one wall. Because a shared wall is one wall, an opening\n * between two rooms exists exactly once and needs no de-duplication anywhere.\n */\nexport interface PlanOpening {\n id: string;\n wallId: string;\n kind: OpeningKind;\n /**\n * Distance in millimetres from the wall's node `a` to the opening's CENTRE, measured\n * along the centreline.\n *\n * Deliberately absolute rather than a 0..1 parameter: with a parameter, stretching a\n * wall by dragging one of its nodes would rescale every door on it. Absolute offsets\n * are clamped instead when a wall shortens.\n */\n offset: number;\n /** Millimetres, along the wall. */\n width: number;\n /**\n * Height of the opening's BOTTOM above the floor, in millimetres: 0 for a door, around\n * 900 for a window. Nothing in the 2D plan reads it, since a plan is a horizontal cut\n * and every opening looks the same from above. It is here so the same plan can drive a\n * 3D view later without the heights having to be invented or asked for again.\n */\n sill: number;\n /** Height of the opening's TOP above the floor, in millimetres. Typically 2100. */\n head: number;\n /** Only meaningful for `OpeningKind.Door`. */\n swing?: DoorSwing;\n}\n\n/**\n * Room METADATA. This is not a geometric object: the polygon comes from face\n * extraction. The trailing `wallIds` / `area` fields are a match cache maintained by\n * `derivePlan`, and are the reason a room's name survives edits.\n */\nexport interface PlanRoom {\n id: string;\n name: string;\n /** Any CSS colour. Omit to use the theme default. */\n colour?: string;\n /** Free-form usage tag (\"kitchen\", \"bath\"), for later fixture and 3D defaults. */\n usage?: string;\n /**\n * A point that lay inside the room's polygon when it was last written. Used as the\n * label position and as the secondary identity signal during matching.\n */\n anchor: PlanPoint;\n /** Set once the user drags the label; `derivePlan` then stops moving it. */\n anchorPinned: boolean;\n /** Monotonic creation counter, used as a deterministic tie-break when matching. */\n seq: number;\n /** Match cache: the wall ids on this room's boundary at the last successful match. */\n wallIds: string[];\n /** Match cache: area in mm² at the last successful match. */\n area: number;\n}\n\nexport interface PlanFloor {\n id: string;\n label: string;\n /** Finished floor level of this storey, millimetres above datum. */\n elevation: number;\n /** Default storey height in millimetres, used when a wall omits its own `height`. */\n height: number;\n /**\n * Keyed by id for O(1) lookup. Ids must not be numeric strings ('n_12', never '12'),\n * so that JavaScript preserves insertion order and iteration stays reproducible.\n */\n nodes: Record<string, PlanNode>;\n walls: Record<string, PlanWall>;\n openings: Record<string, PlanOpening>;\n rooms: Record<string, PlanRoom>;\n}\n\nexport interface FloorPlan {\n id: string;\n name?: string;\n /** Schema version, for future migrations. */\n version: 1;\n /** Display formatting only. Never read by geometry. */\n unitSystem: PlanUnitSystem;\n floors: PlanFloor[];\n /**\n * Bumped by every mutating operation. Use it as the memo key for `derivePlan`, so a\n * gesture that does not actually change the graph does not trigger a re-derive.\n */\n revision: number;\n}\n\n/**\n * A raw face from the planar walk, before room metadata is attached.\n *\n * WINDING: `outer` is positively wound under the shoelace formula, which in SVG's\n * y-down space means it reads as visually CLOCKWISE. Anything downstream that assumes\n * counter-clockwise (extruded slab normals, most triangulators) must flip it.\n */\nexport interface PlanFace {\n /**\n * Derived from the boundary itself, so it is stable across derives for as long as\n * the geometry is unchanged. Safe to use as a React key.\n */\n id: string;\n /** Outer ring, closed implicitly: the first vertex is not repeated at the end. */\n outer: PlanPoint[];\n /** Inner rings from nested components, wound opposite to `outer`. */\n holes: PlanPoint[][];\n /** mm², always positive, with holes already subtracted. */\n area: number;\n /** mm, outer ring only. */\n perimeter: number;\n /**\n * Wall ids on the boundary, in traversal order. A dangling wall inside this face\n * appears TWICE, once per direction, so consumers needing unique ids must dedupe.\n */\n wallIds: string[];\n nodeIds: string[];\n}\n\n/** A face with its matched metadata. This is what the components render. */\nexport interface DerivedRoom extends PlanFace {\n /** `null` when no `PlanRoom` matched this face during this derive. */\n roomId: string | null;\n meta: PlanRoom | null;\n /** Guaranteed inside `outer` and outside every hole. The label position. */\n anchor: PlanPoint;\n}\n\nexport enum PlanIssueKind {\n ZeroLengthWall = 'zeroLengthWall',\n SelfLoopWall = 'selfLoopWall',\n DuplicateWall = 'duplicateWall',\n CoincidentNodes = 'coincidentNodes',\n /** Two walls cross with no node at the intersection. Corrupts face extraction. */\n UnsplitCrossing = 'unsplitCrossing',\n /** A node sits on a wall's interior but that wall was never split there. */\n UnsplitNodeOnWall = 'unsplitNodeOnWall',\n /** Two walls leave a node in the same direction, tying the angular sort. */\n OverlappingWalls = 'overlappingWalls',\n OrphanNode = 'orphanNode',\n DanglingOpening = 'danglingOpening',\n /** A `PlanRoom` matched no face this derive. It is kept, never deleted. */\n UnmatchedRoom = 'unmatchedRoom',\n /** An opening was moved or dropped because its wall no longer has room for it. */\n OpeningDropped = 'openingDropped',\n}\n\nexport interface PlanIssue {\n kind: PlanIssueKind;\n message: string;\n nodeIds?: string[];\n wallIds?: string[];\n roomIds?: string[];\n openingIds?: string[];\n}\n\nexport interface PlanDerivation {\n /** The floor with room match caches and anchors refreshed. Pure: a new object. */\n floor: PlanFloor;\n rooms: DerivedRoom[];\n issues: PlanIssue[];\n}\n\n/** The uniform result of every graph mutation. All of them are pure. */\nexport interface PlanEdit<T = void> {\n floor: PlanFloor;\n result: T;\n issues: PlanIssue[];\n}\n\n/**\n * The viewport: which world point sits at the canvas's top-left corner, and how many\n * screen pixels one world millimetre occupies.\n *\n * A 6m plan filling a 600px canvas is `zoom: 0.1`. Note this is a transform on a group,\n * not an SVG `viewBox`: handles, labels and hit tolerances are then sized in screen\n * pixels and stay constant as you zoom, instead of scaling with the drawing.\n */\nexport interface PlanView {\n x: number;\n y: number;\n zoom: number;\n}\n\n/** What is currently selected or hovered. */\nexport type PlanSelection =\n | { type: 'room'; id: string }\n | { type: 'wall'; id: string }\n | { type: 'opening'; id: string }\n | { type: 'node'; id: string };\n"],"mappings":"AAoBA,IAAY,EAAL,SAAA,EAAA,OAEL,GAAA,OAAA,SAEA,EAAA,SAAA,YACF,EAAA,CAAA,CAAA,EAEY,EAAL,SAAA,EAAA,OAEL,GAAA,SAAA,WAEA,EAAA,SAAA,WAEA,EAAA,UAAA,YAMA,EAAA,QAAA,WACF,EAAA,CAAA,CAAA,EAEY,EAAL,SAAA,EAAA,OAEL,GAAA,KAAA,OAEA,EAAA,OAAA,SAEA,EAAA,QAAA,UAMA,EAAA,IAAA,OACF,EAAA,CAAA,CAAA,EAEY,EAAL,SAAA,EAAA,OACL,GAAA,KAAA,OAEA,EAAA,UAAA,YACA,EAAA,WAAA,aACA,EAAA,QAAA,UACA,EAAA,SAAA,WAEA,EAAA,OAAA,SACA,EAAA,QAAA,WACF,EAAA,CAAA,CAAA,EA8JY,EAAL,SAAA,EAAA,OACL,GAAA,eAAA,iBACA,EAAA,aAAA,eACA,EAAA,cAAA,gBACA,EAAA,gBAAA,kBAEA,EAAA,gBAAA,kBAEA,EAAA,kBAAA,oBAEA,EAAA,iBAAA,mBACA,EAAA,WAAA,aACA,EAAA,gBAAA,kBAEA,EAAA,cAAA,gBAEA,EAAA,eAAA,kBACF,EAAA,CAAA,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{useLabels as e}from"../configProvider/useLabels.mjs";import t from"../actionButtons/actionButtons.module.mjs";import{ButtonStyleType as
|
|
1
|
+
"use client";import{useLabels as e}from"../configProvider/useLabels.mjs";import{ThemeColor as t}from"../themeProvider/color.types.mjs";import n from"../actionButtons/actionButtons.module.mjs";import{ButtonStyleType as r}from"../button/button.types.mjs";import i from"../button/button.mjs";import{PopoverAlign as a,PopoverPlacement as o}from"../popover/popover.types.mjs";import s from"../popover/popover.mjs";import c from"../chip/chip.mjs";import l from"../chip/chipContainer.mjs";import u from"../modal/modal.mjs";import d from"../../services/klipy.mjs";import f from"../searchInput/searchInput.mjs";import p from"./components/gifPreview/gifPreview.mjs";import m from"./components/gifView/gifView.mjs";import h from"./klipyPicker.module.mjs";import{useMemo as g,useState as _}from"react";import v from"classnames";import{Fragment as y,jsx as b,jsxs as x}from"react/jsx-runtime";var S={search:`Pick gif`};function C({className:C,token:w=``,isModal:T=!1,onSelect:E=()=>void 0,selected:D=null,labels:O}){let k=e(`KlipyPicker`,O,S),A=g(()=>new d(w),[w]),[j,M]=_(``),[N,P]=_([]),[F,I]=_([]),[L,R]=_(null),[z,B]=_(!1);async function V(e){if(M(e),!e.trim()){P([]),I([]),R(null);return}let[{results:t=[],next:n=null},{results:r=[]}]=await Promise.all([A.search(e,{limit:18,contentfilter:`medium`}),A.searchSuggestions(e)]);P(t),R(n),I(r)}async function H(){let{results:e=[],next:t=null}=await A.search(j,{limit:36,pos:L??void 0,contentfilter:`medium`});R(t),P(t=>[...t,...e])}async function U(e){await E(e),B(!1),e&&A.registerShare(j,e.id)}function W(){return b(l,{inline:!0,className:h.klipyPickerSuggestionsContainer,children:F.map(e=>b(c,{className:h.klipyPickerSuggestionsItem,text:e,onClick:()=>V(e)},e))})}function G(){return b(p,{previewItems:N,onSelect:U,onLoadAdditional:H})}function K(){return b(f,{label:k.search,value:j,onDebounce:V,onChange:M})}return T?x(`div`,{className:v(h.klipyPicker,C),children:[x(`div`,{className:n.actionButtons,children:[b(i,{onClick:()=>B(!0),children:`Pick gif`}),D&&b(i,{styleType:r.Filled,color:t.Error,onClick:()=>U(null),children:`Remove gif`})]}),D&&b(m,{className:h.klipyPickerSelected,src:D}),b(u,{isOpen:z,onClose:()=>B(!1),children:x(`div`,{className:h.klipyPickerModalContent,children:[K(),W(),G()]})})]}):x(`div`,{className:v(h.klipyPicker,C),children:[b(s,{placement:o.Bottom,align:a.Start,isOpen:N.length>0&&z,onOpenChange:B,closeOnTriggerClick:!1,constrainWidth:!1,content:x(y,{children:[W(),G()]}),children:K()}),D&&b(i,{styleType:r.Filled,color:t.Error,onClick:()=>U(null),children:`Remove gif`}),D&&b(m,{className:h.klipyPickerSelected,src:D})]})}export{C as default};
|
|
2
2
|
//# sourceMappingURL=klipyPicker.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"klipyPicker.mjs","names":[],"sources":["../../../../package/common/klipyPicker/klipyPicker.tsx"],"sourcesContent":["import { useMemo, useState } from 'react';\nimport cx from 'classnames';\nimport type { ReactElement, ReactNode } from 'react';\nimport KlipyService from 'services/klipy';\nimport type { KlipyResult } from 'services/klipy';\nimport SearchInput from '../searchInput';\nimport GifPreview from './components/gifPreview';\nimport Popover from '../popover';\nimport Button, { ButtonStyleType } from '../button';\nimport Modal from '../modal';\nimport Chip, { ChipContainer } from '../chip';\nimport GifView from './components/gifView';\nimport type { KlipyPickerLabels, KlipyPickerProps } from './klipyPicker.types';\nimport { useLabels } from '../configProvider';\n\nconst DEFAULT_LABELS: Required<KlipyPickerLabels> = {\n search: 'Pick gif',\n};\nimport styles from './klipyPicker.module.pcss';\nimport actionButtonStyles from 'components/common/actionButtons/actionButtons.module.pcss';\nimport { PopoverAlign, PopoverPlacement } from '../popover/popover.types';\n\nexport default function KlipyPicker({\n className,\n token = '',\n isModal = false,\n onSelect = () => undefined,\n selected = null,\n labels,\n}: KlipyPickerProps): ReactElement {\n const text = useLabels('KlipyPicker', labels, DEFAULT_LABELS);\n const klipyService = useMemo(() => new KlipyService(token), [token]);\n\n const [searchText, setSearchText] = useState('');\n const [currentPreviews, setCurrentPreviews] = useState<KlipyResult[]>([]);\n const [currentSuggestions, setCurrentSuggestions] = useState<string[]>([]);\n const [lastNext, setLastNext] = useState<string | null>(null);\n const [isMenuOpen, setIsMenuOpen] = useState(false);\n\n async function searchFor(query: string) {\n setSearchText(query);\n if (!query.trim()) {\n setCurrentPreviews([]);\n setCurrentSuggestions([]);\n setLastNext(null);\n return;\n }\n const [{ results: searchResults = [], next = null }, { results: suggestionResults = [] }] = await Promise.all([\n klipyService.search(query, { limit: 18, contentfilter: 'medium' }),\n klipyService.searchSuggestions(query),\n ]);\n setCurrentPreviews(searchResults);\n setLastNext(next);\n setCurrentSuggestions(suggestionResults);\n }\n\n async function handleLoadAdditional() {\n const { results: searchResults = [], next = null } = await klipyService.search(searchText, {\n limit: 36,\n pos: lastNext ?? undefined,\n contentfilter: 'medium',\n });\n setLastNext(next);\n setCurrentPreviews((prev) => [...prev, ...searchResults]);\n }\n\n async function handlePreviewSelect(preview: KlipyResult | null) {\n await onSelect(preview);\n setIsMenuOpen(false);\n if (preview) klipyService.registerShare(searchText, preview.id);\n }\n\n function renderSuggestions(): ReactNode {\n return (\n <ChipContainer inline className={styles.klipyPickerSuggestionsContainer}>\n {currentSuggestions.map((suggestion) => (\n <Chip\n className={styles.klipyPickerSuggestionsItem}\n key={suggestion}\n text={suggestion}\n onClick={() => searchFor(suggestion)}\n />\n ))}\n </ChipContainer>\n );\n }\n\n function renderPreviewPicker(): ReactNode {\n return (\n <GifPreview\n previewItems={currentPreviews}\n onSelect={handlePreviewSelect}\n onLoadAdditional={handleLoadAdditional}\n />\n );\n }\n\n function renderSearchInput(): ReactNode {\n return <SearchInput label={text.search} value={searchText} onDebounce={searchFor} onChange={setSearchText} />;\n }\n\n if (isModal) {\n return (\n <div className={cx(styles.klipyPicker, className)}>\n <div className={actionButtonStyles.actionButtons}>\n <Button onClick={() => setIsMenuOpen(true)}>Pick gif</Button>\n {selected && (\n <Button
|
|
1
|
+
{"version":3,"file":"klipyPicker.mjs","names":[],"sources":["../../../../package/common/klipyPicker/klipyPicker.tsx"],"sourcesContent":["import { useMemo, useState } from 'react';\nimport cx from 'classnames';\nimport type { ReactElement, ReactNode } from 'react';\nimport KlipyService from 'services/klipy';\nimport type { KlipyResult } from 'services/klipy';\nimport SearchInput from '../searchInput';\nimport GifPreview from './components/gifPreview';\nimport Popover from '../popover';\nimport Button, { ButtonStyleType } from '../button';\nimport Modal from '../modal';\nimport Chip, { ChipContainer } from '../chip';\nimport GifView from './components/gifView';\nimport type { KlipyPickerLabels, KlipyPickerProps } from './klipyPicker.types';\nimport { useLabels } from '../configProvider';\n\nconst DEFAULT_LABELS: Required<KlipyPickerLabels> = {\n search: 'Pick gif',\n};\nimport styles from './klipyPicker.module.pcss';\nimport actionButtonStyles from 'components/common/actionButtons/actionButtons.module.pcss';\nimport { PopoverAlign, PopoverPlacement } from '../popover/popover.types';\nimport { ThemeColor } from '../themeProvider/color.types';\n\nexport default function KlipyPicker({\n className,\n token = '',\n isModal = false,\n onSelect = () => undefined,\n selected = null,\n labels,\n}: KlipyPickerProps): ReactElement {\n const text = useLabels('KlipyPicker', labels, DEFAULT_LABELS);\n const klipyService = useMemo(() => new KlipyService(token), [token]);\n\n const [searchText, setSearchText] = useState('');\n const [currentPreviews, setCurrentPreviews] = useState<KlipyResult[]>([]);\n const [currentSuggestions, setCurrentSuggestions] = useState<string[]>([]);\n const [lastNext, setLastNext] = useState<string | null>(null);\n const [isMenuOpen, setIsMenuOpen] = useState(false);\n\n async function searchFor(query: string) {\n setSearchText(query);\n if (!query.trim()) {\n setCurrentPreviews([]);\n setCurrentSuggestions([]);\n setLastNext(null);\n return;\n }\n const [{ results: searchResults = [], next = null }, { results: suggestionResults = [] }] = await Promise.all([\n klipyService.search(query, { limit: 18, contentfilter: 'medium' }),\n klipyService.searchSuggestions(query),\n ]);\n setCurrentPreviews(searchResults);\n setLastNext(next);\n setCurrentSuggestions(suggestionResults);\n }\n\n async function handleLoadAdditional() {\n const { results: searchResults = [], next = null } = await klipyService.search(searchText, {\n limit: 36,\n pos: lastNext ?? undefined,\n contentfilter: 'medium',\n });\n setLastNext(next);\n setCurrentPreviews((prev) => [...prev, ...searchResults]);\n }\n\n async function handlePreviewSelect(preview: KlipyResult | null) {\n await onSelect(preview);\n setIsMenuOpen(false);\n if (preview) klipyService.registerShare(searchText, preview.id);\n }\n\n function renderSuggestions(): ReactNode {\n return (\n <ChipContainer inline className={styles.klipyPickerSuggestionsContainer}>\n {currentSuggestions.map((suggestion) => (\n <Chip\n className={styles.klipyPickerSuggestionsItem}\n key={suggestion}\n text={suggestion}\n onClick={() => searchFor(suggestion)}\n />\n ))}\n </ChipContainer>\n );\n }\n\n function renderPreviewPicker(): ReactNode {\n return (\n <GifPreview\n previewItems={currentPreviews}\n onSelect={handlePreviewSelect}\n onLoadAdditional={handleLoadAdditional}\n />\n );\n }\n\n function renderSearchInput(): ReactNode {\n return <SearchInput label={text.search} value={searchText} onDebounce={searchFor} onChange={setSearchText} />;\n }\n\n if (isModal) {\n return (\n <div className={cx(styles.klipyPicker, className)}>\n <div className={actionButtonStyles.actionButtons}>\n <Button onClick={() => setIsMenuOpen(true)}>Pick gif</Button>\n {selected && (\n <Button\n styleType={ButtonStyleType.Filled}\n color={ThemeColor.Error}\n onClick={() => handlePreviewSelect(null)}\n >\n Remove gif\n </Button>\n )}\n </div>\n {selected && <GifView className={styles.klipyPickerSelected} src={selected} />}\n <Modal isOpen={isMenuOpen} onClose={() => setIsMenuOpen(false)}>\n <div className={styles.klipyPickerModalContent}>\n {renderSearchInput()}\n {renderSuggestions()}\n {renderPreviewPicker()}\n </div>\n </Modal>\n </div>\n );\n }\n\n return (\n <div className={cx(styles.klipyPicker, className)}>\n <Popover\n placement={PopoverPlacement.Bottom}\n align={PopoverAlign.Start}\n isOpen={currentPreviews.length > 0 && isMenuOpen}\n onOpenChange={setIsMenuOpen}\n // The panel opens while the user is typing in the search field, so a\n // click back into the field must not close it again.\n closeOnTriggerClick={false}\n // The grid sets its own 420px cap.\n constrainWidth={false}\n content={\n <>\n {renderSuggestions()}\n {renderPreviewPicker()}\n </>\n }\n >\n {renderSearchInput()}\n </Popover>\n {selected && (\n <Button styleType={ButtonStyleType.Filled} color={ThemeColor.Error} onClick={() => handlePreviewSelect(null)}>\n Remove gif\n </Button>\n )}\n {selected && <GifView className={styles.klipyPickerSelected} src={selected} />}\n </div>\n );\n}\n"],"mappings":"g3BAeA,IAAM,EAA8C,CAClD,OAAQ,UACV,EAMA,SAAwB,EAAY,CAClC,YACA,QAAQ,GACR,UAAU,GACV,eAAiB,IAAA,GACjB,WAAW,KACX,UACiC,CACjC,IAAM,EAAO,EAAU,cAAe,EAAQ,CAAc,EACtD,EAAe,MAAc,IAAI,EAAa,CAAK,EAAG,CAAC,CAAK,CAAC,EAE7D,CAAC,EAAY,GAAiB,EAAS,EAAE,EACzC,CAAC,EAAiB,GAAsB,EAAwB,CAAC,CAAC,EAClE,CAAC,EAAoB,GAAyB,EAAmB,CAAC,CAAC,EACnE,CAAC,EAAU,GAAe,EAAwB,IAAI,EACtD,CAAC,EAAY,GAAiB,EAAS,EAAK,EAElD,eAAe,EAAU,EAAe,CAEtC,GADA,EAAc,CAAK,EACf,CAAC,EAAM,KAAK,EAAG,CACjB,EAAmB,CAAC,CAAC,EACrB,EAAsB,CAAC,CAAC,EACxB,EAAY,IAAI,EAChB,MACF,CACA,GAAM,CAAC,CAAE,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C3D,GACC,EAAC,EAAD,CACE,UAAW,EAAgB,OAC3B,MAAO,EAAW,MAClB,YAAe,EAAoB,IAAI,EACxC,SAAA,YAEO,CAAA,CAEP,IACJ,GAAY,EAAC,EAAD,CAAS,UAAW,EAAO,oBAAqB,IAAK,CAAW,CAAA,EAC7E,EAAC,EAAD,CAAO,OAAQ,EAAY,YAAe,EAAc,EAAK,EAC3D,SAAA,EAAC,MAAD,CAAK,UAAW,EAAO,wBAAvB,SAAA,CACG,EAAkB,EAClB,EAAkB,EAClB,EAAoB,CAClB,GACA,CAAA,CACJ,IAKP,EAAC,MAAD,CAAK,UAAW,EAAG,EAAO,YAAa,CAAS,EAAhD,SAAA,CACE,EAAC,EAAD,CACE,UAAW,EAAiB,OAC5B,MAAO,EAAa,MACpB,OAAQ,EAAgB,OAAS,GAAK,EACtC,aAAc,EAGd,oBAAqB,GAErB,eAAgB,GAChB,QACE,EAAA,EAAA,CAAA,SAAA,CACG,EAAkB,EAClB,EAAoB,CACrB,CAAA,CAAA,EAGH,SAAA,EAAkB,CACZ,CAAA,EACR,GACC,EAAC,EAAD,CAAQ,UAAW,EAAgB,OAAQ,MAAO,EAAW,MAAO,YAAe,EAAoB,IAAI,EAAG,SAAA,YAEtG,CAAA,EAET,GAAY,EAAC,EAAD,CAAS,UAAW,EAAO,oBAAqB,IAAK,CAAW,CAAA,CAC1E,GAET"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{useComponentDefaults as e}from"../configProvider/useComponentDefaults.mjs";import{useLabels as t}from"../configProvider/useLabels.mjs";import{usePresentationDefault as n}from"../configProvider/usePresentationDefault.mjs";import r from"../bodyEnd/bodyEnd.mjs";import
|
|
1
|
+
"use client";import{useComponentDefaults as e}from"../configProvider/useComponentDefaults.mjs";import{useLabels as t}from"../configProvider/useLabels.mjs";import{usePresentationDefault as n}from"../configProvider/usePresentationDefault.mjs";import r from"../actionIcon/actionIcon.mjs";import i from"../bodyEnd/bodyEnd.mjs";import a from"../styles/sheet.module.mjs";import{useVisualViewportSize as o}from"../hooks/useVisualViewportSize.mjs";import s from"../hooks/useSheet.mjs";import{useOverlay as c}from"../hooks/useOverlay.mjs";import l from"../styles/scrollFade.module.mjs";import u from"./modal.module.mjs";import{useScrollEdges as d}from"../hooks/useScrollEdges.mjs";import{useEffect as f,useId as p,useRef as m,useState as h}from"react";import g from"classnames";import{faXmark as _}from"@fortawesome/free-solid-svg-icons";import{jsx as v,jsxs as y}from"react/jsx-runtime";var b={close:`Close`};function x(x){let{children:S=null,title:C,isOpen:w=!1,onClose:T=()=>null,footer:E=null,className:D=``,style:O,hideHeader:k=!1,closeOnEscape:A=!0,presentation:j,classNames:M,styles:N,labels:P,...F}=e(`Modal`,x),I=t(`Modal`,P,b),[L,R]=h(w),[z,B]=h(w),V=m(null),H=m(null),U=p(),{height:W,offsetTop:G}=o(),K=n(),{isSheet:q,sheetStyle:J}=s(j??K);f(()=>{if(w){R(!0);let e=setTimeout(()=>B(!0),1);return()=>clearTimeout(e)}B(!1);let e=setTimeout(()=>R(!1),300);return()=>clearTimeout(e)},[w]),c({isActive:L&&z,containerRef:V,onEscape:A?T:void 0});let{hasStart:Y,hasEnd:X}=d(H,{isEnabled:L&&z});if(!L)return null;let Z=!k&&!!C;return v(i,{children:y(`div`,{className:g(u.modalContainer,M?.container),style:{height:W,top:G,...N?.container},children:[v(`div`,{className:g(u.modalWrapper,z&&u.modalWrapperShown,M?.backdrop),style:N?.backdrop,onClick:T}),z&&y(`div`,{...F,ref:V,role:`dialog`,"aria-modal":`true`,"aria-labelledby":Z&&!F[`aria-label`]?U:void 0,tabIndex:-1,className:g(u.modal,z&&u.modalShown,q&&[a.sheet,a.sheetSurface,u.modalSheet],D,M?.modal),style:{...q?J:void 0,...O,...N?.modal},onClick:e=>e.stopPropagation(),children:[!k&&y(`div`,{className:g(u.modalHeader,M?.header),style:N?.header,children:[v(`div`,{id:U,className:M?.title,style:N?.title,children:C}),v(r,{icon:_,onClick:T,"aria-label":I.close,className:g(u.modalCloseButton,M?.closeButton),style:N?.closeButton})]}),v(`div`,{ref:H,className:g(u.modalBody,l.scrollFade,l.scrollFadeY,Y&&l.scrollFadeFadedStart,X&&l.scrollFadeFadedEnd,M?.body),style:N?.body,children:S}),E&&v(`div`,{className:g(u.modalFooter,M?.footer),style:N?.footer,children:E})]})]})})}export{x as default};
|
|
2
2
|
//# sourceMappingURL=modal.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal.mjs","names":[],"sources":["../../../../package/common/modal/modal.tsx"],"sourcesContent":["import cx from 'classnames';\nimport BodyEnd from 'components/common/bodyEnd';\n\nimport styles from './modal.module.pcss';\nimport sheetStyles from 'components/common/styles/sheet.module.pcss';\nimport {
|
|
1
|
+
{"version":3,"file":"modal.mjs","names":[],"sources":["../../../../package/common/modal/modal.tsx"],"sourcesContent":["import cx from 'classnames';\nimport BodyEnd from 'components/common/bodyEnd';\n\nimport styles from './modal.module.pcss';\nimport sheetStyles from 'components/common/styles/sheet.module.pcss';\nimport { faXmark as closeIcon } from '@fortawesome/free-solid-svg-icons';\nimport { ModalProps } from './modal.types';\nimport type { ModalLabels } from './modal.types';\nimport { useEffect, useId, useRef, useState } from 'react';\nimport { useVisualViewportSize } from 'components/common/hooks/useVisualViewportSize';\nimport { useOverlay } from 'components/common/hooks/useOverlay';\nimport { useSheet } from 'components/common/hooks/useSheet';\nimport { useScrollEdges } from 'components/common/hooks/useScrollEdges';\nimport fadeStyles from 'components/common/styles/scrollFade.module.pcss';\nimport { useComponentDefaults, useLabels, usePresentationDefault } from 'components/common/configProvider';\nimport ActionIcon from 'components/common/actionIcon';\n\nconst DEFAULT_LABELS: Required<ModalLabels> = {\n close: 'Close',\n};\n\nfunction Modal(props: ModalProps) {\n const {\n children = null,\n title,\n isOpen = false,\n onClose = () => null,\n footer = null,\n className = '',\n style,\n hideHeader = false,\n closeOnEscape = true,\n presentation: presentationProp,\n classNames,\n styles: slotStyles,\n labels,\n ...rest\n } = useComponentDefaults('Modal', props);\n const text = useLabels('Modal', labels, DEFAULT_LABELS);\n const [isRendered, setIsRendered] = useState(isOpen);\n const [animateIn, setAnimateIn] = useState(isOpen);\n const modalRef = useRef<HTMLDivElement>(null);\n const bodyRef = useRef<HTMLDivElement>(null);\n const titleId = useId();\n // Centering/sizing against the actually-visible viewport (not the full layout viewport) keeps\n // the modal — and whatever's focused inside it — from ending up under a mobile keyboard.\n const { height: viewportHeight, offsetTop: viewportOffsetTop } = useVisualViewportSize();\n // Explicit prop → this component's global default → the app-wide one. There's no built-in\n // fallback to add: `Default` and no presentation at all both mean the ordinary centred dialog.\n const appPresentation = usePresentationDefault();\n const presentation = presentationProp ?? appPresentation;\n const { isSheet, sheetStyle } = useSheet(presentation);\n\n // Cancelled on a flip back, or a reopen during the close animation is hidden by its late unmount.\n useEffect(() => {\n if (isOpen) {\n // eslint-disable-next-line react-hooks/set-state-in-effect\n setIsRendered(true);\n const id = setTimeout(() => setAnimateIn(true), 1);\n return () => clearTimeout(id);\n }\n setAnimateIn(false);\n const id = setTimeout(() => setIsRendered(false), 300);\n return () => clearTimeout(id);\n }, [isOpen]);\n\n // Keyed on `animateIn` rather than `isOpen`, because the panel this needs to focus and trap\n // focus inside of only mounts once that flips.\n useOverlay({\n isActive: isRendered && animateIn,\n containerRef: modalRef,\n onEscape: closeOnEscape ? onClose : undefined,\n });\n\n const { hasStart, hasEnd } = useScrollEdges(bodyRef, { isEnabled: isRendered && animateIn });\n\n if (!isRendered) return null;\n\n const hasHeaderTitle = !hideHeader && !!title;\n\n return (\n <BodyEnd>\n <div\n className={cx(styles.modalContainer, classNames?.container)}\n style={{ height: viewportHeight, top: viewportOffsetTop, ...slotStyles?.container }}\n >\n <div\n className={cx(styles.modalWrapper, animateIn && styles.modalWrapperShown, classNames?.backdrop)}\n style={slotStyles?.backdrop}\n onClick={onClose}\n />\n {animateIn && (\n <div\n {...rest}\n ref={modalRef}\n role='dialog'\n aria-modal='true'\n // aria-labelledby would outrank aria-label, which is the only way to name a title with no text.\n aria-labelledby={hasHeaderTitle && !rest['aria-label'] ? titleId : undefined}\n // Focusable so the trap has somewhere to put focus when the content has no tabbables.\n tabIndex={-1}\n className={cx(\n styles.modal,\n animateIn && styles.modalShown,\n // The panel is its own sheet surface here: there's no inner panel to fill, since\n // Modal already splits itself into a fixed header and a scrolling body.\n isSheet && [sheetStyles.sheet, sheetStyles.sheetSurface, styles.modalSheet],\n className,\n classNames?.modal,\n )}\n style={{ ...(isSheet ? sheetStyle : undefined), ...style, ...slotStyles?.modal }}\n onClick={(e) => e.stopPropagation()}\n >\n {!hideHeader && (\n <div className={cx(styles.modalHeader, classNames?.header)} style={slotStyles?.header}>\n <div id={titleId} className={classNames?.title} style={slotStyles?.title}>\n {title}\n </div>\n <ActionIcon\n icon={closeIcon}\n onClick={onClose}\n aria-label={text.close}\n className={cx(styles.modalCloseButton, classNames?.closeButton)}\n style={slotStyles?.closeButton}\n />\n </div>\n )}\n <div\n ref={bodyRef}\n className={cx(\n styles.modalBody,\n fadeStyles.scrollFade,\n fadeStyles.scrollFadeY,\n hasStart && fadeStyles.scrollFadeFadedStart,\n hasEnd && fadeStyles.scrollFadeFadedEnd,\n classNames?.body,\n )}\n style={slotStyles?.body}\n >\n {children}\n </div>\n {footer && (\n <div className={cx(styles.modalFooter, classNames?.footer)} style={slotStyles?.footer}>\n {footer}\n </div>\n )}\n </div>\n )}\n </div>\n </BodyEnd>\n );\n}\n\nexport default Modal;\n"],"mappings":"+2BAiBA,IAAM,EAAwC,CAC5C,MAAO,OACT,EAEA,SAAS,EAAM,EAAmB,CAChC,GAAM,CACJ,WAAW,KACX,QACA,SAAS,GACT,cAAgB,KAChB,SAAS,KACT,YAAY,GACZ,QACA,aAAa,GACb,gBAAgB,GAChB,aAAc,EACd,aACA,OAAQ,EACR,SACA,GAAG,GACD,EAAqB,QAAS,CAAK,EACjC,EAAO,EAAU,QAAS,EAAQ,CAAc,EAChD,CAAC,EAAY,GAAiB,EAAS,CAA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AAY,KACd,EACA,MAAO,CAAE,GAAI,EAAU,EAAa,IAAA,GAAY,GAAG,EAAO,GAAG,GAAY,KAAM,EAC/E,QAAU,GAAM,EAAE,gBAAgB,EAnBpC,SAAA,CAqBG,CAAC,GACA,EAAC,MAAD,CAAK,UAAW,EAAG,EAAO,YAAa,GAAY,MAAM,EAAG,MAAO,GAAY,OAA/E,SAAA,CACE,EAAC,MAAD,CAAK,GAAI,EAAS,UAAW,GAAY,MAAO,MAAO,GAAY,MAChE,SAAA,CACE,CAAA,EACL,EAAC,EAAD,CACE,KAAM,EACN,QAAS,EACT,aAAY,EAAK,MACjB,UAAW,EAAG,EAAO,iBAAkB,GAAY,WAAW,EAC9D,MAAO,GAAY,WACpB,CAAA,CACE,IAEP,EAAC,MAAD,CACE,IAAK,EACL,UAAW,EACT,EAAO,UACP,EAAW,WACX,EAAW,YACX,GAAY,EAAW,qBACvB,GAAU,EAAW,mBACrB,GAAY,IACd,EACA,MAAO,GAAY,KAElB,UACE,CAAA,EACJ,GACC,EAAC,MAAD,CAAK,UAAW,EAAG,EAAO,YAAa,GAAY,MAAM,EAAG,MAAO,GAAY,OAC5E,SAAA,CACE,CAAA,CAEJ,CAEJ,CAAA,CAAA,CACE,CAAA,CAAA,CAAA,CAEb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal.module.mjs","names":[],"sources":["../../../../package/common/modal/modal.module.pcss"],"sourcesContent":[".modal {\n /* Theme tokens resolved once, each with a built-in fallback. Set any of the public\n `--modal-*` variables via ThemeProvider (theme-wide) or `style` (per instance) to\n override; unset ones fall back to the values below. */\n --custom-modal-padding: var(--modal-padding, var(--spacing-l));\n --custom-modal-gap: var(--modal-gap, var(--spacing-l));\n\n /* Half the gap, so the scroll port's clipping edge — where the divider sits — lands midway\n between the chrome and where the content rests, with the same room either side. Flush\n against the chrome (bleed = gap) reads as a sliced line of text colliding with the title;\n an unrelated value (this was `0.6em`) puts it at a distance that drifts with the font size. */\n --custom-modal-body-bleed: var(--modal-body-bleed, calc(var(--custom-modal-gap) / 2));\n\n /* The panel never comes closer to the screen edge than its own padding, at every size. A\n percentage instead reads as a different inset on every screen, and pairing one with a\n breakpoint made the two axes disagree: 5% of a 390px width is 19.5px but 5% of a 780px\n height is 39px, so the same rule came out narrower and taller than the default on one phone. */\n --custom-modal-max-width: var(--modal-max-width, calc(100% - 2 * var(--custom-modal-padding)));\n --custom-modal-max-height: var(--modal-max-height, calc(100% - 2 * var(--custom-modal-padding)));\n\n padding: var(--custom-modal-padding);\n border-radius: var(--default-border-radius);\n background: var(--background-modal);\n color: var(--text-color);\n font-family: var(--default-font);\n box-sizing: border-box;\n position: relative;\n display: flex;\n flex-direction: column;\n transform-origin: bottom center;\n animation:\n slideIn 0.2s,\n fadeIn 0.3s forwards;\n max-width: var(--custom-modal-max-width);\n max-height: var(--custom-modal-max-height);\n\n /* The panel itself never scrolls, so the header stays put; `&-body` is what scrolls. */\n overflow: hidden;\n\n /* A sheet-presented modal carries forms and detail views, not a short menu, so it takes more\n of the screen than the shared default — and keeps the panel's own padding at the bottom edge. */\n &-sheet {\n --sheet-max-height: 90dvh;\n --sheet-safe-padding: var(--custom-modal-padding);\n }\n\n &-container {\n position: fixed;\n width: 100%;\n height: 100%;\n display: flex;\n justify-content: center;\n align-items: center;\n top: 0;\n left: 0;\n\n /* Shared by every overlay, so the order they are portaled in, which is the order they opened in, decides. */\n z-index: 1;\n }\n\n &-header {\n display: flex;\n gap: var(--spacing-m);\n justify-content: space-between;\n align-items: center;\n margin-bottom: var(--custom-modal-gap);\n flex: 0 0 auto;\n\n div {\n overflow: hidden;\n text-overflow: ellipsis;\n }\n }\n\n &-body {\n /* `min-height: 0` lets this shrink below its content's height so it, not the panel, scrolls. */\n flex: 1 1 auto;\n min-height: 0;\n overflow: auto;\n\n /* A negative margin cancelled by an equal padding, so a focus ring or a floating label at\n the body's edge isn't clipped by the scroll container. Override the pair with\n `--modal-body-bleed`, never with a plain `padding`, which drops the negative half and\n brings the clipping back. See `docs/Modal.md` for what the two do together. */\n margin: calc(-1 * var(--custom-modal-body-bleed));\n padding: var(--custom-modal-body-bleed);\n\n /* The mask lives in `styles/scrollFade.module.pcss`; the component applies it along with the\n modifiers saying which end genuinely hides content. The run has to clear the port's own\n padding before any content fades at all, hence gap + bleed. Set here as the shared sheet's\n private length rather than as `--scroll-fade-length`, which would inherit down into a\n `ScrollFade` nested in the body. */\n --custom-scroll-fade-length: var(\n --modal-scroll-fade,\n calc(var(--custom-modal-gap) + var(--custom-modal-body-bleed))\n );\n }\n\n &-footer {\n margin-top: var(--custom-modal-gap);\n flex: 0 0 auto;\n }\n\n &-close-button {\n flex-shrink: 0;\n
|
|
1
|
+
{"version":3,"file":"modal.module.mjs","names":[],"sources":["../../../../package/common/modal/modal.module.pcss"],"sourcesContent":[".modal {\n /* Theme tokens resolved once, each with a built-in fallback. Set any of the public\n `--modal-*` variables via ThemeProvider (theme-wide) or `style` (per instance) to\n override; unset ones fall back to the values below. */\n --custom-modal-padding: var(--modal-padding, var(--spacing-l));\n --custom-modal-gap: var(--modal-gap, var(--spacing-l));\n\n /* Half the gap, so the scroll port's clipping edge — where the divider sits — lands midway\n between the chrome and where the content rests, with the same room either side. Flush\n against the chrome (bleed = gap) reads as a sliced line of text colliding with the title;\n an unrelated value (this was `0.6em`) puts it at a distance that drifts with the font size. */\n --custom-modal-body-bleed: var(--modal-body-bleed, calc(var(--custom-modal-gap) / 2));\n\n /* The panel never comes closer to the screen edge than its own padding, at every size. A\n percentage instead reads as a different inset on every screen, and pairing one with a\n breakpoint made the two axes disagree: 5% of a 390px width is 19.5px but 5% of a 780px\n height is 39px, so the same rule came out narrower and taller than the default on one phone. */\n --custom-modal-max-width: var(--modal-max-width, calc(100% - 2 * var(--custom-modal-padding)));\n --custom-modal-max-height: var(--modal-max-height, calc(100% - 2 * var(--custom-modal-padding)));\n\n padding: var(--custom-modal-padding);\n border-radius: var(--default-border-radius);\n background: var(--background-modal);\n color: var(--text-color);\n font-family: var(--default-font);\n box-sizing: border-box;\n position: relative;\n display: flex;\n flex-direction: column;\n transform-origin: bottom center;\n animation:\n slideIn 0.2s,\n fadeIn 0.3s forwards;\n max-width: var(--custom-modal-max-width);\n max-height: var(--custom-modal-max-height);\n\n /* The panel itself never scrolls, so the header stays put; `&-body` is what scrolls. */\n overflow: hidden;\n\n /* A sheet-presented modal carries forms and detail views, not a short menu, so it takes more\n of the screen than the shared default — and keeps the panel's own padding at the bottom edge. */\n &-sheet {\n --sheet-max-height: 90dvh;\n --sheet-safe-padding: var(--custom-modal-padding);\n }\n\n &-container {\n position: fixed;\n width: 100%;\n height: 100%;\n display: flex;\n justify-content: center;\n align-items: center;\n top: 0;\n left: 0;\n\n /* Shared by every overlay, so the order they are portaled in, which is the order they opened in, decides. */\n z-index: 1;\n }\n\n &-header {\n display: flex;\n gap: var(--spacing-m);\n justify-content: space-between;\n align-items: center;\n margin-bottom: var(--custom-modal-gap);\n flex: 0 0 auto;\n\n div {\n overflow: hidden;\n text-overflow: ellipsis;\n }\n }\n\n &-body {\n /* `min-height: 0` lets this shrink below its content's height so it, not the panel, scrolls. */\n flex: 1 1 auto;\n min-height: 0;\n overflow: auto;\n\n /* A negative margin cancelled by an equal padding, so a focus ring or a floating label at\n the body's edge isn't clipped by the scroll container. Override the pair with\n `--modal-body-bleed`, never with a plain `padding`, which drops the negative half and\n brings the clipping back. See `docs/Modal.md` for what the two do together. */\n margin: calc(-1 * var(--custom-modal-body-bleed));\n padding: var(--custom-modal-body-bleed);\n\n /* The mask lives in `styles/scrollFade.module.pcss`; the component applies it along with the\n modifiers saying which end genuinely hides content. The run has to clear the port's own\n padding before any content fades at all, hence gap + bleed. Set here as the shared sheet's\n private length rather than as `--scroll-fade-length`, which would inherit down into a\n `ScrollFade` nested in the body. */\n --custom-scroll-fade-length: var(\n --modal-scroll-fade,\n calc(var(--custom-modal-gap) + var(--custom-modal-body-bleed))\n );\n }\n\n &-footer {\n margin-top: var(--custom-modal-gap);\n flex: 0 0 auto;\n }\n\n &-close-button {\n flex-shrink: 0;\n }\n\n &-wrapper {\n position: fixed;\n width: 100%;\n height: 100%;\n background: #00000052;\n top: 0;\n left: 0;\n transition: all 0.3s ease-in-out;\n opacity: 0;\n\n &-shown {\n opacity: 1;\n }\n }\n}\n\n@keyframes slideIn {\n from {\n transform: scale(0);\n }\n\n to {\n transform: scale(0.99);\n }\n}\n\n@keyframes fadeIn {\n from {\n opacity: 0;\n }\n\n to {\n opacity: 1;\n }\n}\n\n/* Only the scale-in goes; the backdrop and the panel still fade, which is not motion.\n `slideIn` ends at scale(0.99) and the panel has no transform of its own, so dropping the\n animation lands it at scale(1) rather than leaving it collapsed. */\n@media (prefers-reduced-motion: reduce) {\n .modal {\n animation: fadeIn 0.3s forwards;\n }\n}\n"],"mappings":""}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{useComponentDefaults as e}from"../configProvider/useComponentDefaults.mjs";import{useLabels as t}from"../configProvider/useLabels.mjs";import{
|
|
1
|
+
"use client";import{useComponentDefaults as e}from"../configProvider/useComponentDefaults.mjs";import{useLabels as t}from"../configProvider/useLabels.mjs";import{ThemeColor as n}from"../themeProvider/color.types.mjs";import{ButtonSize as r}from"../button/button.types.mjs";import i from"../button/button.mjs";import a from"../hooks/useCoarsePointer.mjs";import ee from"../buttonGroup/buttonGroup.mjs";import o from"../input/input.mjs";import s from"./numberInput.module.mjs";import te from"./useStepRepeat.mjs";import c from"react";import l from"classnames";import{FontAwesomeIcon as u}from"@fortawesome/react-fontawesome";import{faChevronDown as ne,faChevronUp as re,faMinus as ie,faPlus as ae}from"@fortawesome/free-solid-svg-icons";import{jsx as d,jsxs as f}from"react/jsx-runtime";import{NumericFormat as p}from"react-number-format";var oe={increase:`Increase`,decrease:`Decrease`};function m({label:e,disabled:t,direction:n,onStart:r,onStop:i}){return{tabIndex:-1,disabled:t,"aria-label":e,onPointerDown:e=>{(e.button===0||e.pointerType!==`mouse`)&&(e.preventDefault(),r(n,e.shiftKey?10:1))},onPointerUp:i,onPointerCancel:i,onContextMenu:e=>e.preventDefault()}}function h(e){return d(`button`,{type:`button`,...m(e),className:l(s.arrowBtn,e.className),style:e.style,children:d(u,{icon:e.icon,"aria-hidden":`true`})})}function g(e){let{disabled:t,...a}=m(e);return d(i,{...a,className:l(s.splitBtn,e.className),style:e.style,color:n.Neutral,size:r.Icon,disabled:t,icon:e.icon})}function _(n){let r=c.useRef(void 0),{value:i,onChange:u,formValidator:m,label:_,error:v,className:y,style:b,classNames:x,styles:S,allowNegative:C=!1,decimalSeparator:se,thousandSeparator:ce,prefix:le,suffix:ue,decimalScale:w,fixedDecimalScale:de=!0,placeholder:fe,sign:T,showArrows:pe=!1,step:E=1,min:D,max:O,arrowsLayout:k=`auto`,labels:me,readOnly:A=!1,disabled:j=!1,isRequired:he=!1,onKeyDown:M,ref:ge,...N}=e(`NumberInput`,n),P=t(`NumberInput`,me,oe),[,F]=c.useState(0);c.useEffect(()=>{if(r.current=m,!m)return;let e=()=>F(e=>e+1);return m.registerOnUpdateListener(e),()=>{m.removeOnUpdateListener(e)}},[m]);let I=he||!!m?.validators.find(e=>e.validatorId===`required`),L=m==null?i:m.value,R=T!=null&&L!=null?Math.abs(Number(L)):L,z=R==null?``:String(R);function B(e){let t=e;t!==void 0&&(T===`-`&&(t=-Math.abs(t)),T===`+`&&(t=Math.abs(t))),m?.set(t??null),u?.(t)}function V(e){let t=e;return!C&&T!==`-`&&(t=Math.max(0,t)),T===`-`&&(t=Math.min(0,t)),D!==void 0&&(t=Math.max(D,t)),O!==void 0&&(t=Math.min(O,t)),t}let H=L!=null&&L!==``?Number(L):0;function U(){if(A||j||L==null||L===``)return;let e=Number(L);if(!Number.isFinite(e))return;let t=V(e);t!==e&&B(t)}function W(e){if(A||j)return!1;let t=V(H+e);return t!==H&&(B(t),!0)}let{start:_e,stop:ve}=te(e=>W(e*E));function ye(e){if(e.key===`Enter`){U(),M?.(e);return}if(!G){M?.(e);return}if(e.key===`ArrowUp`){e.preventDefault(),W(e.shiftKey?E*10:E);return}if(e.key===`ArrowDown`){e.preventDefault(),W(e.shiftKey?-E*10:-E);return}M?.(e)}let be=T===`-`?`-`:T===`+`?`+`:le,xe=a(),G=pe&&!A&&!j,K=k===`split`||k===`auto`&&xe,q=V(H+E)!==H,J=V(H-E)!==H,Y={onStart:_e,onStop:ve},X=G&&!K?f(`div`,{className:l(s.arrows,x?.arrows),style:S?.arrows,children:[d(h,{className:x?.increaseButton,style:S?.increaseButton,label:P.increase,icon:re,disabled:!q,direction:1,...Y}),d(h,{className:x?.decreaseButton,style:S?.decreaseButton,label:P.decrease,icon:ne,disabled:!J,direction:-1,...Y})]}):null,Se=G?{role:`spinbutton`,"aria-valuenow":Number.isFinite(H)?H:void 0,"aria-valuemin":D,"aria-valuemax":O,"aria-valuetext":z||void 0}:{},Z=m?!m.touched||!m.hasError():!v,Q=G&&K,$=d(o,{label:_,className:l(s.numberInput,{[s.numberInputSplit]:Q},Q?void 0:y,Q?void 0:x?.root,x?.input),style:{...Q?void 0:b,...Q?void 0:S?.root,...S?.input},value:z,onChange:()=>{},formValidator:null,isRequired:I,onBlur:()=>{U(),r.current&&(r.current.touched=!0)},isValid:Z,errorMessage:m?m.touched?m.getCurrentErrorMessage()??``:``:v??``,placeholder:fe,readOnly:A,disabled:j,suffix:X,classNames:X?{suffix:s.arrowSuffix}:void 0,inputMode:w===0?`numeric`:`decimal`,customInput:d(p,{onValueChange:e=>B(e.floatValue),allowNegative:T==null&&C,decimalSeparator:se,thousandSeparator:ce,decimalScale:w,fixedDecimalScale:de,prefix:be,suffix:ue,onKeyDown:ye,getInputRef:ge,...Se,...N})});return Q?f(ee,{className:l(s.split,{[s.splitInvalid]:!Z},y,x?.root),style:{...b,...S?.root},children:[d(g,{className:x?.decreaseButton,style:S?.decreaseButton,label:P.decrease,icon:ie,disabled:!J,direction:-1,...Y}),$,d(g,{className:x?.increaseButton,style:S?.increaseButton,label:P.increase,icon:ae,disabled:!q,direction:1,...Y})]}):$}export{_ as default};
|
|
2
2
|
//# sourceMappingURL=numberInput.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"numberInput.mjs","names":[],"sources":["../../../../package/common/numberInput/numberInput.tsx"],"sourcesContent":["import type { CSSProperties, ReactElement } from 'react';\nimport React from 'react';\nimport cx from 'classnames';\nimport { NumericFormat } from 'react-number-format';\nimport type { FormValidator } from 'services/formValidation';\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\nimport { faChevronUp, faChevronDown, faMinus, faPlus } from '@fortawesome/free-solid-svg-icons';\n\nimport styles from './numberInput.module.pcss';\nimport Input from '../input';\nimport Button from '../button';\nimport ButtonGroup from '../buttonGroup';\nimport { ButtonSize } from '../button/button.types';\nimport { useComponentDefaults, useLabels } from '../configProvider';\nimport { useCoarsePointer } from '../hooks/useCoarsePointer';\nimport { useStepRepeat } from './useStepRepeat';\nimport type { NumberInputLabels, NumberInputProps } from './numberInput.types';\n\nexport type { NumberInputProps, NumberInputArrowsLayout } from './numberInput.types';\n\ninterface StepButtonProps {\n label: string;\n className?: string;\n style?: CSSProperties;\n icon: typeof faPlus;\n disabled: boolean;\n direction: 1 | -1;\n onStart: (direction: 1 | -1, multiplier: number) => void;\n onStop: () => void;\n}\n\n/** Press-and-hold behaviour shared by both stepper layouts. */\nconst DEFAULT_LABELS: Required<NumberInputLabels> = {\n increase: 'Increase',\n decrease: 'Decrease',\n};\n\nfunction stepButtonProps({ label, disabled, direction, onStart, onStop }: StepButtonProps) {\n return {\n // The input keeps the tab stop — it carries role=\"spinbutton\", which announces the value\n // and the arrow-key affordance, so two more tab stops per field would be noise.\n tabIndex: -1,\n disabled,\n 'aria-label': label,\n // pointerdown (not click) keeps focus in the field and responds immediately on touch.\n // Deliberately no setPointerCapture: capturing retargets the following click to the captured\n // element, past the node Button's ripple listens on. useStepRepeat watches the window for\n // the release instead.\n onPointerDown: (e: React.PointerEvent<HTMLElement>) => {\n if (e.button !== 0 && e.pointerType === 'mouse') return;\n e.preventDefault();\n onStart(direction, e.shiftKey ? 10 : 1);\n },\n onPointerUp: onStop,\n onPointerCancel: onStop,\n onContextMenu: (e: React.SyntheticEvent) => e.preventDefault(),\n };\n}\n\n/** Stacked-layout chevron: borderless, sits inside the field's border. */\nfunction ChevronStepButton(props: StepButtonProps): ReactElement {\n return (\n <button\n type='button'\n {...stepButtonProps(props)}\n className={cx(styles.arrowBtn, props.className)}\n style={props.style}\n >\n <FontAwesomeIcon icon={props.icon} aria-hidden='true' />\n </button>\n );\n}\n\n/** Split-layout stepper: a standalone control, so a real Button. */\nfunction SplitStepButton(props: StepButtonProps): ReactElement {\n const { disabled, ...handlers } = stepButtonProps(props);\n return (\n <Button\n {...handlers}\n className={cx(styles.splitBtn, props.className)}\n style={props.style}\n size={ButtonSize.Icon}\n disabled={disabled}\n icon={props.icon}\n />\n );\n}\n\nfunction NumberInput(props: NumberInputProps): ReactElement {\n const fvRef = React.useRef<FormValidator | null | undefined>(undefined);\n const {\n value,\n onChange,\n formValidator,\n label,\n error,\n className,\n style,\n classNames,\n styles: slotStyles,\n allowNegative = false,\n decimalSeparator,\n thousandSeparator,\n prefix,\n suffix,\n decimalScale,\n fixedDecimalScale = true,\n placeholder,\n sign,\n showArrows = false,\n step = 1,\n min,\n max,\n arrowsLayout = 'auto',\n labels,\n readOnly = false,\n disabled = false,\n isRequired = false,\n onKeyDown: onKeyDownProp,\n ref,\n ...rest\n } = useComponentDefaults('NumberInput', props);\n const text = useLabels('NumberInput', labels, DEFAULT_LABELS);\n const [, forceUpdate] = React.useState(0);\n React.useEffect(() => {\n fvRef.current = formValidator;\n if (!formValidator) return;\n const listener = () => forceUpdate((n) => n + 1);\n formValidator.registerOnUpdateListener(listener);\n return () => {\n formValidator.removeOnUpdateListener(listener);\n };\n }, [formValidator]);\n const computedIsRequired =\n isRequired || !!formValidator?.validators.find((v) => (v as { validatorId?: string }).validatorId === 'required');\n const rawValue = formValidator != null ? (formValidator.value as number | string) : value;\n // When a sign is forced, display the absolute value — the prefix character carries the sign visually.\n const displayValue = sign != null && rawValue != null ? Math.abs(Number(rawValue)) : rawValue;\n const controlledValue = displayValue != null ? String(displayValue) : '';\n\n function handleValueChange(floatValue: number | undefined) {\n let out = floatValue;\n if (out !== undefined) {\n if (sign === '-') out = -Math.abs(out);\n if (sign === '+') out = Math.abs(out);\n }\n if (formValidator != null) formValidator.set(out ?? null);\n onChange?.(out);\n }\n\n function clamp(next: number): number {\n let out = next;\n if (!allowNegative && sign !== '-') out = Math.max(0, out);\n if (sign === '-') out = Math.min(0, out);\n if (min !== undefined) out = Math.max(min, out);\n if (max !== undefined) out = Math.min(max, out);\n return out;\n }\n\n const currentNumber = rawValue != null && rawValue !== '' ? Number(rawValue) : 0;\n\n /**\n * Called on blur and Enter, never per keystroke: rejecting an out-of-bounds edit as it is\n * typed swallows keystrokes on their way somewhere valid (with `max: 10`, typing `1` in front\n * of `8` to reach `18`). An empty field is skipped so a `min` is never typed in for the user.\n */\n function clampToBounds() {\n if (readOnly || disabled) return;\n if (rawValue == null || rawValue === '') return;\n const n = Number(rawValue);\n if (!Number.isFinite(n)) return;\n const next = clamp(n);\n if (next !== n) handleValueChange(next);\n }\n\n /** Returns whether the value moved, which is how useStepRepeat knows to end a hold at a bound. */\n function handleStep(delta: number): boolean {\n if (readOnly || disabled) return false;\n const next = clamp(currentNumber + delta);\n if (next === currentNumber) return false;\n handleValueChange(next);\n return true;\n }\n\n const { start: startRepeat, stop: stopRepeat } = useStepRepeat((delta) => handleStep(delta * step));\n\n function handleKeyDown(e: React.KeyboardEvent<HTMLInputElement>) {\n // Enter submits the surrounding form without ever blurring, so the blur clamp would not run.\n // Before the stepper guard, since the bounds apply with or without steppers.\n if (e.key === 'Enter') {\n clampToBounds();\n onKeyDownProp?.(e);\n return;\n }\n if (!showStepper) {\n onKeyDownProp?.(e);\n return;\n }\n if (e.key === 'ArrowUp') {\n e.preventDefault();\n handleStep(e.shiftKey ? step * 10 : step);\n return;\n }\n if (e.key === 'ArrowDown') {\n e.preventDefault();\n handleStep(e.shiftKey ? -step * 10 : -step);\n return;\n }\n onKeyDownProp?.(e);\n }\n\n const resolvedPrefix = sign === '-' ? '-' : sign === '+' ? '+' : prefix;\n\n const isCoarsePointer = useCoarsePointer();\n const showStepper = showArrows && !readOnly && !disabled;\n const isSplit = arrowsLayout === 'split' || (arrowsLayout === 'auto' && isCoarsePointer);\n\n const canIncrease = clamp(currentNumber + step) !== currentNumber;\n const canDecrease = clamp(currentNumber - step) !== currentNumber;\n\n const stepperProps = { onStart: startRepeat, onStop: stopRepeat };\n\n const stackedArrows =\n showStepper && !isSplit ? (\n <div className={cx(styles.arrows, classNames?.arrows)} style={slotStyles?.arrows}>\n <ChevronStepButton\n className={classNames?.increaseButton}\n style={slotStyles?.increaseButton}\n label={text.increase}\n icon={faChevronUp}\n disabled={!canIncrease}\n direction={1}\n {...stepperProps}\n />\n <ChevronStepButton\n className={classNames?.decreaseButton}\n style={slotStyles?.decreaseButton}\n label={text.decrease}\n icon={faChevronDown}\n disabled={!canDecrease}\n direction={-1}\n {...stepperProps}\n />\n </div>\n ) : null;\n\n // aria-* is spread onto NumericFormat, which forwards unknown props to the DOM input.\n // Input's own cloneElement doesn't set these keys, so they survive the clone.\n const spinButtonProps = showStepper\n ? {\n role: 'spinbutton',\n 'aria-valuenow': Number.isFinite(currentNumber) ? currentNumber : undefined,\n 'aria-valuemin': min,\n 'aria-valuemax': max,\n 'aria-valuetext': controlledValue || undefined,\n }\n : {};\n\n // Shared with the split group, whose buttons have to mirror the field's invalid state — they\n // form one continuous border.\n const isValid = formValidator ? (formValidator.touched ? !formValidator.hasError() : true) : !error;\n\n // In the split layout the ButtonGroup is the root, so the consumer's className and style\n // belong there rather than on the Input.\n const isSplitGroup = showStepper && isSplit;\n\n const input = (\n <Input\n label={label}\n className={cx(\n styles.numberInput,\n { [styles.numberInputSplit]: isSplitGroup },\n // In split mode the ButtonGroup around all three is the root, so the\n // consumer's root class belongs there rather than on the field.\n isSplitGroup ? undefined : className,\n isSplitGroup ? undefined : classNames?.root,\n classNames?.input,\n )}\n style={{\n ...(isSplitGroup ? undefined : style),\n ...(isSplitGroup ? undefined : slotStyles?.root),\n ...slotStyles?.input,\n }}\n value={controlledValue}\n onChange={() => {}}\n formValidator={null}\n isRequired={computedIsRequired}\n onBlur={() => {\n clampToBounds();\n if (fvRef.current) fvRef.current.touched = true;\n }}\n isValid={isValid}\n errorMessage={\n formValidator ? (formValidator.touched ? (formValidator.getCurrentErrorMessage() ?? '') : '') : (error ?? '')\n }\n placeholder={placeholder}\n readOnly={readOnly}\n disabled={disabled}\n suffix={stackedArrows}\n // Input centres its suffix wrapper; this lets the chevrons claim the field's full height.\n classNames={stackedArrows ? { suffix: styles.arrowSuffix } : undefined}\n inputMode={decimalScale === 0 ? 'numeric' : 'decimal'}\n customInput={\n <NumericFormat\n onValueChange={(vals) => handleValueChange(vals.floatValue)}\n allowNegative={sign != null ? false : allowNegative}\n decimalSeparator={decimalSeparator}\n thousandSeparator={thousandSeparator}\n decimalScale={decimalScale}\n fixedDecimalScale={fixedDecimalScale}\n prefix={resolvedPrefix}\n suffix={suffix}\n onKeyDown={handleKeyDown}\n // react-number-format owns the <input>, so its ref is reachable only through this prop.\n getInputRef={ref}\n {...spinButtonProps}\n {...rest}\n />\n }\n />\n );\n\n if (!isSplitGroup) return input;\n\n return (\n // ButtonGroup collapses the doubled borders and flattens the inner corners, so the three\n // read as one control.\n <ButtonGroup\n className={cx(styles.split, { [styles.splitInvalid]: !isValid }, className, classNames?.root)}\n style={{ ...style, ...slotStyles?.root }}\n >\n <SplitStepButton\n className={classNames?.decreaseButton}\n style={slotStyles?.decreaseButton}\n label={text.decrease}\n icon={faMinus}\n disabled={!canDecrease}\n direction={-1}\n {...stepperProps}\n />\n {input}\n <SplitStepButton\n className={classNames?.increaseButton}\n style={slotStyles?.increaseButton}\n label={text.increase}\n icon={faPlus}\n disabled={!canIncrease}\n direction={1}\n {...stepperProps}\n />\n </Button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AC,EAAD,CACE,UAAW,GAAY,eACvB,MAAO,GAAY,eACnB,MAAO,EAAK,SACZ,KAAM,GACN,SAAU,CAAC,EACX,UAAW,GACX,GAAI,CACL,CAAA,EACA,EACD,EAAC,EAAD,CACE,UAAW,GAAY,eACvB,MAAO,GAAY,eACnB,MAAO,EAAK,SACZ,KAAM,GACN,SAAU,CAAC,EACX,UAAW,EACX,GAAI,CACL,CAAA,CACU,IA5BW,CA8B5B"}
|
|
1
|
+
{"version":3,"file":"numberInput.mjs","names":[],"sources":["../../../../package/common/numberInput/numberInput.tsx"],"sourcesContent":["import type { CSSProperties, ReactElement } from 'react';\nimport React from 'react';\nimport cx from 'classnames';\nimport { NumericFormat } from 'react-number-format';\nimport type { FormValidator } from 'services/formValidation';\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome';\nimport { faChevronUp, faChevronDown, faMinus, faPlus } from '@fortawesome/free-solid-svg-icons';\n\nimport styles from './numberInput.module.pcss';\nimport Input from '../input';\nimport Button from '../button';\nimport ButtonGroup from '../buttonGroup';\nimport { ButtonSize } from '../button/button.types';\nimport { useComponentDefaults, useLabels } from '../configProvider';\nimport { useCoarsePointer } from '../hooks/useCoarsePointer';\nimport { useStepRepeat } from './useStepRepeat';\nimport type { NumberInputLabels, NumberInputProps } from './numberInput.types';\nimport { ThemeColor } from '../themeProvider/color.types';\n\nexport type { NumberInputProps, NumberInputArrowsLayout } from './numberInput.types';\n\ninterface StepButtonProps {\n label: string;\n className?: string;\n style?: CSSProperties;\n icon: typeof faPlus;\n disabled: boolean;\n direction: 1 | -1;\n onStart: (direction: 1 | -1, multiplier: number) => void;\n onStop: () => void;\n}\n\n/** Press-and-hold behaviour shared by both stepper layouts. */\nconst DEFAULT_LABELS: Required<NumberInputLabels> = {\n increase: 'Increase',\n decrease: 'Decrease',\n};\n\nfunction stepButtonProps({ label, disabled, direction, onStart, onStop }: StepButtonProps) {\n return {\n // The input keeps the tab stop — it carries role=\"spinbutton\", which announces the value\n // and the arrow-key affordance, so two more tab stops per field would be noise.\n tabIndex: -1,\n disabled,\n 'aria-label': label,\n // pointerdown (not click) keeps focus in the field and responds immediately on touch.\n // Deliberately no setPointerCapture: capturing retargets the following click to the captured\n // element, past the node Button's ripple listens on. useStepRepeat watches the window for\n // the release instead.\n onPointerDown: (e: React.PointerEvent<HTMLElement>) => {\n if (e.button !== 0 && e.pointerType === 'mouse') return;\n e.preventDefault();\n onStart(direction, e.shiftKey ? 10 : 1);\n },\n onPointerUp: onStop,\n onPointerCancel: onStop,\n onContextMenu: (e: React.SyntheticEvent) => e.preventDefault(),\n };\n}\n\n/** Stacked-layout chevron: borderless, sits inside the field's border. */\nfunction ChevronStepButton(props: StepButtonProps): ReactElement {\n return (\n <button\n type='button'\n {...stepButtonProps(props)}\n className={cx(styles.arrowBtn, props.className)}\n style={props.style}\n >\n <FontAwesomeIcon icon={props.icon} aria-hidden='true' />\n </button>\n );\n}\n\n/** Split-layout stepper: a standalone control, so a real Button. */\nfunction SplitStepButton(props: StepButtonProps): ReactElement {\n const { disabled, ...handlers } = stepButtonProps(props);\n return (\n <Button\n {...handlers}\n className={cx(styles.splitBtn, props.className)}\n style={props.style}\n color={ThemeColor.Neutral}\n size={ButtonSize.Icon}\n disabled={disabled}\n icon={props.icon}\n />\n );\n}\n\nfunction NumberInput(props: NumberInputProps): ReactElement {\n const fvRef = React.useRef<FormValidator | null | undefined>(undefined);\n const {\n value,\n onChange,\n formValidator,\n label,\n error,\n className,\n style,\n classNames,\n styles: slotStyles,\n allowNegative = false,\n decimalSeparator,\n thousandSeparator,\n prefix,\n suffix,\n decimalScale,\n fixedDecimalScale = true,\n placeholder,\n sign,\n showArrows = false,\n step = 1,\n min,\n max,\n arrowsLayout = 'auto',\n labels,\n readOnly = false,\n disabled = false,\n isRequired = false,\n onKeyDown: onKeyDownProp,\n ref,\n ...rest\n } = useComponentDefaults('NumberInput', props);\n const text = useLabels('NumberInput', labels, DEFAULT_LABELS);\n const [, forceUpdate] = React.useState(0);\n React.useEffect(() => {\n fvRef.current = formValidator;\n if (!formValidator) return;\n const listener = () => forceUpdate((n) => n + 1);\n formValidator.registerOnUpdateListener(listener);\n return () => {\n formValidator.removeOnUpdateListener(listener);\n };\n }, [formValidator]);\n const computedIsRequired =\n isRequired || !!formValidator?.validators.find((v) => (v as { validatorId?: string }).validatorId === 'required');\n const rawValue = formValidator != null ? (formValidator.value as number | string) : value;\n // When a sign is forced, display the absolute value — the prefix character carries the sign visually.\n const displayValue = sign != null && rawValue != null ? Math.abs(Number(rawValue)) : rawValue;\n const controlledValue = displayValue != null ? String(displayValue) : '';\n\n function handleValueChange(floatValue: number | undefined) {\n let out = floatValue;\n if (out !== undefined) {\n if (sign === '-') out = -Math.abs(out);\n if (sign === '+') out = Math.abs(out);\n }\n if (formValidator != null) formValidator.set(out ?? null);\n onChange?.(out);\n }\n\n function clamp(next: number): number {\n let out = next;\n if (!allowNegative && sign !== '-') out = Math.max(0, out);\n if (sign === '-') out = Math.min(0, out);\n if (min !== undefined) out = Math.max(min, out);\n if (max !== undefined) out = Math.min(max, out);\n return out;\n }\n\n const currentNumber = rawValue != null && rawValue !== '' ? Number(rawValue) : 0;\n\n /**\n * Called on blur and Enter, never per keystroke: rejecting an out-of-bounds edit as it is\n * typed swallows keystrokes on their way somewhere valid (with `max: 10`, typing `1` in front\n * of `8` to reach `18`). An empty field is skipped so a `min` is never typed in for the user.\n */\n function clampToBounds() {\n if (readOnly || disabled) return;\n if (rawValue == null || rawValue === '') return;\n const n = Number(rawValue);\n if (!Number.isFinite(n)) return;\n const next = clamp(n);\n if (next !== n) handleValueChange(next);\n }\n\n /** Returns whether the value moved, which is how useStepRepeat knows to end a hold at a bound. */\n function handleStep(delta: number): boolean {\n if (readOnly || disabled) return false;\n const next = clamp(currentNumber + delta);\n if (next === currentNumber) return false;\n handleValueChange(next);\n return true;\n }\n\n const { start: startRepeat, stop: stopRepeat } = useStepRepeat((delta) => handleStep(delta * step));\n\n function handleKeyDown(e: React.KeyboardEvent<HTMLInputElement>) {\n // Enter submits the surrounding form without ever blurring, so the blur clamp would not run.\n // Before the stepper guard, since the bounds apply with or without steppers.\n if (e.key === 'Enter') {\n clampToBounds();\n onKeyDownProp?.(e);\n return;\n }\n if (!showStepper) {\n onKeyDownProp?.(e);\n return;\n }\n if (e.key === 'ArrowUp') {\n e.preventDefault();\n handleStep(e.shiftKey ? step * 10 : step);\n return;\n }\n if (e.key === 'ArrowDown') {\n e.preventDefault();\n handleStep(e.shiftKey ? -step * 10 : -step);\n return;\n }\n onKeyDownProp?.(e);\n }\n\n const resolvedPrefix = sign === '-' ? '-' : sign === '+' ? '+' : prefix;\n\n const isCoarsePointer = useCoarsePointer();\n const showStepper = showArrows && !readOnly && !disabled;\n const isSplit = arrowsLayout === 'split' || (arrowsLayout === 'auto' && isCoarsePointer);\n\n const canIncrease = clamp(currentNumber + step) !== currentNumber;\n const canDecrease = clamp(currentNumber - step) !== currentNumber;\n\n const stepperProps = { onStart: startRepeat, onStop: stopRepeat };\n\n const stackedArrows =\n showStepper && !isSplit ? (\n <div className={cx(styles.arrows, classNames?.arrows)} style={slotStyles?.arrows}>\n <ChevronStepButton\n className={classNames?.increaseButton}\n style={slotStyles?.increaseButton}\n label={text.increase}\n icon={faChevronUp}\n disabled={!canIncrease}\n direction={1}\n {...stepperProps}\n />\n <ChevronStepButton\n className={classNames?.decreaseButton}\n style={slotStyles?.decreaseButton}\n label={text.decrease}\n icon={faChevronDown}\n disabled={!canDecrease}\n direction={-1}\n {...stepperProps}\n />\n </div>\n ) : null;\n\n // aria-* is spread onto NumericFormat, which forwards unknown props to the DOM input.\n // Input's own cloneElement doesn't set these keys, so they survive the clone.\n const spinButtonProps = showStepper\n ? {\n role: 'spinbutton',\n 'aria-valuenow': Number.isFinite(currentNumber) ? currentNumber : undefined,\n 'aria-valuemin': min,\n 'aria-valuemax': max,\n 'aria-valuetext': controlledValue || undefined,\n }\n : {};\n\n // Shared with the split group, whose buttons have to mirror the field's invalid state — they\n // form one continuous border.\n const isValid = formValidator ? (formValidator.touched ? !formValidator.hasError() : true) : !error;\n\n // In the split layout the ButtonGroup is the root, so the consumer's className and style\n // belong there rather than on the Input.\n const isSplitGroup = showStepper && isSplit;\n\n const input = (\n <Input\n label={label}\n className={cx(\n styles.numberInput,\n { [styles.numberInputSplit]: isSplitGroup },\n // In split mode the ButtonGroup around all three is the root, so the\n // consumer's root class belongs there rather than on the field.\n isSplitGroup ? undefined : className,\n isSplitGroup ? undefined : classNames?.root,\n classNames?.input,\n )}\n style={{\n ...(isSplitGroup ? undefined : style),\n ...(isSplitGroup ? undefined : slotStyles?.root),\n ...slotStyles?.input,\n }}\n value={controlledValue}\n onChange={() => {}}\n formValidator={null}\n isRequired={computedIsRequired}\n onBlur={() => {\n clampToBounds();\n if (fvRef.current) fvRef.current.touched = true;\n }}\n isValid={isValid}\n errorMessage={\n formValidator ? (formValidator.touched ? (formValidator.getCurrentErrorMessage() ?? '') : '') : (error ?? '')\n }\n placeholder={placeholder}\n readOnly={readOnly}\n disabled={disabled}\n suffix={stackedArrows}\n // Input centres its suffix wrapper; this lets the chevrons claim the field's full height.\n classNames={stackedArrows ? { suffix: styles.arrowSuffix } : undefined}\n inputMode={decimalScale === 0 ? 'numeric' : 'decimal'}\n customInput={\n <NumericFormat\n onValueChange={(vals) => handleValueChange(vals.floatValue)}\n allowNegative={sign != null ? false : allowNegative}\n decimalSeparator={decimalSeparator}\n thousandSeparator={thousandSeparator}\n decimalScale={decimalScale}\n fixedDecimalScale={fixedDecimalScale}\n prefix={resolvedPrefix}\n suffix={suffix}\n onKeyDown={handleKeyDown}\n // react-number-format owns the <input>, so its ref is reachable only through this prop.\n getInputRef={ref}\n {...spinButtonProps}\n {...rest}\n />\n }\n />\n );\n\n if (!isSplitGroup) return input;\n\n return (\n // ButtonGroup collapses the doubled borders and flattens the inner corners, so the three\n // read as one control.\n <ButtonGroup\n className={cx(styles.split, { [styles.splitInvalid]: !isValid }, className, classNames?.root)}\n style={{ ...style, ...slotStyles?.root }}\n >\n <SplitStepButton\n className={classNames?.decreaseButton}\n style={slotStyles?.decreaseButton}\n label={text.decrease}\n icon={faMinus}\n disabled={!canDecrease}\n direction={-1}\n {...stepperProps}\n />\n {input}\n <SplitStepButton\n className={classNames?.increaseButton}\n style={slotStyles?.increaseButton}\n label={text.increase}\n icon={faPlus}\n disabled={!canIncrease}\n direction={1}\n {...stepperProps}\n />\n </ButtonGroup>\n );\n}\n\nexport default NumberInput;\n"],"mappings":"q0BAiCA,IAAM,GAA8C,CAClD,SAAU,WACV,SAAU,UACZ,EAEA,SAAS,EAAgB,CAAE,QAAO,WAAU,YAAW,UAAS,UAA2B,CACzF,MAAO,CAGL,SAAU,GACV,WACA,aAAc,EAKd,cAAgB,GAAuC,EACjD,EAAE,SAAW,GAAK,EAAE,cAAgB,WACxC,EAAE,eAAe,EACjB,EAAQ,EAAW,EAAE,SAAW,GAAK,CAAC,EACxC,EACA,YAAa,EACb,gBAAiB,EACjB,cAAgB,GAA4B,EAAE,eAAe,CAC/D,CACF,CAGA,SAAS,EAAkB,EAAsC,CAC/D,OACE,EAAC,SAAD,CACE,KAAK,SACL,GAAI,EAAgB,CAAK,EACzB,UAAW,EAAG,EAAO,SAAU,EAAM,SAAS,EAC9C,MAAO,EAAM,MAEb,SAAA,EAAC,EAAD,CAAiB,KAAM,EAAM,KAAM,cAAY,MAAQ,CAAA,CACjD,CAAA,CAEZ,CAGA,SAAS,EAAgB,EAAsC,CAC7D,GAAM,CAAE,WAAU,GAAG,GAAa,EAAgB,CAAK,EACvD,OACE,EAAC,EAAD,CACE,GAAI,EACJ,UAAW,EAAG,EAAO,SAAU,EAAM,SAAS,EAC9C,MAAO,EAAM,MACb,MAAO,EAAW,QAClB,KAAM,EAAW,KACP,WACV,KAAM,EAAM,IACb,CAAA,CAEL,CAEA,SAAS,EAAY,EAAuC,CAC1D,IAAM,EAAQ,EAAM,OAAyC,IAAA,EAAS,EAChE,CACJ,QACA,WACA,gBACA,QACA,QACA,YACA,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,qBACnB,OAAQ,GACA,UACR,UAAW,GAEX,YAAa,GACb,GAAI,GACJ,GAAI,CACL,CAAA,CAEJ,CAAA,EAKH,OAFK,EAKH,EAAC,GAAD,CACE,UAAW,EAAG,EAAO,MAAO,EAAG,EAAO,cAAe,CAAC,CAAQ,EAAG,EAAW,GAAY,IAAI,EAC5F,MAAO,CAAE,GAAG,EAAO,GAAG,GAAY,IAAK,EAFzC,SAAA,CAIE,EAAC,EAAD,CACE,UAAW,GAAY,eACvB,MAAO,GAAY,eACnB,MAAO,EAAK,SACZ,KAAM,GACN,SAAU,CAAC,EACX,UAAW,GACX,GAAI,CACL,CAAA,EACA,EACD,EAAC,EAAD,CACE,UAAW,GAAY,eACvB,MAAO,GAAY,eACnB,MAAO,EAAK,SACZ,KAAM,GACN,SAAU,CAAC,EACX,UAAW,EACX,GAAI,CACL,CAAA,CACU,IA5BW,CA8B5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"numberInput.module.mjs","names":[],"sources":["../../../../package/common/numberInput/numberInput.module.pcss"],"sourcesContent":[".numberInput {\n /* Only set when the split layout wraps this input in a flex row. */\n &-split {\n flex: 1;\n min-width: 0;\n }\n}\n\n/* ── Stacked layout: chevrons inside the field's right edge (mouse-oriented) ───────── */\n\n/* Input's `suffix` slot: stretch to the field so the chevrons get its full height. */\n.arrowSuffix {\n align-self: stretch;\n display: flex;\n padding-right: 0;\n}\n\n.arrows {\n display: flex;\n flex-direction: column;\n align-self: stretch;\n border-left: 1px solid var(--border-color);\n\n /* Sitting flush against the field's edge, the chevrons' background would square off its\n rounded corner, so it is clipped. Read from --group-radius-* like Input's own border, so it\n still flattens inside a ButtonGroup. */\n overflow: hidden;\n border-top-right-radius: var(--group-radius-tr, var(--default-border-radius));\n border-bottom-right-radius: var(--group-radius-br, var(--default-border-radius));\n}\n\n.arrowBtn {\n flex: 1;\n display: flex;\n align-items: center;\n justify-content: center;\n background: none;\n border: none;\n padding: 0 0.5em;\n\n /* No min-height: the two halves divide the field's own height, so a stepper never makes a\n NumberInput taller than a plain Input. In em, so it tracks the field's text size. */\n min-width: 1.75em;\n font-size: 0.75em;\n line-height: 1;\n color: var(--text-dark);\n cursor: pointer;\n -webkit-tap-highlight-color: transparent;\n\n /* So a long press reads as a hold, not a text gesture. */\n touch-action: manipulation;\n user-select: none;\n -webkit-user-select: none;\n -webkit-touch-callout: none;\n transition:\n color 0.15s,\n opacity 0.15s;\n\n &:disabled {\n cursor: default;\n opacity: 0.35;\n }\n\n &:focus-visible {\n outline: 2px solid var(--focus-border-color, var(--primary-color));\n outline-offset: -2px;\n }\n\n /* (hover: hover) only — on touch a :hover state latches after a tap until you tap elsewhere.\n\n Colour-only, unlike the --background-accent-light hover surface used elsewhere in the\n library: this button sits flush against .arrows' 1px --border-color divider, and in dark\n palettes those two tokens are close enough in luminance that painting the surface right up\n to the line eats most of the divider's already-low contrast, under the pointer. Tuning the\n hover colour per theme would not hold — the collision is between three tokens (divider,\n hover surface, field background), so any new theme can reintroduce it. The chevron turning\n --primary-color is affordance enough on a target this small. */\n @media (hover: hover) {\n &:hover:not(:disabled) {\n color: var(--primary-color);\n }\n }\n\n &:active:not(:disabled) {\n color: var(--primary-color);\n }\n}\n\n/* ── Split layout: full-height − / + flanking the field (touch-oriented) ───────────── */\n\n/* ButtonGroup is inline-flex; a form field fills its row instead, with the Input taking the\n slack (see .numberInput-split). The class is repeated to beat `.buttonGroup`'s own `display`\n without depending on which CSS module the bundler emits first. */\n.split.split {\n display: flex;\n width: 100%;\n}\n\n
|
|
1
|
+
{"version":3,"file":"numberInput.module.mjs","names":[],"sources":["../../../../package/common/numberInput/numberInput.module.pcss"],"sourcesContent":[".numberInput {\n /* Only set when the split layout wraps this input in a flex row. */\n &-split {\n flex: 1;\n min-width: 0;\n }\n}\n\n/* ── Stacked layout: chevrons inside the field's right edge (mouse-oriented) ───────── */\n\n/* Input's `suffix` slot: stretch to the field so the chevrons get its full height. */\n.arrowSuffix {\n align-self: stretch;\n display: flex;\n padding-right: 0;\n}\n\n.arrows {\n display: flex;\n flex-direction: column;\n align-self: stretch;\n border-left: 1px solid var(--border-color);\n\n /* Sitting flush against the field's edge, the chevrons' background would square off its\n rounded corner, so it is clipped. Read from --group-radius-* like Input's own border, so it\n still flattens inside a ButtonGroup. */\n overflow: hidden;\n border-top-right-radius: var(--group-radius-tr, var(--default-border-radius));\n border-bottom-right-radius: var(--group-radius-br, var(--default-border-radius));\n}\n\n.arrowBtn {\n flex: 1;\n display: flex;\n align-items: center;\n justify-content: center;\n background: none;\n border: none;\n padding: 0 0.5em;\n\n /* No min-height: the two halves divide the field's own height, so a stepper never makes a\n NumberInput taller than a plain Input. In em, so it tracks the field's text size. */\n min-width: 1.75em;\n font-size: 0.75em;\n line-height: 1;\n color: var(--text-dark);\n cursor: pointer;\n -webkit-tap-highlight-color: transparent;\n\n /* So a long press reads as a hold, not a text gesture. */\n touch-action: manipulation;\n user-select: none;\n -webkit-user-select: none;\n -webkit-touch-callout: none;\n transition:\n color 0.15s,\n opacity 0.15s;\n\n &:disabled {\n cursor: default;\n opacity: 0.35;\n }\n\n &:focus-visible {\n outline: 2px solid var(--focus-border-color, var(--primary-color));\n outline-offset: -2px;\n }\n\n /* (hover: hover) only — on touch a :hover state latches after a tap until you tap elsewhere.\n\n Colour-only, unlike the --background-accent-light hover surface used elsewhere in the\n library: this button sits flush against .arrows' 1px --border-color divider, and in dark\n palettes those two tokens are close enough in luminance that painting the surface right up\n to the line eats most of the divider's already-low contrast, under the pointer. Tuning the\n hover colour per theme would not hold — the collision is between three tokens (divider,\n hover surface, field background), so any new theme can reintroduce it. The chevron turning\n --primary-color is affordance enough on a target this small. */\n @media (hover: hover) {\n &:hover:not(:disabled) {\n color: var(--primary-color);\n }\n }\n\n &:active:not(:disabled) {\n color: var(--primary-color);\n }\n}\n\n/* ── Split layout: full-height − / + flanking the field (touch-oriented) ───────────── */\n\n/* ButtonGroup is inline-flex; a form field fills its row instead, with the Input taking the\n slack (see .numberInput-split). The class is repeated to beat `.buttonGroup`'s own `display`\n without depending on which CSS module the bundler emits first. */\n.split.split {\n display: flex;\n width: 100%;\n}\n\n/* Two classes, to outrank Button's one-class rules whichever stylesheet loads first. Resting state\n only: Button's hover and press layer tints over it. */\n.split .splitBtn {\n background: var(--input-background);\n color: var(--text-dark);\n border-color: var(--border-color);\n}\n\n.splitBtn {\n flex: 0 0 auto;\n\n /* No fixed height — ButtonGroup stretches these to the field.\n\n The width repeats Input's own height formula (`line-height: 1.25` plus the 8px/6px padding\n of `.input-field-default`) to come out square at any text size, and must follow it if that\n padding changes. `aspect-ratio: 1` cannot do this: a flex item's main size is resolved from\n its content before the stretched cross size exists. */\n align-self: stretch;\n width: calc(1.25em + 14px);\n touch-action: manipulation;\n user-select: none;\n -webkit-user-select: none;\n -webkit-touch-callout: none;\n transition: opacity 0.15s;\n\n &:disabled {\n opacity: 0.35;\n }\n\n &:focus-visible {\n outline: 2px solid var(--focus-border-color, var(--primary-color));\n outline-offset: 2px;\n }\n}\n\n/* One continuous border, so the buttons follow the field's focus and error colours — left grey,\n the group reads as a box inside a box. */\n.split:focus-within .splitBtn {\n border-color: var(--focus-border-color, var(--primary-color));\n}\n\n.split-invalid .splitBtn {\n border-color: var(--error-border-color);\n}\n"],"mappings":""}
|