@nordhealth/components 4.26.2 → 5.0.0-alpha.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/custom-elements.json +53898 -21499
- package/lib/Accordion.js +2 -0
- package/lib/Accordion.js.map +1 -0
- package/lib/AccordionHeader.js +2 -0
- package/lib/AccordionHeader.js.map +1 -0
- package/lib/AccordionItem.js +2 -0
- package/lib/AccordionItem.js.map +1 -0
- package/lib/AccordionPanel.js +2 -0
- package/lib/AccordionPanel.js.map +1 -0
- package/lib/AccordionTrigger.js +2 -0
- package/lib/AccordionTrigger.js.map +1 -0
- package/lib/ActiveDescendantController-BnMqM79O.js +2 -0
- package/lib/ActiveDescendantController-BnMqM79O.js.map +1 -0
- package/lib/Aside.js +5 -7
- package/lib/Aside.js.map +1 -1
- package/lib/AsideDrawer.js +7 -11
- package/lib/AsideDrawer.js.map +1 -1
- package/lib/AsideTrigger.js +3 -4
- package/lib/AsideTrigger.js.map +1 -1
- package/lib/Autocomplete.js +2 -0
- package/lib/Autocomplete.js.map +1 -0
- package/lib/Avatar.js +1 -1
- package/lib/Avatar.js.map +1 -1
- package/lib/Badge.js +1 -1
- package/lib/Badge.js.map +1 -1
- package/lib/Banner.js +1 -1
- package/lib/Banner.js.map +1 -1
- package/lib/Button.js +7 -12
- package/lib/Button.js.map +1 -1
- package/lib/ButtonGroup.js +1 -1
- package/lib/ButtonGroup.js.map +1 -1
- package/lib/Calendar-C1SxrlzN.js +2 -0
- package/lib/Calendar-C1SxrlzN.js.map +1 -0
- package/lib/Calendar.js +1 -1
- package/lib/Card.js +1 -1
- package/lib/Card.js.map +1 -1
- package/lib/Checkbox.js +1 -1
- package/lib/Checkbox.js.map +1 -1
- package/lib/CollapseController-BtKNFNyJ.js +2 -0
- package/lib/CollapseController-BtKNFNyJ.js.map +1 -0
- package/lib/Collapsible.js +2 -0
- package/lib/Collapsible.js.map +1 -0
- package/lib/CollapsiblePanel.js +2 -0
- package/lib/CollapsiblePanel.js.map +1 -0
- package/lib/CollapsibleTrigger.js +2 -0
- package/lib/CollapsibleTrigger.js.map +1 -0
- package/lib/Combobox-By4h1Sp-.js +2 -0
- package/lib/Combobox-By4h1Sp-.js.map +1 -0
- package/lib/Combobox.js +2 -0
- package/lib/Combobox.js.map +1 -0
- package/lib/ComboboxBase.js +2 -0
- package/lib/ComboboxBase.js.map +1 -0
- package/lib/ComboboxEvents.js +2 -0
- package/lib/ComboboxEvents.js.map +1 -0
- package/lib/ComboboxGroup.js +2 -0
- package/lib/ComboboxGroup.js.map +1 -0
- package/lib/ComboboxOption.js +2 -0
- package/lib/ComboboxOption.js.map +1 -0
- package/lib/CommandMenu.js +1 -1
- package/lib/CommandMenu.js.map +1 -1
- package/lib/CommandMenuAction.js +1 -1
- package/lib/CommandMenuAction.js.map +1 -1
- package/lib/Component-BJ5O5n8k.js +2 -0
- package/lib/Component-BJ5O5n8k.js.map +1 -0
- package/lib/DatePicker.js +1 -1
- package/lib/DatePicker.js.map +1 -1
- package/lib/DateRangeChangeEvent.js +2 -0
- package/lib/DateRangeChangeEvent.js.map +1 -0
- package/lib/DateRangePicker.js +2 -0
- package/lib/DateRangePicker.js.map +1 -0
- package/lib/DateRangeSelectEvent.js +2 -0
- package/lib/DateRangeSelectEvent.js.map +1 -0
- package/lib/Divider.js +1 -1
- package/lib/Divider.js.map +1 -1
- package/lib/DraftComponentMixin-4qug5Rky.js +2 -0
- package/lib/DraftComponentMixin-4qug5Rky.js.map +1 -0
- package/lib/Drawer.js +1 -1
- package/lib/Drawer.js.map +1 -1
- package/lib/Dropdown.js +1 -1
- package/lib/Dropdown.js.map +1 -1
- package/lib/DropdownGroup.js +1 -1
- package/lib/DropdownGroup.js.map +1 -1
- package/lib/DropdownItem-BYbOLth6.js +2 -0
- package/lib/DropdownItem-BYbOLth6.js.map +1 -0
- package/lib/DropdownItem.js +1 -1
- package/lib/DropdownItem.js.map +1 -1
- package/lib/DropdownSubmenu.js +1 -1
- package/lib/DropdownSubmenu.js.map +1 -1
- package/lib/EmptyState.js +1 -1
- package/lib/EmptyState.js.map +1 -1
- package/lib/Field.js +2 -0
- package/lib/Field.js.map +1 -0
- package/lib/FieldContent.js +2 -0
- package/lib/FieldContent.js.map +1 -0
- package/lib/FieldControlMixin-BXNZJXu9.js +2 -0
- package/lib/FieldControlMixin-BXNZJXu9.js.map +1 -0
- package/lib/FieldDescription.js +2 -0
- package/lib/FieldDescription.js.map +1 -0
- package/lib/FieldError.js +2 -0
- package/lib/FieldError.js.map +1 -0
- package/lib/FieldGroup.js +2 -0
- package/lib/FieldGroup.js.map +1 -0
- package/lib/FieldLabel.js +2 -0
- package/lib/FieldLabel.js.map +1 -0
- package/lib/FieldLegend.js +2 -0
- package/lib/FieldLegend.js.map +1 -0
- package/lib/FieldSeparator.js +2 -0
- package/lib/FieldSeparator.js.map +1 -0
- package/lib/FieldSet.js +2 -0
- package/lib/FieldSet.js.map +1 -0
- package/lib/FieldTitle.js +2 -0
- package/lib/FieldTitle.js.map +1 -0
- package/lib/Fieldset2.js +2 -0
- package/lib/Fieldset2.js.map +1 -0
- package/lib/FilterAddButton.js +2 -0
- package/lib/FilterAddButton.js.map +1 -0
- package/lib/FilterAddButtonEvents.js +2 -0
- package/lib/FilterAddButtonEvents.js.map +1 -0
- package/lib/FilterBar.js +2 -0
- package/lib/FilterBar.js.map +1 -0
- package/lib/FilterDateRange.js +2 -0
- package/lib/FilterDateRange.js.map +1 -0
- package/lib/FilterDateRangeEvents.js +2 -0
- package/lib/FilterDateRangeEvents.js.map +1 -0
- package/lib/FilterDropdown.js +2 -0
- package/lib/FilterDropdown.js.map +1 -0
- package/lib/FilterDropdownEvents.js +2 -0
- package/lib/FilterDropdownEvents.js.map +1 -0
- package/lib/FilterField.js +2 -0
- package/lib/FilterField.js.map +1 -0
- package/lib/FilterFieldEvents.js +2 -0
- package/lib/FilterFieldEvents.js.map +1 -0
- package/lib/FilterInput.js +2 -0
- package/lib/FilterInput.js.map +1 -0
- package/lib/FilterResetButton.js +2 -0
- package/lib/FilterResetButton.js.map +1 -0
- package/lib/FocusableWhenDisabledController-C_Mn1mfN.js +2 -0
- package/lib/FocusableWhenDisabledController-C_Mn1mfN.js.map +1 -0
- package/lib/Footer.js +1 -1
- package/lib/Footer.js.map +1 -1
- package/lib/FormAssociatedMixin-D9aPREgv.js +2 -0
- package/lib/FormAssociatedMixin-D9aPREgv.js.map +1 -0
- package/lib/FormField-CMgEFZCK.js +2 -0
- package/lib/FormField-CMgEFZCK.js.map +1 -0
- package/lib/Header.js +1 -1
- package/lib/Header.js.map +1 -1
- package/lib/Icon.js +1 -1
- package/lib/Icon.js.map +1 -1
- package/lib/Input.js +1 -1
- package/lib/Input.js.map +1 -1
- package/lib/Item.js +2 -0
- package/lib/Item.js.map +1 -0
- package/lib/ItemActions.js +2 -0
- package/lib/ItemActions.js.map +1 -0
- package/lib/ItemContent.js +2 -0
- package/lib/ItemContent.js.map +1 -0
- package/lib/ItemDescription.js +2 -0
- package/lib/ItemDescription.js.map +1 -0
- package/lib/ItemFooter.js +2 -0
- package/lib/ItemFooter.js.map +1 -0
- package/lib/ItemGroup.js +2 -0
- package/lib/ItemGroup.js.map +1 -0
- package/lib/ItemHeader.js +2 -0
- package/lib/ItemHeader.js.map +1 -0
- package/lib/ItemMedia.js +2 -0
- package/lib/ItemMedia.js.map +1 -0
- package/lib/ItemSeparator.js +2 -0
- package/lib/ItemSeparator.js.map +1 -0
- package/lib/ItemTitle.js +2 -0
- package/lib/ItemTitle.js.map +1 -0
- package/lib/Kbd.js +2 -0
- package/lib/Kbd.js.map +1 -0
- package/lib/KbdGroup.js +2 -0
- package/lib/KbdGroup.js.map +1 -0
- package/lib/Layout.js +1 -3
- package/lib/Layout.js.map +1 -1
- package/lib/LocalizeController.js +1 -1
- package/lib/LocalizeController.js.map +1 -1
- package/lib/Message.js +1 -1
- package/lib/Message.js.map +1 -1
- package/lib/Meter.js +2 -0
- package/lib/Meter.js.map +1 -0
- package/lib/Modal.js +1 -1
- package/lib/Modal.js.map +1 -1
- package/lib/ModalController.js +1 -1
- package/lib/ModalController.js.map +1 -1
- package/lib/NavGroup.js +1 -1
- package/lib/NavGroup.js.map +1 -1
- package/lib/NavItem.js +1 -1
- package/lib/NavItem.js.map +1 -1
- package/lib/NavToggle-BY83xpx0.js +2 -0
- package/lib/NavToggle-BY83xpx0.js.map +1 -0
- package/lib/NavToggle.js +1 -1
- package/lib/Navigation.js +1 -1
- package/lib/Navigation.js.map +1 -1
- package/lib/Notification.js +1 -1
- package/lib/Notification.js.map +1 -1
- package/lib/NotificationGroup.js +1 -1
- package/lib/NotificationGroup.js.map +1 -1
- package/lib/NumberField.js +2 -0
- package/lib/NumberField.js.map +1 -0
- package/lib/NumberFieldEvents.js +2 -0
- package/lib/NumberFieldEvents.js.map +1 -0
- package/lib/OpenStateController-CCnZ7up6.js +2 -0
- package/lib/OpenStateController-CCnZ7up6.js.map +1 -0
- package/lib/OtpField.js +2 -0
- package/lib/OtpField.js.map +1 -0
- package/lib/OtpFieldEvents.js +2 -0
- package/lib/OtpFieldEvents.js.map +1 -0
- package/lib/Pagination.js +2 -0
- package/lib/Pagination.js.map +1 -0
- package/lib/PaginationContent.js +2 -0
- package/lib/PaginationContent.js.map +1 -0
- package/lib/PaginationEllipsis.js +2 -0
- package/lib/PaginationEllipsis.js.map +1 -0
- package/lib/PaginationItem.js +2 -0
- package/lib/PaginationItem.js.map +1 -0
- package/lib/PaginationLink.js +2 -0
- package/lib/PaginationLink.js.map +1 -0
- package/lib/PaginationNext.js +2 -0
- package/lib/PaginationNext.js.map +1 -0
- package/lib/PaginationPrevious.js +2 -0
- package/lib/PaginationPrevious.js.map +1 -0
- package/lib/Popout-DpN7PP9h.js +2 -0
- package/lib/Popout-DpN7PP9h.js.map +1 -0
- package/lib/Popout.js +1 -1
- package/lib/Progress.js +1 -1
- package/lib/Progress.js.map +1 -1
- package/lib/ProgressBar.js +1 -1
- package/lib/ProgressBar.js.map +1 -1
- package/lib/Qrcode.js +2 -2
- package/lib/Radio.js +1 -1
- package/lib/Radio.js.map +1 -1
- package/lib/Range.js +1 -1
- package/lib/Range.js.map +1 -1
- package/lib/ReadonlyMixin-BdJPGtQ3.js +2 -0
- package/lib/ReadonlyMixin-BdJPGtQ3.js.map +1 -0
- package/lib/ResizeController-14PUwRQy.js +2 -0
- package/lib/ResizeController-14PUwRQy.js.map +1 -0
- package/lib/ScrollArea.js +2 -0
- package/lib/ScrollArea.js.map +1 -0
- package/lib/SegmentedControl.js +1 -1
- package/lib/SegmentedControl.js.map +1 -1
- package/lib/SegmentedControlItem.js +23 -40
- package/lib/SegmentedControlItem.js.map +1 -1
- package/lib/Select.js +1 -1
- package/lib/Select.js.map +1 -1
- package/lib/Skeleton.js +1 -1
- package/lib/Skeleton.js.map +1 -1
- package/lib/Spinner.js +1 -1
- package/lib/Spinner.js.map +1 -1
- package/lib/Stack.js +1 -1
- package/lib/Stack.js.map +1 -1
- package/lib/StateAttributesController-BIh96sXZ.js +2 -0
- package/lib/StateAttributesController-BIh96sXZ.js.map +1 -0
- package/lib/Sticky-CZImMrGj.js +2 -0
- package/lib/Sticky-CZImMrGj.js.map +1 -0
- package/lib/Tab.js +1 -1
- package/lib/Tab.js.map +1 -1
- package/lib/TabGroup.js +1 -1
- package/lib/TabGroup.js.map +1 -1
- package/lib/TabPanel.js +1 -1
- package/lib/TabPanel.js.map +1 -1
- package/lib/Table.js +1 -1
- package/lib/Table.js.map +1 -1
- package/lib/Tag.js +1 -1
- package/lib/Tag.js.map +1 -1
- package/lib/TagGroup.js +1 -1
- package/lib/TagGroup.js.map +1 -1
- package/lib/TextField-CSKvieoG.js +2 -0
- package/lib/TextField-CSKvieoG.js.map +1 -0
- package/lib/TextSelectableMixin-Cfv__lHS.js.map +1 -1
- package/lib/Textarea.js +1 -1
- package/lib/Textarea.js.map +1 -1
- package/lib/TimePicker.js +2 -0
- package/lib/TimePicker.js.map +1 -0
- package/lib/Toast.js +1 -1
- package/lib/Toast.js.map +1 -1
- package/lib/ToastGroup.js +1 -1
- package/lib/ToastGroup.js.map +1 -1
- package/lib/Toggle.js +1 -1
- package/lib/Toggle.js.map +1 -1
- package/lib/Tooltip.js +1 -1
- package/lib/Tooltip.js.map +1 -1
- package/lib/TopBar.js +1 -1
- package/lib/TopBar.js.map +1 -1
- package/lib/Truncate.js +1 -1
- package/lib/Truncate.js.map +1 -1
- package/lib/VisuallyHidden.js +1 -1
- package/lib/bundle.js +91 -91
- package/lib/bundle.js.map +1 -1
- package/lib/combobox-context.js +2 -0
- package/lib/combobox-context.js.map +1 -0
- package/lib/context-consumer-BJVUulGf.js +7 -0
- package/lib/context-consumer-BJVUulGf.js.map +1 -0
- package/lib/context-provider-D8lrPLVi.js +12 -0
- package/lib/context-provider-D8lrPLVi.js.map +1 -0
- package/lib/context-request-event-CCRlXoeR.js +7 -0
- package/lib/context-request-event-CCRlXoeR.js.map +1 -0
- package/lib/create-context-CJ69ntlY.js +7 -0
- package/lib/create-context-CJ69ntlY.js.map +1 -0
- package/lib/currency.js +2 -0
- package/lib/currency.js.map +1 -0
- package/lib/date-adapter.js +1 -1
- package/lib/dates-C-ZvzXaC.js +2 -0
- package/lib/dates-C-ZvzXaC.js.map +1 -0
- package/lib/dates.js +2 -0
- package/lib/dates.js.map +1 -0
- package/lib/dismiss.js +2 -0
- package/lib/dismiss.js.map +1 -0
- package/lib/en-us.js +1 -1
- package/lib/en-us.js.map +1 -1
- package/lib/fi-fi.js +1 -1
- package/lib/fi-fi.js.map +1 -1
- package/lib/field-context.js +2 -0
- package/lib/field-context.js.map +1 -0
- package/lib/filter-chip-C97zd4PT.js +2 -0
- package/lib/filter-chip-C97zd4PT.js.map +1 -0
- package/lib/format.js +2 -0
- package/lib/format.js.map +1 -0
- package/lib/index.js +1 -1
- package/lib/interface-add-small-B-hv2v9J.js +2 -0
- package/lib/interface-add-small-B-hv2v9J.js.map +1 -0
- package/lib/interface-calendar-Cw2bJfbS.js +2 -0
- package/lib/interface-calendar-Cw2bJfbS.js.map +1 -0
- package/lib/interface-close-BvKnv9eh.js +2 -0
- package/lib/interface-close-BvKnv9eh.js.map +1 -0
- package/lib/interface-dropdown-small-CYvgxudU.js +2 -0
- package/lib/interface-dropdown-small-CYvgxudU.js.map +1 -0
- package/lib/interface-filter-CCsx9-u6.js +2 -0
- package/lib/interface-filter-CCsx9-u6.js.map +1 -0
- package/lib/interface-remove-small-DUaWSs90.js +2 -0
- package/lib/interface-remove-small-DUaWSs90.js.map +1 -0
- package/lib/light-dom-styles-DXsbiKU9.js +2 -0
- package/lib/light-dom-styles-DXsbiKU9.js.map +1 -0
- package/lib/localization.js +1 -1
- package/lib/localization.js.map +1 -1
- package/lib/localization10.js +2 -0
- package/lib/localization10.js.map +1 -0
- package/lib/localization11.js +2 -0
- package/lib/localization11.js.map +1 -0
- package/lib/localization12.js +2 -0
- package/lib/localization12.js.map +1 -0
- package/lib/localization13.js +2 -0
- package/lib/localization13.js.map +1 -0
- package/lib/localization14.js +2 -0
- package/lib/localization14.js.map +1 -0
- package/lib/localization15.js +2 -0
- package/lib/localization15.js.map +1 -0
- package/lib/localization16.js +2 -0
- package/lib/localization16.js.map +1 -0
- package/lib/localization17.js +2 -0
- package/lib/localization17.js.map +1 -0
- package/lib/localization18.js +2 -0
- package/lib/localization18.js.map +1 -0
- package/lib/localization19.js +2 -0
- package/lib/localization19.js.map +1 -0
- package/lib/localization2.js +1 -1
- package/lib/localization2.js.map +1 -1
- package/lib/localization20.js +2 -0
- package/lib/localization20.js.map +1 -0
- package/lib/localization21.js +2 -0
- package/lib/localization21.js.map +1 -0
- package/lib/localization22.js +2 -0
- package/lib/localization22.js.map +1 -0
- package/lib/localization3.js +1 -1
- package/lib/localization3.js.map +1 -1
- package/lib/localization4.js +1 -1
- package/lib/localization4.js.map +1 -1
- package/lib/localization5.js +1 -1
- package/lib/localization5.js.map +1 -1
- package/lib/localization6.js +1 -1
- package/lib/localization6.js.map +1 -1
- package/lib/localization7.js +1 -1
- package/lib/localization7.js.map +1 -1
- package/lib/localization8.js +1 -1
- package/lib/localization8.js.map +1 -1
- package/lib/localization9.js +1 -1
- package/lib/localization9.js.map +1 -1
- package/lib/navigation-search-CBbIGzo2.js +2 -0
- package/lib/navigation-search-CBbIGzo2.js.map +1 -0
- package/lib/paginate.js +2 -0
- package/lib/paginate.js.map +1 -0
- package/lib/parse.js +2 -0
- package/lib/parse.js.map +1 -0
- package/lib/primitives-Dj0vyf1-.js +2 -0
- package/lib/primitives-Dj0vyf1-.js.map +1 -0
- package/lib/react.d.ts +505 -0
- package/lib/src/accordion/Accordion.d.ts +121 -0
- package/lib/src/accordion/AccordionHeader.d.ts +28 -0
- package/lib/src/accordion/AccordionItem.d.ts +68 -0
- package/lib/src/accordion/AccordionPanel.d.ts +35 -0
- package/lib/src/accordion/AccordionTrigger.d.ts +47 -0
- package/lib/src/aside-drawer/AsideDrawer.d.ts +2 -0
- package/lib/src/aside-trigger/AsideTrigger.d.ts +2 -0
- package/lib/src/autocomplete/Autocomplete.d.ts +190 -0
- package/lib/src/autocomplete/localization.d.ts +5 -0
- package/lib/src/badge/Badge.d.ts +1 -1
- package/lib/src/banner/Banner.d.ts +3 -0
- package/lib/src/button-group/ButtonGroup.d.ts +1 -1
- package/lib/src/calendar/Calendar.d.ts +44 -0
- package/lib/src/calendar/DateRangeSelectEvent.d.ts +16 -0
- package/lib/src/collapsible/Collapsible.d.ts +69 -0
- package/lib/src/collapsible/CollapsiblePanel.d.ts +35 -0
- package/lib/src/collapsible/CollapsibleTrigger.d.ts +38 -0
- package/lib/src/combobox/Combobox.d.ts +131 -0
- package/lib/src/combobox/ComboboxBase.d.ts +421 -0
- package/lib/src/combobox/ComboboxEvents.d.ts +25 -0
- package/lib/src/combobox/ComboboxGroup.d.ts +34 -0
- package/lib/src/combobox/ComboboxOption.d.ts +47 -0
- package/lib/src/combobox/combobox-context.d.ts +18 -0
- package/lib/src/combobox/localization.d.ts +6 -0
- package/lib/src/common/controllers/ActiveDescendantController.d.ts +45 -0
- package/lib/src/common/controllers/CollapseController.d.ts +50 -0
- package/lib/src/common/controllers/FocusableWhenDisabledController.d.ts +29 -0
- package/lib/src/common/controllers/OpenStateController.d.ts +58 -0
- package/lib/src/common/controllers/RovingFocusController.d.ts +40 -0
- package/lib/src/common/controllers/StateAttributesController.d.ts +47 -0
- package/lib/src/common/controllers/TransitionStatusController.d.ts +48 -0
- package/lib/src/common/dates.d.ts +13 -0
- package/lib/src/common/light-dom-styles.d.ts +17 -0
- package/lib/src/common/mixins/FieldControlMixin.d.ts +60 -0
- package/lib/src/common/mixins/FormAssociatedMixin.d.ts +8 -25
- package/lib/src/common/mixins/TextSelectableMixin.d.ts +1 -0
- package/lib/src/common/prefers-reduced-motion.d.ts +7 -0
- package/lib/src/date-picker/DatePicker.d.ts +2 -0
- package/lib/src/date-range-picker/DateRangeChangeEvent.d.ts +27 -0
- package/lib/src/date-range-picker/DateRangePicker.d.ts +307 -0
- package/lib/src/date-range-picker/localization.d.ts +42 -0
- package/lib/src/dropdown/Dropdown.d.ts +1 -1
- package/lib/src/dropdown-group/DropdownGroup.d.ts +3 -1
- package/lib/src/dropdown-item/DropdownItem.d.ts +3 -1
- package/lib/src/dropdown-submenu/DropdownSubmenu.d.ts +2 -0
- package/lib/src/field/Field.d.ts +102 -0
- package/lib/src/field/FieldContent.d.ts +22 -0
- package/lib/src/field/FieldDescription.d.ts +21 -0
- package/lib/src/field/FieldError.d.ts +25 -0
- package/lib/src/field/FieldGroup.d.ts +25 -0
- package/lib/src/field/FieldLabel.d.ts +41 -0
- package/lib/src/field/FieldLegend.d.ts +20 -0
- package/lib/src/field/FieldSeparator.d.ts +21 -0
- package/lib/src/field/FieldSet.d.ts +28 -0
- package/lib/src/field/FieldTitle.d.ts +21 -0
- package/lib/src/field/field-context.d.ts +47 -0
- package/lib/src/fieldset/Fieldset.d.ts +12 -4
- package/lib/src/filter-add-button/FilterAddButton.d.ts +91 -0
- package/lib/src/filter-add-button/FilterAddButtonEvents.d.ts +17 -0
- package/lib/src/filter-add-button/localization.d.ts +4 -0
- package/lib/src/filter-bar/FilterBar.d.ts +37 -0
- package/lib/src/filter-date-range/FilterDateRange.d.ts +96 -0
- package/lib/src/filter-date-range/FilterDateRangeEvents.d.ts +37 -0
- package/lib/src/filter-date-range/localization.d.ts +11 -0
- package/lib/src/filter-dropdown/FilterDropdown.d.ts +247 -0
- package/lib/src/filter-dropdown/FilterDropdownEvents.d.ts +57 -0
- package/lib/src/filter-dropdown/localization.d.ts +14 -0
- package/lib/src/filter-field/FilterField.d.ts +89 -0
- package/lib/src/filter-field/FilterFieldEvents.d.ts +18 -0
- package/lib/src/filter-field/localization.d.ts +8 -0
- package/lib/src/filter-input/FilterInput.d.ts +102 -0
- package/lib/src/filter-input/localization.d.ts +5 -0
- package/lib/src/filter-reset-button/FilterResetButton.d.ts +50 -0
- package/lib/src/filter-reset-button/localization.d.ts +4 -0
- package/lib/src/index.d.ts +59 -0
- package/lib/src/input/Input.d.ts +2 -1
- package/lib/src/item/Item.d.ts +44 -0
- package/lib/src/item/ItemActions.d.ts +20 -0
- package/lib/src/item/ItemContent.d.ts +22 -0
- package/lib/src/item/ItemDescription.d.ts +20 -0
- package/lib/src/item/ItemFooter.d.ts +20 -0
- package/lib/src/item/ItemGroup.d.ts +22 -0
- package/lib/src/item/ItemHeader.d.ts +20 -0
- package/lib/src/item/ItemMedia.d.ts +28 -0
- package/lib/src/item/ItemSeparator.d.ts +21 -0
- package/lib/src/item/ItemTitle.d.ts +19 -0
- package/lib/src/kbd/Kbd.d.ts +54 -0
- package/lib/src/kbd/KbdGroup.d.ts +22 -0
- package/lib/src/layout/Layout.d.ts +2 -2
- package/lib/src/localization/en-us.d.ts +85 -0
- package/lib/src/localization/translation.d.ts +85 -0
- package/lib/src/meter/Meter.d.ts +76 -0
- package/lib/src/nav-group/NavGroup.d.ts +2 -0
- package/lib/src/nav-item/NavItem.d.ts +2 -0
- package/lib/src/nav-toggle/NavToggle.d.ts +3 -1
- package/lib/src/notification-group/NotificationGroup.d.ts +2 -0
- package/lib/src/number-field/NumberField.d.ts +377 -0
- package/lib/src/number-field/NumberFieldEvents.d.ts +37 -0
- package/lib/src/number-field/currency.d.ts +24 -0
- package/lib/src/number-field/format.d.ts +8 -0
- package/lib/src/number-field/localization.d.ts +6 -0
- package/lib/src/number-field/parse.d.ts +44 -0
- package/lib/src/number-field/validate.d.ts +24 -0
- package/lib/src/otp-field/OtpField.d.ts +177 -0
- package/lib/src/otp-field/OtpFieldEvents.d.ts +38 -0
- package/lib/src/otp-field/localization.d.ts +4 -0
- package/lib/src/pagination/Pagination.d.ts +51 -0
- package/lib/src/pagination/PaginationContent.d.ts +27 -0
- package/lib/src/pagination/PaginationEllipsis.d.ts +27 -0
- package/lib/src/pagination/PaginationItem.d.ts +24 -0
- package/lib/src/pagination/PaginationLink.d.ts +30 -0
- package/lib/src/pagination/PaginationNext.d.ts +24 -0
- package/lib/src/pagination/PaginationPrevious.d.ts +24 -0
- package/lib/src/pagination/localization.d.ts +4 -0
- package/lib/src/pagination/paginate.d.ts +20 -0
- package/lib/src/popout/Popout.d.ts +9 -0
- package/lib/src/scroll-area/ScrollArea.d.ts +101 -0
- package/lib/src/segmented-control-item/SegmentedControlItem.d.ts +2 -0
- package/lib/src/storybook-utils/dates.d.ts +2 -0
- package/lib/src/storybook-utils/dismiss.d.ts +1 -0
- package/lib/src/storybook-utils/story-descriptions.d.ts +2 -0
- package/lib/src/tab-group/TabGroup.d.ts +2 -0
- package/lib/src/tab-panel/TabPanel.d.ts +2 -0
- package/lib/src/tag-group/TagGroup.d.ts +2 -0
- package/lib/src/time-picker/TimePicker.d.ts +105 -0
- package/lib/src/time-picker/localization.d.ts +4 -0
- package/lib/src/toast-group/ToastGroup.d.ts +11 -0
- package/lib/story-descriptions.js +2 -0
- package/lib/story-descriptions.js.map +1 -0
- package/lib/translation.js +1 -1
- package/lib/translation.js.map +1 -1
- package/lib/validate.js +2 -0
- package/lib/validate.js.map +1 -0
- package/lib/vue.d.ts +407 -0
- package/package.json +9 -12
- package/lib/Calendar-ChNZdVRO.js +0 -2
- package/lib/Calendar-ChNZdVRO.js.map +0 -1
- package/lib/Component-DSU3Qp0O.js +0 -2
- package/lib/Component-DSU3Qp0O.js.map +0 -1
- package/lib/DropdownItem-Cb-7cHMg.js +0 -2
- package/lib/DropdownItem-Cb-7cHMg.js.map +0 -1
- package/lib/Fieldset.js +0 -2
- package/lib/Fieldset.js.map +0 -1
- package/lib/FormAssociatedMixin-B4Qj-CQN.js +0 -2
- package/lib/FormAssociatedMixin-B4Qj-CQN.js.map +0 -1
- package/lib/FormField-BFaVzUjk.js +0 -2
- package/lib/FormField-BFaVzUjk.js.map +0 -1
- package/lib/NavToggle-DzKbd-El.js +0 -2
- package/lib/NavToggle-DzKbd-El.js.map +0 -1
- package/lib/Popout-CYqn_dZu.js +0 -2
- package/lib/Popout-CYqn_dZu.js.map +0 -1
- package/lib/Sticky-DqnqENYN.js +0 -2
- package/lib/Sticky-DqnqENYN.js.map +0 -1
- package/lib/TextField-B955GOhe.js +0 -2
- package/lib/TextField-B955GOhe.js.map +0 -1
- package/lib/dates-CAAlPKZi.js +0 -2
- package/lib/dates-CAAlPKZi.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PaginationNext.js","sources":["../src/pagination/PaginationNext.ts"],"sourcesContent":["import { LitElement } from 'lit'\nimport { customElement } from 'lit/decorators.js'\n\nimport { injectLightDomStyles } from '../common/light-dom-styles.js'\nimport { DraftComponentMixin } from '../common/mixins/DraftComponentMixin.js'\nimport style from './primitives.css'\n\n/**\n * The \"next page\" control in a composed [Pagination](/components/pagination/). A\n * layout wrapper around your own interactive element — provide an `<a>` (e.g. a\n * framework `<Link>`) or a `nord-button` with its own icon, label and\n * navigation, and disable it when there is no next page.\n *\n * @status draft\n * @category navigation\n * @lightDom true\n *\n * @slot - Default slot for the next-page link or button.\n */\n@customElement('nord-pagination-next')\nexport default class PaginationNext extends DraftComponentMixin(LitElement) {\n connectedCallback() {\n super.connectedCallback()\n injectLightDomStyles(this, style)\n }\n\n protected createRenderRoot() {\n return this\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nord-pagination-next': PaginationNext\n }\n}\n"],"names":["PaginationNext","DraftComponentMixin","LitElement","connectedCallback","super","injectLightDomStyles","this","style","createRenderRoot","__decorate","customElement"],"mappings":"qRAoBe,IAAMA,EAAN,cAA6BC,EAAoBC,IAC9D,iBAAAC,GACEC,MAAMD,oBACNE,EAAqBC,KAAMC,EAC5B,CAES,gBAAAC,GACR,OAAOF,IACR,GARkBN,EAAcS,EAAA,CADlCC,EAAc,yBACMV,SAAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{_ as t}from"./tslib.es6-CmLYFWVC.js";import{LitElement as o}from"lit";import{customElement as r}from"lit/decorators.js";import{i as s}from"./light-dom-styles-DXsbiKU9.js";import{D as e}from"./DraftComponentMixin-4qug5Rky.js";import{s as i}from"./primitives-Dj0vyf1-.js";let a=class extends(e(o)){connectedCallback(){super.connectedCallback(),s(this,i)}createRenderRoot(){return this}};a=t([r("nord-pagination-previous")],a);var m=a;export{m as default};
|
|
2
|
+
//# sourceMappingURL=PaginationPrevious.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PaginationPrevious.js","sources":["../src/pagination/PaginationPrevious.ts"],"sourcesContent":["import { LitElement } from 'lit'\nimport { customElement } from 'lit/decorators.js'\n\nimport { injectLightDomStyles } from '../common/light-dom-styles.js'\nimport { DraftComponentMixin } from '../common/mixins/DraftComponentMixin.js'\nimport style from './primitives.css'\n\n/**\n * The \"previous page\" control in a composed [Pagination](/components/pagination/).\n * A layout wrapper around your own interactive element — provide an `<a>`\n * (e.g. a framework `<Link>`) or a `nord-button` with its own icon, label and\n * navigation, and disable it when there is no previous page.\n *\n * @status draft\n * @category navigation\n * @lightDom true\n *\n * @slot - Default slot for the previous-page link or button.\n */\n@customElement('nord-pagination-previous')\nexport default class PaginationPrevious extends DraftComponentMixin(LitElement) {\n connectedCallback() {\n super.connectedCallback()\n injectLightDomStyles(this, style)\n }\n\n protected createRenderRoot() {\n return this\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nord-pagination-previous': PaginationPrevious\n }\n}\n"],"names":["PaginationPrevious","DraftComponentMixin","LitElement","connectedCallback","super","injectLightDomStyles","this","style","createRenderRoot","__decorate","customElement"],"mappings":"qRAoBe,IAAMA,EAAN,cAAiCC,EAAoBC,IAClE,iBAAAC,GACEC,MAAMD,oBACNE,EAAqBC,KAAMC,EAC5B,CAES,gBAAAC,GACR,OAAOF,IACR,GARkBN,EAAkBS,EAAA,CADtCC,EAAc,6BACMV,SAAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{_ as t}from"./tslib.es6-CmLYFWVC.js";import{o as e,a as o,s as i,h as s,l as n,f as a,c as r,b as l}from"./positioning-D-K8Mueq.js";import{css as h,html as p,LitElement as d}from"lit";import{property as c,query as m,state as u,customElement as f}from"lit/decorators.js";import{D as g}from"./DirectionController-ChvNGESZ.js";import{E as v}from"./EventController-BBOmvfLa.js";import{L as y}from"./LightDismissController-4pH8cdko.js";import{S as b}from"./ScrollbarController-BFC67Y2x.js";import{o as w}from"./observe-D0n0zOfU.js";import{N as x,t as E}from"./events-Bv6wNHwJ.js";import{s as A}from"./Component-BJ5O5n8k.js";function k(e){class o extends e{constructor(){super(...arguments),this.open=!1,this.align="start",this.position="block-end",this.sideOffset=8,this.alignOffset=0}}return t([c({type:Boolean,reflect:!0})],o.prototype,"open",void 0),t([c({reflect:!0})],o.prototype,"align",void 0),t([c({reflect:!0})],o.prototype,"position",void 0),t([c({reflect:!0,type:Number,attribute:"side-offset"})],o.prototype,"sideOffset",void 0),t([c({reflect:!0,type:Number,attribute:"align-offset"})],o.prototype,"alignOffset",void 0),o}const C=h`:host{background:none;block-size:auto;border:none;color:var(--n-color-text);inline-size:auto;inset:auto;left:var(--_n-popout-position-x);margin:0;opacity:0;overflow:visible;padding:0;pointer-events:none;position:fixed;top:var(--_n-popout-position-y);transition:opacity var(--n-transition-slowly);z-index:var(--n-index-popout)}.n-popout{background:var(--n-popout-background,var(--n-color-surface));border-radius:var(--n-border-radius-s);box-shadow:var(--n-popout-box-shadow,var(--n-box-shadow-popout));pointer-events:none;transform:translateY(-10px) scale(.97);transform-origin:top left;transition:transform var(--n-transition-slowly),visibility var(--n-transition-slowly);visibility:hidden;will-change:transform,opacity,visibility}:host([open]){opacity:1}:host([open]) .n-popout{pointer-events:auto;transform:translateY(0) translateX(0) scale(1);transition-property:transform;visibility:visible}@media (max-width:35.9375em){:host(:not([always-floating])){background:#0000;inset:0;opacity:1;overflow-y:auto;position:fixed;transition:background var(--n-transition-mobile)}:host([open]:not([always-floating])){background:var(--n-color-overlay);pointer-events:auto}:host([open]:not([always-floating])) .n-popout{transform:translateY(0)}:host(:not([always-floating])) .n-popout{border-radius:0;inset:0;inset-block-start:auto;position:fixed;transform:translateY(100%);transform-origin:bottom center;transition:transform var(--n-transition-mobile),visibility var(--n-transition-mobile)}}.top-end,.top-start{transform:translateY(10px) scale(.97)}.left-end,.left-start{transform:translateX(10px) scale(.97)}.right-end,.right-start{transform:translateX(-10px) scale(.97)}.bottom-start.is-rtl,.left-end,.top-end{transform-origin:bottom right}.bottom-end,.left-start,.top-start.is-rtl{transform-origin:top right}.bottom-end.is-rtl,.right-end,.right-start{transform-origin:bottom left}.right-start,.top-end.is-rtl{transform-origin:top left}`,O="undefined"==typeof matchMedia?{matches:!1,addEventListener(){}}:matchMedia("(max-width: 35.9375em)");let P=class extends(k(d)){constructor(){super(...arguments),this.scrollBar=new b(this),this.dismiss=new y(this,{isOpen:()=>this.open,onDismiss:t=>this.hide("click"!==t.type),isDismissible:t=>t!==this.popout&&t!==this.targetElement}),this.events=new v(this),this.direction=new g(this),this.smallViewport=O.matches,this.id="",this.alwaysFloating=!1,this.controlled=!1,this.enableScroll=()=>{this.open||(this.scrollBar.unlockScroll(),this.leaveTopLayer())},this.updatePosition=async()=>{var t;if(!this.anchorElement)return;const l={strategy:"fixed"};"auto"===this.position?l.middleware=[e({mainAxis:this.sideOffset,alignmentAxis:this.alignOffset}),o({alignment:this.align,padding:8}),i({padding:8}),s()]:(l.placement=n(this.position,this.align,this.direction.dir),l.middleware=[e({mainAxis:this.sideOffset,alignmentAxis:this.alignOffset}),a(),i({padding:8}),s()]);const{x:h,y:p,placement:d,middlewareData:c}=await r(this.anchorElement,this,l);this.computedPosition=d,this.style.setProperty("--_n-popout-position-x",`${h}px`),this.style.setProperty("--_n-popout-position-y",`${p}px`),(null===(t=c.hide)||void 0===t?void 0:t.referenceHidden)&&this.hide()},this.toggleOpen=t=>{t.preventDefault(),this.open?this.hide(!1):!this.smallViewport||this.alwaysFloating?(this.enterTopLayer(),this.updatePosition().then((()=>this.show()))):this.show()},this.handleMediaQueryChange=()=>{var t;this.smallViewport=O.matches,null===(t=this.cleanupAutoUpdate)||void 0===t||t.call(this),(!this.smallViewport||this.alwaysFloating)&&this.open&&this.anchorElement?(this.cleanupAutoUpdate=l(this.anchorElement,this,this.updatePosition),this.scrollBar.unlockScroll()):this.open&&this.scrollBar.lockScroll()}}async show(){return this.open?Promise.resolve():(this.enterTopLayer(),this.open=!0,await this.updateComplete,this.dispatchEvent(new x("open")),E(this.popout))}async hide(t=!0){var e,o;if(!this.open)return Promise.resolve();this.open=!1,null===(e=this.cleanupAutoUpdate)||void 0===e||e.call(this),this.dispatchEvent(new x("close")),t&&(null===(o=this.targetElement)||void 0===o||o.focus({preventScroll:!0}));const i=await E(this.popout);return this.leaveTopLayer(),i}firstUpdated(){this.smallViewport&&!this.alwaysFloating||this.updatePosition()}connectedCallback(){super.connectedCallback(),this.events.listen(O,"change",this.handleMediaQueryChange),this.initializeElements()}disconnectedCallback(){var t,e;super.disconnectedCallback(),null===(t=this.cleanupAutoUpdate)||void 0===t||t.call(this),null===(e=this.targetElement)||void 0===e||e.removeAttribute("aria-expanded")}render(){return p`<div class="n-popout ${this.computedPosition} is-${this.direction.dir}" aria-hidden="${this.open?"false":"true"}" @transitionend="${this.enableScroll}"><slot></slot></div>`}handleIdChange(){var t;null===(t=this.targetElement)||void 0===t||t.removeEventListener("click",this.toggleOpen),this.id?this.initializeElements():console.warn("NORD: popout requires an id attribute and value")}initializeElements(){this.targetElement=this.getToggle(),this.anchorElement=this.getAnchor(),this.controlled||this.events.listen(this.targetElement,"click",this.toggleOpen)}handleOpenChange(){var t,e;null===(t=this.targetElement)||void 0===t||t.setAttribute("aria-expanded",`${this.open}`),this.open?(this.enterTopLayer(),this.smallViewport&&!this.alwaysFloating?this.scrollBar.lockScroll():this.anchorElement&&(this.cleanupAutoUpdate=l(this.anchorElement,this,this.updatePosition))):null===(e=this.cleanupAutoUpdate)||void 0===e||e.call(this)}handleAnchorChange(){var t;null===(t=this.cleanupAutoUpdate)||void 0===t||t.call(this),this.anchorElement=this.getAnchor(),this.open&&(!this.smallViewport||this.alwaysFloating)&&this.anchorElement&&(this.cleanupAutoUpdate=l(this.anchorElement,this,this.updatePosition))}enterTopLayer(){if("function"==typeof this.showPopover)try{this.setAttribute("popover","manual"),this.showPopover()}catch(t){this.removeAttribute("popover")}}leaveTopLayer(){this.removeAttribute("popover")}getToggle(){const t=this.getRootNode(),e=t.querySelectorAll(`[aria-controls='${this.id}']`);let o=e[0];if(e.length>1){const i=[...t.querySelectorAll(`[id='${this.id}']`)].indexOf(this);i>=0&&i<e.length&&(o=e[i])}return o instanceof HTMLSlotElement?o.assignedElements()[0]:o}getAnchor(){if(!this.anchor)return this.targetElement;const t=this.getRootNode().querySelector(`#${this.anchor}`);return t instanceof HTMLSlotElement?t.assignedElements()[0]:t}};P.styles=[A,C],t([m(".n-popout",!0)],P.prototype,"popout",void 0),t([u()],P.prototype,"computedPosition",void 0),t([u()],P.prototype,"smallViewport",void 0),t([c({reflect:!0})],P.prototype,"id",void 0),t([c({reflect:!0})],P.prototype,"anchor",void 0),t([c({reflect:!0,type:Boolean,attribute:"always-floating"})],P.prototype,"alwaysFloating",void 0),t([c({reflect:!0,type:Boolean})],P.prototype,"controlled",void 0),t([w("id")],P.prototype,"handleIdChange",null),t([w("open")],P.prototype,"handleOpenChange",null),t([w("anchor")],P.prototype,"handleAnchorChange",null),P=t([f("nord-popout")],P);var S=P;export{k as F,S as P};
|
|
2
|
+
//# sourceMappingURL=Popout-DpN7PP9h.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Popout-DpN7PP9h.js","sources":["../src/common/mixins/FloatingComponentMixin.ts","../src/popout/Popout.ts"],"sourcesContent":["import type { Alignment } from '@floating-ui/dom'\nimport type { LitElement } from 'lit'\nimport type { LogicalSide } from '../positioning.js'\nimport { property } from 'lit/decorators.js'\n\ntype Constructor<T = Record<string, unknown>> = new (...args: any[]) => T\n\nexport declare class FloatingMixinInterface {\n open: boolean\n align: Alignment\n position: LogicalSide | 'auto'\n sideOffset: number\n alignOffset: number\n}\n\nexport function FloatingMixin<T extends Constructor<LitElement>>(\n superClass: T,\n): Constructor<FloatingMixinInterface> & T {\n class FloatingElement extends superClass {\n /**\n * Controls whether the component is open or not.\n */\n @property({ type: Boolean, reflect: true }) open = false\n\n /**\n * Set the alignment in relation to the toggle (or anchor) depending on the position.\n * `start` will align it to the left of the toggle (or anchor).\n * `end` will align it to the right of the toggle (or anchor).\n * Setting the `position` to `inline-start` or `inline-end` will switch\n * `start` and `end` to the top and bottom respectively.\n */\n @property({ reflect: true }) align: 'start' | 'end' = 'start'\n\n /**\n * Set the position in relation to the toggle (or anchor).\n * Options follow logical properties.\n * `block-start` and `block-end` referring to top and bottom respectively,\n * `inline-start` and `inline-end` referring to left and right respectively.\n * You can also set it to `auto` for automatic positioning depending on\n * which side has the most space available.\n */\n @property({ reflect: true }) position: 'block-end' | 'block-start' | 'inline-start' | 'inline-end' | 'auto'\n = 'block-end'\n\n /**\n * Distance in pixels from the toggle (or anchor) along the main axis — the\n * gap between the floating element and the side it opens against. Fed into\n * Floating UI's `offset` middleware as `mainAxis`. Defaults to `8`.\n */\n @property({ reflect: true, type: Number, attribute: 'side-offset' }) sideOffset = 8\n\n /**\n * Offset in pixels along the alignment axis — slides the floating element\n * toward the `start` or `end` of the toggle (or anchor). Fed into Floating\n * UI's `offset` middleware as `alignmentAxis`. Defaults to `0`.\n */\n @property({ reflect: true, type: Number, attribute: 'align-offset' }) alignOffset = 0\n }\n\n return FloatingElement\n}\n","import type {\n ComputePositionConfig,\n Placement,\n} from '@floating-ui/dom'\nimport {\n autoPlacement,\n autoUpdate,\n computePosition,\n flip,\n hide,\n offset,\n shift,\n} from '@floating-ui/dom'\nimport { html, LitElement } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\nimport { DirectionController } from '../common/controllers/DirectionController.js'\nimport { EventController } from '../common/controllers/EventController.js'\nimport { LightDismissController } from '../common/controllers/LightDismissController.js'\nimport { ScrollbarController } from '../common/controllers/ScrollbarController.js'\n\nimport { observe } from '../common/decorators/observe.js'\nimport { NordEvent, transition } from '../common/events.js'\nimport { FloatingMixin } from '../common/mixins/FloatingComponentMixin.js'\nimport { logicalToPhysical } from '../common/positioning.js'\nimport componentStyle from '../common/styles/Component.css'\nimport style from './Popout.css'\n\n/*\n * The breakpoint width to switch between \"sheet\" design and floating design\n */\nconst mediaQuery\n = typeof matchMedia === 'undefined'\n ? ({\n matches: false,\n addEventListener() {\n /* noop */\n },\n } as unknown as MediaQueryList)\n : matchMedia('(max-width: 35.9375em)')\n\n/**\n * Popouts are small overlays that open on demand. They let users access additional content and actions without cluttering the page.\n *\n * @status ready\n * @category overlay\n * @slot - The popout content.\n *\n * @cssprop [--n-popout-background=var(--n-color-surface)] - Background of the popout container. Set to `transparent` to suppress the popout's own surface (e.g. when a slotted element paints its own background).\n * @cssprop [--n-popout-box-shadow=var(--n-box-shadow-popout)] - Box-shadow of the popout container. Set to `none` to suppress the popout's own shadow.\n */\n@customElement('nord-popout')\nexport default class Popout extends FloatingMixin(LitElement) {\n static styles = [componentStyle, style]\n\n private targetElement?: HTMLElement\n private anchorElement?: HTMLElement\n private cleanupAutoUpdate?: ReturnType<typeof autoUpdate>\n\n @query('.n-popout', true) private popout!: HTMLDivElement\n\n private scrollBar = new ScrollbarController(this)\n\n /**\n * Handle dismissal of the popout, clicking outside the target button and popout.\n */\n private dismiss = new LightDismissController(this, {\n isOpen: () => this.open,\n onDismiss: e => this.hide(e.type !== 'click'),\n isDismissible: node => node !== this.popout && node !== this.targetElement,\n })\n\n private events = new EventController(this)\n private direction = new DirectionController(this)\n\n @state() private computedPosition?: Placement\n\n @state() private smallViewport = mediaQuery.matches\n\n /**\n * The id for the active element to reference via aria-controls.\n */\n\n @property({ reflect: true }) id: string = ''\n\n /**\n * Set an optional anchor element to align against, replacing the triggering element.\n */\n @property({ reflect: true }) anchor?: string\n\n /**\n * Set to true to always display the popout as a floating overlay, even on smaller viewports.\n */\n @property({ reflect: true, type: Boolean, attribute: 'always-floating' }) alwaysFloating: boolean = false\n\n /**\n * Set to true when the consuming component owns the `open` state and drives\n * the popout itself (e.g. via its own trigger `@click` and `show()`/`hide()`).\n * The popout stays presentational — positioning, top layer, light dismiss and\n * transitions all still work — but it does NOT attach its own click-to-toggle\n * listener to the `aria-controls` trigger, avoiding a competing second toggle\n * on the same click.\n */\n @property({ reflect: true, type: Boolean }) controlled: boolean = false\n\n /**\n * Show the popout.\n * A promise that resolves to a `TransitionEvent` when the popout's show animation ends or is cancelled.\n * If the popout is already open, the promise resolves immediately with `undefined`.\n */\n async show(): Promise<TransitionEvent | void> {\n if (this.open) {\n return Promise.resolve()\n }\n\n this.enterTopLayer()\n this.open = true\n\n // we should only focus once the popout is visible after render is complete\n await this.updateComplete\n\n /**\n * Dispatched when the popout is opened.\n */\n this.dispatchEvent(new NordEvent('open'))\n\n return transition(this.popout)\n }\n\n /**\n * Hide the popout.\n * Returns a promise that resolves to a `TransitionEvent` when the popout's hide animation ends or is cancelled.\n * If the popout is already closed, the promise resolves immediately with `undefined`.\n * @param {boolean} moveFocusToButton prevent focus returning to the target button. Default is true.\n */\n async hide(moveFocusToButton: boolean = true): Promise<TransitionEvent | void> {\n if (!this.open) {\n return Promise.resolve()\n }\n\n this.open = false\n\n this.cleanupAutoUpdate?.()\n\n /**\n * Dispatched when the popout is closed.\n */\n this.dispatchEvent(new NordEvent('close'))\n\n if (moveFocusToButton) {\n this.targetElement?.focus({ preventScroll: true })\n }\n\n const result = await transition(this.popout)\n this.leaveTopLayer()\n return result\n }\n\n /**\n * Position the popout on load.\n */\n firstUpdated() {\n if (!this.smallViewport || this.alwaysFloating) {\n this.updatePosition()\n }\n }\n\n connectedCallback() {\n super.connectedCallback()\n\n this.events.listen(mediaQuery, 'change', this.handleMediaQueryChange)\n\n this.initializeElements()\n }\n\n disconnectedCallback() {\n super.disconnectedCallback()\n\n this.cleanupAutoUpdate?.()\n this.targetElement?.removeAttribute('aria-expanded')\n }\n\n render() {\n return html`\n <div\n class=\"n-popout ${this.computedPosition} is-${this.direction.dir}\"\n aria-hidden=${this.open ? 'false' : 'true'}\n @transitionend=${this.enableScroll}\n >\n <slot></slot>\n </div>\n `\n }\n\n @observe('id')\n protected handleIdChange() {\n // clean up any old listeners\n this.targetElement?.removeEventListener('click', this.toggleOpen)\n\n if (!this.id) {\n console.warn('NORD: popout requires an id attribute and value')\n }\n else {\n this.initializeElements()\n }\n }\n\n private initializeElements() {\n this.targetElement = this.getToggle()\n this.anchorElement = this.getAnchor()\n\n // In controlled mode the consuming component owns the toggle, so the popout\n // resolves its trigger (for positioning, aria-expanded and light dismiss) but\n // does not attach its own click-to-toggle listener.\n if (!this.controlled) {\n this.events.listen(this.targetElement, 'click', this.toggleOpen)\n }\n }\n\n @observe('open')\n protected handleOpenChange() {\n this.targetElement?.setAttribute('aria-expanded', `${this.open}`)\n\n if (this.open) {\n this.enterTopLayer()\n\n if (this.smallViewport && !this.alwaysFloating) {\n // hide scrollbar and prevent scroll on body\n this.scrollBar.lockScroll()\n }\n else if (this.anchorElement) {\n this.cleanupAutoUpdate = autoUpdate(this.anchorElement, this, this.updatePosition)\n }\n }\n else {\n this.cleanupAutoUpdate?.()\n }\n }\n\n @observe('anchor')\n protected handleAnchorChange() {\n this.cleanupAutoUpdate?.()\n this.anchorElement = this.getAnchor()\n\n // if the popout is already open when the anchor changes, we should update its position\n if (this.open && (!this.smallViewport || this.alwaysFloating) && this.anchorElement) {\n this.cleanupAutoUpdate = autoUpdate(this.anchorElement, this, this.updatePosition)\n }\n }\n\n private enableScroll = () => {\n // scrollbar should only be restored when the backdrop has transitioned\n // that way we avoid awkward double scrollbars.\n if (!this.open) {\n this.scrollBar.unlockScroll()\n this.leaveTopLayer()\n }\n }\n\n /**\n * Place the element in the top layer via the Popover API so that\n * position: fixed works relative to the viewport regardless of\n * container queries or other containing block ancestors.\n */\n private enterTopLayer() {\n if (typeof this.showPopover !== 'function')\n return\n\n try {\n this.setAttribute('popover', 'manual')\n this.showPopover()\n }\n catch {\n this.removeAttribute('popover')\n }\n }\n\n private leaveTopLayer() {\n this.removeAttribute('popover')\n }\n\n /**\n * Get the position of the element toggling the popout\n * and position the popout underneath it, taking into account the optional placement.\n */\n private updatePosition = async () => {\n if (!this.anchorElement) {\n return\n }\n\n const computePositionConfig: ComputePositionConfig = {\n strategy: 'fixed',\n }\n\n if (this.position === 'auto') {\n computePositionConfig.middleware = [\n offset({ mainAxis: this.sideOffset, alignmentAxis: this.alignOffset }),\n autoPlacement({ alignment: this.align, padding: 8 }),\n shift({\n padding: 8,\n }),\n hide(),\n ]\n }\n else {\n computePositionConfig.placement = logicalToPhysical(this.position, this.align, this.direction.dir)\n computePositionConfig.middleware = [\n offset({ mainAxis: this.sideOffset, alignmentAxis: this.alignOffset }),\n flip(),\n shift({\n padding: 8,\n }),\n hide(),\n ]\n }\n\n const { x, y, placement, middlewareData } = await computePosition(this.anchorElement, this, computePositionConfig)\n\n this.computedPosition = placement\n\n // use physical properties here since floating-ui\n // works exclusively in physical dimensions\n // we do all the mapping in logicalToPhysical\n this.style.setProperty('--_n-popout-position-x', `${x}px`)\n this.style.setProperty('--_n-popout-position-y', `${y}px`)\n\n if (middlewareData.hide?.referenceHidden) {\n this.hide()\n }\n }\n\n /**\n * Toggle the popout open or closed using state.\n * Updating the position to underneath the target button before the popout is opened.\n */\n private toggleOpen = (e: Event) => {\n e.preventDefault()\n if (this.open) {\n this.hide(false)\n }\n else if (!this.smallViewport || this.alwaysFloating) {\n this.enterTopLayer()\n this.updatePosition().then(() => this.show())\n }\n else {\n this.show()\n }\n }\n\n private getToggle() {\n const rootNode = this.getRootNode() as Document | ShadowRoot\n const allToggles = rootNode.querySelectorAll<HTMLElement>(`[aria-controls='${this.id}']`)\n\n let toggle = allToggles[0]\n\n // When multiple toggles share the same aria-controls (duplicate IDs on page),\n // pair each toggle with its corresponding popout by document order.\n if (allToggles.length > 1) {\n const index = [...rootNode.querySelectorAll<HTMLElement>(`[id='${this.id}']`)].indexOf(this)\n if (index >= 0 && index < allToggles.length) {\n toggle = allToggles[index]\n }\n }\n\n if (toggle instanceof HTMLSlotElement) {\n return toggle.assignedElements()[0] as HTMLElement\n }\n\n return toggle\n }\n\n private getAnchor() {\n if (!this.anchor) {\n return this.targetElement\n }\n\n const rootNode = this.getRootNode() as Document | ShadowRoot\n const anchor = <HTMLElement>rootNode.querySelector(`#${this.anchor}`)\n\n if (anchor instanceof HTMLSlotElement) {\n return anchor.assignedElements()[0] as HTMLElement\n }\n\n return anchor\n }\n\n /**\n * Update the smallViewport flag to switch between \"sheet\" and \"floating\".\n * autoUpdate is needed when a viewport gets larger and the popout is open.\n */\n private handleMediaQueryChange = () => {\n this.smallViewport = mediaQuery.matches\n\n this.cleanupAutoUpdate?.()\n\n if ((!this.smallViewport || this.alwaysFloating) && this.open && this.anchorElement) {\n this.cleanupAutoUpdate = autoUpdate(this.anchorElement, this, this.updatePosition)\n this.scrollBar.unlockScroll()\n }\n else if (this.open) {\n this.scrollBar.lockScroll()\n }\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nord-popout': Popout\n }\n}\n"],"names":["FloatingMixin","superClass","FloatingElement","constructor","this","open","align","position","sideOffset","alignOffset","__decorate","property","type","Boolean","reflect","prototype","Number","attribute","mediaQuery","matchMedia","matches","addEventListener","Popout","LitElement","scrollBar","ScrollbarController","dismiss","LightDismissController","isOpen","onDismiss","e","hide","isDismissible","node","popout","targetElement","events","EventController","direction","DirectionController","smallViewport","id","alwaysFloating","controlled","enableScroll","unlockScroll","leaveTopLayer","updatePosition","async","anchorElement","computePositionConfig","strategy","middleware","offset","mainAxis","alignmentAxis","autoPlacement","alignment","padding","shift","placement","logicalToPhysical","dir","flip","x","y","middlewareData","computePosition","computedPosition","style","setProperty","_a","referenceHidden","toggleOpen","preventDefault","enterTopLayer","then","show","handleMediaQueryChange","cleanupAutoUpdate","call","autoUpdate","lockScroll","Promise","resolve","updateComplete","dispatchEvent","NordEvent","transition","moveFocusToButton","_b","focus","preventScroll","result","firstUpdated","connectedCallback","super","listen","initializeElements","disconnectedCallback","removeAttribute","render","html","handleIdChange","removeEventListener","console","warn","getToggle","getAnchor","handleOpenChange","setAttribute","handleAnchorChange","showPopover","rootNode","getRootNode","allToggles","querySelectorAll","toggle","length","index","indexOf","HTMLSlotElement","assignedElements","anchor","querySelector","styles","componentStyle","query","state","observe","customElement"],"mappings":"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"}
|
package/lib/Popout.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"./tslib.es6-CmLYFWVC.js";import"./positioning-D-K8Mueq.js";import"lit";import"lit/decorators.js";import"./DirectionController-ChvNGESZ.js";import"./EventController-BBOmvfLa.js";import"./LightDismissController-4pH8cdko.js";import"./ScrollbarController-BFC67Y2x.js";import"./observe-D0n0zOfU.js";import"./events-Bv6wNHwJ.js";export{P as default}from"./Popout-
|
|
1
|
+
import"./tslib.es6-CmLYFWVC.js";import"./positioning-D-K8Mueq.js";import"lit";import"lit/decorators.js";import"./DirectionController-ChvNGESZ.js";import"./EventController-BBOmvfLa.js";import"./LightDismissController-4pH8cdko.js";import"./ScrollbarController-BFC67Y2x.js";import"./observe-D0n0zOfU.js";import"./events-Bv6wNHwJ.js";export{P as default}from"./Popout-DpN7PP9h.js";import"./Component-BJ5O5n8k.js";import"./ShortcutController-BIb3WGzH.js";import"./tinykeys.module-_6MZt7MP.js";
|
|
2
2
|
//# sourceMappingURL=Popout.js.map
|
package/lib/Progress.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{_ as s}from"./tslib.es6-CmLYFWVC.js";import{css as r,LitElement as o,html as t,svg as e}from"lit";import{property as i,state as n,customElement as a}from"lit/decorators.js";import{ifDefined as l}from"lit/directives/if-defined.js";import{c}from"./cond-CI1KbneT.js";import{s as h}from"./Component-
|
|
1
|
+
import{_ as s}from"./tslib.es6-CmLYFWVC.js";import{css as r,LitElement as o,html as t,svg as e}from"lit";import{property as i,state as n,customElement as a}from"lit/decorators.js";import{ifDefined as l}from"lit/directives/if-defined.js";import{c}from"./cond-CI1KbneT.js";import{s as h}from"./Component-BJ5O5n8k.js";const g=r`:host{--_n-progress-color:var(--n-progress-color,var(--n-color-accent));--_n-progress-size:var(--n-size-icon-m);--_n-progress-background:var(--n-color-background);block-size:var(--_n-progress-size);display:inline-flex;inline-size:var(--_n-progress-size);position:relative}:host([size=xs]){--_n-progress-size:var(--n-size-icon-xs)}:host([size=s]){--_n-progress-size:var(--n-size-icon-s)}:host([size=l]){--_n-progress-size:var(--n-size-icon-l)}:host([size=xl]){--_n-progress-size:var(--n-size-icon-xl)}:host([size=xxl]){--_n-progress-size:var(--n-size-icon-xxl)}:host([color=success]){--_n-progress-color:var(--n-color-status-success)}:host([color=warning]){--_n-progress-color:var(--n-color-status-warning)}:host([color=danger]){--_n-progress-color:var(--n-color-status-danger)}:host([color=highlight]){--_n-progress-color:var(--n-color-status-highlight)}:host([color=info]){--_n-progress-color:var(--n-color-status-info)}:host svg{block-size:100%;inline-size:100%}`,d=11.25,p=11.25;let m=0;let _=class extends o{constructor(){super(),this.size="m",this.progress=0,this._animatedProgress=0,this._animationId=null,this._targetProgress=0,this._instanceId=0,this._instanceId=m++}connectedCallback(){super.connectedCallback(),this._animatedProgress=this.progress,this._targetProgress=this.progress}disconnectedCallback(){super.disconnectedCallback(),null!==this._animationId&&(cancelAnimationFrame(this._animationId),this._animationId=null)}updated(s){s.has("progress")&&(this._targetProgress=Math.max(0,Math.min(100,this.progress)),this._animate())}_animate(){null!==this._animationId&&cancelAnimationFrame(this._animationId);const s=()=>{const r=this._targetProgress-this._animatedProgress;if(Math.abs(r)<.5)return this._animatedProgress=this._targetProgress,void(this._animationId=null);this._animatedProgress+=.15*r,this._animationId=requestAnimationFrame(s)};this._animationId=requestAnimationFrame(s)}get _clampedProgress(){return Math.max(0,Math.min(100,this._animatedProgress))}get _isSemanticColor(){var s;return["success","warning","danger","highlight","info"].includes(null!==(s=this.color)&&void 0!==s?s:"")}get _customColorStyle(){if(this.color&&!this._isSemanticColor)return`--_n-progress-color:${this.color}`}render(){const s=Boolean(this.label),r=function(s){const r=Math.max(0,Math.min(100,s));if(0===r)return"";if(100===r)return"M11.25,5.25\n A6,6 0 1 1 11.25,17.25\n A6,6 0 1 1 11.25,5.25 Z";const o=r/100*360,t=(-90+o)*(Math.PI/180);return`M11.25,11.25\n L11.25,5.25\n A6,6 0 ${o>180?1:0},1 ${d+6*Math.cos(t)},${p+6*Math.sin(t)}\n Z`}(this._clampedProgress),o=`n-progress-clip-${this._instanceId}`;return t`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22.5 22.5" fill="none" role="${c(s,"progressbar")}" aria-label="${l(this.label)}" aria-valuenow="${c(s,Math.round(this._clampedProgress))}" aria-valuemin="${c(s,"0")}" aria-valuemax="${c(s,"100")}" aria-hidden="${c(!s,"true")}" style="${l(this._customColorStyle)}"><g clip-path="url(#${o})"><rect x="1.25" y="1.25" width="20" height="20" rx="10" fill="var(--_n-progress-background)"/><circle cx="${d}" cy="${p}" r="${9}" fill="var(--_n-progress-background)" stroke="var(--_n-progress-color)" stroke-width="2"/>${e`<path fill="var(--_n-progress-color)" d="${r}">`}</g><rect x="0.625" y="0.625" width="21.25" height="21.25" rx="10.625" stroke="var(--_n-progress-background)" stroke-width="1.25"/><defs><clipPath id="${o}"><rect x="1.25" y="1.25" width="20" height="20" rx="10" fill="white"/></clipPath></defs></svg>`}};_.styles=[h,g],s([i({reflect:!0})],_.prototype,"size",void 0),s([i({reflect:!0})],_.prototype,"color",void 0),s([i({reflect:!0})],_.prototype,"label",void 0),s([i({reflect:!0,type:Number})],_.prototype,"progress",void 0),s([n()],_.prototype,"_animatedProgress",void 0),_=s([a("nord-progress")],_);var u=_;export{u as default};
|
|
2
2
|
//# sourceMappingURL=Progress.js.map
|
package/lib/Progress.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Progress.js","sources":["../src/progress/Progress.ts"],"sourcesContent":["import { html, LitElement, svg } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\nimport { ifDefined } from 'lit/directives/if-defined.js'\nimport { cond } from '../common/directives/cond.js'\nimport componentStyle from '../common/styles/Component.css'\nimport style from './Progress.css'\n\nconst CX = 11.25\nconst CY = 11.25\nconst OUTER_RADIUS = 9\nconst INNER_RADIUS = 6\n\nlet instanceCounter = 0\n\n/**\n * Generates an SVG path for a pie sector starting from 12 o'clock, sweeping clockwise.\n * @param percent - The progress percentage (0-100)\n * @returns The SVG path data string\n */\nfunction sectorPath(percent: number): string {\n const p = Math.max(0, Math.min(100, percent))\n if (p === 0)\n return ''\n if (p === 100) {\n return `M${CX},${CY - INNER_RADIUS}\n A${INNER_RADIUS},${INNER_RADIUS} 0 1 1 ${CX},${CY + INNER_RADIUS}\n A${INNER_RADIUS},${INNER_RADIUS} 0 1 1 ${CX},${CY - INNER_RADIUS} Z`\n }\n const sweep = (p / 100) * 360\n const theta = (-90 + sweep) * (Math.PI / 180)\n const ex = CX + INNER_RADIUS * Math.cos(theta)\n const ey = CY + INNER_RADIUS * Math.sin(theta)\n const large = sweep > 180 ? 1 : 0\n return `M${CX},${CY}\n L${CX},${CY - INNER_RADIUS}\n A${INNER_RADIUS},${INNER_RADIUS} 0 ${large},1 ${ex},${ey}\n Z`\n}\n\n/**\n * Progress component is used to display a circular pie-chart style progress indicator.\n * You can customize the size and color of the progress indicator with the\n * provided properties.\n *\n * @status ready\n * @category feedback\n * @cssprop [--n-progress-color=var(--n-color-accent)] - Controls the color of the progress indicator.\n */\n@customElement('nord-progress')\nexport default class Progress extends LitElement {\n static styles = [componentStyle, style]\n\n /**\n * The size of the progress indicator.\n */\n @property({ reflect: true }) size: 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl' = 'm'\n\n /**\n * The color of the progress indicator.\n * Can accept any valid CSS color value, including custom properties.\n * Takes precedence over the `--n-progress-color` CSS custom property.\n */\n @property({ reflect: true }) color?: string\n\n /**\n * An accessible label for the progress indicator.\n * If no label is supplied, the component is hidden from assistive technology.\n */\n @property({ reflect: true }) label?: string\n\n /**\n * The progress percentage value.\n */\n @property({ reflect: true, type: Number }) progress: number = 0\n\n /**\n * Internal state for the animated progress value.\n */\n @state() private _animatedProgress: number = 0\n\n /**\n * Animation frame ID for cleanup.\n */\n private _animationId: number | null = null\n\n /**\n * Target progress for animation.\n */\n private _targetProgress: number = 0\n\n /**\n * Unique ID for this component instance, used for SVG clipPath.\n */\n private _instanceId: number = 0\n\n constructor() {\n super()\n this._instanceId = instanceCounter++\n }\n\n connectedCallback() {\n super.connectedCallback()\n this._animatedProgress = this.progress\n this._targetProgress = this.progress\n }\n\n disconnectedCallback() {\n super.disconnectedCallback()\n if (this._animationId !== null) {\n cancelAnimationFrame(this._animationId)\n this._animationId = null\n }\n }\n\n updated(changedProperties: Map<string, unknown>) {\n if (changedProperties.has('progress')) {\n this._targetProgress = Math.max(0, Math.min(100, this.progress))\n this._animate()\n }\n }\n\n private _animate() {\n if (this._animationId !== null) {\n cancelAnimationFrame(this._animationId)\n }\n\n const animate = () => {\n const diff = this._targetProgress - this._animatedProgress\n if (Math.abs(diff) < 0.5) {\n this._animatedProgress = this._targetProgress\n this._animationId = null\n return\n }\n // Ease towards target with smooth interpolation\n this._animatedProgress += diff * 0.15\n this._animationId = requestAnimationFrame(animate)\n }\n\n this._animationId = requestAnimationFrame(animate)\n }\n\n private get _clampedProgress(): number {\n return Math.max(0, Math.min(100, this._animatedProgress))\n }\n\n /**\n * Check if the color is a semantic value handled by CSS.\n */\n private get _isSemanticColor(): boolean {\n return ['success', 'warning', 'danger', 'highlight', 'info'].includes(this.color ?? '')\n }\n\n /**\n * Get the custom color style if not a semantic value.\n */\n private get _customColorStyle(): string | undefined {\n if (this.color && !this._isSemanticColor) {\n return `--_n-progress-color:${this.color}`\n }\n return undefined\n }\n\n render() {\n const hasLabel = Boolean(this.label)\n const pathData = sectorPath(this._clampedProgress)\n const clipId = `n-progress-clip-${this._instanceId}`\n\n return html`\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 22.5 22.5\"\n fill=\"none\"\n role=${cond(hasLabel, 'progressbar')}\n aria-label=${ifDefined(this.label)}\n aria-valuenow=${cond(hasLabel, Math.round(this._clampedProgress))}\n aria-valuemin=${cond(hasLabel, '0')}\n aria-valuemax=${cond(hasLabel, '100')}\n aria-hidden=${cond(!hasLabel, 'true')}\n style=${ifDefined(this._customColorStyle)}\n >\n <g clip-path=\"url(#${clipId})\">\n <rect x=\"1.25\" y=\"1.25\" width=\"20\" height=\"20\" rx=\"10\" fill=\"var(--_n-progress-background)\" />\n <circle\n cx=\"${CX}\"\n cy=\"${CY}\"\n r=\"${OUTER_RADIUS}\"\n fill=\"var(--_n-progress-background)\"\n stroke=\"var(--_n-progress-color)\"\n stroke-width=\"2\"\n />\n ${svg`<path fill=\"var(--_n-progress-color)\" d=\"${pathData}\" />`}\n </g>\n <rect\n x=\"0.625\"\n y=\"0.625\"\n width=\"21.25\"\n height=\"21.25\"\n rx=\"10.625\"\n stroke=\"var(--_n-progress-background)\"\n stroke-width=\"1.25\"\n />\n <defs>\n <clipPath id=\"${clipId}\">\n <rect x=\"1.25\" y=\"1.25\" width=\"20\" height=\"20\" rx=\"10\" fill=\"white\" />\n </clipPath>\n </defs>\n </svg>\n `\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nord-progress': Progress\n }\n}\n"],"names":["CX","CY","instanceCounter","Progress","LitElement","constructor","super","this","size","progress","_animatedProgress","_animationId","_targetProgress","_instanceId","connectedCallback","disconnectedCallback","cancelAnimationFrame","updated","changedProperties","has","Math","max","min","_animate","animate","diff","abs","requestAnimationFrame","_clampedProgress","_isSemanticColor","includes","_a","color","_customColorStyle","render","hasLabel","Boolean","label","pathData","percent","p","sweep","theta","PI","cos","sin","sectorPath","clipId","html","cond","ifDefined","round","svg","styles","componentStyle","style","__decorate","property","reflect","prototype","type","Number","state","customElement"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Progress.js","sources":["../src/progress/Progress.ts"],"sourcesContent":["import { html, LitElement, svg } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\nimport { ifDefined } from 'lit/directives/if-defined.js'\nimport { cond } from '../common/directives/cond.js'\nimport componentStyle from '../common/styles/Component.css'\nimport style from './Progress.css'\n\nconst CX = 11.25\nconst CY = 11.25\nconst OUTER_RADIUS = 9\nconst INNER_RADIUS = 6\n\nlet instanceCounter = 0\n\n/**\n * Generates an SVG path for a pie sector starting from 12 o'clock, sweeping clockwise.\n * @param percent - The progress percentage (0-100)\n * @returns The SVG path data string\n */\nfunction sectorPath(percent: number): string {\n const p = Math.max(0, Math.min(100, percent))\n if (p === 0)\n return ''\n if (p === 100) {\n return `M${CX},${CY - INNER_RADIUS}\n A${INNER_RADIUS},${INNER_RADIUS} 0 1 1 ${CX},${CY + INNER_RADIUS}\n A${INNER_RADIUS},${INNER_RADIUS} 0 1 1 ${CX},${CY - INNER_RADIUS} Z`\n }\n const sweep = (p / 100) * 360\n const theta = (-90 + sweep) * (Math.PI / 180)\n const ex = CX + INNER_RADIUS * Math.cos(theta)\n const ey = CY + INNER_RADIUS * Math.sin(theta)\n const large = sweep > 180 ? 1 : 0\n return `M${CX},${CY}\n L${CX},${CY - INNER_RADIUS}\n A${INNER_RADIUS},${INNER_RADIUS} 0 ${large},1 ${ex},${ey}\n Z`\n}\n\n/**\n * Progress component is used to display a circular pie-chart style progress indicator.\n * You can customize the size and color of the progress indicator with the\n * provided properties.\n *\n * @status ready\n * @category feedback\n * @cssprop [--n-progress-color=var(--n-color-accent)] - Controls the color of the progress indicator.\n */\n@customElement('nord-progress')\nexport default class Progress extends LitElement {\n static styles = [componentStyle, style]\n\n /**\n * The size of the progress indicator.\n */\n @property({ reflect: true }) size: 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl' = 'm'\n\n /**\n * The color of the progress indicator.\n * Can accept any valid CSS color value, including custom properties.\n * Takes precedence over the `--n-progress-color` CSS custom property.\n */\n @property({ reflect: true }) color?: string\n\n /**\n * An accessible label for the progress indicator.\n * If no label is supplied, the component is hidden from assistive technology.\n */\n @property({ reflect: true }) label?: string\n\n /**\n * The progress percentage value.\n */\n @property({ reflect: true, type: Number }) progress: number = 0\n\n /**\n * Internal state for the animated progress value.\n */\n @state() private _animatedProgress: number = 0\n\n /**\n * Animation frame ID for cleanup.\n */\n private _animationId: number | null = null\n\n /**\n * Target progress for animation.\n */\n private _targetProgress: number = 0\n\n /**\n * Unique ID for this component instance, used for SVG clipPath.\n */\n private _instanceId: number = 0\n\n constructor() {\n super()\n this._instanceId = instanceCounter++\n }\n\n connectedCallback() {\n super.connectedCallback()\n this._animatedProgress = this.progress\n this._targetProgress = this.progress\n }\n\n disconnectedCallback() {\n super.disconnectedCallback()\n if (this._animationId !== null) {\n cancelAnimationFrame(this._animationId)\n this._animationId = null\n }\n }\n\n updated(changedProperties: Map<string, unknown>) {\n if (changedProperties.has('progress')) {\n this._targetProgress = Math.max(0, Math.min(100, this.progress))\n this._animate()\n }\n }\n\n private _animate() {\n if (this._animationId !== null) {\n cancelAnimationFrame(this._animationId)\n }\n\n const animate = () => {\n const diff = this._targetProgress - this._animatedProgress\n if (Math.abs(diff) < 0.5) {\n this._animatedProgress = this._targetProgress\n this._animationId = null\n return\n }\n // Ease towards target with smooth interpolation\n this._animatedProgress += diff * 0.15\n this._animationId = requestAnimationFrame(animate)\n }\n\n this._animationId = requestAnimationFrame(animate)\n }\n\n private get _clampedProgress(): number {\n return Math.max(0, Math.min(100, this._animatedProgress))\n }\n\n /**\n * Check if the color is a semantic value handled by CSS.\n */\n private get _isSemanticColor(): boolean {\n return ['success', 'warning', 'danger', 'highlight', 'info'].includes(this.color ?? '')\n }\n\n /**\n * Get the custom color style if not a semantic value.\n */\n private get _customColorStyle(): string | undefined {\n if (this.color && !this._isSemanticColor) {\n return `--_n-progress-color:${this.color}`\n }\n return undefined\n }\n\n render() {\n const hasLabel = Boolean(this.label)\n const pathData = sectorPath(this._clampedProgress)\n const clipId = `n-progress-clip-${this._instanceId}`\n\n return html`\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 22.5 22.5\"\n fill=\"none\"\n role=${cond(hasLabel, 'progressbar')}\n aria-label=${ifDefined(this.label)}\n aria-valuenow=${cond(hasLabel, Math.round(this._clampedProgress))}\n aria-valuemin=${cond(hasLabel, '0')}\n aria-valuemax=${cond(hasLabel, '100')}\n aria-hidden=${cond(!hasLabel, 'true')}\n style=${ifDefined(this._customColorStyle)}\n >\n <g clip-path=\"url(#${clipId})\">\n <rect x=\"1.25\" y=\"1.25\" width=\"20\" height=\"20\" rx=\"10\" fill=\"var(--_n-progress-background)\" />\n <circle\n cx=\"${CX}\"\n cy=\"${CY}\"\n r=\"${OUTER_RADIUS}\"\n fill=\"var(--_n-progress-background)\"\n stroke=\"var(--_n-progress-color)\"\n stroke-width=\"2\"\n />\n ${svg`<path fill=\"var(--_n-progress-color)\" d=\"${pathData}\" />`}\n </g>\n <rect\n x=\"0.625\"\n y=\"0.625\"\n width=\"21.25\"\n height=\"21.25\"\n rx=\"10.625\"\n stroke=\"var(--_n-progress-background)\"\n stroke-width=\"1.25\"\n />\n <defs>\n <clipPath id=\"${clipId}\">\n <rect x=\"1.25\" y=\"1.25\" width=\"20\" height=\"20\" rx=\"10\" fill=\"white\" />\n </clipPath>\n </defs>\n </svg>\n `\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nord-progress': Progress\n }\n}\n"],"names":["CX","CY","instanceCounter","Progress","LitElement","constructor","super","this","size","progress","_animatedProgress","_animationId","_targetProgress","_instanceId","connectedCallback","disconnectedCallback","cancelAnimationFrame","updated","changedProperties","has","Math","max","min","_animate","animate","diff","abs","requestAnimationFrame","_clampedProgress","_isSemanticColor","includes","_a","color","_customColorStyle","render","hasLabel","Boolean","label","pathData","percent","p","sweep","theta","PI","cos","sin","sectorPath","clipId","html","cond","ifDefined","round","svg","styles","componentStyle","style","__decorate","property","reflect","prototype","type","Number","state","customElement"],"mappings":"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"}
|
package/lib/ProgressBar.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{_ as r}from"./tslib.es6-CmLYFWVC.js";import{css as e,html as o,LitElement as s}from"lit";import{property as a,customElement as
|
|
1
|
+
import{_ as r}from"./tslib.es6-CmLYFWVC.js";import{css as e,html as o,LitElement as s}from"lit";import{property as a,customElement as i}from"lit/decorators.js";import{ifDefined as n}from"lit/directives/if-defined.js";import{ref as t}from"lit/directives/ref.js";import{F as d}from"./FocusableMixin-BlQLNPdJ.js";import{s as l}from"./Component-BJ5O5n8k.js";const p=e`:host{--_n-progress-size:var(--n-progress-size,var(--n-space-s));--_n-progress-border-radius:var(--n-progress-border-radius,var(--n-border-radius-s));--_n-progress-color:var(--n-progress-color,var(--n-color-accent));inline-size:100%}progress{appearance:none;background-color:var(--n-color-surface-lowered);block-size:var(--_n-progress-size);border:0;border-radius:var(--_n-progress-border-radius);box-shadow:none;inline-size:100%;margin:0}label,progress{display:block}progress::-webkit-progress-bar{background-color:initial;border-radius:var(--_n-progress-border-radius)}progress::-moz-progress-bar{background:var(--_n-progress-color);border-radius:var(--_n-progress-border-radius)}progress::-webkit-progress-value{background:var(--_n-progress-color);border-radius:var(--_n-progress-border-radius);transition:width .25s ease-out,background .25s ease-out}progress:indeterminate{animation:animate-indeterminate 2s ease infinite;background-color:var(--n-color-nav-hover);background-image:linear-gradient(to right,#0000 45%,var(--n-color-accent) 0,var(--n-color-accent) 55%,#0000 0);background-position:100%;background-size:225% 100%}progress:indeterminate::-moz-progress-bar{background-color:initial}progress:indeterminate::-webkit-progress-value{background-color:initial}@keyframes animate-indeterminate{50%{background-position:0}}progress:focus{box-shadow:0 0 0 1px var(--n-color-background),0 0 0 3px var(--n-color-accent);outline:none}`;let c=class extends(d(s)){constructor(){super(...arguments),this.max=100,this.label="Current progress"}render(){return o`<label><nord-visually-hidden>${this.label}</nord-visually-hidden><progress ${t(this.focusableRef)} aria-valuenow="${n(this.value)}" aria-valuemin="0" aria-valuemax="${this.max}" tabindex="-1" max="${this.max}" value="${n(this.value)}"></progress></label>`}};c.styles=[l,p],r([a({reflect:!0,type:Number})],c.prototype,"value",void 0),r([a({reflect:!0,type:Number})],c.prototype,"max",void 0),r([a({reflect:!0})],c.prototype,"label",void 0),c=r([i("nord-progress-bar")],c);var u=c;export{u as default};
|
|
2
2
|
//# sourceMappingURL=ProgressBar.js.map
|
package/lib/ProgressBar.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProgressBar.js","sources":["../src/progress-bar/ProgressBar.ts"],"sourcesContent":["import { html, LitElement } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\nimport { ifDefined } from 'lit/directives/if-defined.js'\nimport { ref } from 'lit/directives/ref.js'\nimport { FocusableMixin } from '../common/mixins/FocusableMixin.js'\n\nimport componentStyle from '../common/styles/Component.css'\nimport style from './ProgressBar.css'\n\n/**\n * Progress Bar is used to visually represent the completion\n * of a task or process. It shows how much of the task has\n * been completed and how much is still left.\n *\n * @status ready\n * @category feedback\n *\n * @cssprop [--n-progress-size=var(--n-space-s)] - Controls the thickness of the progress bar, using our [spacing tokens](/tokens/#space).\n * @cssprop [--n-progress-border-radius=var(--n-border-radius-s)] - Controls how rounded the corners are, using [border radius tokens](/tokens/#border-radius).\n * @cssprop [--n-progress-color=var(--n-color-accent)] - Controls the color of the progress bar, using [color tokens](/tokens/#color).\n */\n@customElement('nord-progress-bar')\nexport default class ProgressBar extends FocusableMixin(LitElement) {\n static styles = [componentStyle, style]\n\n /**\n * Specifies how much of the task has been completed. Must be a valid floating\n * point number between 0 and max, or between 0 and 100 if max is omitted. If\n * there is no value, the progress bar is indeterminate; this indicates that\n * an activity is ongoing with no indication of how long it’s expected to take.\n */\n @property({ reflect: true, type: Number }) value?: number\n\n /**\n * Describes how much work the task indicated by the progress element requires.\n * The max attribute, if present, must have a value greater than 0 and be a\n * valid floating point number.\n */\n @property({ reflect: true, type: Number }) max: number = 100\n\n /**\n * Accessible label for the progress indicator. Visually hidden, but shown\n * for assistive technology.\n */\n @property({ reflect: true }) label: string = 'Current progress'\n\n render() {\n /**\n * The Aria properties are required for now due to a Chrome bug.\n * In the future we can probably get rid of them. For context:\n * https://bugs.chromium.org/p/chromium/issues/detail?id=1310779\n */\n return html`<label>\n <nord-visually-hidden>${this.label}</nord-visually-hidden>\n <progress\n ${ref(this.focusableRef)}\n aria-valuenow=${ifDefined(this.value)}\n aria-valuemin=\"0\"\n aria-valuemax=${this.max}\n tabindex=\"-1\"\n max=${this.max}\n value=${ifDefined(this.value)}\n ></progress>\n </label>`\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nord-progress-bar': ProgressBar\n }\n}\n"],"names":["ProgressBar","FocusableMixin","LitElement","constructor","this","max","label","render","html","ref","focusableRef","ifDefined","value","styles","componentStyle","style","__decorate","property","reflect","type","Number","prototype","customElement"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ProgressBar.js","sources":["../src/progress-bar/ProgressBar.ts"],"sourcesContent":["import { html, LitElement } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\nimport { ifDefined } from 'lit/directives/if-defined.js'\nimport { ref } from 'lit/directives/ref.js'\nimport { FocusableMixin } from '../common/mixins/FocusableMixin.js'\n\nimport componentStyle from '../common/styles/Component.css'\nimport style from './ProgressBar.css'\n\n/**\n * Progress Bar is used to visually represent the completion\n * of a task or process. It shows how much of the task has\n * been completed and how much is still left.\n *\n * @status ready\n * @category feedback\n *\n * @cssprop [--n-progress-size=var(--n-space-s)] - Controls the thickness of the progress bar, using our [spacing tokens](/tokens/#space).\n * @cssprop [--n-progress-border-radius=var(--n-border-radius-s)] - Controls how rounded the corners are, using [border radius tokens](/tokens/#border-radius).\n * @cssprop [--n-progress-color=var(--n-color-accent)] - Controls the color of the progress bar, using [color tokens](/tokens/#color).\n */\n@customElement('nord-progress-bar')\nexport default class ProgressBar extends FocusableMixin(LitElement) {\n static styles = [componentStyle, style]\n\n /**\n * Specifies how much of the task has been completed. Must be a valid floating\n * point number between 0 and max, or between 0 and 100 if max is omitted. If\n * there is no value, the progress bar is indeterminate; this indicates that\n * an activity is ongoing with no indication of how long it’s expected to take.\n */\n @property({ reflect: true, type: Number }) value?: number\n\n /**\n * Describes how much work the task indicated by the progress element requires.\n * The max attribute, if present, must have a value greater than 0 and be a\n * valid floating point number.\n */\n @property({ reflect: true, type: Number }) max: number = 100\n\n /**\n * Accessible label for the progress indicator. Visually hidden, but shown\n * for assistive technology.\n */\n @property({ reflect: true }) label: string = 'Current progress'\n\n render() {\n /**\n * The Aria properties are required for now due to a Chrome bug.\n * In the future we can probably get rid of them. For context:\n * https://bugs.chromium.org/p/chromium/issues/detail?id=1310779\n */\n return html`<label>\n <nord-visually-hidden>${this.label}</nord-visually-hidden>\n <progress\n ${ref(this.focusableRef)}\n aria-valuenow=${ifDefined(this.value)}\n aria-valuemin=\"0\"\n aria-valuemax=${this.max}\n tabindex=\"-1\"\n max=${this.max}\n value=${ifDefined(this.value)}\n ></progress>\n </label>`\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nord-progress-bar': ProgressBar\n }\n}\n"],"names":["ProgressBar","FocusableMixin","LitElement","constructor","this","max","label","render","html","ref","focusableRef","ifDefined","value","styles","componentStyle","style","__decorate","property","reflect","type","Number","prototype","customElement"],"mappings":"0wDAsBe,IAAMA,EAAN,cAA0BC,EAAeC,IAAzC,WAAAC,uBAgB8BC,KAAGC,IAAW,IAM5BD,KAAKE,MAAW,kBAqB9C,CAnBC,MAAAC,GAME,OAAOC,CAAI,gCACeJ,KAAKE,yCAEzBG,EAAIL,KAAKM,gCACKC,EAAUP,KAAKQ,4CAEfR,KAAKC,2BAEfD,KAAKC,eACHM,EAAUP,KAAKQ,6BAG5B,GAzCMZ,EAAAa,OAAS,CAACC,EAAgBC,GAQUC,EAAA,CAA1CC,EAAS,CAAEC,SAAS,EAAMC,KAAMC,UAAwBpB,EAAAqB,UAAA,aAAA,GAOdL,EAAA,CAA1CC,EAAS,CAAEC,SAAS,EAAMC,KAAMC,UAA2BpB,EAAAqB,UAAA,WAAA,GAM/BL,EAAA,CAA5BC,EAAS,CAAEC,SAAS,KAA0ClB,EAAAqB,UAAA,aAAA,GAtB5CrB,EAAWgB,EAAA,CAD/BM,EAAc,sBACMtB,SAAAA"}
|
package/lib/Qrcode.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{_ as t}from"./tslib.es6-CmLYFWVC.js";import{css as e,LitElement as r,html as o}from"lit";import{query as n,property as i,customElement as l}from"lit/decorators.js";import{styleMap as a}from"lit/directives/style-map.js";import{o as h}from"./observe-D0n0zOfU.js";import{s}from"./Component-
|
|
1
|
+
import{_ as t}from"./tslib.es6-CmLYFWVC.js";import{css as e,LitElement as r,html as o}from"lit";import{query as n,property as i,customElement as l}from"lit/decorators.js";import{styleMap as a}from"lit/directives/style-map.js";import{o as h}from"./observe-D0n0zOfU.js";import{s}from"./Component-BJ5O5n8k.js";
|
|
2
2
|
/*!
|
|
3
3
|
Copyright (c) 2023 Paul Miller (paulmillr.com)
|
|
4
4
|
The library paulmillr-qr is dual-licensed under the Apache 2.0 OR MIT license.
|
|
@@ -15,5 +15,5 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
15
15
|
See the License for the specific language governing permissions and
|
|
16
16
|
limitations under the License.
|
|
17
17
|
*/
|
|
18
|
-
const c=10,d=27;function f(t,e){return t.toString(2).padStart(e,"0")}function u(t,e){const r=t%e;return r>=0?r:e+r}function g(t,e){return new Array(t).fill(e)}function m(...t){let e=0;for(const r of t)e=Math.max(e,r.length);const r=[];for(let o=0;o<e;o++)for(const e of t)o>=e.length||r.push(e[o]);return new Uint8Array(r)}function w(t,e,r){if(r<0||r+e.length>t.length)return!1;for(let o=0;o<e.length;o++)if(e[o]!==t[r+o])return!1;return!0}function p(t){return{has:e=>t.includes(e),decode:e=>{if(!Array.isArray(e)||e.length&&"string"!=typeof e[0])throw new Error("alphabet.decode input should be array of strings");return e.map((e=>{if("string"!=typeof e)throw new Error(`alphabet.decode: not string element=${e}`);const r=t.indexOf(e);if(-1===r)throw new Error(`Unknown letter: "${e}". Allowed: ${t}`);return r}))},encode:e=>{if(!Array.isArray(e)||e.length&&"number"!=typeof e[0])throw new Error("alphabet.encode input should be an array of numbers");return e.map((e=>{if(function(t){if(!Number.isSafeInteger(t))throw new Error(`integer expected: ${t}`)}(e),e<0||e>=t.length)throw new Error(`Digit index outside alphabet: ${e} (alphabet: ${t.length})`);return t[e]}))}}}class y{static size(t,e){if("number"==typeof t&&(t={height:t,width:t}),!Number.isSafeInteger(t.height)&&t.height!==1/0)throw new Error(`Bitmap: invalid height=${t.height} (${typeof t.height})`);if(!Number.isSafeInteger(t.width)&&t.width!==1/0)throw new Error(`Bitmap: invalid width=${t.width} (${typeof t.width})`);return void 0!==e&&(t={width:Math.min(t.width,e.width),height:Math.min(t.height,e.height)}),t}static fromString(t){const e=(t=t.replace(/^\n+/g,"").replace(/\n+$/g,"")).split(String.fromCharCode(c)),r=e.length,o=new Array(r);let n;for(const t of e){const e=t.split("").map((t=>{if("X"===t)return!0;if(" "===t)return!1;if("?"!==t)throw new Error(`Bitmap.fromString: unknown symbol=${t}`)}));if(n&&e.length!==n)throw new Error(`Bitmap.fromString different row sizes: width=${n} cur=${e.length}`);n=e.length,o.push(e)}return n||(n=0),new y({height:r,width:n},o)}constructor(t,e){const{height:r,width:o}=y.size(t);this.data=e||Array.from({length:r},(()=>g(o,void 0))),this.height=r,this.width=o}point(t){return this.data[t.y][t.x]}isInside(t){return 0<=t.x&&t.x<this.width&&0<=t.y&&t.y<this.height}size(t){if(!t)return{height:this.height,width:this.width};const{x:e,y:r}=this.xy(t);return{height:this.height-r,width:this.width-e}}xy(t){if("number"==typeof t&&(t={x:t,y:t}),!Number.isSafeInteger(t.x))throw new Error(`Bitmap: invalid x=${t.x}`);if(!Number.isSafeInteger(t.y))throw new Error(`Bitmap: invalid y=${t.y}`);return t.x=u(t.x,this.width),t.y=u(t.y,this.height),t}rect(t,e,r){const{x:o,y:n}=this.xy(t),{height:i,width:l}=y.size(e,this.size({x:o,y:n}));for(let t=0;t<i;t++)for(let e=0;e<l;e++)this.data[n+t][o+e]="function"==typeof r?r({x:e,y:t},this.data[n+t][o+e]):r;return this}rectRead(t,e,r){return this.rect(t,e,((t,e)=>(r(t,e),e)))}hLine(t,e,r){return this.rect(t,{width:e,height:1},r)}vLine(t,e,r){return this.rect(t,{width:1,height:e},r)}border(t=2,e){const r=this.height+2*t,o=this.width+2*t,n=g(t,e),i=Array.from({length:t},(()=>g(o,e)));return new y({height:r,width:o},[...i,...this.data.map((t=>[...n,...t,...n])),...i])}embed(t,e){return this.rect(t,e.size(),(({x:t,y:r})=>e.data[r][t]))}rectSlice(t,e=this.size()){const r=new y(y.size(e,this.size(this.xy(t))));return this.rect(t,e,(({x:t,y:e},o)=>r.data[e][t]=o)),r}inverse(){const{height:t,width:e}=this;return new y({height:e,width:t}).rect({x:0,y:0},1/0,(({x:t,y:e})=>this.data[t][e]))}scale(t){if(!Number.isSafeInteger(t)||t>1024)throw new Error(`invalid scale factor: ${t}`);const{height:e,width:r}=this;return new y({height:t*e,width:t*r}).rect({x:0,y:0},1/0,(({x:e,y:r})=>this.data[Math.floor(r/t)][Math.floor(e/t)]))}clone(){return new y(this.size()).rect({x:0,y:0},this.size(),(({x:t,y:e})=>this.data[e][t]))}assertDrawn(){this.rectRead(0,1/0,((t,e)=>{if("boolean"!=typeof e)throw new Error("Invalid color type="+typeof e)}))}toString(){return this.data.map((t=>t.map((t=>void 0===t?"?":t?"X":" ")).join(""))).join(String.fromCharCode(c))}toASCII(){const{height:t,width:e,data:r}=this;let o="";for(let n=0;n<t;n+=2){for(let i=0;i<e;i++){const e=r[n][i],l=n+1>=t||r[n+1][i];e||l?!e&&l?o+="▀":e&&!l?o+="▄":e&&l&&(o+=" "):o+="█"}o+=String.fromCharCode(c)}return o}toTerm(){const t=String.fromCharCode(d),e=t+"[0m",r=t+"[1;47m "+e,o=t+"[40m "+e;return this.data.map((t=>t.map((t=>t?o:r)).join(""))).join(String.fromCharCode(c))}toSVG(t=!0){let e,r=`<svg viewBox="0 0 ${this.width} ${this.height}" xmlns="http://www.w3.org/2000/svg">`,o="";return this.rectRead(0,1/0,((n,i)=>{if(!i)return;const{x:l,y:a}=n;if(!t)return void(r+=`<rect x="${l}" y="${a}" width="1" height="1" />`);let h=`M${l} ${a}`;if(e){const t=`m${l-e.x} ${a-e.y}`;t.length<=h.length&&(h=t)}o+=`${h}h1v1${l<10?`H${l}`:"h-1"}Z`,e=n})),t&&(r+=`<path d="${o}"/>`),r+="</svg>",r}toGIF(){const t=t=>[255&t,t>>>8&255],e=[...t(this.width),...t(this.height)],r=[];this.rectRead(0,1/0,((t,e)=>r.push(+(!0===e))));const o=126,n=[71,73,70,56,55,97,...e,246,0,0,255,255,255,...g(381,0),44,0,0,0,0,...e,0,7],i=Math.floor(r.length/o);for(let t=0;t<i;t++)n.push(127,128,...r.slice(o*t,o*(t+1)).map((t=>+t)));return n.push(r.length%o+1,128,...r.slice(i*o).map((t=>+t))),n.push(1,129,0,59),new Uint8Array(n)}toImage(t=!1){const{height:e,width:r}=this.size(),o=new Uint8Array(e*r*(t?3:4));let n=0;for(let i=0;i<e;i++)for(let e=0;e<r;e++){const r=this.data[i][e]?0:255;o[n++]=r,o[n++]=r,o[n++]=r,t||(o[n++]=255)}return{height:e,width:r,data:o}}}const v=["low","medium","quartile","high"],b=["numeric","alphanumeric","byte","kanji","eci"],x=[26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706],$={low:[7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],medium:[10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],quartile:[13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],high:[17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]},E={low:[1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],medium:[1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],quartile:[1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],high:[1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]},S={size:{encode:t=>21+4*(t-1),decode:t=>(t-17)/4},sizeType:t=>Math.floor((t+7)/17),alignmentPatterns(t){if(1===t)return[];const e=S.size.encode(t)-6-1,r=e-6,o=Math.ceil(r/28);let n=Math.floor(r/o);n%2?n+=1:r%o*2>=o&&(n+=2);const i=[6];for(let t=1;t<o;t++)i.push(e-(o-t)*n);return i.push(e),i},ECCode:{low:1,medium:0,quartile:3,high:2},formatMask:21522,formatBits(t,e){const r=S.ECCode[t]<<3|e;let o=r;for(let t=0;t<10;t++)o=o<<1^1335*(o>>9);return(r<<10|o)^S.formatMask},versionBits(t){let e=t;for(let t=0;t<12;t++)e=e<<1^7973*(e>>11);return t<<12|e},alphabet:{numeric:p("0123456789"),alphanumerc:p("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:")},lengthBits:(t,e)=>({numeric:[10,12,14],alphanumeric:[9,11,13],byte:[8,16,16],kanji:[8,10,12],eci:[0,0,0]}[e][S.sizeType(t)]),modeBits:{numeric:"0001",alphanumeric:"0010",byte:"0100",kanji:"1000",eci:"0111"},capacity(t,e){const r=x[t-1],o=$[e][t-1],n=E[e][t-1],i=Math.floor(r/n)-o,l=n-r%n;return{words:o,numBlocks:n,shortBlocks:l,blockLen:i,capacity:8*(r-o*n),total:(o+i)*n+n-l}}},k=[(t,e)=>(t+e)%2==0,(t,e)=>e%2==0,(t,e)=>t%3==0,(t,e)=>(t+e)%3==0,(t,e)=>(Math.floor(e/2)+Math.floor(t/3))%2==0,(t,e)=>t*e%2+t*e%3==0,(t,e)=>(t*e%2+t*e%3)%2==0,(t,e)=>((t+e)%2+t*e%3)%2==0],z={tables:(()=>{const t=g(256,0),e=g(256,0);for(let r=0,o=1;r<256;r++)t[r]=o,e[o]=r,o<<=1,256&o&&(o^=285);return{exp:t,log:e}})(),exp:t=>z.tables.exp[t],log(t){if(0===t)throw new Error(`GF.log: invalid arg=${t}`);return z.tables.log[t]%255},mul:(t,e)=>0===t||0===e?0:z.tables.exp[(z.tables.log[t]+z.tables.log[e])%255],add:(t,e)=>t^e,pow:(t,e)=>z.tables.exp[z.tables.log[t]*e%255],inv(t){if(0===t)throw new Error(`GF.inverse: invalid arg=${t}`);return z.tables.exp[255-z.tables.log[t]]},polynomial(t){if(0==t.length)throw new Error("GF.polymomial: invalid length");if(0!==t[0])return t;let e=0;for(;e<t.length-1&&0==t[e];e++);return t.slice(e)},monomial(t,e){if(t<0)throw new Error(`GF.monomial: invalid degree=${t}`);if(0==e)return[0];let r=g(t+1,0);return r[0]=e,z.polynomial(r)},degree:t=>t.length-1,coefficient:(t,e)=>t[z.degree(t)-e],mulPoly(t,e){if(0===t[0]||0===e[0])return[0];const r=g(t.length+e.length-1,0);for(let o=0;o<t.length;o++)for(let n=0;n<e.length;n++)r[o+n]=z.add(r[o+n],z.mul(t[o],e[n]));return z.polynomial(r)},mulPolyScalar(t,e){if(0==e)return[0];if(1==e)return t;const r=g(t.length,0);for(let o=0;o<t.length;o++)r[o]=z.mul(t[o],e);return z.polynomial(r)},mulPolyMonomial(t,e,r){if(e<0)throw new Error("GF.mulPolyMonomial: invalid degree");if(0==r)return[0];const o=g(t.length+e,0);for(let e=0;e<t.length;e++)o[e]=z.mul(t[e],r);return z.polynomial(o)},addPoly(t,e){if(0===t[0])return e;if(0===e[0])return t;let r=t,o=e;r.length>o.length&&([r,o]=[o,r]);let n=g(o.length,0),i=o.length-r.length,l=o.slice(0,i);for(let t=0;t<l.length;t++)n[t]=l[t];for(let t=i;t<o.length;t++)n[t]=z.add(r[t-i],o[t]);return z.polynomial(n)},remainderPoly(t,e){const r=Array.from(t);for(let o=0;o<t.length-e.length+1;o++){const t=r[o];if(0!==t)for(let n=1;n<e.length;n++)0!==e[n]&&(r[o+n]=z.add(r[o+n],z.mul(e[n],t)))}return r.slice(t.length-e.length+1,r.length)},divisorPoly(t){let e=[1];for(let r=0;r<t;r++)e=z.mulPoly(e,[1,z.pow(2,r)]);return e},evalPoly(t,e){if(0==e)return z.coefficient(t,0);let r=t[0];for(let o=1;o<t.length;o++)r=z.add(z.mul(e,r),t[o]);return r},euclidian(t,e,r){z.degree(t)<z.degree(e)&&([t,e]=[e,t]);let o=t,n=e,i=[0],l=[1];for(;2*z.degree(n)>=r;){let t=o,e=i;if(o=n,i=l,0===o[0])throw new Error("rLast[0] === 0");n=t;let r=[0];const a=z.inv(o[0]);for(;z.degree(n)>=z.degree(o)&&0!==n[0];){const t=z.degree(n)-z.degree(o),e=z.mul(n[0],a);r=z.addPoly(r,z.monomial(t,e)),n=z.addPoly(n,z.mulPolyMonomial(o,t,e))}if(r=z.mulPoly(r,i),l=z.addPoly(r,e),z.degree(n)>=z.degree(o))throw new Error(`Division failed r: ${n}, rLast: ${o}`)}const a=z.coefficient(l,0);if(0==a)throw new Error("sigmaTilde(0) was zero");const h=z.inv(a);return[z.mulPolyScalar(l,h),z.mulPolyScalar(n,h)]}};function A(t,e){const{words:r,shortBlocks:o,numBlocks:n,blockLen:i,total:l}=S.capacity(t,e),a=(h=r,{encode(t){const e=z.divisorPoly(h),r=Array.from(t);return r.push(...e.slice(0,-1).fill(0)),Uint8Array.from(z.remainderPoly(r,e))},decode(t){const e=t.slice(),r=z.polynomial(Array.from(t));let o=g(h,0),n=!1;for(let t=0;t<h;t++){const e=z.evalPoly(r,z.exp(t));o[o.length-1-t]=e,0!==e&&(n=!0)}if(!n)return e;o=z.polynomial(o);const i=z.monomial(h,1),[l,a]=z.euclidian(i,o,h),s=g(z.degree(l),0);let c=0;for(let t=1;t<256&&c<s.length;t++)0===z.evalPoly(l,t)&&(s[c++]=z.inv(t));if(c!==s.length)throw new Error("RS.decode: invalid errors number");for(let t=0;t<s.length;t++){const r=e.length-1-z.log(s[t]);if(r<0)throw new Error("RS.decode: invalid error location");const o=z.inv(s[t]);let n=1;for(let e=0;e<s.length;e++)t!==e&&(n=z.mul(n,z.add(1,z.mul(s[e],o))));e[r]=z.add(e[r],z.mul(z.evalPoly(a,o),z.inv(n)))}return e}});var h;return{encode(t){const e=[],r=[];for(let l=0;l<n;l++){const n=i+(l<o?0:1);e.push(t.subarray(0,n)),r.push(a.encode(t.subarray(0,n))),t=t.subarray(n)}const l=m(...e),h=m(...r),s=new Uint8Array(l.length+h.length);return s.set(l),s.set(h,l.length),s},decode(t){if(t.length!==l)throw new Error(`interleave.decode: len(data)=${t.length}, total=${l}`);const e=[];for(let t=0;t<n;t++){const n=t<o;e.push(new Uint8Array(r+i+(n?0:1)))}let h=0;for(let r=0;r<i;r++)for(let o=0;o<n;o++)e[o][r]=t[h++];for(let r=o;r<n;r++)e[r][i]=t[h++];for(let l=i;l<i+r;l++)for(let r=0;r<n;r++){const n=r<o;e[r][l+(n?0:1)]=t[h++]}const s=[];for(const t of e)s.push(...Array.from(a.decode(t)).slice(0,-r));return Uint8Array.from(s)}}}function M(t,e,r,o){let n="",i=r.length;if("numeric"===o){const t=S.alphabet.numeric.decode(r.split("")),e=t.length;for(let r=0;r<e-2;r+=3)n+=f(100*t[r]+10*t[r+1]+t[r+2],10);e%3==1?n+=f(t[e-1],4):e%3==2&&(n+=f(10*t[e-2]+t[e-1],7))}else if("alphanumeric"===o){const t=S.alphabet.alphanumerc.decode(r.split("")),e=t.length;for(let r=0;r<e-1;r+=2)n+=f(45*t[r]+t[r+1],11);e%2==1&&(n+=f(t[e-1],6))}else{if("byte"!==o)throw new Error("encode: unsupported type");{const t=function(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}(r);i=t.length,n=Array.from(t).map((t=>f(t,8))).join("")}}const{capacity:l}=S.capacity(t,e),a=f(i,S.lengthBits(t,o));let h=S.modeBits[o]+a+n;if(h.length>l)throw new Error("Capacity overflow");h+="0".repeat(Math.min(4,Math.max(0,l-h.length))),h.length%8&&(h+="0".repeat(8-h.length%8));const s="1110110000010001";for(let t=0;h.length!==l;t++)h+=s[t%16];const c=Uint8Array.from(h.match(/(.{8})/g).map((t=>Number(`0b${t}`))));return A(t,e).encode(c)}function P(t,e,r,o,n=!1){const i=function(t,e,r,o=!1){const n=S.size.encode(t);let i=new y(n+2);const l=new y(3).rect(0,3,!0).border(1,!1).border(1,!0).border(1,!1);i=i.embed(0,l).embed({x:-l.width,y:0},l).embed({x:0,y:-l.height},l),i=i.rectSlice(1,n);const a=new y(1).rect(0,1,!0).border(1,!1).border(1,!0),h=S.alignmentPatterns(t);for(const t of h)for(const e of h)void 0===i.data[t][e]&&i.embed({x:e-2,y:t-2},a);i=i.hLine({x:0,y:6},1/0,(({x:t},e)=>void 0===e?t%2==0:e)).vLine({x:6,y:0},1/0,(({y:t},e)=>void 0===e?t%2==0:e));{const t=S.formatBits(e,r),l=e=>!o&&1==(t>>e&1);for(let t=0;t<6;t++)i.data[t][8]=l(t);for(let t=6;t<8;t++)i.data[t+1][8]=l(t);for(let t=8;t<15;t++)i.data[n-15+t][8]=l(t);for(let t=0;t<8;t++)i.data[8][n-t-1]=l(t);for(let t=8;t<9;t++)i.data[8][15-t-1+1]=l(t);for(let t=9;t<15;t++)i.data[8][15-t-1]=l(t);i.data[n-8][8]=!o}if(t>=7){const e=S.versionBits(t);for(let t=0;t<18;t+=1){const r=!o&&1==(e>>t&1),l=Math.floor(t/3),a=t%3+n-8-3;i.data[l][a]=r,i.data[a][l]=r}}return i}(t,e,o,n);let l=0;const a=8*r.length;if(function(t,e,r){const o=t.height,n=k[e];let i=-1,l=o-1;for(let e=o-1;e>0;e-=2){for(6==e&&(e=5);;l+=i){for(let o=0;o<2;o+=1){const i=e-o;void 0===t.data[l][i]&&r(i,l,n(i,l))}if(l+i<0||l+i>=o)break}i=-i}}(i,o,((t,e,o)=>{let n=!1;l<a&&(n=!!(r[l>>>3]>>(7-l&7)&1),l++),i.data[e][t]=n!==o})),l!==a)throw new Error("QR: bytes left after draw");return i}function C(t){const e=t.inverse(),r=t=>{let e=0;for(let r,o=0,n=1;o<t.length;o++)r===t[o]&&(n++,o!==t.length-1)||(n>=5&&(e+=n-5+3),r=t[o],n=1);return e};let o=0;t.data.forEach((t=>o+=r(t))),e.data.forEach((t=>o+=r(t)));let n=0,i=t.data;const l=t.width-1,a=t.height-1;for(let t=0;t<l;t++)for(let e=0;e<a;e++){const r=t+1,o=e+1;i[t][e]===i[r][e]&&i[r][e]===i[t][o]&&i[r][e]===i[r][o]&&(n+=3)}const h=t=>{const e=[!0,!1,!0,!0,!0,!1,!0],r=[!1,!1,!1,!1],o=[...e,...r],n=[...r,...e];let i=0;for(let e=0;e<t.length;e++)w(t,o,e)&&(i+=40),w(t,n,e)&&(i+=40);return i};let s=0;for(const e of t.data)s+=h(e);for(const t of e.data)s+=h(t);let c=0;t.rectRead(0,1/0,((t,e)=>c+=e?1:0));const d=c/(t.height*t.width)*100,f=10*Math.floor(Math.abs(d-50)/5);return o+n+s+f}function B(t,e="raw",r={}){const o=void 0!==r.ecc?r.ecc:"medium";!function(t){if(!v.includes(t))throw new Error(`Invalid error correction mode=${t}. Expected: ${v}`)}(o);const n=void 0!==r.encoding?r.encoding:function(t){let e="numeric";for(let r of t)if(!S.alphabet.numeric.has(r)&&(e="alphanumeric",!S.alphabet.alphanumerc.has(r)))return"byte";return e}(t);!function(t){if(!b.includes(t))throw new Error(`Encoding: invalid mode=${t}. Expected: ${b}`);if("kanji"===t||"eci"===t)throw new Error(`Encoding: ${t} is not supported (yet?).`)}(n),void 0!==r.mask&&function(t){if(![0,1,2,3,4,5,6,7].includes(t)||!k[t])throw new Error(`Invalid mask=${t}. Expected number [0..7]`)}(r.mask);let i,l=r.version,a=new Error("Unknown error");if(void 0!==l)!function(t){if(!Number.isSafeInteger(t)||t<1||t>40)throw new Error(`Invalid version=${t}. Expected number [1..40]`)}(l),i=M(l,o,t,n);else for(let e=1;e<=40;e++)try{i=M(e,o,t,n),l=e;break}catch(t){a=t}if(!l||!i)throw a;let h=function(t,e,r,o){if(void 0===o){const n=function(){let t,e=1/0;return{add(r,o){r>=e||(t=o,e=r)},get:()=>t,score:()=>e}}();for(let o=0;o<k.length;o++)n.add(C(P(t,e,r,o,!0)),o);o=n.get()}if(void 0===o)throw new Error("Cannot find mask");return P(t,e,r,o)}(l,o,i,r.mask);h.assertDrawn();const s=void 0===r.border?2:r.border;if(!Number.isSafeInteger(s))throw new Error("invalid border type="+typeof s);if(h=h.border(s,!1),void 0!==r.scale&&(h=h.scale(r.scale)),"raw"===e)return h.data;if("ascii"===e)return h.toASCII();if("svg"===e)return h.toSVG(r.optimize);if("gif"===e)return h.toGIF();if("term"===e)return h.toTerm();throw new Error(`Unknown output: ${e}`)}const I=e`:host{display:inline-block}.n-qrcode{position:relative}canvas{position:absolute;inset-block-start:0;inset-inline-start:0;inline-size:100%;block-size:100%}`,U={L:"low",M:"medium",Q:"quartile",H:"high"};let j=class extends r{constructor(){super(...arguments),this.value="",this.label="",this.size=128,this.color="var(--n-color-text)",this.background="var(--n-color-surface)",this.correction="H"}firstUpdated(){this.generate()}generate(){if(!this.hasUpdated)return;const{backgroundColor:t,color:e}=getComputedStyle(this.computed),r=B(this.value,"raw",{ecc:U[this.correction],border:0}),o=2*this.size,n=this.canvas.getContext("2d"),i=o/r.length;this.canvas.width=o,this.canvas.height=o,n&&(n.fillStyle=t,n.fillRect(0,0,o,o),r.forEach(((t,r)=>{t.forEach(((t,o)=>{t&&(n.fillStyle=e,n.fillRect(o*i,r*i,i,i))}))})))}render(){return o`<div class="n-qrcode" style="${a({"inline-size":`${this.size}px`,"block-size":`${this.size}px`})}"><canvas role="img" aria-label="${this.label.length>0?this.label:this.value}"></canvas></div><div class="computed" hidden style="${a({"background-color":`${this.background}`,color:`${this.color}`})}"></div>`}};j.styles=[s,I],t([n("canvas",!0)],j.prototype,"canvas",void 0),t([n(".computed",!0)],j.prototype,"computed",void 0),t([i({reflect:!0})],j.prototype,"value",void 0),t([i({reflect:!0})],j.prototype,"label",void 0),t([i({reflect:!0,type:Number})],j.prototype,"size",void 0),t([i({reflect:!0})],j.prototype,"color",void 0),t([i({reflect:!0})],j.prototype,"background",void 0),t([i({reflect:!0})],j.prototype,"correction",void 0),t([h("correction"),h("color"),h("background"),h("size"),h("value")],j.prototype,"generate",null),j=t([l("nord-qrcode")],j);var N=j;export{N as default};
|
|
18
|
+
const c=10,d=27;function f(t,e){return t.toString(2).padStart(e,"0")}function u(t,e){const r=t%e;return r>=0?r:e+r}function g(t,e){return new Array(t).fill(e)}function m(...t){let e=0;for(const r of t)e=Math.max(e,r.length);const r=[];for(let o=0;o<e;o++)for(const e of t)o>=e.length||r.push(e[o]);return new Uint8Array(r)}function w(t,e,r){if(r<0||r+e.length>t.length)return!1;for(let o=0;o<e.length;o++)if(e[o]!==t[r+o])return!1;return!0}function p(t){return{has:e=>t.includes(e),decode:e=>{if(!Array.isArray(e)||e.length&&"string"!=typeof e[0])throw new Error("alphabet.decode input should be array of strings");return e.map((e=>{if("string"!=typeof e)throw new Error(`alphabet.decode: not string element=${e}`);const r=t.indexOf(e);if(-1===r)throw new Error(`Unknown letter: "${e}". Allowed: ${t}`);return r}))},encode:e=>{if(!Array.isArray(e)||e.length&&"number"!=typeof e[0])throw new Error("alphabet.encode input should be an array of numbers");return e.map((e=>{if(function(t){if(!Number.isSafeInteger(t))throw new Error(`integer expected: ${t}`)}(e),e<0||e>=t.length)throw new Error(`Digit index outside alphabet: ${e} (alphabet: ${t.length})`);return t[e]}))}}}class y{static size(t,e){if("number"==typeof t&&(t={height:t,width:t}),!Number.isSafeInteger(t.height)&&t.height!==1/0)throw new Error(`Bitmap: invalid height=${t.height} (${typeof t.height})`);if(!Number.isSafeInteger(t.width)&&t.width!==1/0)throw new Error(`Bitmap: invalid width=${t.width} (${typeof t.width})`);return void 0!==e&&(t={width:Math.min(t.width,e.width),height:Math.min(t.height,e.height)}),t}static fromString(t){const e=(t=t.replace(/^\n+/g,"").replace(/\n+$/g,"")).split(String.fromCharCode(c)),r=e.length,o=new Array(r);let n;for(const t of e){const e=t.split("").map((t=>{if("X"===t)return!0;if(" "===t)return!1;if("?"!==t)throw new Error(`Bitmap.fromString: unknown symbol=${t}`)}));if(n&&e.length!==n)throw new Error(`Bitmap.fromString different row sizes: width=${n} cur=${e.length}`);n=e.length,o.push(e)}return n||(n=0),new y({height:r,width:n},o)}constructor(t,e){const{height:r,width:o}=y.size(t);this.data=e||Array.from({length:r},(()=>g(o,void 0))),this.height=r,this.width=o}point(t){return this.data[t.y][t.x]}isInside(t){return 0<=t.x&&t.x<this.width&&0<=t.y&&t.y<this.height}size(t){if(!t)return{height:this.height,width:this.width};const{x:e,y:r}=this.xy(t);return{height:this.height-r,width:this.width-e}}xy(t){if("number"==typeof t&&(t={x:t,y:t}),!Number.isSafeInteger(t.x))throw new Error(`Bitmap: invalid x=${t.x}`);if(!Number.isSafeInteger(t.y))throw new Error(`Bitmap: invalid y=${t.y}`);return t.x=u(t.x,this.width),t.y=u(t.y,this.height),t}rect(t,e,r){const{x:o,y:n}=this.xy(t),{height:i,width:l}=y.size(e,this.size({x:o,y:n}));for(let t=0;t<i;t++)for(let e=0;e<l;e++)this.data[n+t][o+e]="function"==typeof r?r({x:e,y:t},this.data[n+t][o+e]):r;return this}rectRead(t,e,r){return this.rect(t,e,((t,e)=>(r(t,e),e)))}hLine(t,e,r){return this.rect(t,{width:e,height:1},r)}vLine(t,e,r){return this.rect(t,{width:1,height:e},r)}border(t=2,e){const r=this.height+2*t,o=this.width+2*t,n=g(t,e),i=Array.from({length:t},(()=>g(o,e)));return new y({height:r,width:o},[...i,...this.data.map((t=>[...n,...t,...n])),...i])}embed(t,e){return this.rect(t,e.size(),(({x:t,y:r})=>e.data[r][t]))}rectSlice(t,e=this.size()){const r=new y(y.size(e,this.size(this.xy(t))));return this.rect(t,e,(({x:t,y:e},o)=>r.data[e][t]=o)),r}inverse(){const{height:t,width:e}=this;return new y({height:e,width:t}).rect({x:0,y:0},1/0,(({x:t,y:e})=>this.data[t][e]))}scale(t){if(!Number.isSafeInteger(t)||t>1024)throw new Error(`invalid scale factor: ${t}`);const{height:e,width:r}=this;return new y({height:t*e,width:t*r}).rect({x:0,y:0},1/0,(({x:e,y:r})=>this.data[Math.floor(r/t)][Math.floor(e/t)]))}clone(){return new y(this.size()).rect({x:0,y:0},this.size(),(({x:t,y:e})=>this.data[e][t]))}assertDrawn(){this.rectRead(0,1/0,((t,e)=>{if("boolean"!=typeof e)throw new Error("Invalid color type="+typeof e)}))}toString(){return this.data.map((t=>t.map((t=>void 0===t?"?":t?"X":" ")).join(""))).join(String.fromCharCode(c))}toASCII(){const{height:t,width:e,data:r}=this;let o="";for(let n=0;n<t;n+=2){for(let i=0;i<e;i++){const e=r[n][i],l=n+1>=t||r[n+1][i];e||l?!e&&l?o+="▀":e&&!l?o+="▄":e&&l&&(o+=" "):o+="█"}o+=String.fromCharCode(c)}return o}toTerm(){const t=String.fromCharCode(d),e=t+"[0m",r=t+"[1;47m "+e,o=t+"[40m "+e;return this.data.map((t=>t.map((t=>t?o:r)).join(""))).join(String.fromCharCode(c))}toSVG(t=!0){let e,r=`<svg viewBox="0 0 ${this.width} ${this.height}" xmlns="http://www.w3.org/2000/svg">`,o="";return this.rectRead(0,1/0,((n,i)=>{if(!i)return;const{x:l,y:a}=n;if(!t)return void(r+=`<rect x="${l}" y="${a}" width="1" height="1" />`);let h=`M${l} ${a}`;if(e){const t=`m${l-e.x} ${a-e.y}`;t.length<=h.length&&(h=t)}o+=`${h}h1v1${l<10?`H${l}`:"h-1"}Z`,e=n})),t&&(r+=`<path d="${o}"/>`),r+="</svg>",r}toGIF(){const t=t=>[255&t,t>>>8&255],e=[...t(this.width),...t(this.height)],r=[];this.rectRead(0,1/0,((t,e)=>r.push(+(!0===e))));const o=126,n=[71,73,70,56,55,97,...e,246,0,0,255,255,255,...g(381,0),44,0,0,0,0,...e,0,7],i=Math.floor(r.length/o);for(let t=0;t<i;t++)n.push(127,128,...r.slice(o*t,o*(t+1)).map((t=>+t)));return n.push(r.length%o+1,128,...r.slice(i*o).map((t=>+t))),n.push(1,129,0,59),new Uint8Array(n)}toImage(t=!1){const{height:e,width:r}=this.size(),o=new Uint8Array(e*r*(t?3:4));let n=0;for(let i=0;i<e;i++)for(let e=0;e<r;e++){const r=this.data[i][e]?0:255;o[n++]=r,o[n++]=r,o[n++]=r,t||(o[n++]=255)}return{height:e,width:r,data:o}}}const v=["low","medium","quartile","high"],b=["numeric","alphanumeric","byte","kanji","eci"],x=[26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706],$={low:[7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],medium:[10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],quartile:[13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],high:[17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]},E={low:[1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],medium:[1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],quartile:[1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],high:[1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]},S={size:{encode:t=>21+4*(t-1),decode:t=>(t-17)/4},sizeType:t=>Math.floor((t+7)/17),alignmentPatterns(t){if(1===t)return[];const e=S.size.encode(t)-6-1,r=e-6,o=Math.ceil(r/28);let n=Math.floor(r/o);n%2?n+=1:r%o*2>=o&&(n+=2);const i=[6];for(let t=1;t<o;t++)i.push(e-(o-t)*n);return i.push(e),i},ECCode:{low:1,medium:0,quartile:3,high:2},formatMask:21522,formatBits(t,e){const r=S.ECCode[t]<<3|e;let o=r;for(let t=0;t<10;t++)o=o<<1^1335*(o>>9);return(r<<10|o)^S.formatMask},versionBits(t){let e=t;for(let t=0;t<12;t++)e=e<<1^7973*(e>>11);return t<<12|e},alphabet:{numeric:p("0123456789"),alphanumerc:p("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:")},lengthBits:(t,e)=>({numeric:[10,12,14],alphanumeric:[9,11,13],byte:[8,16,16],kanji:[8,10,12],eci:[0,0,0]}[e][S.sizeType(t)]),modeBits:{numeric:"0001",alphanumeric:"0010",byte:"0100",kanji:"1000",eci:"0111"},capacity(t,e){const r=x[t-1],o=$[e][t-1],n=E[e][t-1],i=Math.floor(r/n)-o,l=n-r%n;return{words:o,numBlocks:n,shortBlocks:l,blockLen:i,capacity:8*(r-o*n),total:(o+i)*n+n-l}}},k=[(t,e)=>(t+e)%2==0,(t,e)=>e%2==0,(t,e)=>t%3==0,(t,e)=>(t+e)%3==0,(t,e)=>(Math.floor(e/2)+Math.floor(t/3))%2==0,(t,e)=>t*e%2+t*e%3==0,(t,e)=>(t*e%2+t*e%3)%2==0,(t,e)=>((t+e)%2+t*e%3)%2==0],z={tables:(()=>{const t=g(256,0),e=g(256,0);for(let r=0,o=1;r<256;r++)t[r]=o,e[o]=r,o<<=1,256&o&&(o^=285);return{exp:t,log:e}})(),exp:t=>z.tables.exp[t],log(t){if(0===t)throw new Error(`GF.log: invalid arg=${t}`);return z.tables.log[t]%255},mul:(t,e)=>0===t||0===e?0:z.tables.exp[(z.tables.log[t]+z.tables.log[e])%255],add:(t,e)=>t^e,pow:(t,e)=>z.tables.exp[z.tables.log[t]*e%255],inv(t){if(0===t)throw new Error(`GF.inverse: invalid arg=${t}`);return z.tables.exp[255-z.tables.log[t]]},polynomial(t){if(0==t.length)throw new Error("GF.polymomial: invalid length");if(0!==t[0])return t;let e=0;for(;e<t.length-1&&0==t[e];e++);return t.slice(e)},monomial(t,e){if(t<0)throw new Error(`GF.monomial: invalid degree=${t}`);if(0==e)return[0];let r=g(t+1,0);return r[0]=e,z.polynomial(r)},degree:t=>t.length-1,coefficient:(t,e)=>t[z.degree(t)-e],mulPoly(t,e){if(0===t[0]||0===e[0])return[0];const r=g(t.length+e.length-1,0);for(let o=0;o<t.length;o++)for(let n=0;n<e.length;n++)r[o+n]=z.add(r[o+n],z.mul(t[o],e[n]));return z.polynomial(r)},mulPolyScalar(t,e){if(0==e)return[0];if(1==e)return t;const r=g(t.length,0);for(let o=0;o<t.length;o++)r[o]=z.mul(t[o],e);return z.polynomial(r)},mulPolyMonomial(t,e,r){if(e<0)throw new Error("GF.mulPolyMonomial: invalid degree");if(0==r)return[0];const o=g(t.length+e,0);for(let e=0;e<t.length;e++)o[e]=z.mul(t[e],r);return z.polynomial(o)},addPoly(t,e){if(0===t[0])return e;if(0===e[0])return t;let r=t,o=e;r.length>o.length&&([r,o]=[o,r]);let n=g(o.length,0),i=o.length-r.length,l=o.slice(0,i);for(let t=0;t<l.length;t++)n[t]=l[t];for(let t=i;t<o.length;t++)n[t]=z.add(r[t-i],o[t]);return z.polynomial(n)},remainderPoly(t,e){const r=Array.from(t);for(let o=0;o<t.length-e.length+1;o++){const t=r[o];if(0!==t)for(let n=1;n<e.length;n++)0!==e[n]&&(r[o+n]=z.add(r[o+n],z.mul(e[n],t)))}return r.slice(t.length-e.length+1,r.length)},divisorPoly(t){let e=[1];for(let r=0;r<t;r++)e=z.mulPoly(e,[1,z.pow(2,r)]);return e},evalPoly(t,e){if(0==e)return z.coefficient(t,0);let r=t[0];for(let o=1;o<t.length;o++)r=z.add(z.mul(e,r),t[o]);return r},euclidian(t,e,r){z.degree(t)<z.degree(e)&&([t,e]=[e,t]);let o=t,n=e,i=[0],l=[1];for(;2*z.degree(n)>=r;){let t=o,e=i;if(o=n,i=l,0===o[0])throw new Error("rLast[0] === 0");n=t;let r=[0];const a=z.inv(o[0]);for(;z.degree(n)>=z.degree(o)&&0!==n[0];){const t=z.degree(n)-z.degree(o),e=z.mul(n[0],a);r=z.addPoly(r,z.monomial(t,e)),n=z.addPoly(n,z.mulPolyMonomial(o,t,e))}if(r=z.mulPoly(r,i),l=z.addPoly(r,e),z.degree(n)>=z.degree(o))throw new Error(`Division failed r: ${n}, rLast: ${o}`)}const a=z.coefficient(l,0);if(0==a)throw new Error("sigmaTilde(0) was zero");const h=z.inv(a);return[z.mulPolyScalar(l,h),z.mulPolyScalar(n,h)]}};function A(t,e){const{words:r,shortBlocks:o,numBlocks:n,blockLen:i,total:l}=S.capacity(t,e),a=(h=r,{encode(t){const e=z.divisorPoly(h),r=Array.from(t);return r.push(...e.slice(0,-1).fill(0)),Uint8Array.from(z.remainderPoly(r,e))},decode(t){const e=t.slice(),r=z.polynomial(Array.from(t));let o=g(h,0),n=!1;for(let t=0;t<h;t++){const e=z.evalPoly(r,z.exp(t));o[o.length-1-t]=e,0!==e&&(n=!0)}if(!n)return e;o=z.polynomial(o);const i=z.monomial(h,1),[l,a]=z.euclidian(i,o,h),s=g(z.degree(l),0);let c=0;for(let t=1;t<256&&c<s.length;t++)0===z.evalPoly(l,t)&&(s[c++]=z.inv(t));if(c!==s.length)throw new Error("RS.decode: invalid errors number");for(let t=0;t<s.length;t++){const r=e.length-1-z.log(s[t]);if(r<0)throw new Error("RS.decode: invalid error location");const o=z.inv(s[t]);let n=1;for(let e=0;e<s.length;e++)t!==e&&(n=z.mul(n,z.add(1,z.mul(s[e],o))));e[r]=z.add(e[r],z.mul(z.evalPoly(a,o),z.inv(n)))}return e}});var h;return{encode(t){const e=[],r=[];for(let l=0;l<n;l++){const n=i+(l<o?0:1);e.push(t.subarray(0,n)),r.push(a.encode(t.subarray(0,n))),t=t.subarray(n)}const l=m(...e),h=m(...r),s=new Uint8Array(l.length+h.length);return s.set(l),s.set(h,l.length),s},decode(t){if(t.length!==l)throw new Error(`interleave.decode: len(data)=${t.length}, total=${l}`);const e=[];for(let t=0;t<n;t++){const n=t<o;e.push(new Uint8Array(r+i+(n?0:1)))}let h=0;for(let r=0;r<i;r++)for(let o=0;o<n;o++)e[o][r]=t[h++];for(let r=o;r<n;r++)e[r][i]=t[h++];for(let l=i;l<i+r;l++)for(let r=0;r<n;r++){const n=r<o;e[r][l+(n?0:1)]=t[h++]}const s=[];for(const t of e)s.push(...Array.from(a.decode(t)).slice(0,-r));return Uint8Array.from(s)}}}function M(t,e,r,o){let n="",i=r.length;if("numeric"===o){const t=S.alphabet.numeric.decode(r.split("")),e=t.length;for(let r=0;r<e-2;r+=3)n+=f(100*t[r]+10*t[r+1]+t[r+2],10);e%3==1?n+=f(t[e-1],4):e%3==2&&(n+=f(10*t[e-2]+t[e-1],7))}else if("alphanumeric"===o){const t=S.alphabet.alphanumerc.decode(r.split("")),e=t.length;for(let r=0;r<e-1;r+=2)n+=f(45*t[r]+t[r+1],11);e%2==1&&(n+=f(t[e-1],6))}else{if("byte"!==o)throw new Error("encode: unsupported type");{const t=function(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}(r);i=t.length,n=Array.from(t).map((t=>f(t,8))).join("")}}const{capacity:l}=S.capacity(t,e),a=f(i,S.lengthBits(t,o));let h=S.modeBits[o]+a+n;if(h.length>l)throw new Error("Capacity overflow");h+="0".repeat(Math.min(4,Math.max(0,l-h.length))),h.length%8&&(h+="0".repeat(8-h.length%8));const s="1110110000010001";for(let t=0;h.length!==l;t++)h+=s[t%16];const c=Uint8Array.from(h.match(/(.{8})/g).map((t=>Number(`0b${t}`))));return A(t,e).encode(c)}function P(t,e,r,o,n=!1){const i=function(t,e,r,o=!1){const n=S.size.encode(t);let i=new y(n+2);const l=new y(3).rect(0,3,!0).border(1,!1).border(1,!0).border(1,!1);i=i.embed(0,l).embed({x:-l.width,y:0},l).embed({x:0,y:-l.height},l),i=i.rectSlice(1,n);const a=new y(1).rect(0,1,!0).border(1,!1).border(1,!0),h=S.alignmentPatterns(t);for(const t of h)for(const e of h)void 0===i.data[t][e]&&i.embed({x:e-2,y:t-2},a);i=i.hLine({x:0,y:6},1/0,(({x:t},e)=>void 0===e?t%2==0:e)).vLine({x:6,y:0},1/0,(({y:t},e)=>void 0===e?t%2==0:e));{const t=S.formatBits(e,r),l=e=>!o&&1==(t>>e&1);for(let t=0;t<6;t++)i.data[t][8]=l(t);for(let t=6;t<8;t++)i.data[t+1][8]=l(t);for(let t=8;t<15;t++)i.data[n-15+t][8]=l(t);for(let t=0;t<8;t++)i.data[8][n-t-1]=l(t);for(let t=8;t<9;t++)i.data[8][15-t-1+1]=l(t);for(let t=9;t<15;t++)i.data[8][15-t-1]=l(t);i.data[n-8][8]=!o}if(t>=7){const e=S.versionBits(t);for(let t=0;t<18;t+=1){const r=!o&&1==(e>>t&1),l=Math.floor(t/3),a=t%3+n-8-3;i.data[l][a]=r,i.data[a][l]=r}}return i}(t,e,o,n);let l=0;const a=8*r.length;if(function(t,e,r){const o=t.height,n=k[e];let i=-1,l=o-1;for(let e=o-1;e>0;e-=2){for(6==e&&(e=5);;l+=i){for(let o=0;o<2;o+=1){const i=e-o;void 0===t.data[l][i]&&r(i,l,n(i,l))}if(l+i<0||l+i>=o)break}i=-i}}(i,o,((t,e,o)=>{let n=!1;l<a&&(n=!!(r[l>>>3]>>(7-l&7)&1),l++),i.data[e][t]=n!==o})),l!==a)throw new Error("QR: bytes left after draw");return i}function C(t){const e=t.inverse(),r=t=>{let e=0;for(let r,o=0,n=1;o<t.length;o++)r===t[o]&&(n++,o!==t.length-1)||(n>=5&&(e+=n-5+3),r=t[o],n=1);return e};let o=0;t.data.forEach((t=>o+=r(t))),e.data.forEach((t=>o+=r(t)));let n=0,i=t.data;const l=t.width-1,a=t.height-1;for(let t=0;t<l;t++)for(let e=0;e<a;e++){const r=t+1,o=e+1;i[t][e]===i[r][e]&&i[r][e]===i[t][o]&&i[r][e]===i[r][o]&&(n+=3)}const h=t=>{const e=[!0,!1,!0,!0,!0,!1,!0],r=[!1,!1,!1,!1],o=[...e,...r],n=[...r,...e];let i=0;for(let e=0;e<t.length;e++)w(t,o,e)&&(i+=40),w(t,n,e)&&(i+=40);return i};let s=0;for(const e of t.data)s+=h(e);for(const t of e.data)s+=h(t);let c=0;t.rectRead(0,1/0,((t,e)=>c+=e?1:0));const d=c/(t.height*t.width)*100,f=10*Math.floor(Math.abs(d-50)/5);return o+n+s+f}function B(t,e="raw",r={}){const o=void 0!==r.ecc?r.ecc:"medium";!function(t){if(!v.includes(t))throw new Error(`Invalid error correction mode=${t}. Expected: ${v}`)}(o);const n=void 0!==r.encoding?r.encoding:function(t){let e="numeric";for(let r of t)if(!S.alphabet.numeric.has(r)&&(e="alphanumeric",!S.alphabet.alphanumerc.has(r)))return"byte";return e}(t);!function(t){if(!b.includes(t))throw new Error(`Encoding: invalid mode=${t}. Expected: ${b}`);if("kanji"===t||"eci"===t)throw new Error(`Encoding: ${t} is not supported (yet?).`)}(n),void 0!==r.mask&&function(t){if(![0,1,2,3,4,5,6,7].includes(t)||!k[t])throw new Error(`Invalid mask=${t}. Expected number [0..7]`)}(r.mask);let i,l=r.version,a=new Error("Unknown error");if(void 0!==l)!function(t){if(!Number.isSafeInteger(t)||t<1||t>40)throw new Error(`Invalid version=${t}. Expected number [1..40]`)}(l),i=M(l,o,t,n);else for(let e=1;e<=40;e++)try{i=M(e,o,t,n),l=e;break}catch(t){a=t}if(!l||!i)throw a;let h=function(t,e,r,o){if(void 0===o){const n=function(){let t,e=1/0;return{add(r,o){r>=e||(t=o,e=r)},get:()=>t,score:()=>e}}();for(let o=0;o<k.length;o++)n.add(C(P(t,e,r,o,!0)),o);o=n.get()}if(void 0===o)throw new Error("Cannot find mask");return P(t,e,r,o)}(l,o,i,r.mask);h.assertDrawn();const s=void 0===r.border?2:r.border;if(!Number.isSafeInteger(s))throw new Error("invalid border type="+typeof s);if(h=h.border(s,!1),void 0!==r.scale&&(h=h.scale(r.scale)),"raw"===e)return h.data;if("ascii"===e)return h.toASCII();if("svg"===e)return h.toSVG(r.optimize);if("gif"===e)return h.toGIF();if("term"===e)return h.toTerm();throw new Error(`Unknown output: ${e}`)}const I=e`:host{display:inline-block}.n-qrcode{position:relative}canvas{block-size:100%;inline-size:100%;inset-block-start:0;inset-inline-start:0;position:absolute}`,U={L:"low",M:"medium",Q:"quartile",H:"high"};let j=class extends r{constructor(){super(...arguments),this.value="",this.label="",this.size=128,this.color="var(--n-color-text)",this.background="var(--n-color-surface)",this.correction="H"}firstUpdated(){this.generate()}generate(){if(!this.hasUpdated)return;const{backgroundColor:t,color:e}=getComputedStyle(this.computed),r=B(this.value,"raw",{ecc:U[this.correction],border:0}),o=2*this.size,n=this.canvas.getContext("2d"),i=o/r.length;this.canvas.width=o,this.canvas.height=o,n&&(n.fillStyle=t,n.fillRect(0,0,o,o),r.forEach(((t,r)=>{t.forEach(((t,o)=>{t&&(n.fillStyle=e,n.fillRect(o*i,r*i,i,i))}))})))}render(){return o`<div class="n-qrcode" style="${a({"inline-size":`${this.size}px`,"block-size":`${this.size}px`})}"><canvas role="img" aria-label="${this.label.length>0?this.label:this.value}"></canvas></div><div class="computed" hidden style="${a({"background-color":`${this.background}`,color:`${this.color}`})}"></div>`}};j.styles=[s,I],t([n("canvas",!0)],j.prototype,"canvas",void 0),t([n(".computed",!0)],j.prototype,"computed",void 0),t([i({reflect:!0})],j.prototype,"value",void 0),t([i({reflect:!0})],j.prototype,"label",void 0),t([i({reflect:!0,type:Number})],j.prototype,"size",void 0),t([i({reflect:!0})],j.prototype,"color",void 0),t([i({reflect:!0})],j.prototype,"background",void 0),t([i({reflect:!0})],j.prototype,"correction",void 0),t([h("correction"),h("color"),h("background"),h("size"),h("value")],j.prototype,"generate",null),j=t([l("nord-qrcode")],j);var N=j;export{N as default};
|
|
19
19
|
//# sourceMappingURL=Qrcode.js.map
|
package/lib/Radio.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{_ as
|
|
1
|
+
import{_ as t}from"./tslib.es6-CmLYFWVC.js";import{css as i,html as e,nothing as o,LitElement as n}from"lit";import{property as r,customElement as s}from"lit/decorators.js";import{ref as a}from"lit/directives/ref.js";import{L as l}from"./LightDomController-DIwtVelV.js";import{L as d}from"./LightSlotController-Coyy4nqS.js";import{o as c}from"./observe-D0n0zOfU.js";import{c as h}from"./cond-CI1KbneT.js";import{F as p}from"./FocusableMixin-BlQLNPdJ.js";import{F as m}from"./FormAssociatedMixin-D9aPREgv.js";import{I as v}from"./InputMixin-LetXsCyv.js";import{S as u}from"./SizeMixin-CU9cLbLC.js";import{s as b}from"./Component-BJ5O5n8k.js";import{s as f}from"./FormField-CMgEFZCK.js";import"./SlotController-Z6eG7LSZ.js";import"./EventController-BBOmvfLa.js";import"./FormDataController-OUt5L5uC.js";import"./events-Bv6wNHwJ.js";import"./FieldControlMixin-BXNZJXu9.js";import"./context-consumer-BJVUulGf.js";import"./context-request-event-CCRlXoeR.js";import"./field-context.js";import"./create-context-CJ69ntlY.js";import"./light-dom-styles-DXsbiKU9.js";import"./VisuallyHidden.js";const g=i`:host{--_n-radio-size:calc(var(--n-space-m)*1.25);--_n-radio-dot-size:var(--n-space-s);--_n-radio-dot-inset:calc((var(--_n-radio-size) - var(--_n-radio-dot-size))/2);display:inline-block;line-height:var(--n-line-height)}.n-flex{display:flex}.n-expand{flex:1}.n-input-container{position:relative}::slotted(input){--_n-radio-accent-color:var(--n-color-accent);appearance:none;block-size:var(--_n-radio-size)!important;border:1px solid var(--_n-radio-border-color,var(--n-color-border-hover))!important;border-radius:var(--n-border-radius-circle)!important;cursor:pointer;display:block!important;inline-size:var(--_n-radio-size)!important;margin:0!important;padding:0!important;transition:none!important}::slotted(input:checked){--_n-radio-border-color:var(--n-color-accent);background:var(--_n-radio-accent-color)!important}::slotted(input[aria-invalid]){--_n-radio-accent-color:var(--n-color-status-danger);--_n-radio-border-color:var(--_n-radio-accent-color)}::slotted(input:active){opacity:.8}::slotted(input:focus-visible){outline:none!important}::slotted(input:focus){box-shadow:0 0 0 1px var(--n-color-surface),0 0 0 3px var(--n-color-accent)!important;outline:none!important}:host([disabled]) ::slotted(label){color:var(--n-color-text-weaker);cursor:default}:host([disabled]) ::slotted(input){background:var(--_n-radio-accent-color);cursor:default;opacity:1}:host([disabled]) ::slotted(input:not(:checked)){--_n-radio-accent-color:var(--n-color-active);--_n-radio-border-color:var(--n-color-border-neutral)}:host([disabled]) ::slotted(input:checked){opacity:.3}.n-dot{background-color:var(--n-color-text-on-accent);block-size:var(--_n-radio-dot-size);border-radius:var(--n-border-radius-circle);inline-size:var(--_n-radio-dot-size);inset-block-start:var(--_n-radio-dot-inset);inset-inline-start:var(--_n-radio-dot-inset);pointer-events:none;position:absolute;z-index:var(--n-index-default)}.n-label-container{margin-block-end:0}::slotted(label){cursor:pointer;font-weight:var(--n-font-weight)!important;line-height:var(--n-line-height)!important;padding-inline-start:var(--n-space-s)!important;user-select:none}.n-error,.n-hint{padding-inline-start:var(--n-space-s)}.n-error{margin-block-start:var(--n-space-xs)}:host([hint-below]) :is(.n-hint,.n-error){padding-inline-start:0}:host([size=s]){--_n-radio-size:var(--n-size-icon-m);--_n-radio-dot-size:calc(var(--n-size-icon-s)/2)}:host([size=s]:not([hide-label])) .n-input-container{margin:calc(var(--n-space-s)/3) 0}:host([size=l]){--_n-radio-size:var(--n-size-icon-l);--_n-radio-dot-size:var(--n-size-icon-xs)}:host([size=l]:not([hide-label])) .n-label-container{margin:2px 0 0}`;let $=0;const k=t=>`nord-radio-${t}-${$++}`;let x=class extends(u(m(v(p(n))))){constructor(){super(...arguments),this.inputId=k("input"),this.hintId=k("hint"),this.errorId=k("error"),this.hintSlot=new d(this,{slotName:"hint",render:()=>this.hint?e`<div slot="hint-internal" id="${this.hintId}">${this.hint}</div>`:o,syncLightDom:t=>{t.id=this.hintId}}),this.labelSlot=new d(this,{slotName:"label",render:()=>this.label?e`<label slot="label-internal" for="${this.inputId}">${this.label}</label>`:o,syncLightDom:t=>{!function(t){return"label"===t.localName}(t)?console.warn('NORD: Only <label> elements should be placed in radio\'s "label" slot'):t.htmlFor=this.inputId}}),this.errorSlot=new d(this,{slotName:"error",render:()=>this.error?e`<div slot="error-internal" id="${this.errorId}">${this.error}</div>`:o,syncLightDom:t=>{t.id=this.hintId}}),this.inputSlot=new l(this,{render:()=>e`<input slot="input" @blur="${this.handleBlur}" @focus="${this.handleFocus}" ${a(this.focusableRef)} class="n-input" id="${this.inputId}" type="radio" name="${h(this.name)}" .value="${h(this.value)}" .checked="${this.checked}" ?disabled="${this.effectiveDisabled}" ?required="${this.required}" aria-label="${h(this.controlAriaLabel)}" aria-describedby="${h(this.controlAriaDescribedby)}" aria-invalid="${h(this.controlAriaInvalid)}" form="${h(this._formId)}">`}),this.checked=!1,this.handleBlur=t=>{t.stopPropagation(),this.dispatchEvent(new Event("blur",{bubbles:!1,cancelable:!0}))},this.handleFocus=t=>{t.stopPropagation(),this.dispatchEvent(new Event("focus",{bubbles:!1,cancelable:!0}))}}get formValue(){}render(){const t=e`<div class="n-caption n-hint" ?hidden="${!this.hasHint}"><slot name="hint"></slot><slot name="hint-internal"></slot></div>`,i=e`<div class="n-caption n-error" role="alert" ?hidden="${!this.hasError}"><slot name="error"></slot><slot name="error-internal"></slot></div>`;return e`<div class="n-flex"><div class="n-input-container" @change="${this.handleChange}"><slot name="input"></slot>${this.checked?e`<div class="n-dot"></div>`:o}</div><div class="n-expand"><div class="n-label-container">${this.insideField?o:(n=this.hideLabel,r=()=>e`<slot name="label"></slot><slot name="label-internal"></slot>`,s=t=>e`<nord-visually-hidden>${t}</nord-visually-hidden>`,n?s(r()):r())} ${this.isHintBelow?o:t}</div>${this.isHintBelow?o:i}</div></div>${this.isHintBelow?i:o} ${this.isHintBelow?t:o}`;var n,r,s}handleCheckedChange(t){!t&&this.checked&&this.uncheckSiblings()}uncheckSiblings(){this.getRootNode().querySelectorAll(`nord-radio[name="${this.name}"]`).forEach((t=>{t!==this&&t.checked&&(t.checked=!1,function(t){t.style.display="none",t.offsetHeight,t.style.display="inline-block"}(t))}))}handleChange(t){t.stopPropagation();const i=t.target;this.checked=i.checked,super.handleChange(t)}};x.styles=[b,f,g],t([r({type:Boolean,reflect:!0})],x.prototype,"checked",void 0),t([c("checked")],x.prototype,"handleCheckedChange",null),x=t([s("nord-radio")],x);var _=x;export{_ as default};
|
|
2
2
|
//# sourceMappingURL=Radio.js.map
|
package/lib/Radio.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Radio.js","sources":["../src/radio/Radio.ts","../src/common/directives/wrapIf.ts"],"sourcesContent":["import { html, LitElement, nothing } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\nimport { ref } from 'lit/directives/ref.js'\nimport { LightDomController } from '../common/controllers/LightDomController.js'\nimport { LightSlotController } from '../common/controllers/LightSlotController.js'\nimport { observe } from '../common/decorators/observe.js'\nimport { cond } from '../common/directives/cond.js'\nimport { wrapIf } from '../common/directives/wrapIf.js'\n\nimport { FocusableMixin } from '../common/mixins/FocusableMixin.js'\nimport { FormAssociatedMixin } from '../common/mixins/FormAssociatedMixin.js'\nimport { InputMixin } from '../common/mixins/InputMixin.js'\nimport { SizeMixin } from '../common/mixins/SizeMixin.js'\n\nimport componentStyle from '../common/styles/Component.css'\nimport formFieldStyle from '../common/styles/FormField.css'\nimport style from './Radio.css'\n\nlet id = 0\nconst createId = (suffix: string) => `nord-radio-${suffix}-${id++}`\n\nfunction isLabel(element: Element): element is HTMLLabelElement {\n return element.localName === 'label'\n}\n\n/**\n * Force reflow (and with it a repaint) of a radio button because of a macOS Safari rendering bug\n *\n * @see https://bugs.webkit.org/show_bug.cgi?id=249706\n */\nfunction forceReflow(radio: Radio) {\n radio.style.display = 'none'\n // eslint-disable-next-line ts/no-unused-expressions\n radio.offsetHeight // no need to store this anywhere, the reference is enough\n radio.style.display = 'inline-block'\n}\n\n/**\n * Radio buttons are graphical user interface elements that allow user to choose only one option from\n * a predefined set of mutually exclusive options.\n *\n * @status ready\n * @category form\n * @slot label - Use when a label requires more than plain text.\n * @slot hint - Optional slot that holds hint text for the input.\n * @slot error - Optional slot that holds error text for the input.\n *\n * @cssprop [--n-label-color=var(--n-color-text)] - Controls the text color of the label, using our [color tokens](/tokens/#color).\n */\n@customElement('nord-radio')\nexport default class Radio extends SizeMixin(FormAssociatedMixin(InputMixin(FocusableMixin(LitElement)))) {\n static styles = [componentStyle, formFieldStyle, style]\n\n protected override inputId = createId('input')\n protected override hintId = createId('hint')\n protected override errorId = createId('error')\n\n /**\n * For accessibility reasons, we render some parts of the component to the light DOM.\n */\n protected override hintSlot = new LightSlotController(this, {\n slotName: 'hint',\n render: () => (this.hint ? html`<div slot=\"hint-internal\" id=${this.hintId}>${this.hint}</div>` : nothing),\n syncLightDom: (element) => {\n element.id = this.hintId\n },\n })\n\n protected override labelSlot = new LightSlotController(this, {\n slotName: 'label',\n render: () => (this.label ? html`<label slot=\"label-internal\" for=${this.inputId}>${this.label}</label>` : nothing),\n syncLightDom: (element) => {\n if (!isLabel(element)) {\n console.warn(`NORD: Only <label> elements should be placed in radio's \"label\" slot`)\n }\n else {\n element.htmlFor = this.inputId\n }\n },\n })\n\n protected override errorSlot = new LightSlotController(this, {\n slotName: 'error',\n render: () => (this.error ? html`<div slot=\"error-internal\" id=${this.errorId}>${this.error}</div>` : nothing),\n syncLightDom: (element) => {\n element.id = this.hintId\n },\n })\n\n protected inputSlot = new LightDomController(this, {\n render: () => html`\n <input\n slot=\"input\"\n @blur=${this.handleBlur}\n @focus=${this.handleFocus}\n ${ref(this.focusableRef)}\n class=\"n-input\"\n id=${this.inputId}\n type=\"radio\"\n name=${cond(this.name)}\n .value=${cond(this.value)}\n .checked=${this.checked}\n ?disabled=${this.disabled}\n ?required=${this.required}\n aria-describedby=${cond(this.getDescribedBy())}\n aria-invalid=${cond(this.getInvalid())}\n form=${cond(this._formId)}\n />\n `,\n })\n\n protected override get formValue() {\n // opt out of formdata event, since radio button is in light dom\n return undefined\n }\n\n /**\n * Controls whether the checkbox is checked or not.\n */\n @property({ type: Boolean, reflect: true }) checked: boolean = false\n\n render() {\n const hint = html`\n <div class=\"n-caption n-hint\" ?hidden=${!this.hasHint}>\n <slot name=\"hint\"></slot>\n <slot name=\"hint-internal\"></slot>\n </div>\n `\n const error = html`\n <div class=\"n-caption n-error\" role=\"alert\" ?hidden=${!this.hasError}>\n <slot name=\"error\"></slot>\n <slot name=\"error-internal\"></slot>\n </div>\n `\n\n return html`\n <div class=\"n-flex\">\n <div class=\"n-input-container\" @change=${this.handleChange}>\n <slot name=\"input\"></slot>\n ${this.checked ? html`<div class=\"n-dot\"></div>` : nothing}\n </div>\n <div class=\"n-expand\">\n <div class=\"n-label-container\">\n ${wrapIf(\n this.hideLabel,\n () => html`\n <slot name=\"label\"></slot>\n <slot name=\"label-internal\"></slot>\n `,\n content => html`<nord-visually-hidden>${content}</nord-visually-hidden>`,\n )}\n ${this.isHintBelow ? nothing : hint}\n </div>\n ${this.isHintBelow ? nothing : error}\n </div>\n </div>\n ${this.isHintBelow ? error : nothing}\n ${this.isHintBelow ? hint : nothing}\n `\n }\n\n @observe('checked')\n protected handleCheckedChange(previousChecked: boolean) {\n // if this component was previous unchecked but is now checked,\n // then we need to uncheck any radios in the same group\n if (!previousChecked && this.checked) {\n this.uncheckSiblings()\n }\n }\n\n private uncheckSiblings() {\n const root = this.getRootNode() as Document | ShadowRoot\n\n root.querySelectorAll<Radio>(`nord-radio[name=\"${this.name}\"]`).forEach((radio) => {\n if (radio !== this && radio.checked) {\n radio.checked = false\n forceReflow(radio)\n }\n })\n }\n\n protected handleChange(e: Event): void {\n e.stopPropagation()\n const target = e.target as HTMLInputElement\n\n this.checked = target.checked\n super.handleChange(e)\n }\n\n private handleBlur = (e: Event) => {\n e.stopPropagation()\n this.dispatchEvent(new Event('blur', { bubbles: false, cancelable: true }))\n }\n\n private handleFocus = (e: Event) => {\n e.stopPropagation()\n this.dispatchEvent(new Event('focus', { bubbles: false, cancelable: true }))\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nord-radio': Radio\n }\n}\n","// some clever typing so that TS knows what happens if you pass true/false values\nexport function wrapIf<TInner, TWrapper>(\n condition: false,\n inner: () => TInner,\n wrapper: (inner: TInner) => TWrapper,\n): TInner\nexport function wrapIf<TInner, TWrapper>(\n condition: true,\n inner: () => TInner,\n wrapper: (inner: TInner) => TWrapper,\n): TWrapper\nexport function wrapIf<TInner, TWrapper>(\n condition: unknown,\n inner: () => TInner,\n wrapper: (inner: TInner) => TWrapper,\n): TInner | TWrapper\n\n/**\n * @returns if condition is truthy, return result of wrapper, passing result of inner as arg. if falsy, return result of inner\n */\nexport function wrapIf<TInner, TWrapper>(condition: any, inner: () => TInner, wrapper: (innards: TInner) => TWrapper) {\n return condition ? wrapper(inner()) : inner()\n}\n"],"names":["id","createId","suffix","Radio","SizeMixin","FormAssociatedMixin","InputMixin","FocusableMixin","LitElement","constructor","this","inputId","hintId","errorId","hintSlot","LightSlotController","slotName","render","hint","html","nothing","syncLightDom","element","labelSlot","label","localName","isLabel","console","warn","htmlFor","errorSlot","error","inputSlot","LightDomController","handleBlur","handleFocus","ref","focusableRef","cond","name","value","checked","disabled","required","getDescribedBy","getInvalid","_formId","e","stopPropagation","dispatchEvent","Event","bubbles","cancelable","formValue","hasHint","hasError","handleChange","condition","hideLabel","inner","wrapper","content","isHintBelow","handleCheckedChange","previousChecked","uncheckSiblings","getRootNode","querySelectorAll","forEach","radio","style","display","offsetHeight","forceReflow","target","super","styles","componentStyle","formFieldStyle","__decorate","property","type","Boolean","reflect","prototype","observe","customElement"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"Radio.js","sources":["../src/radio/Radio.ts","../src/common/directives/wrapIf.ts"],"sourcesContent":["import { html, LitElement, nothing } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\nimport { ref } from 'lit/directives/ref.js'\nimport { LightDomController } from '../common/controllers/LightDomController.js'\nimport { LightSlotController } from '../common/controllers/LightSlotController.js'\nimport { observe } from '../common/decorators/observe.js'\nimport { cond } from '../common/directives/cond.js'\nimport { wrapIf } from '../common/directives/wrapIf.js'\n\nimport { FocusableMixin } from '../common/mixins/FocusableMixin.js'\nimport { FormAssociatedMixin } from '../common/mixins/FormAssociatedMixin.js'\nimport { InputMixin } from '../common/mixins/InputMixin.js'\nimport { SizeMixin } from '../common/mixins/SizeMixin.js'\n\nimport componentStyle from '../common/styles/Component.css'\nimport formFieldStyle from '../common/styles/FormField.css'\nimport style from './Radio.css'\n\nlet id = 0\nconst createId = (suffix: string) => `nord-radio-${suffix}-${id++}`\n\nfunction isLabel(element: Element): element is HTMLLabelElement {\n return element.localName === 'label'\n}\n\n/**\n * Force reflow (and with it a repaint) of a radio button because of a macOS Safari rendering bug\n *\n * @see https://bugs.webkit.org/show_bug.cgi?id=249706\n */\nfunction forceReflow(radio: Radio) {\n radio.style.display = 'none'\n // eslint-disable-next-line ts/no-unused-expressions\n radio.offsetHeight // no need to store this anywhere, the reference is enough\n radio.style.display = 'inline-block'\n}\n\n/**\n * Radio buttons are graphical user interface elements that allow user to choose only one option from\n * a predefined set of mutually exclusive options.\n *\n * @status ready\n * @category form\n * @slot label - Use when a label requires more than plain text.\n * @slot hint - Optional slot that holds hint text for the input.\n * @slot error - Optional slot that holds error text for the input.\n *\n * @cssprop [--n-label-color=var(--n-color-text)] - Controls the text color of the label, using our [color tokens](/tokens/#color).\n */\n@customElement('nord-radio')\nexport default class Radio extends SizeMixin(FormAssociatedMixin(InputMixin(FocusableMixin(LitElement)))) {\n static styles = [componentStyle, formFieldStyle, style]\n\n protected override inputId = createId('input')\n protected override hintId = createId('hint')\n protected override errorId = createId('error')\n\n /**\n * For accessibility reasons, we render some parts of the component to the light DOM.\n */\n protected override hintSlot = new LightSlotController(this, {\n slotName: 'hint',\n render: () => (this.hint ? html`<div slot=\"hint-internal\" id=${this.hintId}>${this.hint}</div>` : nothing),\n syncLightDom: (element) => {\n element.id = this.hintId\n },\n })\n\n protected override labelSlot = new LightSlotController(this, {\n slotName: 'label',\n render: () => (this.label ? html`<label slot=\"label-internal\" for=${this.inputId}>${this.label}</label>` : nothing),\n syncLightDom: (element) => {\n if (!isLabel(element)) {\n console.warn(`NORD: Only <label> elements should be placed in radio's \"label\" slot`)\n }\n else {\n element.htmlFor = this.inputId\n }\n },\n })\n\n protected override errorSlot = new LightSlotController(this, {\n slotName: 'error',\n render: () => (this.error ? html`<div slot=\"error-internal\" id=${this.errorId}>${this.error}</div>` : nothing),\n syncLightDom: (element) => {\n element.id = this.hintId\n },\n })\n\n protected inputSlot = new LightDomController(this, {\n render: () => html`\n <input\n slot=\"input\"\n @blur=${this.handleBlur}\n @focus=${this.handleFocus}\n ${ref(this.focusableRef)}\n class=\"n-input\"\n id=${this.inputId}\n type=\"radio\"\n name=${cond(this.name)}\n .value=${cond(this.value)}\n .checked=${this.checked}\n ?disabled=${this.effectiveDisabled}\n ?required=${this.required}\n aria-label=${cond(this.controlAriaLabel)}\n aria-describedby=${cond(this.controlAriaDescribedby)}\n aria-invalid=${cond(this.controlAriaInvalid)}\n form=${cond(this._formId)}\n />\n `,\n })\n\n protected override get formValue() {\n // opt out of formdata event, since radio button is in light dom\n return undefined\n }\n\n /**\n * Controls whether the checkbox is checked or not.\n */\n @property({ type: Boolean, reflect: true }) checked: boolean = false\n\n render() {\n const hint = html`\n <div class=\"n-caption n-hint\" ?hidden=${!this.hasHint}>\n <slot name=\"hint\"></slot>\n <slot name=\"hint-internal\"></slot>\n </div>\n `\n const error = html`\n <div class=\"n-caption n-error\" role=\"alert\" ?hidden=${!this.hasError}>\n <slot name=\"error\"></slot>\n <slot name=\"error-internal\"></slot>\n </div>\n `\n\n return html`\n <div class=\"n-flex\">\n <div class=\"n-input-container\" @change=${this.handleChange}>\n <slot name=\"input\"></slot>\n ${this.checked ? html`<div class=\"n-dot\"></div>` : nothing}\n </div>\n <div class=\"n-expand\">\n <div class=\"n-label-container\">\n ${this.insideField\n ? nothing\n : wrapIf(\n this.hideLabel,\n () => html`\n <slot name=\"label\"></slot>\n <slot name=\"label-internal\"></slot>\n `,\n content => html`<nord-visually-hidden>${content}</nord-visually-hidden>`,\n )}\n ${this.isHintBelow ? nothing : hint}\n </div>\n ${this.isHintBelow ? nothing : error}\n </div>\n </div>\n ${this.isHintBelow ? error : nothing}\n ${this.isHintBelow ? hint : nothing}\n `\n }\n\n @observe('checked')\n protected handleCheckedChange(previousChecked: boolean) {\n // if this component was previous unchecked but is now checked,\n // then we need to uncheck any radios in the same group\n if (!previousChecked && this.checked) {\n this.uncheckSiblings()\n }\n }\n\n private uncheckSiblings() {\n const root = this.getRootNode() as Document | ShadowRoot\n\n root.querySelectorAll<Radio>(`nord-radio[name=\"${this.name}\"]`).forEach((radio) => {\n if (radio !== this && radio.checked) {\n radio.checked = false\n forceReflow(radio)\n }\n })\n }\n\n protected handleChange(e: Event): void {\n e.stopPropagation()\n const target = e.target as HTMLInputElement\n\n this.checked = target.checked\n super.handleChange(e)\n }\n\n private handleBlur = (e: Event) => {\n e.stopPropagation()\n this.dispatchEvent(new Event('blur', { bubbles: false, cancelable: true }))\n }\n\n private handleFocus = (e: Event) => {\n e.stopPropagation()\n this.dispatchEvent(new Event('focus', { bubbles: false, cancelable: true }))\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nord-radio': Radio\n }\n}\n","// some clever typing so that TS knows what happens if you pass true/false values\nexport function wrapIf<TInner, TWrapper>(\n condition: false,\n inner: () => TInner,\n wrapper: (inner: TInner) => TWrapper,\n): TInner\nexport function wrapIf<TInner, TWrapper>(\n condition: true,\n inner: () => TInner,\n wrapper: (inner: TInner) => TWrapper,\n): TWrapper\nexport function wrapIf<TInner, TWrapper>(\n condition: unknown,\n inner: () => TInner,\n wrapper: (inner: TInner) => TWrapper,\n): TInner | TWrapper\n\n/**\n * @returns if condition is truthy, return result of wrapper, passing result of inner as arg. if falsy, return result of inner\n */\nexport function wrapIf<TInner, TWrapper>(condition: any, inner: () => TInner, wrapper: (innards: TInner) => TWrapper) {\n return condition ? wrapper(inner()) : inner()\n}\n"],"names":["id","createId","suffix","Radio","SizeMixin","FormAssociatedMixin","InputMixin","FocusableMixin","LitElement","constructor","this","inputId","hintId","errorId","hintSlot","LightSlotController","slotName","render","hint","html","nothing","syncLightDom","element","labelSlot","label","localName","isLabel","console","warn","htmlFor","errorSlot","error","inputSlot","LightDomController","handleBlur","handleFocus","ref","focusableRef","cond","name","value","checked","effectiveDisabled","required","controlAriaLabel","controlAriaDescribedby","controlAriaInvalid","_formId","e","stopPropagation","dispatchEvent","Event","bubbles","cancelable","formValue","hasHint","hasError","handleChange","insideField","condition","hideLabel","inner","wrapper","content","isHintBelow","handleCheckedChange","previousChecked","uncheckSiblings","getRootNode","querySelectorAll","forEach","radio","style","display","offsetHeight","forceReflow","target","super","styles","componentStyle","formFieldStyle","__decorate","property","type","Boolean","reflect","prototype","observe","customElement"],"mappings":"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"}
|
package/lib/Range.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{_ as r}from"./tslib.es6-CmLYFWVC.js";import{css as e,html as n,nothing as a,LitElement as o}from"lit";import{property as t,customElement as i}from"lit/decorators.js";import{classMap as s}from"lit/directives/class-map.js";import{ifDefined as l}from"lit/directives/if-defined.js";import{ref as c}from"lit/directives/ref.js";import{D as d}from"./DirectionController-ChvNGESZ.js";import{N as
|
|
1
|
+
import{_ as r}from"./tslib.es6-CmLYFWVC.js";import{css as e,html as n,nothing as a,LitElement as o}from"lit";import{property as t,customElement as i}from"lit/decorators.js";import{classMap as s}from"lit/directives/class-map.js";import{ifDefined as l}from"lit/directives/if-defined.js";import{ref as c}from"lit/directives/ref.js";import{D as d}from"./DirectionController-ChvNGESZ.js";import{N as m}from"./events-Bv6wNHwJ.js";import{A as b}from"./AutocompleteMixin-D8eiOxvO.js";import{F as u}from"./FocusableMixin-BlQLNPdJ.js";import{F as g}from"./FormAssociatedMixin-D9aPREgv.js";import{I as h}from"./InputMixin-LetXsCyv.js";import{R as p}from"./ReadonlyMixin-BdJPGtQ3.js";import{s as v}from"./Component-BJ5O5n8k.js";import{s as f}from"./FormField-CMgEFZCK.js";import{s as _}from"./TextField-CSKvieoG.js";import"./FormDataController-OUt5L5uC.js";import"./FieldControlMixin-BXNZJXu9.js";import"./context-consumer-BJVUulGf.js";import"./context-request-event-CCRlXoeR.js";import"./field-context.js";import"./create-context-CJ69ntlY.js";import"./SlotController-Z6eG7LSZ.js";import"./EventController-BBOmvfLa.js";import"./light-dom-styles-DXsbiKU9.js";import"./VisuallyHidden.js";const x=e`:host{--_n-range-progress:0%;--_n-range-thumb-focus-ring:0 0 0 1px var(--n-color-accent);--_n-range-thumb-color:var(--n-color-text-on-accent);--_n-range-thumb-border-size:1px;--_n-range-thumb-border-color:var(--n-color-border-strong);--_n-range-gradient-direction:right;--_n-range-thumb-size:var(--n-range-thumb-size,20px);--_n-range-track-color-active:var(--n-range-track-color-active,var(--n-color-accent));--_n-range-track-color-inactive:var(--n-range-track-color-inactive,var(--n-color-border-strong));--_n-range-track-size:var(--n-range-track-size,3px)}.n-range{appearance:none;background:linear-gradient(to var(--_n-range-gradient-direction),var(--_n-range-track-color-active) 0,var(--_n-range-track-color-active) var(--_n-range-progress),var(--_n-range-track-color-inactive) var(--_n-range-progress));border-radius:var(--n-border-radius-s);inline-size:100%}.n-range.is-rtl{--_n-range-gradient-direction:left}.n-range::-webkit-slider-runnable-track{block-size:var(--_n-range-track-size);inline-size:100%}.n-range::-webkit-slider-thumb{appearance:none;background:var(--_n-range-thumb-color);block-size:var(--_n-range-thumb-size);border:var(--_n-range-thumb-border-size) solid var(--_n-range-thumb-border-color);border-radius:var(--n-border-radius-circle);box-shadow:var(--n-box-shadow),var(--n-box-shadow);cursor:pointer;inline-size:var(--_n-range-thumb-size);margin-block-start:calc(var(--_n-range-thumb-size)/2*-1 - var(--_n-range-track-size)/2*-1)}.n-range::-moz-range-track{block-size:var(--_n-range-track-size);border:var(--n-space-s) solid var(--n-color-surface);inline-size:100%}.n-range::-moz-range-thumb{appearance:none;background:var(--_n-range-thumb-color);block-size:var(--_n-range-thumb-size);border:var(--_n-range-thumb-border-size) solid var(--_n-range-thumb-border-color);border-radius:var(--n-border-radius-circle);box-shadow:var(--n-box-shadow);cursor:pointer;inline-size:var(--_n-range-thumb-size);margin-block-start:calc(var(--_n-range-thumb-size)/2*-1 - var(--_n-range-track-size)/2*-1)}.n-label-container{inline-size:100%;margin-block-end:0}label{display:flex!important}.n-range-output{color:var(--n-color-text-weaker);font-size:var(--n-font-size-m);font-weight:var(--n-font-weight);margin-inline-start:auto}.n-range:focus{outline:none}.n-label-container:hover+.n-input-container .n-input:disabled,.n-range:disabled{opacity:.5}.n-range:disabled::-webkit-slider-thumb,.n-range[readonly]::-webkit-slider-thumb{--_n-range-thumb-color:var(--n-color-border);--_n-range-thumb-border-color:var(--n-color-border);box-shadow:none;cursor:default}.n-range:disabled::-moz-range-thumb,.n-range[readonly]::-moz-range-thumb{--_n-range-thumb-color:var(--n-color-border);--_n-range-thumb-border-color:var(--n-color-border);box-shadow:none;cursor:default}.n-range:focus::-webkit-slider-thumb{--_n-range-thumb-border-color:var(--n-color-accent);box-shadow:var(--_n-range-thumb-focus-ring)}.n-range:focus::-moz-range-thumb{--_n-range-thumb-border-color:var(--n-color-accent);box-shadow:var(--_n-range-thumb-focus-ring)}`;let z=class extends(g(b(p(h(u(o)))))){constructor(){super(...arguments),this.direction=new d(this),this.min=0,this.max=10,this.step=1,this.expand=!1}render(){const r=Number(this.value)||0,e=Math.max(0,(r-this.min)/(this.max-this.min));return n`<div class="n-input-container">${this.renderLabel(n`<span class="n-range-output" aria-hidden="true">${r}</span>`)} <input ${c(this.focusableRef)} id="${this.inputId}" type="range" class="${s({"n-range":!0,"is-rtl":this.direction.isRTL})}" name="${l(this.name)}" min="${this.min}" step="${this.step}" max="${this.max}" style="${`--_n-range-progress: ${100*e}%`}" ?disabled="${this.effectiveDisabled}" ?required="${this.required}" ?readonly="${this.readonly}" .value="${this.value?this.value:"0"}" @input="${this.handleInput}" @change="${this.handleChange}" aria-label="${l(this.controlAriaLabel)}" aria-describedby="${l(this.controlAriaDescribedby)}" aria-invalid="${l(this.controlAriaInvalid)}"></div>${this.renderError()} ${this.isHintBelow?this.renderHint():a}`}handleInput(r){r.stopPropagation();const e=r.target;if(this.readonly)return r.preventDefault(),void(e.value=this.value);this.value=e.value,this.dispatchEvent(new m("input"))}};z.styles=[v,f,_,x],r([t({reflect:!0,type:Number})],z.prototype,"min",void 0),r([t({reflect:!0,type:Number})],z.prototype,"max",void 0),r([t({reflect:!0,type:Number})],z.prototype,"step",void 0),r([t({reflect:!0,type:Boolean})],z.prototype,"expand",void 0),z=r([i("nord-range")],z);var k=z;export{k as default};
|
|
2
2
|
//# sourceMappingURL=Range.js.map
|
package/lib/Range.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Range.js","sources":["../src/range/Range.ts"],"sourcesContent":["import { html, LitElement, nothing } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\nimport { classMap } from 'lit/directives/class-map.js'\nimport { ifDefined } from 'lit/directives/if-defined.js'\nimport { ref } from 'lit/directives/ref.js'\nimport { DirectionController } from '../common/controllers/DirectionController.js'\n\nimport { NordEvent } from '../common/events.js'\nimport { AutocompleteMixin } from '../common/mixins/AutocompleteMixin.js'\nimport { FocusableMixin } from '../common/mixins/FocusableMixin.js'\nimport { FormAssociatedMixin } from '../common/mixins/FormAssociatedMixin.js'\nimport { InputMixin } from '../common/mixins/InputMixin.js'\nimport { ReadonlyMixin } from '../common/mixins/ReadonlyMixin.js'\n\nimport componentStyle from '../common/styles/Component.css'\nimport formFieldStyle from '../common/styles/FormField.css'\nimport textFieldStyle from '../common/styles/TextField.css'\nimport style from './Range.css'\n\n/**\n * Range input lets user specify a numeric value using a slider which\n * must be no less than a given value, and no more than another given value.\n *\n * @status ready\n * @category form\n * @slot label - Use when a label requires more than plain text.\n * @slot hint - Optional slot that holds hint text for the input.\n * @slot error - Optional slot that holds error text for the input.\n *\n * @cssprop [--n-range-thumb-size=20px] - Controls the size of the thumb.\n * @cssprop [--n-range-track-color-active=var(--n-color-accent)] - Controls the color of the portion of the track that represents the current value.\n * @cssprop [--n-range-track-color-inactive=var(--n-color-border-strong)] - Controls the color of the portion of the track that represents the remaining value.\n * @cssprop [--n-range-track-size=3px] - Controls the height of the track.\n */\n@customElement('nord-range')\nexport default class Range extends FormAssociatedMixin(\n AutocompleteMixin(ReadonlyMixin(InputMixin(FocusableMixin(LitElement)))),\n) {\n static styles = [componentStyle, formFieldStyle, textFieldStyle, style]\n\n private direction = new DirectionController(this)\n\n /**\n * Minimum value for the range slider.\n */\n @property({ reflect: true, type: Number }) min: number = 0\n\n /**\n * Maximum value for the range slider.\n */\n @property({ reflect: true, type: Number }) max: number = 10\n\n /**\n * Step amount for the range slider.\n */\n @property({ reflect: true, type: Number }) step: number = 1\n\n /**\n * Controls whether the input expands to fill the width of its container.\n */\n @property({ reflect: true, type: Boolean }) expand = false\n\n render() {\n const value = Number(this.value) || 0\n const percent = Math.max(0, (value - this.min) / (this.max - this.min))\n\n return html`\n <div class=\"n-input-container\">\n ${this.renderLabel(html`<span class=\"n-range-output\" aria-hidden=\"true\">${value}</span>`)}\n\n <input\n ${ref(this.focusableRef)}\n id=${this.inputId}\n type=\"range\"\n class=${classMap({\n 'n-range': true,\n 'is-rtl': this.direction.isRTL,\n })}\n name=${ifDefined(this.name)}\n min=${this.min}\n step=${this.step}\n max=${this.max}\n style=${`--_n-range-progress: ${percent * 100}%`}\n ?disabled=${this.
|
|
1
|
+
{"version":3,"file":"Range.js","sources":["../src/range/Range.ts"],"sourcesContent":["import { html, LitElement, nothing } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\nimport { classMap } from 'lit/directives/class-map.js'\nimport { ifDefined } from 'lit/directives/if-defined.js'\nimport { ref } from 'lit/directives/ref.js'\nimport { DirectionController } from '../common/controllers/DirectionController.js'\n\nimport { NordEvent } from '../common/events.js'\nimport { AutocompleteMixin } from '../common/mixins/AutocompleteMixin.js'\nimport { FocusableMixin } from '../common/mixins/FocusableMixin.js'\nimport { FormAssociatedMixin } from '../common/mixins/FormAssociatedMixin.js'\nimport { InputMixin } from '../common/mixins/InputMixin.js'\nimport { ReadonlyMixin } from '../common/mixins/ReadonlyMixin.js'\n\nimport componentStyle from '../common/styles/Component.css'\nimport formFieldStyle from '../common/styles/FormField.css'\nimport textFieldStyle from '../common/styles/TextField.css'\nimport style from './Range.css'\n\n/**\n * Range input lets user specify a numeric value using a slider which\n * must be no less than a given value, and no more than another given value.\n *\n * @status ready\n * @category form\n * @slot label - Use when a label requires more than plain text.\n * @slot hint - Optional slot that holds hint text for the input.\n * @slot error - Optional slot that holds error text for the input.\n *\n * @cssprop [--n-range-thumb-size=20px] - Controls the size of the thumb.\n * @cssprop [--n-range-track-color-active=var(--n-color-accent)] - Controls the color of the portion of the track that represents the current value.\n * @cssprop [--n-range-track-color-inactive=var(--n-color-border-strong)] - Controls the color of the portion of the track that represents the remaining value.\n * @cssprop [--n-range-track-size=3px] - Controls the height of the track.\n */\n@customElement('nord-range')\nexport default class Range extends FormAssociatedMixin(\n AutocompleteMixin(ReadonlyMixin(InputMixin(FocusableMixin(LitElement)))),\n) {\n static styles = [componentStyle, formFieldStyle, textFieldStyle, style]\n\n private direction = new DirectionController(this)\n\n /**\n * Minimum value for the range slider.\n */\n @property({ reflect: true, type: Number }) min: number = 0\n\n /**\n * Maximum value for the range slider.\n */\n @property({ reflect: true, type: Number }) max: number = 10\n\n /**\n * Step amount for the range slider.\n */\n @property({ reflect: true, type: Number }) step: number = 1\n\n /**\n * Controls whether the input expands to fill the width of its container.\n */\n @property({ reflect: true, type: Boolean }) expand = false\n\n render() {\n const value = Number(this.value) || 0\n const percent = Math.max(0, (value - this.min) / (this.max - this.min))\n\n return html`\n <div class=\"n-input-container\">\n ${this.renderLabel(html`<span class=\"n-range-output\" aria-hidden=\"true\">${value}</span>`)}\n\n <input\n ${ref(this.focusableRef)}\n id=${this.inputId}\n type=\"range\"\n class=${classMap({\n 'n-range': true,\n 'is-rtl': this.direction.isRTL,\n })}\n name=${ifDefined(this.name)}\n min=${this.min}\n step=${this.step}\n max=${this.max}\n style=${`--_n-range-progress: ${percent * 100}%`}\n ?disabled=${this.effectiveDisabled}\n ?required=${this.required}\n ?readonly=${this.readonly}\n .value=${this.value ? this.value : '0'}\n @input=${this.handleInput}\n @change=${this.handleChange}\n aria-label=${ifDefined(this.controlAriaLabel)}\n aria-describedby=${ifDefined(this.controlAriaDescribedby)}\n aria-invalid=${ifDefined(this.controlAriaInvalid)}\n />\n </div>\n\n ${this.renderError()}\n ${this.isHintBelow ? this.renderHint() : nothing}\n `\n }\n\n protected handleInput(e: Event) {\n e.stopPropagation()\n const target = e.target as HTMLInputElement\n\n if (this.readonly) {\n e.preventDefault()\n target.value = this.value\n return\n }\n\n this.value = target.value\n\n /**\n * Fired as the user types into the input.\n */\n this.dispatchEvent(new NordEvent('input'))\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nord-range': Range\n }\n}\n"],"names":["Range","FormAssociatedMixin","AutocompleteMixin","ReadonlyMixin","InputMixin","FocusableMixin","LitElement","constructor","this","direction","DirectionController","min","max","step","expand","render","value","Number","percent","Math","html","renderLabel","ref","focusableRef","inputId","classMap","isRTL","ifDefined","name","effectiveDisabled","required","readonly","handleInput","handleChange","controlAriaLabel","controlAriaDescribedby","controlAriaInvalid","renderError","isHintBelow","renderHint","nothing","e","stopPropagation","target","preventDefault","dispatchEvent","NordEvent","styles","componentStyle","formFieldStyle","textFieldStyle","style","__decorate","property","reflect","type","prototype","Boolean","customElement"],"mappings":"onIAmCe,IAAMA,EAAN,cAAoBC,EACjCC,EAAkBC,EAAcC,EAAWC,EAAeC,QAD7C,WAAAC,uBAKLC,KAAAC,UAAY,IAAIC,EAAoBF,MAKDA,KAAGG,IAAW,EAKdH,KAAGI,IAAW,GAKdJ,KAAIK,KAAW,EAKdL,KAAMM,QAAG,CAyDtD,CAvDC,MAAAC,GACE,MAAMC,EAAQC,OAAOT,KAAKQ,QAAU,EAC9BE,EAAUC,KAAKP,IAAI,GAAII,EAAQR,KAAKG,MAAQH,KAAKI,IAAMJ,KAAKG,MAElE,OAAOS,CAAI,kCAELZ,KAAKa,YAAYD,CAAI,mDAAmDJ,sBAGtEM,EAAId,KAAKe,qBACNf,KAAKgB,gCAEFC,EAAS,CACf,WAAW,EACX,SAAUjB,KAAKC,UAAUiB,kBAEpBC,EAAUnB,KAAKoB,eAChBpB,KAAKG,cACJH,KAAKK,cACNL,KAAKI,eACH,wBAAkC,IAAVM,oBACpBV,KAAKqB,iCACLrB,KAAKsB,wBACLtB,KAAKuB,qBACRvB,KAAKQ,MAAQR,KAAKQ,MAAQ,gBAC1BR,KAAKwB,yBACJxB,KAAKyB,6BACFN,EAAUnB,KAAK0B,wCACTP,EAAUnB,KAAK2B,0CACnBR,EAAUnB,KAAK4B,8BAIhC5B,KAAK6B,iBACL7B,KAAK8B,YAAc9B,KAAK+B,aAAeC,GAE5C,CAES,WAAAR,CAAYS,GACpBA,EAAEC,kBACF,MAAMC,EAASF,EAAEE,OAEjB,GAAInC,KAAKuB,SAGP,OAFAU,EAAEG,sBACFD,EAAO3B,MAAQR,KAAKQ,OAItBR,KAAKQ,MAAQ2B,EAAO3B,MAKpBR,KAAKqC,cAAc,IAAIC,EAAU,SAClC,GA9EM9C,EAAM+C,OAAG,CAACC,EAAgBC,EAAgBC,EAAgBC,GAOtBC,EAAA,CAA1CC,EAAS,CAAEC,SAAS,EAAMC,KAAMtC,UAAyBjB,EAAAwD,UAAA,WAAA,GAKfJ,EAAA,CAA1CC,EAAS,CAAEC,SAAS,EAAMC,KAAMtC,UAA0BjB,EAAAwD,UAAA,WAAA,GAKhBJ,EAAA,CAA1CC,EAAS,CAAEC,SAAS,EAAMC,KAAMtC,UAA0BjB,EAAAwD,UAAA,YAAA,GAKfJ,EAAA,CAA3CC,EAAS,CAAEC,SAAS,EAAMC,KAAME,WAAyBzD,EAAAwD,UAAA,cAAA,GAzBvCxD,EAAKoD,EAAA,CADzBM,EAAc,eACM1D,SAAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{_ as o}from"./tslib.es6-CmLYFWVC.js";import{property as r}from"lit/decorators.js";function t(t){class e extends t{constructor(){super(...arguments),this.readonly=!1}}return o([r({type:Boolean,reflect:!0})],e.prototype,"readonly",void 0),e}export{t as R};
|
|
2
|
+
//# sourceMappingURL=ReadonlyMixin-BdJPGtQ3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReadonlyMixin-BdJPGtQ3.js","sources":["../src/common/mixins/ReadonlyMixin.ts"],"sourcesContent":["import type { LitElement } from 'lit'\nimport { property } from 'lit/decorators.js'\n\ntype Constructor<T = Record<string, unknown>> = new (...args: any[]) => T\n\nexport declare class ReadonlyMixinInterface {\n readonly: boolean\n}\n\nexport function ReadonlyMixin<T extends Constructor<LitElement>>(\n superClass: T,\n): Constructor<ReadonlyMixinInterface> & T {\n class ReadonlyElement extends superClass {\n /**\n * Makes the component readonly, so that it is not editable.\n * Readonly differs from disabled in that readonly fields are still focusable and will be submitted with a form.\n */\n @property({ type: Boolean, reflect: true }) readonly = false\n }\n\n return ReadonlyElement\n}\n"],"names":["ReadonlyMixin","superClass","ReadonlyElement","constructor","this","readonly","__decorate","property","type","Boolean","reflect","prototype"],"mappings":"yFASM,SAAUA,EACdC,GAEA,MAAMC,UAAwBD,EAA9B,WAAAE,uBAK8CC,KAAQC,UAAG,CACxD,EAED,OAH8CC,EAAA,CAA3CC,EAAS,CAAEC,KAAMC,QAASC,SAAS,KAAwBR,EAAAS,UAAA,gBAAA,GAGvDT,CACT"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{isServer as e}from"lit";class t{constructor(t,r){this.target=r,this.hadFirstUpdate=!1,t.addController(this),e||(this.observer=new ResizeObserver((([e])=>{const[r]=e.borderBoxSize;this.borderBoxSize=r,t.requestUpdate()})))}get inlineSize(){var e;return null===(e=this.borderBoxSize)||void 0===e?void 0:e.inlineSize}get blockSize(){var e;return null===(e=this.borderBoxSize)||void 0===e?void 0:e.blockSize}hostUpdated(){!this.hadFirstUpdate&&this.observer&&(this.observer.observe(this.target()),this.hadFirstUpdate=!0)}hostConnected(){this.hadFirstUpdate&&this.observer&&this.observer.observe(this.target())}hostDisconnected(){this.observer&&this.observer.disconnect()}}export{t as R};
|
|
2
|
+
//# sourceMappingURL=ResizeController-14PUwRQy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResizeController-14PUwRQy.js","sources":["../src/common/controllers/ResizeController.ts"],"sourcesContent":["import type { ReactiveController, ReactiveControllerHost } from 'lit'\nimport { isServer } from 'lit'\n\nexport class ResizeController implements ReactiveController {\n private observer?: ResizeObserver\n private hadFirstUpdate = false\n private borderBoxSize?: ResizeObserverSize\n\n constructor(\n host: ReactiveControllerHost,\n private target: () => HTMLElement,\n ) {\n host.addController(this)\n\n if (!isServer) {\n this.observer = new ResizeObserver(([entry]) => {\n const [borderBoxSize] = entry.borderBoxSize\n this.borderBoxSize = borderBoxSize\n host.requestUpdate()\n })\n }\n }\n\n get inlineSize() {\n return this.borderBoxSize?.inlineSize\n }\n\n get blockSize() {\n return this.borderBoxSize?.blockSize\n }\n\n hostUpdated() {\n if (!this.hadFirstUpdate && this.observer) {\n this.observer.observe(this.target())\n this.hadFirstUpdate = true\n }\n }\n\n hostConnected() {\n // in case the host has rendered, disconnected, and is now reconnected\n if (this.hadFirstUpdate && this.observer) {\n this.observer.observe(this.target())\n }\n }\n\n hostDisconnected() {\n if (this.observer) {\n this.observer.disconnect()\n }\n }\n}\n"],"names":["ResizeController","constructor","host","target","this","hadFirstUpdate","addController","isServer","observer","ResizeObserver","entry","borderBoxSize","requestUpdate","inlineSize","_a","blockSize","hostUpdated","observe","hostConnected","hostDisconnected","disconnect"],"mappings":"qCAGaA,EAKX,WAAAC,CACEC,EACQC,GAAAC,KAAMD,OAANA,EALFC,KAAcC,gBAAG,EAOvBH,EAAKI,cAAcF,MAEdG,IACHH,KAAKI,SAAW,IAAIC,gBAAe,EAAEC,MACnC,MAAOC,GAAiBD,EAAMC,cAC9BP,KAAKO,cAAgBA,EACrBT,EAAKU,eAAe,IAGzB,CAED,cAAIC,SACF,OAAyB,UAAlBT,KAAKO,qBAAa,IAAAG,OAAA,EAAAA,EAAED,UAC5B,CAED,aAAIE,SACF,OAAyB,UAAlBX,KAAKO,qBAAa,IAAAG,OAAA,EAAAA,EAAEC,SAC5B,CAED,WAAAC,IACOZ,KAAKC,gBAAkBD,KAAKI,WAC/BJ,KAAKI,SAASS,QAAQb,KAAKD,UAC3BC,KAAKC,gBAAiB,EAEzB,CAED,aAAAa,GAEMd,KAAKC,gBAAkBD,KAAKI,UAC9BJ,KAAKI,SAASS,QAAQb,KAAKD,SAE9B,CAED,gBAAAgB,GACMf,KAAKI,UACPJ,KAAKI,SAASY,YAEjB"}
|