origam 2.41.0 → 2.42.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +103 -0
- package/dist/src/assets/locales/en.json +10 -1
- package/dist/src/assets/locales/fr.json +10 -1
- package/dist/src/components/Alert/OrigamAlert.vue +1 -2
- package/dist/src/components/Audio/OrigamAudio.vue +15 -14
- package/dist/src/components/Badge/OrigamBadge.vue +6 -1
- package/dist/src/components/Bracket/OrigamBracket.vue +5 -5
- package/dist/src/components/Breadcrumb/OrigamBreadcrumbDivider.vue +1 -2
- package/dist/src/components/Btn/OrigamBtn.vue +71 -27
- package/dist/src/components/Card/OrigamCard.vue +2 -1
- package/dist/src/components/Carousel/OrigamCarousel.vue +14 -13
- package/dist/src/components/Chart/OrigamChartBullet.vue +4 -1
- package/dist/src/components/Chart/OrigamChartPictorial.vue +3 -6
- package/dist/src/components/Chart/OrigamChartPolar.vue +2 -1
- package/dist/src/components/Chart/OrigamChartPolarBar.vue +3 -1
- package/dist/src/components/Chart/OrigamChartSankey.vue +9 -167
- package/dist/src/components/Chart/OrigamChartStreamgraph.vue +14 -12
- package/dist/src/components/Chart/OrigamChartSunburst.vue +10 -2
- package/dist/src/components/Chart/OrigamChartWordCloud.vue +39 -36
- package/dist/src/components/Checkbox/OrigamCheckboxBtn.vue +3 -4
- package/dist/src/components/Chip/OrigamChip.vue +14 -15
- package/dist/src/components/Chip/OrigamChipGroup.vue +2 -3
- package/dist/src/components/Clipboard/OrigamClipboard.vue +1 -1
- package/dist/src/components/Code/OrigamCode.vue +4 -2
- package/dist/src/components/ColorPicker/OrigamColorPicker.vue +5 -1
- package/dist/src/components/ColorPicker/OrigamColorPickerEdit.vue +1 -2
- package/dist/src/components/ColorPicker/OrigamColorPickerPreview.vue +1 -2
- package/dist/src/components/ColorPicker/OrigamColorPickerSwatches.vue +1 -2
- package/dist/src/components/CommandPalette/OrigamCommandPalette.vue +6 -2
- package/dist/src/components/ConfirmWrapper/OrigamConfirmWrapper.vue +2 -4
- package/dist/src/components/Counter/OrigamCounter.vue +1 -0
- package/dist/src/components/DataTable/OrigamDataTable.vue +2 -3
- package/dist/src/components/DataTable/OrigamDataTableGroupHeaderRow.vue +1 -2
- package/dist/src/components/DataTable/OrigamDataTableHeadersCellMobile.vue +3 -2
- package/dist/src/components/DataTable/OrigamDataTableRow.vue +2 -3
- package/dist/src/components/DataTable/OrigamDataTableRows.vue +43 -39
- package/dist/src/components/DatePicker/OrigamDatePickerControls.vue +3 -4
- package/dist/src/components/DatePicker/OrigamDatePickerMonth.vue +1 -1
- package/dist/src/components/DatePickerField/OrigamDatePickerField.vue +1 -2
- package/dist/src/components/Dialog/OrigamDialog.vue +1 -2
- package/dist/src/components/ExpansionPanel/OrigamExpansionPanelHeader.vue +2 -3
- package/dist/src/components/Field/OrigamField.vue +2 -6
- package/dist/src/components/FileField/OrigamFileField.vue +23 -6
- package/dist/src/components/FileField/OrigamFileFieldDragNDropItem.vue +3 -4
- package/dist/src/components/FileField/OrigamFileFieldListItem.vue +3 -4
- package/dist/src/components/Form/OrigamForm.vue +0 -2
- package/dist/src/components/InlineEdit/OrigamInlineEdit.vue +7 -7
- package/dist/src/components/Input/OrigamInput.vue +3 -11
- package/dist/src/components/List/OrigamListGroup.vue +2 -3
- package/dist/src/components/List/OrigamListItem.vue +11 -5
- package/dist/src/components/Media/OrigamMediaController.vue +12 -13
- package/dist/src/components/Media/OrigamMediaScrubber.vue +15 -12
- package/dist/src/components/Media/OrigamMediaVolumeControl.vue +4 -5
- package/dist/src/components/Menu/OrigamMenu.vue +1 -2
- package/dist/src/components/NumberField/OrigamNumberField.vue +7 -10
- package/dist/src/components/NumberFormat/OrigamNumberFormat.vue +7 -1
- package/dist/src/components/OtpInputField/OrigamOtpInputField.vue +1 -1
- package/dist/src/components/Pagination/OrigamPagination.vue +4 -5
- package/dist/src/components/Parallax/OrigamParallaxElement.vue +1 -4
- package/dist/src/components/PasswordField/OrigamPasswordField.vue +37 -15
- package/dist/src/components/Progress/OrigamProgressLinear.vue +7 -6
- package/dist/src/components/Radio/OrigamRadio.vue +5 -2
- package/dist/src/components/Radio/OrigamRadioBtn.vue +7 -5
- package/dist/src/components/RatingField/OrigamRatingField.vue +1 -2
- package/dist/src/components/RatingField/OrigamRatingFieldItem.vue +2 -3
- package/dist/src/components/Select/OrigamSelect.vue +174 -107
- package/dist/src/components/SelectionControl/OrigamSelectionControl.vue +7 -2
- package/dist/src/components/Slide/OrigamSlideGroup.vue +7 -10
- package/dist/src/components/SliderField/OrigamSliderField.vue +1 -2
- package/dist/src/components/Snackbar/OrigamSnackbarItem.vue +9 -10
- package/dist/src/components/Stepper/OrigamStepper.vue +7 -11
- package/dist/src/components/Stepper/OrigamStepperItem.vue +2 -3
- package/dist/src/components/Switch/OrigamSwitch.vue +0 -9
- package/dist/src/components/Tabs/OrigamTabs.vue +1 -1
- package/dist/src/components/TextField/OrigamTextField.vue +2 -5
- package/dist/src/components/TextareaField/OrigamTextareaField.vue +3 -2
- package/dist/src/components/TextareaField/OrigamTextareaFieldRichToolbar.vue +13 -14
- package/dist/src/components/Transition/OrigamExpandX.vue +4 -10
- package/dist/src/components/Transition/OrigamExpandY.vue +4 -10
- package/dist/src/components/Transition/OrigamSnack.vue +2 -8
- package/dist/src/components/Treeview/OrigamTreeviewNode.vue +24 -18
- package/dist/src/components/Video/OrigamVideo.vue +14 -19
- package/dist/src/components/Window/OrigamWindow.vue +2 -3
- package/dist/src/composables/Audio/use-waveform.composable.cjs +24 -19
- package/dist/src/composables/Audio/use-waveform.composable.js +24 -19
- package/dist/src/composables/Calendar/calendar.composable.cjs +11 -11
- package/dist/src/composables/Calendar/calendar.composable.js +1 -1
- package/dist/src/composables/Chart/chart.composable.cjs +541 -415
- package/dist/src/composables/Chart/chart.composable.d.ts +2 -5
- package/dist/src/composables/Chart/chart.composable.js +392 -338
- package/dist/src/composables/Code/code.composable.cjs +4 -4
- package/dist/src/composables/Code/code.composable.js +1 -1
- package/dist/src/composables/Commons/color.composable.cjs +106 -48
- package/dist/src/composables/Commons/color.composable.js +55 -48
- package/dist/src/composables/Commons/display.composable.cjs +7 -1
- package/dist/src/composables/Commons/display.composable.js +2 -2
- package/dist/src/composables/Commons/dragResizer.composable.cjs +11 -10
- package/dist/src/composables/Commons/dragResizer.composable.js +2 -1
- package/dist/src/composables/Commons/group.composable.cjs +17 -14
- package/dist/src/composables/Commons/group.composable.js +19 -15
- package/dist/src/composables/Commons/nested.composable.cjs +16 -16
- package/dist/src/composables/Commons/nested.composable.d.ts +1 -1
- package/dist/src/composables/Commons/nested.composable.js +1 -1
- package/dist/src/composables/Commons/nestedItem.composable.cjs +3 -3
- package/dist/src/composables/Commons/nestedItem.composable.d.ts +1 -1
- package/dist/src/composables/Commons/nestedItem.composable.js +1 -1
- package/dist/src/composables/Commons/size.composable.cjs +1 -1
- package/dist/src/composables/Commons/size.composable.js +1 -1
- package/dist/src/composables/Commons/stateEffect.composable.cjs +54 -32
- package/dist/src/composables/Commons/stateEffect.composable.js +43 -33
- package/dist/src/composables/Commons/teleport.composable.cjs +2 -1
- package/dist/src/composables/Commons/teleport.composable.js +4 -1
- package/dist/src/composables/Commons/touch.composable.cjs +77 -33
- package/dist/src/composables/Commons/touch.composable.js +77 -33
- package/dist/src/composables/Commons/vModel.composable.cjs +1 -1
- package/dist/src/composables/Commons/vModel.composable.js +1 -1
- package/dist/src/composables/Commons/validation.composable.cjs +1 -1
- package/dist/src/composables/Commons/validation.composable.js +1 -1
- package/dist/src/composables/Commons/velocity.composable.cjs +5 -1
- package/dist/src/composables/Commons/velocity.composable.js +5 -1
- package/dist/src/composables/DataTable/headers.composable.cjs +36 -30
- package/dist/src/composables/DataTable/headers.composable.d.ts +1 -1
- package/dist/src/composables/DataTable/headers.composable.js +29 -23
- package/dist/src/composables/DataTable/headersCell.composable.cjs +2 -2
- package/dist/src/composables/DataTable/headersCell.composable.js +1 -1
- package/dist/src/composables/DataTable/select.composable.cjs +4 -4
- package/dist/src/composables/DataTable/select.composable.js +1 -1
- package/dist/src/composables/DataTable/sort.composable.cjs +6 -6
- package/dist/src/composables/DataTable/sort.composable.js +1 -1
- package/dist/src/composables/Form/form.composable.cjs +1 -1
- package/dist/src/composables/Form/form.composable.js +3 -1
- package/dist/src/composables/Masonry/masonry.composable.cjs +29 -20
- package/dist/src/composables/Masonry/masonry.composable.d.ts +0 -14
- package/dist/src/composables/Masonry/masonry.composable.js +29 -20
- package/dist/src/composables/NumberFormat/number-format.composable.cjs +28 -23
- package/dist/src/composables/NumberFormat/number-format.composable.js +28 -23
- package/dist/src/composables/Parallax/parallax.composable.cjs +9 -9
- package/dist/src/composables/Parallax/parallax.composable.js +3 -3
- package/dist/src/composables/Parallax/transform.composable.cjs +14 -13
- package/dist/src/composables/Parallax/transform.composable.js +2 -1
- package/dist/src/composables/PasswordField/passwordStrength.composable.cjs +2 -2
- package/dist/src/composables/PasswordField/passwordStrength.composable.js +1 -1
- package/dist/src/composables/QrCode/qr-code.composable.cjs +1 -1
- package/dist/src/composables/QrCode/qr-code.composable.js +1 -1
- package/dist/src/composables/Sheet/sheetSwipe.composable.cjs +3 -4
- package/dist/src/composables/Sheet/sheetSwipe.composable.js +4 -4
- package/dist/src/composables/TextareaField/textarea-field-rich.composable.cjs +31 -31
- package/dist/src/composables/TextareaField/textarea-field-rich.composable.js +1 -1
- package/dist/src/composables/Watermark/watermark.composable.cjs +1 -1
- package/dist/src/composables/Watermark/watermark.composable.js +1 -1
- package/dist/src/consts/Audio/audio.const.cjs +5 -4
- package/dist/src/consts/Audio/audio.const.d.ts +2 -1
- package/dist/src/consts/Audio/audio.const.js +2 -1
- package/dist/src/consts/Blockquote/blockquote.const.cjs +3 -3
- package/dist/src/consts/Blockquote/blockquote.const.js +1 -1
- package/dist/src/consts/Bracket/bracket.const.cjs +4 -3
- package/dist/src/consts/Bracket/bracket.const.js +2 -1
- package/dist/src/consts/Code/code.const.cjs +3 -3
- package/dist/src/consts/Code/code.const.d.ts +1 -1
- package/dist/src/consts/Code/code.const.js +1 -1
- package/dist/src/consts/Commons/autocomplete.const.cjs +2 -2
- package/dist/src/consts/Commons/autocomplete.const.d.ts +1 -1
- package/dist/src/consts/Commons/autocomplete.const.js +1 -1
- package/dist/src/consts/Commons/display.const.cjs +2 -2
- package/dist/src/consts/Commons/display.const.js +1 -1
- package/dist/src/consts/Commons/hotkey.const.cjs +2 -2
- package/dist/src/consts/Commons/hotkey.const.js +1 -1
- package/dist/src/consts/Commons/margin.const.cjs +1 -1
- package/dist/src/consts/Commons/margin.const.js +1 -1
- package/dist/src/consts/Commons/padding.const.cjs +1 -1
- package/dist/src/consts/Commons/padding.const.js +1 -1
- package/dist/src/consts/Commons/rounded.const.cjs +6 -2
- package/dist/src/consts/Commons/rounded.const.js +6 -2
- package/dist/src/consts/EmptyState/empty-state.const.cjs +12 -12
- package/dist/src/consts/EmptyState/empty-state.const.js +6 -6
- package/dist/src/consts/PasswordField/password-field.const.cjs +20 -11
- package/dist/src/consts/PasswordField/password-field.const.d.ts +10 -5
- package/dist/src/consts/PasswordField/password-field.const.js +17 -10
- package/dist/src/consts/QrCode/qr-code.const.cjs +2 -2
- package/dist/src/consts/QrCode/qr-code.const.js +1 -1
- package/dist/src/consts/TextField/text-field.const.cjs +21 -21
- package/dist/src/consts/TextField/text-field.const.js +1 -1
- package/dist/src/consts/TextareaField/textarea-field.const.cjs +32 -4
- package/dist/src/consts/TextareaField/textarea-field.const.d.ts +1 -0
- package/dist/src/consts/TextareaField/textarea-field.const.js +29 -1
- package/dist/src/directives/Contrast/contrast.directive.cjs +5 -3
- package/dist/src/directives/Contrast/contrast.directive.js +5 -3
- package/dist/src/directives/Intersect/intersect.directive.cjs +2 -1
- package/dist/src/directives/Intersect/intersect.directive.js +2 -1
- package/dist/src/interfaces/Chart/chart.interface.d.ts +70 -1
- package/dist/src/interfaces/ColorPicker/color-picker.interface.d.ts +1 -1
- package/dist/src/interfaces/Commons/border.interface.d.ts +11 -10
- package/dist/src/interfaces/Commons/filters.interface.d.ts +7 -0
- package/dist/src/interfaces/Commons/margin.interface.d.ts +12 -11
- package/dist/src/interfaces/Commons/padding.interface.d.ts +12 -11
- package/dist/src/interfaces/Commons/ripple.interface.d.ts +1 -3
- package/dist/src/interfaces/Commons/rounded.interface.d.ts +10 -9
- package/dist/src/interfaces/DataTable/sort.interface.d.ts +6 -0
- package/dist/src/interfaces/Grid/grid.interface.d.ts +4 -4
- package/dist/src/interfaces/PasswordField/password-field.interface.d.ts +5 -1
- package/dist/src/interfaces/PasswordField/password-requirement.interface.d.ts +8 -0
- package/dist/src/interfaces/Radio/radio-btn.interface.d.ts +2 -2
- package/dist/src/interfaces/Radio/radio.interface.d.ts +2 -1
- package/dist/src/interfaces/Select/select.interface.d.ts +1 -0
- package/dist/src/interfaces/SelectionControl/selection-control.interface.d.ts +5 -1
- package/dist/src/interfaces/SliderField/slider-field.interface.d.ts +4 -4
- package/dist/src/origam-core.cjs +51 -33
- package/dist/src/origam-core.js +21 -27
- package/dist/src/types/Commons/box-value.type.cjs +1 -0
- package/dist/src/types/Commons/box-value.type.d.ts +1 -0
- package/dist/src/types/Commons/box-value.type.js +0 -0
- package/dist/src/types/Commons/location.type.d.ts +13 -0
- package/dist/src/types/Commons/point.type.d.ts +1 -1
- package/dist/src/types/DataTable/data-table.type.d.ts +1 -0
- package/dist/src/types/Grid/grid.type.d.ts +7 -0
- package/dist/src/types/SliderField/slider-field.type.d.ts +8 -0
- package/dist/src/utils/Bracket/bracket-surface.util.cjs +9 -2
- package/dist/src/utils/Bracket/bracket-surface.util.js +9 -2
- package/dist/src/utils/Calendar/rrule.util.cjs +12 -7
- package/dist/src/utils/Calendar/rrule.util.js +12 -7
- package/dist/src/utils/Chart/chart-point.util.cjs +15 -0
- package/dist/src/utils/Chart/chart-point.util.d.ts +11 -0
- package/dist/src/utils/Chart/chart-point.util.js +8 -0
- package/dist/src/utils/Chart/sankey-layout.util.cjs +144 -0
- package/dist/src/utils/Chart/sankey-layout.util.d.ts +27 -0
- package/dist/src/utils/Chart/sankey-layout.util.js +130 -0
- package/dist/src/utils/Code/parse-highlight-lines.util.cjs +17 -14
- package/dist/src/utils/Code/parse-highlight-lines.util.js +17 -14
- package/dist/src/utils/CommandPalette/fuzzy-match.util.cjs +13 -9
- package/dist/src/utils/CommandPalette/fuzzy-match.util.js +13 -9
- package/dist/src/utils/Commons/anchor.util.cjs +6 -1
- package/dist/src/utils/Commons/anchor.util.js +6 -1
- package/dist/src/utils/Commons/apply-mask.util.cjs +11 -14
- package/dist/src/utils/Commons/apply-mask.util.js +7 -10
- package/dist/src/utils/Commons/apply-theme.util.cjs +6 -4
- package/dist/src/utils/Commons/apply-theme.util.js +6 -4
- package/dist/src/utils/Commons/bindProps.util.cjs +3 -5
- package/dist/src/utils/Commons/bindProps.util.js +3 -5
- package/dist/src/utils/Commons/color.util.cjs +43 -36
- package/dist/src/utils/Commons/color.util.js +44 -31
- package/dist/src/utils/Commons/commons.util.cjs +3 -3
- package/dist/src/utils/Commons/commons.util.js +3 -3
- package/dist/src/utils/Commons/console.util.cjs +6 -0
- package/dist/src/utils/Commons/console.util.d.ts +11 -0
- package/dist/src/utils/Commons/console.util.js +5 -0
- package/dist/src/utils/Commons/date.util.cjs +2 -27
- package/dist/src/utils/Commons/date.util.js +2 -27
- package/dist/src/utils/Commons/display.util.cjs +10 -1
- package/dist/src/utils/Commons/display.util.d.ts +8 -1
- package/dist/src/utils/Commons/display.util.js +9 -1
- package/dist/src/utils/Commons/eventListener.util.cjs +1 -2
- package/dist/src/utils/Commons/eventListener.util.js +1 -2
- package/dist/src/utils/Commons/filters.util.cjs +48 -34
- package/dist/src/utils/Commons/filters.util.d.ts +3 -8
- package/dist/src/utils/Commons/filters.util.js +47 -34
- package/dist/src/utils/Commons/forwardRefs.util.cjs +44 -40
- package/dist/src/utils/Commons/forwardRefs.util.js +44 -40
- package/dist/src/utils/Commons/group.util.cjs +1 -1
- package/dist/src/utils/Commons/group.util.js +1 -1
- package/dist/src/utils/Commons/hotkey.util.cjs +65 -61
- package/dist/src/utils/Commons/hotkey.util.js +56 -53
- package/dist/src/utils/Commons/hover.util.cjs +2 -2
- package/dist/src/utils/Commons/hover.util.js +2 -2
- package/dist/src/utils/Commons/locale.util.cjs +1 -1
- package/dist/src/utils/Commons/locale.util.js +1 -1
- package/dist/src/utils/Commons/location.util.cjs +87 -92
- package/dist/src/utils/Commons/location.util.js +75 -83
- package/dist/src/utils/Commons/nested.util.cjs +11 -11
- package/dist/src/utils/Commons/nested.util.js +1 -1
- package/dist/src/utils/Commons/point.util.cjs +16 -14
- package/dist/src/utils/Commons/point.util.js +13 -8
- package/dist/src/utils/Commons/ripple.util.cjs +4 -4
- package/dist/src/utils/Commons/ripple.util.js +4 -4
- package/dist/src/utils/Commons/scroll.util.cjs +9 -6
- package/dist/src/utils/Commons/scroll.util.js +9 -6
- package/dist/src/utils/Commons/token-name.util.cjs +22 -21
- package/dist/src/utils/Commons/token-name.util.js +22 -21
- package/dist/src/utils/Commons/validate-pattern.util.cjs +6 -6
- package/dist/src/utils/Commons/validate-pattern.util.js +1 -1
- package/dist/src/utils/DataTable/headers.util.cjs +20 -26
- package/dist/src/utils/DataTable/headers.util.js +18 -26
- package/dist/src/utils/DataTable/sort.util.cjs +41 -47
- package/dist/src/utils/DataTable/sort.util.d.ts +2 -7
- package/dist/src/utils/DataTable/sort.util.js +49 -47
- package/dist/src/utils/List/list-item.util.cjs +6 -1
- package/dist/src/utils/List/list-item.util.js +6 -1
- package/dist/src/utils/Parallax/parallax-element.util.cjs +13 -14
- package/dist/src/utils/Parallax/parallax-element.util.js +10 -11
- package/dist/src/utils/Slide/slide-group.util.cjs +4 -4
- package/dist/src/utils/Slide/slide-group.util.js +4 -4
- package/dist/src/utils/TextareaField/html-to-markdown.util.cjs +5 -36
- package/dist/src/utils/TextareaField/html-to-markdown.util.js +5 -36
- package/dist/src/utils/TextareaField/sanitize-html.util.cjs +18 -22
- package/dist/src/utils/TextareaField/sanitize-html.util.js +19 -23
- package/dist/src/utils/index.cjs +11 -0
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/src/utils/index.js +1 -0
- package/package.json +1 -1
|
@@ -34,32 +34,27 @@ export function convertToInternalHeaders(items) {
|
|
|
34
34
|
}
|
|
35
35
|
export function parseFixedColumns(items) {
|
|
36
36
|
let seenFixed = false;
|
|
37
|
+
const markFixedLeaf = (item) => {
|
|
38
|
+
if (!seenFixed) {
|
|
39
|
+
item.lastFixed = true;
|
|
40
|
+
} else if (isNaN(+item.width)) {
|
|
41
|
+
consoleError(`Multiple fixed columns should have a static width (key: ${item.key})`);
|
|
42
|
+
}
|
|
43
|
+
seenFixed = true;
|
|
44
|
+
};
|
|
37
45
|
const setFixed = (item, parentFixed = false) => {
|
|
38
46
|
if (!item) return;
|
|
39
47
|
if (parentFixed) {
|
|
40
48
|
item.fixed = true;
|
|
41
49
|
}
|
|
42
|
-
if (item.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
setFixed(item.children[i], true);
|
|
46
|
-
}
|
|
47
|
-
} else {
|
|
48
|
-
if (!seenFixed) {
|
|
49
|
-
item.lastFixed = true;
|
|
50
|
-
} else if (isNaN(+item.width)) {
|
|
51
|
-
consoleError(`Multiple fixed columns should have a static width (key: ${item.key})`);
|
|
52
|
-
}
|
|
53
|
-
seenFixed = true;
|
|
50
|
+
if (item.children) {
|
|
51
|
+
for (let i = item.children.length - 1; i >= 0; i--) {
|
|
52
|
+
setFixed(item.children[i], !!item.fixed);
|
|
54
53
|
}
|
|
54
|
+
} else if (item.fixed) {
|
|
55
|
+
markFixedLeaf(item);
|
|
55
56
|
} else {
|
|
56
|
-
|
|
57
|
-
for (let i = item.children.length - 1; i >= 0; i--) {
|
|
58
|
-
setFixed(item.children[i]);
|
|
59
|
-
}
|
|
60
|
-
} else {
|
|
61
|
-
seenFixed = false;
|
|
62
|
-
}
|
|
57
|
+
seenFixed = false;
|
|
63
58
|
}
|
|
64
59
|
};
|
|
65
60
|
const setFixedOffset = (item, fixedOffset2 = 0) => {
|
|
@@ -88,10 +83,9 @@ export function parseHeaderItems(items, maxDepth) {
|
|
|
88
83
|
let currentDepth = 0;
|
|
89
84
|
const queue = priorityQueue(items);
|
|
90
85
|
while (queue.size() > 0) {
|
|
91
|
-
|
|
92
|
-
let fraction = 1;
|
|
86
|
+
const rowSize = queue.count();
|
|
93
87
|
const row = [];
|
|
94
|
-
|
|
88
|
+
for (let fraction = 1; fraction <= rowSize; fraction++) {
|
|
95
89
|
const { element: item, priority } = queue.dequeue();
|
|
96
90
|
const diff = maxDepth - currentDepth - getHeaderDepth(item);
|
|
97
91
|
row.push({
|
|
@@ -105,8 +99,6 @@ export function parseHeaderItems(items, maxDepth) {
|
|
|
105
99
|
queue.enqueue(child, currentDepth + diff + sort);
|
|
106
100
|
}
|
|
107
101
|
}
|
|
108
|
-
fraction += 1;
|
|
109
|
-
rowSize -= 1;
|
|
110
102
|
}
|
|
111
103
|
currentDepth += 1;
|
|
112
104
|
headers.push(row);
|
|
@@ -148,8 +140,8 @@ export function priorityQueue(arr = []) {
|
|
|
148
140
|
let count = 0;
|
|
149
141
|
if (!queue.length) return 0;
|
|
150
142
|
const whole = Math.floor(queue[0].priority);
|
|
151
|
-
for (
|
|
152
|
-
if (Math.floor(
|
|
143
|
+
for (const { priority } of queue) {
|
|
144
|
+
if (Math.floor(priority) === whole) count += 1;
|
|
153
145
|
}
|
|
154
146
|
return count;
|
|
155
147
|
},
|
|
@@ -4,56 +4,50 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.sortItems = sortItems;
|
|
7
|
-
var
|
|
7
|
+
var _sort = require("../../enums/Commons/sort.enum.cjs");
|
|
8
8
|
var _commons = require("../Commons/commons.util.cjs");
|
|
9
|
+
function compareWithCustom(sortKey, raw, values, options) {
|
|
10
|
+
let hasCustomResult = false;
|
|
11
|
+
for (const [compare, valueA, valueB] of [[options?.sortRawFunctions?.[sortKey], raw[0], raw[1]], [options?.sortFunctions?.[sortKey], values[0], values[1]]]) {
|
|
12
|
+
if (!compare) continue;
|
|
13
|
+
const customResult = compare(valueA, valueB);
|
|
14
|
+
if (customResult == null) return null;
|
|
15
|
+
hasCustomResult = true;
|
|
16
|
+
if (customResult !== 0) return customResult;
|
|
17
|
+
}
|
|
18
|
+
return hasCustomResult ? null : void 0;
|
|
19
|
+
}
|
|
20
|
+
function compareValues(valueA, valueB) {
|
|
21
|
+
if (valueA instanceof Date && valueB instanceof Date) {
|
|
22
|
+
return valueA.getTime() - valueB.getTime();
|
|
23
|
+
}
|
|
24
|
+
const sortA = valueA != null ? valueA.toString().toLocaleLowerCase() : valueA;
|
|
25
|
+
const sortB = valueB != null ? valueB.toString().toLocaleLowerCase() : valueB;
|
|
26
|
+
if (sortA === sortB) return void 0;
|
|
27
|
+
if ((0, _commons.isEmpty)(sortA) && (0, _commons.isEmpty)(sortB)) return 0;
|
|
28
|
+
if ((0, _commons.isEmpty)(sortA)) return -1;
|
|
29
|
+
if ((0, _commons.isEmpty)(sortB)) return 1;
|
|
30
|
+
if (!isNaN(sortA) && !isNaN(sortB)) return Number(sortA) - Number(sortB);
|
|
31
|
+
return sortA.localeCompare(sortB);
|
|
32
|
+
}
|
|
33
|
+
function compareBySortItem(a, b, sortByItem, options) {
|
|
34
|
+
const sortKey = sortByItem.key;
|
|
35
|
+
const sortOrder = sortByItem.order ?? _sort.SORT_DIRECTION.ASC;
|
|
36
|
+
if (sortOrder === false) return void 0;
|
|
37
|
+
const [first, second] = sortOrder === _sort.SORT_DIRECTION.DESC ? [b, a] : [a, b];
|
|
38
|
+
const custom = compareWithCustom(sortKey, [first[0].raw, second[0].raw], [first[1][sortKey], second[1][sortKey]], options);
|
|
39
|
+
if (custom === null) return void 0;
|
|
40
|
+
if (custom !== void 0) return custom;
|
|
41
|
+
return compareValues(first[1][sortKey], second[1][sortKey]);
|
|
42
|
+
}
|
|
9
43
|
function sortItems(items, sortByItems, options) {
|
|
10
44
|
const transformedItems = items.map(item => [item, options?.transform ? options.transform(item) : item]);
|
|
11
|
-
|
|
12
|
-
for (
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const sortOrder = sortByItems[i].order ?? _enums.SORT_DIRECTION.ASC;
|
|
16
|
-
if (sortOrder === false) continue;
|
|
17
|
-
let sortA = a[1][sortKey];
|
|
18
|
-
let sortB = b[1][sortKey];
|
|
19
|
-
let sortARaw = a[0].raw;
|
|
20
|
-
let sortBRaw = b[0].raw;
|
|
21
|
-
if (sortOrder === _enums.SORT_DIRECTION.DESC) {
|
|
22
|
-
const tempA = sortA;
|
|
23
|
-
const tempB = sortB;
|
|
24
|
-
sortA = tempB;
|
|
25
|
-
sortB = tempA;
|
|
26
|
-
const tempARaw = sortARaw;
|
|
27
|
-
const tempBRaw = sortBRaw;
|
|
28
|
-
sortARaw = tempBRaw;
|
|
29
|
-
sortBRaw = tempARaw;
|
|
30
|
-
}
|
|
31
|
-
if (options?.sortRawFunctions?.[sortKey]) {
|
|
32
|
-
const customResult = options.sortRawFunctions[sortKey](sortARaw, sortBRaw);
|
|
33
|
-
if (customResult == null) continue;
|
|
34
|
-
hasCustomResult = true;
|
|
35
|
-
if (customResult !== 0) return customResult;
|
|
36
|
-
}
|
|
37
|
-
if (options?.sortFunctions?.[sortKey]) {
|
|
38
|
-
const customResult = options.sortFunctions[sortKey](sortA, sortB);
|
|
39
|
-
if (customResult == null) continue;
|
|
40
|
-
hasCustomResult = true;
|
|
41
|
-
if (customResult !== 0) return customResult;
|
|
42
|
-
}
|
|
43
|
-
if (hasCustomResult) continue;
|
|
44
|
-
if (sortA instanceof Date && sortB instanceof Date) {
|
|
45
|
-
return sortA.getTime() - sortB.getTime();
|
|
46
|
-
}
|
|
47
|
-
sortA = sortA != null ? sortA.toString().toLocaleLowerCase() : sortA;
|
|
48
|
-
sortB = sortB != null ? sortB.toString().toLocaleLowerCase() : sortB;
|
|
49
|
-
if (sortA !== sortB) {
|
|
50
|
-
if ((0, _commons.isEmpty)(sortA) && (0, _commons.isEmpty)(sortB)) return 0;
|
|
51
|
-
if ((0, _commons.isEmpty)(sortA)) return -1;
|
|
52
|
-
if ((0, _commons.isEmpty)(sortB)) return 1;
|
|
53
|
-
if (!isNaN(sortA) && !isNaN(sortB)) return Number(sortA) - Number(sortB);
|
|
54
|
-
return sortA.localeCompare(sortB);
|
|
55
|
-
}
|
|
45
|
+
const sorted = transformedItems.sort((a, b) => {
|
|
46
|
+
for (const sortByItem of sortByItems) {
|
|
47
|
+
const result = compareBySortItem(a, b, sortByItem, options);
|
|
48
|
+
if (result !== void 0) return result;
|
|
56
49
|
}
|
|
57
50
|
return 0;
|
|
58
|
-
})
|
|
51
|
+
});
|
|
52
|
+
return sorted.map(([item]) => item);
|
|
59
53
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { IDataTableSortItem } from '../../interfaces/DataTable/sort.interface';
|
|
1
|
+
import type { IDataTableSortItem, IDataTableSortItemsOptions } from '../../interfaces/DataTable/sort.interface';
|
|
2
2
|
import type { IInternalItem } from '../../interfaces/List/list-children.interface';
|
|
3
|
-
import type { TDataTableCompareFunction } from '../../types/DataTable/data-table.type';
|
|
4
3
|
/**
|
|
5
4
|
* Sort items.
|
|
6
5
|
*
|
|
@@ -8,8 +7,4 @@ import type { TDataTableCompareFunction } from '../../types/DataTable/data-table
|
|
|
8
7
|
* @param sortByItems …
|
|
9
8
|
* @param options …
|
|
10
9
|
*/
|
|
11
|
-
export declare function sortItems<T extends IInternalItem>(items: T[], sortByItems: Array<IDataTableSortItem>, options?:
|
|
12
|
-
transform?: (item: T) => Record<string, any>;
|
|
13
|
-
sortFunctions?: Record<string, TDataTableCompareFunction>;
|
|
14
|
-
sortRawFunctions?: Record<string, TDataTableCompareFunction>;
|
|
15
|
-
}): T[];
|
|
10
|
+
export declare function sortItems<T extends IInternalItem>(items: T[], sortByItems: Array<IDataTableSortItem>, options?: IDataTableSortItemsOptions<T>): T[];
|
|
@@ -1,55 +1,57 @@
|
|
|
1
|
-
import { SORT_DIRECTION } from "../../enums/
|
|
1
|
+
import { SORT_DIRECTION } from "../../enums/Commons/sort.enum.js";
|
|
2
2
|
import { isEmpty } from "../Commons/commons.util.js";
|
|
3
|
+
function compareWithCustom(sortKey, raw, values, options) {
|
|
4
|
+
let hasCustomResult = false;
|
|
5
|
+
for (const [compare, valueA, valueB] of [
|
|
6
|
+
[options?.sortRawFunctions?.[sortKey], raw[0], raw[1]],
|
|
7
|
+
[options?.sortFunctions?.[sortKey], values[0], values[1]]
|
|
8
|
+
]) {
|
|
9
|
+
if (!compare) continue;
|
|
10
|
+
const customResult = compare(valueA, valueB);
|
|
11
|
+
if (customResult == null) return null;
|
|
12
|
+
hasCustomResult = true;
|
|
13
|
+
if (customResult !== 0) return customResult;
|
|
14
|
+
}
|
|
15
|
+
return hasCustomResult ? null : void 0;
|
|
16
|
+
}
|
|
17
|
+
function compareValues(valueA, valueB) {
|
|
18
|
+
if (valueA instanceof Date && valueB instanceof Date) {
|
|
19
|
+
return valueA.getTime() - valueB.getTime();
|
|
20
|
+
}
|
|
21
|
+
const sortA = valueA != null ? valueA.toString().toLocaleLowerCase() : valueA;
|
|
22
|
+
const sortB = valueB != null ? valueB.toString().toLocaleLowerCase() : valueB;
|
|
23
|
+
if (sortA === sortB) return void 0;
|
|
24
|
+
if (isEmpty(sortA) && isEmpty(sortB)) return 0;
|
|
25
|
+
if (isEmpty(sortA)) return -1;
|
|
26
|
+
if (isEmpty(sortB)) return 1;
|
|
27
|
+
if (!isNaN(sortA) && !isNaN(sortB)) return Number(sortA) - Number(sortB);
|
|
28
|
+
return sortA.localeCompare(sortB);
|
|
29
|
+
}
|
|
30
|
+
function compareBySortItem(a, b, sortByItem, options) {
|
|
31
|
+
const sortKey = sortByItem.key;
|
|
32
|
+
const sortOrder = sortByItem.order ?? SORT_DIRECTION.ASC;
|
|
33
|
+
if (sortOrder === false) return void 0;
|
|
34
|
+
const [first, second] = sortOrder === SORT_DIRECTION.DESC ? [b, a] : [a, b];
|
|
35
|
+
const custom = compareWithCustom(
|
|
36
|
+
sortKey,
|
|
37
|
+
[first[0].raw, second[0].raw],
|
|
38
|
+
[first[1][sortKey], second[1][sortKey]],
|
|
39
|
+
options
|
|
40
|
+
);
|
|
41
|
+
if (custom === null) return void 0;
|
|
42
|
+
if (custom !== void 0) return custom;
|
|
43
|
+
return compareValues(first[1][sortKey], second[1][sortKey]);
|
|
44
|
+
}
|
|
3
45
|
export function sortItems(items, sortByItems, options) {
|
|
4
46
|
const transformedItems = items.map(
|
|
5
47
|
(item) => [item, options?.transform ? options.transform(item) : item]
|
|
6
48
|
);
|
|
7
|
-
|
|
8
|
-
for (
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const sortOrder = sortByItems[i].order ?? SORT_DIRECTION.ASC;
|
|
12
|
-
if (sortOrder === false) continue;
|
|
13
|
-
let sortA = a[1][sortKey];
|
|
14
|
-
let sortB = b[1][sortKey];
|
|
15
|
-
let sortARaw = a[0].raw;
|
|
16
|
-
let sortBRaw = b[0].raw;
|
|
17
|
-
if (sortOrder === SORT_DIRECTION.DESC) {
|
|
18
|
-
const tempA = sortA;
|
|
19
|
-
const tempB = sortB;
|
|
20
|
-
sortA = tempB;
|
|
21
|
-
sortB = tempA;
|
|
22
|
-
const tempARaw = sortARaw;
|
|
23
|
-
const tempBRaw = sortBRaw;
|
|
24
|
-
sortARaw = tempBRaw;
|
|
25
|
-
sortBRaw = tempARaw;
|
|
26
|
-
}
|
|
27
|
-
if (options?.sortRawFunctions?.[sortKey]) {
|
|
28
|
-
const customResult = options.sortRawFunctions[sortKey](sortARaw, sortBRaw);
|
|
29
|
-
if (customResult == null) continue;
|
|
30
|
-
hasCustomResult = true;
|
|
31
|
-
if (customResult !== 0) return customResult;
|
|
32
|
-
}
|
|
33
|
-
if (options?.sortFunctions?.[sortKey]) {
|
|
34
|
-
const customResult = options.sortFunctions[sortKey](sortA, sortB);
|
|
35
|
-
if (customResult == null) continue;
|
|
36
|
-
hasCustomResult = true;
|
|
37
|
-
if (customResult !== 0) return customResult;
|
|
38
|
-
}
|
|
39
|
-
if (hasCustomResult) continue;
|
|
40
|
-
if (sortA instanceof Date && sortB instanceof Date) {
|
|
41
|
-
return sortA.getTime() - sortB.getTime();
|
|
42
|
-
}
|
|
43
|
-
sortA = sortA != null ? sortA.toString().toLocaleLowerCase() : sortA;
|
|
44
|
-
sortB = sortB != null ? sortB.toString().toLocaleLowerCase() : sortB;
|
|
45
|
-
if (sortA !== sortB) {
|
|
46
|
-
if (isEmpty(sortA) && isEmpty(sortB)) return 0;
|
|
47
|
-
if (isEmpty(sortA)) return -1;
|
|
48
|
-
if (isEmpty(sortB)) return 1;
|
|
49
|
-
if (!isNaN(sortA) && !isNaN(sortB)) return Number(sortA) - Number(sortB);
|
|
50
|
-
return sortA.localeCompare(sortB);
|
|
51
|
-
}
|
|
49
|
+
const sorted = transformedItems.sort((a, b) => {
|
|
50
|
+
for (const sortByItem of sortByItems) {
|
|
51
|
+
const result = compareBySortItem(a, b, sortByItem, options);
|
|
52
|
+
if (result !== void 0) return result;
|
|
52
53
|
}
|
|
53
54
|
return 0;
|
|
54
|
-
})
|
|
55
|
+
});
|
|
56
|
+
return sorted.map(([item]) => item);
|
|
55
57
|
}
|
|
@@ -6,6 +6,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.transformListItem = transformListItem;
|
|
7
7
|
exports.transformListItems = transformListItems;
|
|
8
8
|
var _commons = require("../Commons/commons.util.cjs");
|
|
9
|
+
function resolveItemProps(props, item) {
|
|
10
|
+
if (props.itemProps !== true) return (0, _commons.getPropertyFromItem)(item, props.itemProps);
|
|
11
|
+
if (typeof item !== "object" || item == null || Array.isArray(item)) return void 0;
|
|
12
|
+
return "children" in item ? (0, _commons.omit)(item, ["children"]) : item;
|
|
13
|
+
}
|
|
9
14
|
function transformListItems(props, items) {
|
|
10
15
|
const array = [];
|
|
11
16
|
for (const item of items) {
|
|
@@ -18,7 +23,7 @@ function transformListItem(props, item) {
|
|
|
18
23
|
const title = (0, _commons.getPropertyFromItem)(item, props.itemTitle, item);
|
|
19
24
|
const value = (0, _commons.getPropertyFromItem)(item, props.itemValue, title);
|
|
20
25
|
const children = (0, _commons.getPropertyFromItem)(item, props.itemChildren);
|
|
21
|
-
const itemProps = props
|
|
26
|
+
const itemProps = resolveItemProps(props, item);
|
|
22
27
|
const _props = {
|
|
23
28
|
title,
|
|
24
29
|
value,
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { getPropertyFromItem, omit } from "../Commons/commons.util.js";
|
|
2
|
+
function resolveItemProps(props, item) {
|
|
3
|
+
if (props.itemProps !== true) return getPropertyFromItem(item, props.itemProps);
|
|
4
|
+
if (typeof item !== "object" || item == null || Array.isArray(item)) return void 0;
|
|
5
|
+
return "children" in item ? omit(item, ["children"]) : item;
|
|
6
|
+
}
|
|
2
7
|
export function transformListItems(props, items) {
|
|
3
8
|
const array = [];
|
|
4
9
|
for (const item of items) {
|
|
@@ -11,7 +16,7 @@ export function transformListItem(props, item) {
|
|
|
11
16
|
const title = getPropertyFromItem(item, props.itemTitle, item);
|
|
12
17
|
const value = getPropertyFromItem(item, props.itemValue, title);
|
|
13
18
|
const children = getPropertyFromItem(item, props.itemChildren);
|
|
14
|
-
const itemProps = props
|
|
19
|
+
const itemProps = resolveItemProps(props, item);
|
|
15
20
|
const _props = {
|
|
16
21
|
title,
|
|
17
22
|
value,
|
|
@@ -5,7 +5,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.cyclicMovement = cyclicMovement;
|
|
7
7
|
exports.elementMovement = elementMovement;
|
|
8
|
-
var
|
|
8
|
+
var _parallax = require("../../enums/Parallax/parallax.enum.cjs");
|
|
9
|
+
function clampMovement(movement, min, max) {
|
|
10
|
+
if (max && movement > max) return max;
|
|
11
|
+
if (min && movement < min) return min;
|
|
12
|
+
return movement;
|
|
13
|
+
}
|
|
9
14
|
function elementMovement(action) {
|
|
10
15
|
const {
|
|
11
16
|
y,
|
|
@@ -24,20 +29,14 @@ function elementMovement(action) {
|
|
|
24
29
|
let {
|
|
25
30
|
originY = 50
|
|
26
31
|
} = action;
|
|
27
|
-
if (event ===
|
|
32
|
+
if (event === _parallax.PARALLAX_EVENT.SCROLL) {
|
|
28
33
|
originY = -originY / 2;
|
|
29
34
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if (minX || maxX) {
|
|
33
|
-
movementX = maxX && movementX > maxX ? maxX : minX && movementX < minX ? minX : movementX;
|
|
34
|
-
}
|
|
35
|
-
if (minY || maxY) {
|
|
36
|
-
movementY = maxY && movementY > maxY ? maxY : minY && movementY < minY ? minY : movementY;
|
|
37
|
-
}
|
|
35
|
+
const movementX = (x - originX / 50) * strength;
|
|
36
|
+
const movementY = (y - originY / 50) * strength;
|
|
38
37
|
return {
|
|
39
|
-
x: movementX,
|
|
40
|
-
y: movementY,
|
|
38
|
+
x: clampMovement(movementX, minX, maxX),
|
|
39
|
+
y: clampMovement(movementY, minY, maxY),
|
|
41
40
|
target
|
|
42
41
|
};
|
|
43
42
|
}
|
|
@@ -49,8 +48,8 @@ function cyclicMovement(cycleData) {
|
|
|
49
48
|
cycles,
|
|
50
49
|
strength
|
|
51
50
|
} = cycleData;
|
|
52
|
-
const spanningRangeX = event ===
|
|
53
|
-
const spanningRangeY = event ===
|
|
51
|
+
const spanningRangeX = event === _parallax.PARALLAX_EVENT.SCROLL ? window.innerWidth : shape?.width;
|
|
52
|
+
const spanningRangeY = event === _parallax.PARALLAX_EVENT.SCROLL ? window.innerHeight : shape?.height;
|
|
54
53
|
const radialPositionX = (referencePosition.x - shape?.left) * (Math.PI * 2) / spanningRangeX;
|
|
55
54
|
const radialPositionY = (referencePosition.y - shape?.top) * (Math.PI * 2) / spanningRangeY;
|
|
56
55
|
const cycleX = spanningRangeX * Math.sin(radialPositionX * cycles);
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import { PARALLAX_EVENT } from "../../enums/
|
|
1
|
+
import { PARALLAX_EVENT } from "../../enums/Parallax/parallax.enum.js";
|
|
2
|
+
function clampMovement(movement, min, max) {
|
|
3
|
+
if (max && movement > max) return max;
|
|
4
|
+
if (min && movement < min) return min;
|
|
5
|
+
return movement;
|
|
6
|
+
}
|
|
2
7
|
export function elementMovement(action) {
|
|
3
8
|
const { y, x, target, strength = 10, event = null, minX, minY, maxX, maxY } = action;
|
|
4
9
|
const { originX = 50 } = action;
|
|
@@ -6,17 +11,11 @@ export function elementMovement(action) {
|
|
|
6
11
|
if (event === PARALLAX_EVENT.SCROLL) {
|
|
7
12
|
originY = -originY / 2;
|
|
8
13
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if (minX || maxX) {
|
|
12
|
-
movementX = maxX && movementX > maxX ? maxX : minX && movementX < minX ? minX : movementX;
|
|
13
|
-
}
|
|
14
|
-
if (minY || maxY) {
|
|
15
|
-
movementY = maxY && movementY > maxY ? maxY : minY && movementY < minY ? minY : movementY;
|
|
16
|
-
}
|
|
14
|
+
const movementX = (x - originX / 50) * strength;
|
|
15
|
+
const movementY = (y - originY / 50) * strength;
|
|
17
16
|
return {
|
|
18
|
-
x: movementX,
|
|
19
|
-
y: movementY,
|
|
17
|
+
x: clampMovement(movementX, minX, maxX),
|
|
18
|
+
y: clampMovement(movementY, minY, maxY),
|
|
20
19
|
target
|
|
21
20
|
};
|
|
22
21
|
}
|
|
@@ -40,11 +40,11 @@ function calculateCenteredTarget({
|
|
|
40
40
|
}
|
|
41
41
|
function getScrollSize(isHorizontal, element) {
|
|
42
42
|
const key = isHorizontal ? "scrollWidth" : "scrollHeight";
|
|
43
|
-
return element?.[key]
|
|
43
|
+
return element?.[key] ?? 0;
|
|
44
44
|
}
|
|
45
45
|
function getClientSize(isHorizontal, element) {
|
|
46
46
|
const key = isHorizontal ? "clientWidth" : "clientHeight";
|
|
47
|
-
return element?.[key]
|
|
47
|
+
return element?.[key] ?? 0;
|
|
48
48
|
}
|
|
49
49
|
function getScrollPosition(isHorizontal, isRtl, element) {
|
|
50
50
|
if (!element) {
|
|
@@ -62,9 +62,9 @@ function getScrollPosition(isHorizontal, isRtl, element) {
|
|
|
62
62
|
}
|
|
63
63
|
function getOffsetSize(isHorizontal, element) {
|
|
64
64
|
const key = isHorizontal ? "offsetWidth" : "offsetHeight";
|
|
65
|
-
return element?.[key]
|
|
65
|
+
return element?.[key] ?? 0;
|
|
66
66
|
}
|
|
67
67
|
function getOffsetPosition(isHorizontal, element) {
|
|
68
68
|
const key = isHorizontal ? "offsetLeft" : "offsetTop";
|
|
69
|
-
return element?.[key]
|
|
69
|
+
return element?.[key] ?? 0;
|
|
70
70
|
}
|
|
@@ -19,11 +19,11 @@ export function calculateCenteredTarget({ selectedElement, containerElement, isH
|
|
|
19
19
|
}
|
|
20
20
|
export function getScrollSize(isHorizontal, element) {
|
|
21
21
|
const key = isHorizontal ? "scrollWidth" : "scrollHeight";
|
|
22
|
-
return element?.[key]
|
|
22
|
+
return element?.[key] ?? 0;
|
|
23
23
|
}
|
|
24
24
|
export function getClientSize(isHorizontal, element) {
|
|
25
25
|
const key = isHorizontal ? "clientWidth" : "clientHeight";
|
|
26
|
-
return element?.[key]
|
|
26
|
+
return element?.[key] ?? 0;
|
|
27
27
|
}
|
|
28
28
|
export function getScrollPosition(isHorizontal, isRtl, element) {
|
|
29
29
|
if (!element) {
|
|
@@ -41,9 +41,9 @@ export function getScrollPosition(isHorizontal, isRtl, element) {
|
|
|
41
41
|
}
|
|
42
42
|
export function getOffsetSize(isHorizontal, element) {
|
|
43
43
|
const key = isHorizontal ? "offsetWidth" : "offsetHeight";
|
|
44
|
-
return element?.[key]
|
|
44
|
+
return element?.[key] ?? 0;
|
|
45
45
|
}
|
|
46
46
|
export function getOffsetPosition(isHorizontal, element) {
|
|
47
47
|
const key = isHorizontal ? "offsetLeft" : "offsetTop";
|
|
48
|
-
return element?.[key]
|
|
48
|
+
return element?.[key] ?? 0;
|
|
49
49
|
}
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.htmlToMarkdown = htmlToMarkdown;
|
|
7
|
+
var _textareaField = require("../../consts/TextareaField/textarea-field.const.cjs");
|
|
7
8
|
function htmlToMarkdown(input) {
|
|
8
9
|
if (input == null || input === "") return "";
|
|
9
10
|
if (typeof input !== "string") return "";
|
|
@@ -20,17 +21,11 @@ function walk(node) {
|
|
|
20
21
|
const el = node;
|
|
21
22
|
const tag = el.tagName.toLowerCase();
|
|
22
23
|
const inner = Array.from(el.childNodes).map(walk).join("");
|
|
24
|
+
if (Object.hasOwn(_textareaField.MARKDOWN_WRAPPERS, tag)) return _textareaField.MARKDOWN_WRAPPERS[tag](inner);
|
|
25
|
+
return renderSpecialTag(el, tag, inner);
|
|
26
|
+
}
|
|
27
|
+
function renderSpecialTag(el, tag, inner) {
|
|
23
28
|
switch (tag) {
|
|
24
|
-
case "strong":
|
|
25
|
-
case "b":
|
|
26
|
-
return inner ? `**${inner}**` : "";
|
|
27
|
-
case "em":
|
|
28
|
-
case "i":
|
|
29
|
-
return inner ? `*${inner}*` : "";
|
|
30
|
-
case "u":
|
|
31
|
-
return inner ? `<u>${inner}</u>` : "";
|
|
32
|
-
case "code":
|
|
33
|
-
return inner ? `\`${inner}\`` : "";
|
|
34
29
|
case "a":
|
|
35
30
|
{
|
|
36
31
|
const href = el.getAttribute("href") ?? "";
|
|
@@ -40,36 +35,10 @@ function walk(node) {
|
|
|
40
35
|
}
|
|
41
36
|
case "br":
|
|
42
37
|
return "\n";
|
|
43
|
-
case "p":
|
|
44
|
-
return inner ? `
|
|
45
|
-
|
|
46
|
-
${inner}
|
|
47
|
-
|
|
48
|
-
` : "";
|
|
49
|
-
case "h1":
|
|
50
|
-
return inner ? `
|
|
51
|
-
|
|
52
|
-
# ${inner}
|
|
53
|
-
|
|
54
|
-
` : "";
|
|
55
|
-
case "h2":
|
|
56
|
-
return inner ? `
|
|
57
|
-
|
|
58
|
-
## ${inner}
|
|
59
|
-
|
|
60
|
-
` : "";
|
|
61
|
-
case "h3":
|
|
62
|
-
return inner ? `
|
|
63
|
-
|
|
64
|
-
### ${inner}
|
|
65
|
-
|
|
66
|
-
` : "";
|
|
67
38
|
case "ul":
|
|
68
39
|
return "\n" + listItems(el, "- ") + "\n";
|
|
69
40
|
case "ol":
|
|
70
41
|
return "\n" + listItems(el, idx => `${idx + 1}. `) + "\n";
|
|
71
|
-
case "li":
|
|
72
|
-
return inner;
|
|
73
42
|
default:
|
|
74
43
|
return inner;
|
|
75
44
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MARKDOWN_WRAPPERS } from "../../consts/TextareaField/textarea-field.const.js";
|
|
1
2
|
export function htmlToMarkdown(input) {
|
|
2
3
|
if (input == null || input === "") return "";
|
|
3
4
|
if (typeof input !== "string") return "";
|
|
@@ -14,17 +15,11 @@ function walk(node) {
|
|
|
14
15
|
const el = node;
|
|
15
16
|
const tag = el.tagName.toLowerCase();
|
|
16
17
|
const inner = Array.from(el.childNodes).map(walk).join("");
|
|
18
|
+
if (Object.hasOwn(MARKDOWN_WRAPPERS, tag)) return MARKDOWN_WRAPPERS[tag](inner);
|
|
19
|
+
return renderSpecialTag(el, tag, inner);
|
|
20
|
+
}
|
|
21
|
+
function renderSpecialTag(el, tag, inner) {
|
|
17
22
|
switch (tag) {
|
|
18
|
-
case "strong":
|
|
19
|
-
case "b":
|
|
20
|
-
return inner ? `**${inner}**` : "";
|
|
21
|
-
case "em":
|
|
22
|
-
case "i":
|
|
23
|
-
return inner ? `*${inner}*` : "";
|
|
24
|
-
case "u":
|
|
25
|
-
return inner ? `<u>${inner}</u>` : "";
|
|
26
|
-
case "code":
|
|
27
|
-
return inner ? `\`${inner}\`` : "";
|
|
28
23
|
case "a": {
|
|
29
24
|
const href = el.getAttribute("href") ?? "";
|
|
30
25
|
if (!inner) return "";
|
|
@@ -33,36 +28,10 @@ function walk(node) {
|
|
|
33
28
|
}
|
|
34
29
|
case "br":
|
|
35
30
|
return "\n";
|
|
36
|
-
case "p":
|
|
37
|
-
return inner ? `
|
|
38
|
-
|
|
39
|
-
${inner}
|
|
40
|
-
|
|
41
|
-
` : "";
|
|
42
|
-
case "h1":
|
|
43
|
-
return inner ? `
|
|
44
|
-
|
|
45
|
-
# ${inner}
|
|
46
|
-
|
|
47
|
-
` : "";
|
|
48
|
-
case "h2":
|
|
49
|
-
return inner ? `
|
|
50
|
-
|
|
51
|
-
## ${inner}
|
|
52
|
-
|
|
53
|
-
` : "";
|
|
54
|
-
case "h3":
|
|
55
|
-
return inner ? `
|
|
56
|
-
|
|
57
|
-
### ${inner}
|
|
58
|
-
|
|
59
|
-
` : "";
|
|
60
31
|
case "ul":
|
|
61
32
|
return "\n" + listItems(el, "- ") + "\n";
|
|
62
33
|
case "ol":
|
|
63
34
|
return "\n" + listItems(el, (idx) => `${idx + 1}. `) + "\n";
|
|
64
|
-
case "li":
|
|
65
|
-
return inner;
|
|
66
35
|
default:
|
|
67
36
|
return inner;
|
|
68
37
|
}
|
|
@@ -44,30 +44,26 @@ function unwrap(el) {
|
|
|
44
44
|
}
|
|
45
45
|
function sanitizeAttributes(el, tag) {
|
|
46
46
|
const allowed = _textareaField.ALLOWED_ATTRIBUTES[tag] ?? [];
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
for (const attr of Array.from(el.attributes)) sanitizeAttribute(el, attr, allowed);
|
|
48
|
+
}
|
|
49
|
+
function sanitizeAttribute(el, attr, allowed) {
|
|
50
|
+
const name = attr.name.toLowerCase();
|
|
51
|
+
if (name.startsWith("on") || !allowed.includes(name)) {
|
|
52
|
+
el.removeAttribute(attr.name);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (name === "href") {
|
|
56
|
+
if (!isSafeUrl(attr.value)) {
|
|
51
57
|
el.removeAttribute(attr.name);
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
if (!allowed.includes(name)) {
|
|
55
|
-
el.removeAttribute(attr.name);
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
if (name === "href") {
|
|
59
|
-
if (!isSafeUrl(attr.value)) {
|
|
60
|
-
el.removeAttribute(attr.name);
|
|
61
|
-
continue;
|
|
62
|
-
}
|
|
63
|
-
;
|
|
64
|
-
el.setAttribute("rel", "noopener noreferrer nofollow");
|
|
65
|
-
el.setAttribute("target", "_blank");
|
|
66
|
-
}
|
|
67
|
-
if (name === "class") {
|
|
68
|
-
const cleaned = filterClassList(attr.value);
|
|
69
|
-
if (cleaned === "") el.removeAttribute(attr.name);else el.setAttribute(attr.name, cleaned);
|
|
58
|
+
return;
|
|
70
59
|
}
|
|
60
|
+
el.setAttribute("rel", "noopener noreferrer nofollow");
|
|
61
|
+
el.setAttribute("target", "_blank");
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (name === "class") {
|
|
65
|
+
const cleaned = filterClassList(attr.value);
|
|
66
|
+
if (cleaned === "") el.removeAttribute(attr.name);else el.setAttribute(attr.name, cleaned);
|
|
71
67
|
}
|
|
72
68
|
}
|
|
73
69
|
function isSafeUrl(raw) {
|