@lostgradient/cinder 0.20.0 → 0.21.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 +162 -0
- package/components.json +1 -1
- package/dist/components/alert-dialog/index.js +481 -162
- package/dist/components/approval-card/approval-card.css +3 -0
- package/dist/components/approval-card/index.js +402 -119
- package/dist/components/area-chart/index.js +252 -1
- package/dist/components/autocomplete/index.js +124 -40
- package/dist/components/avatar-group/index.js +185 -81
- package/dist/components/bar-chart/index.js +252 -1
- package/dist/components/button/button.css +13 -3
- package/dist/components/calendar/calendar.css +3 -0
- package/dist/components/carousel/carousel.css +40 -6
- package/dist/components/carousel/carousel.schema.js +43 -2
- package/dist/components/carousel/carousel.svelte.d.ts +25 -4
- package/dist/components/carousel/carousel.types.d.ts +43 -2
- package/dist/components/carousel/carousel.variables.js +7 -2
- package/dist/components/carousel/index.d.ts +1 -1
- package/dist/components/carousel/index.js +2018 -351
- package/dist/components/checkbox/checkbox.css +1 -1
- package/dist/components/checkbox-group/checkbox-group.css +1 -1
- package/dist/components/chip/chip.css +3 -0
- package/dist/components/code-block/code-block.css +35 -2
- package/dist/components/code-block/code-block.schema.js +9 -1
- package/dist/components/code-block/code-block.types.d.ts +8 -0
- package/dist/components/code-block/index.js +263 -4
- package/dist/components/color-field/color-field.css +1 -1
- package/dist/components/color-picker/color-picker.css +1 -1
- package/dist/components/combobox/combobox.css +4 -1
- package/dist/components/combobox/index.js +124 -40
- package/dist/components/command-menu/index.js +20 -17
- package/dist/components/confirm-dialog/index.js +497 -178
- package/dist/components/connection-indicator/connection-indicator.css +3 -2
- package/dist/components/context-menu/index.js +124 -40
- package/dist/components/copy-button/copy-button.css +4 -1
- package/dist/components/data-grid/data-grid.css +3 -0
- package/dist/components/data-table/index.js +252 -1
- package/dist/components/date-picker/date-picker.css +1 -1
- package/dist/components/date-picker/index.js +124 -40
- package/dist/components/date-range-field/date-range-field.css +7 -1
- package/dist/components/date-range-field/index.js +124 -40
- package/dist/components/diff-statistics/diff-statistics.css +2 -2
- package/dist/components/drawer/drawer.css +20 -12
- package/dist/components/drawer/index.js +106 -25
- package/dist/components/dropdown/dropdown.css +1 -1
- package/dist/components/dropdown/index.js +124 -40
- package/dist/components/dropdown-menu/index.js +20 -17
- package/dist/components/event-stream-viewer/event-stream-viewer.css +29 -4
- package/dist/components/event-stream-viewer/event-stream-viewer.variables.js +5 -2
- package/dist/components/event-timeline/event-timeline.css +3 -0
- package/dist/components/event-timeline/index.js +124 -40
- package/dist/components/focus-trap/index.js +105 -24
- package/dist/components/form-field/form-field.css +1 -1
- package/dist/components/hover-card/hover-card.css +45 -1
- package/dist/components/hover-card/index.js +144 -19
- package/dist/components/inline-loading/inline-loading.css +2 -2
- package/dist/components/input/input.css +1 -1
- package/dist/components/invocation-rule-builder/index.js +124 -40
- package/dist/components/invocation-rule-builder/invocation-rule-builder.css +18 -0
- package/dist/components/json-editor/json-editor.css +4 -1
- package/dist/components/json-schema-editor/index.js +152 -68
- package/dist/components/json-viewer/json-viewer.css +5 -2
- package/dist/components/kanban-board/index.js +2 -2
- package/dist/components/kanban-board/kanban-board.css +1 -1
- package/dist/components/line-chart/index.js +252 -1
- package/dist/components/marquee/marquee.css +3 -0
- package/dist/components/matrix-chart/index.js +252 -1
- package/dist/components/menu-bar/index.js +20 -17
- package/dist/components/menu-bar/menu-bar.css +3 -0
- package/dist/components/meter/index.js +13 -3
- package/dist/components/modal/index.js +447 -130
- package/dist/components/modal/modal.css +56 -24
- package/dist/components/multi-select/index.js +3553 -467
- package/dist/components/multi-select/multi-select.css +4 -10
- package/dist/components/navigation-bar/index.js +20 -17
- package/dist/components/navigation-item/navigation-item.css +3 -0
- package/dist/components/pagination/pagination.css +3 -0
- package/dist/components/permission-matrix/index.js +252 -1
- package/dist/components/permission-matrix/permission-matrix.css +15 -0
- package/dist/components/phone-input/phone-input.css +1 -1
- package/dist/components/pin-input/pin-input.css +10 -2
- package/dist/components/popover/index.js +124 -40
- package/dist/components/qr-code/qr-code.css +1 -1
- package/dist/components/radio-group/radio-group.css +1 -1
- package/dist/components/rating/rating.css +1 -1
- package/dist/components/schema-form/schema-form.css +1 -1
- package/dist/components/scroll-area/index.js +526 -22
- package/dist/components/scroll-area/scroll-area.css +30 -0
- package/dist/components/scroll-area/scroll-area.schema.js +9 -1
- package/dist/components/scroll-area/scroll-area.types.d.ts +17 -0
- package/dist/components/secret-value-field/secret-value-field.css +11 -1
- package/dist/components/segmented-control/segmented-control.css +12 -2
- package/dist/components/select/select.css +4 -1
- package/dist/components/selection-popover/index.js +149 -40
- package/dist/components/selection-popover/selection-popover.css +3 -0
- package/dist/components/selection-popover/virtual-keyboard-dismissal.svelte.d.ts +14 -0
- package/dist/components/sheet/index.js +106 -25
- package/dist/components/sheet/sheet.css +20 -12
- package/dist/components/sidebar/index.js +106 -25
- package/dist/components/sortable-list/index.js +2 -2
- package/dist/components/sortable-list/sortable-list.css +14 -9
- package/dist/components/speed-dial/index.js +20 -17
- package/dist/components/statistic/statistic.css +2 -2
- package/dist/components/statistic-group/statistic-group.css +2 -2
- package/dist/components/status-dot/status-dot.css +2 -2
- package/dist/components/table/index.js +252 -1
- package/dist/components/table/table.css +15 -0
- package/dist/components/tag-input/tag-input.css +1 -1
- package/dist/components/team-section/index.js +193 -89
- package/dist/components/textarea/textarea.css +4 -1
- package/dist/components/time-field/time-field.css +4 -1
- package/dist/components/tooltip/index.js +130 -46
- package/dist/components/tooltip/tooltip.schema.js +7 -3
- package/dist/components/tooltip/tooltip.types.d.ts +20 -2
- package/dist/components/transfer-list/index.js +253 -1
- package/dist/components/transfer-list/transfer-list.css +18 -0
- package/dist/index.js +22861 -22220
- package/dist/server/components/alert-dialog/index.js +7 -4
- package/dist/server/components/approval-card/index.js +9 -8
- package/dist/server/components/area-chart/index.js +6 -4
- package/dist/server/components/autocomplete/index.js +7 -7
- package/dist/server/components/avatar-group/index.js +7 -7
- package/dist/server/components/bar-chart/index.js +6 -4
- package/dist/server/components/carousel/index.js +6 -2
- package/dist/server/components/code-block/index.js +5 -3
- package/dist/server/components/combobox/index.js +8 -8
- package/dist/server/components/command-menu/index.js +5 -5
- package/dist/server/components/confirm-dialog/index.js +7 -4
- package/dist/server/components/context-menu/index.js +7 -7
- package/dist/server/components/data-table/index.js +5 -3
- package/dist/server/components/date-picker/index.js +8 -8
- package/dist/server/components/date-range-field/index.js +8 -8
- package/dist/server/components/drawer/index.js +4 -4
- package/dist/server/components/dropdown/index.js +7 -7
- package/dist/server/components/dropdown-menu/index.js +6 -6
- package/dist/server/components/event-timeline/index.js +6 -6
- package/dist/server/components/focus-trap/index.js +3 -3
- package/dist/server/components/hover-card/index.js +7 -6
- package/dist/server/components/invocation-rule-builder/index.js +8 -8
- package/dist/server/components/json-schema-editor/index.js +6 -6
- package/dist/server/components/kanban-board/index.js +2 -2
- package/dist/server/components/line-chart/index.js +6 -4
- package/dist/server/components/matrix-chart/index.js +6 -4
- package/dist/server/components/menu-bar/index.js +6 -6
- package/dist/server/components/meter/index.js +1 -1
- package/dist/server/components/modal/index.js +7 -4
- package/dist/server/components/multi-select/index.js +9 -2
- package/dist/server/components/navigation-bar/index.js +5 -5
- package/dist/server/components/permission-matrix/index.js +4 -2
- package/dist/server/components/popover/index.js +7 -7
- package/dist/server/components/portal/index.js +3 -3
- package/dist/server/components/run-step-timeline/index.js +1 -1
- package/dist/server/components/scroll-area/index.js +8 -2
- package/dist/server/components/selection-popover/index.js +6 -6
- package/dist/server/components/sheet/index.js +3 -3
- package/dist/server/components/sidebar/index.js +5 -5
- package/dist/server/components/sortable-list/index.js +2 -2
- package/dist/server/components/speed-dial/index.js +6 -6
- package/dist/server/components/speed-dial-action/index.js +4 -4
- package/dist/server/components/table/index.js +5 -3
- package/dist/server/components/team-section/index.js +7 -7
- package/dist/server/components/toast-region/index.js +3 -3
- package/dist/server/components/tooltip/index.js +6 -6
- package/dist/server/components/transfer-list/index.js +4 -2
- package/dist/server/index.js +69 -68
- package/dist/server/{index.server-dvd8t7ds.js → index.server-01bz4wmw.js} +1 -1
- package/dist/server/{index.server-gbj2zt1q.js → index.server-03ndc3td.js} +1 -1
- package/dist/server/{index.server-1qr1qkjb.js → index.server-0p1z1kbs.js} +1 -1
- package/dist/server/{index.server-b36zkjsr.js → index.server-1cnz5ax1.js} +30 -6
- package/dist/server/{index.server-xtx9sey2.js → index.server-2bw5fqwh.js} +1 -1
- package/dist/server/{index.server-v3t6v21s.js → index.server-2eb8pcev.js} +1 -1
- package/dist/server/{index.server-2n185esx.js → index.server-2h45p8kd.js} +2 -2
- package/dist/server/{index.server-3gm8s994.js → index.server-2k0cnsm4.js} +30 -2
- package/dist/server/{index.server-jwrnsnxk.js → index.server-2qydtmtp.js} +1 -1
- package/dist/server/{index.server-4bdnshs1.js → index.server-3e8n2sry.js} +2 -2
- package/dist/server/{index.server-dpyw7nad.js → index.server-4sr9f5r0.js} +1 -1
- package/dist/server/{index.server-rxvbt0y3.js → index.server-4w0rydct.js} +1 -1
- package/dist/server/{index.server-znrr9zve.js → index.server-6184qc69.js} +1 -1
- package/dist/server/{index.server-mw3z3nfz.js → index.server-64dvhh7s.js} +8 -2
- package/dist/server/{index.server-w9tnnse5.js → index.server-6771g0q4.js} +4 -4
- package/dist/server/{index.server-jxy33axv.js → index.server-6e5cj9hs.js} +1 -1
- package/dist/server/{index.server-gp0jh4cx.js → index.server-6z6s8qz8.js} +1 -1
- package/dist/server/{index.server-jj0tkfqp.js → index.server-72d0qgdy.js} +3 -3
- package/dist/server/{index.server-x93qnzqm.js → index.server-77p0jy71.js} +1 -1
- package/dist/server/{index.server-cepvcyxn.js → index.server-7kez94sz.js} +17 -6
- package/dist/server/{index.server-rd908evp.js → index.server-7sxx7645.js} +2 -2
- package/dist/server/{index.server-1br18a82.js → index.server-8t53gqe7.js} +3 -3
- package/dist/server/{index.server-jnp8yqgj.js → index.server-8w95jmf1.js} +1 -1
- package/dist/server/{index.server-g8j7wnpa.js → index.server-9emgn750.js} +1 -1
- package/dist/server/{index.server-zt8d7yer.js → index.server-9n2bc545.js} +1 -1
- package/dist/server/{index.server-bprjmaxb.js → index.server-a5w1wy5w.js} +1 -1
- package/dist/server/{index.server-t6dkkfxk.js → index.server-a5zsgn3k.js} +1 -1
- package/dist/server/{index.server-nsqx19rk.js → index.server-a8gpnzgg.js} +6 -6
- package/dist/server/{index.server-edx404az.js → index.server-ayhcc6z5.js} +1 -1
- package/dist/server/{index.server-z53avp9h.js → index.server-b7pq5xpd.js} +1 -1
- package/dist/server/{index.server-aerjcjgw.js → index.server-cptwpqbr.js} +1 -1
- package/dist/server/{index.server-85dr75be.js → index.server-d70brw24.js} +1 -1
- package/dist/server/{index.server-wsbwydct.js → index.server-fd3az8g2.js} +3 -3
- package/dist/server/{index.server-429t1qje.js → index.server-fka21791.js} +2 -2
- package/dist/server/{index.server-vb58jd7c.js → index.server-grq89cv5.js} +1 -1
- package/dist/server/{index.server-74g52t91.js → index.server-hxjkfdp2.js} +1 -1
- package/dist/server/{index.server-r5y5t888.js → index.server-j4akck2w.js} +1 -1
- package/dist/server/{index.server-sqtgjjc3.js → index.server-j57zek3p.js} +1 -1
- package/dist/server/index.server-ja3fmd29.js +211 -0
- package/dist/server/{index.server-66amt15s.js → index.server-kszs0qx5.js} +25 -2
- package/dist/server/{index.server-f02vwrw5.js → index.server-nbq0tmx1.js} +26 -16
- package/dist/server/{index.server-ktwnf9vg.js → index.server-nbspp00m.js} +1 -1
- package/dist/server/{index.server-xanhe43k.js → index.server-pee1wa4g.js} +1 -1
- package/dist/server/{index.server-dqt9we67.js → index.server-q7r53g7z.js} +1 -1
- package/dist/server/{index.server-1xq7j9dj.js → index.server-scdk1we9.js} +6 -6
- package/dist/server/{index.server-rgcepyhr.js → index.server-sfbna82r.js} +1 -1
- package/dist/server/{index.server-dpe08kr7.js → index.server-sgjc9gkq.js} +1 -1
- package/dist/server/{index.server-wm3t5yw7.js → index.server-sxkkaj8b.js} +13 -3
- package/dist/server/{index.server-r147w5z4.js → index.server-td8rx9dz.js} +1 -1
- package/dist/server/{index.server-3g76h7z7.js → index.server-th1tsad4.js} +62 -26
- package/dist/server/{index.server-ak9pqjfw.js → index.server-tpny5pjk.js} +224 -91
- package/dist/server/{index.server-8wb8g3w1.js → index.server-tvj0x3qy.js} +1 -1
- package/dist/server/{index.server-vqb9m9hq.js → index.server-w2jwyz17.js} +2 -2
- package/dist/server/{index.server-29sg0ywf.js → index.server-w5f4ex0f.js} +9 -6
- package/dist/server/{index.server-5p5r6t6n.js → index.server-w8phxx00.js} +1 -1
- package/dist/server/{index.server-tj2erfba.js → index.server-x6hbm4je.js} +2 -2
- package/dist/server/{index.server-7r9d6g1c.js → index.server-xqbes4jd.js} +6 -6
- package/dist/server/{index.server-j15z5xn7.js → index.server-xsh52hjt.js} +1 -1
- package/dist/server/{index.server-k1625sfw.js → index.server-y8m06g9p.js} +1 -1
- package/dist/server/{index.server-32p6dz3e.js → index.server-ybb5ery2.js} +1 -1
- package/dist/server/{index.server-1p7b8y48.js → index.server-yhjecwfj.js} +6 -6
- package/dist/server/{index.server-4nh4arvs.js → index.server-zfxb12hm.js} +30 -48
- package/dist/utilities/attachments.d.ts +63 -1
- package/dist/utilities/drag-scroll-physics.d.ts +48 -0
- package/dist/utilities/use-drag-scroll.svelte.d.ts +26 -0
- package/dist/utilities/use-drag-scroll.types.d.ts +15 -0
- package/dist/utilities/use-fine-pointer.svelte.d.ts +12 -0
- package/dist/utilities/use-fine-pointer.types.d.ts +4 -0
- package/package.json +2 -2
- package/src/_internal/anchored-overlay.svelte.ts +48 -26
- package/src/components/_sortable-item.svelte +21 -2
- package/src/components/approval-card/approval-card.css +3 -0
- package/src/components/avatar-group/avatar-group.svelte +46 -17
- package/src/components/button/button.css +13 -3
- package/src/components/calendar/calendar.css +3 -0
- package/src/components/carousel/carousel.css +40 -6
- package/src/components/carousel/carousel.examples.json +6 -0
- package/src/components/carousel/carousel.schema.json +42 -1
- package/src/components/carousel/carousel.schema.ts +49 -1
- package/src/components/carousel/carousel.svelte +311 -136
- package/src/components/carousel/carousel.types.ts +47 -2
- package/src/components/carousel/carousel.variables.json +6 -1
- package/src/components/carousel/carousel.variables.ts +6 -1
- package/src/components/carousel/index.ts +1 -0
- package/src/components/checkbox/checkbox.css +1 -1
- package/src/components/checkbox-group/checkbox-group.css +1 -1
- package/src/components/chip/chip.css +3 -0
- package/src/components/code-block/code-block.css +35 -2
- package/src/components/code-block/code-block.schema.json +4 -0
- package/src/components/code-block/code-block.schema.ts +5 -0
- package/src/components/code-block/code-block.svelte +12 -2
- package/src/components/code-block/code-block.types.ts +8 -0
- package/src/components/color-field/color-field.css +1 -1
- package/src/components/color-picker/color-picker.css +1 -1
- package/src/components/combobox/combobox.css +4 -1
- package/src/components/connection-indicator/connection-indicator.css +3 -2
- package/src/components/copy-button/copy-button.css +4 -1
- package/src/components/data-grid/data-grid.css +3 -0
- package/src/components/date-picker/date-picker.css +1 -1
- package/src/components/date-range-field/date-range-field.css +7 -1
- package/src/components/diff-statistics/diff-statistics.css +2 -2
- package/src/components/drawer/drawer.css +20 -12
- package/src/components/drawer/drawer.svelte +5 -1
- package/src/components/dropdown/dropdown.css +1 -1
- package/src/components/event-stream-viewer/event-stream-viewer.css +29 -4
- package/src/components/event-stream-viewer/event-stream-viewer.variables.json +1 -1
- package/src/components/event-stream-viewer/event-stream-viewer.variables.ts +4 -1
- package/src/components/event-timeline/event-timeline.css +3 -0
- package/src/components/form-field/form-field.css +1 -1
- package/src/components/hover-card/hover-card.css +45 -1
- package/src/components/hover-card/hover-card.svelte +64 -2
- package/src/components/inline-loading/inline-loading.css +2 -2
- package/src/components/input/input.css +1 -1
- package/src/components/invocation-rule-builder/invocation-rule-builder.css +18 -0
- package/src/components/json-editor/json-editor.css +4 -1
- package/src/components/json-viewer/json-viewer.css +5 -2
- package/src/components/kanban-board/kanban-board.css +1 -1
- package/src/components/marquee/marquee.css +3 -0
- package/src/components/menu-bar/menu-bar.css +3 -0
- package/src/components/meter/meter.svelte +19 -4
- package/src/components/meter/meter.types.ts +4 -0
- package/src/components/modal/modal.css +56 -24
- package/src/components/modal/modal.svelte +59 -99
- package/src/components/multi-select/multi-select.css +4 -10
- package/src/components/multi-select/multi-select.svelte +43 -0
- package/src/components/navigation-item/navigation-item.css +3 -0
- package/src/components/pagination/pagination.css +3 -0
- package/src/components/permission-matrix/permission-matrix.css +15 -0
- package/src/components/permission-matrix/permission-matrix.svelte +6 -1
- package/src/components/phone-input/phone-input.css +1 -1
- package/src/components/pin-input/pin-input.css +10 -2
- package/src/components/qr-code/qr-code.css +1 -1
- package/src/components/radio-group/radio-group.css +1 -1
- package/src/components/rating/rating.css +1 -1
- package/src/components/schema-form/schema-form.css +1 -1
- package/src/components/scroll-area/scroll-area.css +30 -0
- package/src/components/scroll-area/scroll-area.schema.json +8 -0
- package/src/components/scroll-area/scroll-area.schema.ts +10 -0
- package/src/components/scroll-area/scroll-area.svelte +44 -2
- package/src/components/scroll-area/scroll-area.types.ts +17 -0
- package/src/components/secret-value-field/secret-value-field.css +11 -1
- package/src/components/segmented-control/segmented-control.css +12 -2
- package/src/components/select/select.css +4 -1
- package/src/components/selection-popover/selection-popover.css +3 -0
- package/src/components/selection-popover/selection-popover.svelte +32 -0
- package/src/components/selection-popover/virtual-keyboard-dismissal.svelte.ts +16 -0
- package/src/components/sheet/sheet.css +20 -12
- package/src/components/sheet/sheet.svelte +1 -1
- package/src/components/sortable-list/sortable-list.css +14 -9
- package/src/components/statistic/statistic.css +2 -2
- package/src/components/statistic-group/statistic-group.css +2 -2
- package/src/components/status-dot/status-dot.css +2 -2
- package/src/components/table/table.css +15 -0
- package/src/components/table/table.svelte +2 -0
- package/src/components/tag-input/tag-input.css +1 -1
- package/src/components/textarea/textarea.css +4 -1
- package/src/components/time-field/time-field.css +4 -1
- package/src/components/tooltip/tooltip.schema.json +6 -2
- package/src/components/tooltip/tooltip.schema.ts +8 -2
- package/src/components/tooltip/tooltip.svelte +124 -23
- package/src/components/tooltip/tooltip.types.ts +20 -2
- package/src/components/transfer-list/transfer-list.css +18 -0
- package/src/components/transfer-list/transfer-list.svelte +3 -0
- package/src/styles/components/_control-item.css +3 -0
- package/src/styles/components/_field-label.css +1 -1
- package/src/styles/components/_input-frame.css +3 -0
- package/src/styles/components/_scroll-fade.css +317 -0
- package/src/styles/components/_status-surface.css +21 -1
- package/src/styles/components.css +5 -0
- package/src/styles/index.css +1 -0
- package/src/styles/tokens-base.css +207 -69
- package/src/styles/utilities.css +10 -1
- package/src/utilities/attachments.ts +202 -26
- package/src/utilities/drag-scroll-physics.ts +82 -0
- package/src/utilities/use-drag-scroll.svelte.ts +186 -0
- package/src/utilities/use-drag-scroll.types.ts +17 -0
- package/src/utilities/use-fine-pointer.svelte.ts +23 -0
- package/src/utilities/use-fine-pointer.types.ts +4 -0
|
@@ -56,23 +56,1548 @@ import"@lostgradient/cinder/carousel/styles";
|
|
|
56
56
|
|
|
57
57
|
// src/components/carousel/carousel.svelte
|
|
58
58
|
import"svelte/internal/disclose-version";
|
|
59
|
-
import * as $
|
|
59
|
+
import * as $5 from "svelte/internal/client";
|
|
60
60
|
import { onDestroy, untrack } from "svelte";
|
|
61
61
|
import { SvelteSet } from "svelte/reactivity";
|
|
62
62
|
|
|
63
|
+
// src/_internal/text-direction-container.ts
|
|
64
|
+
function parseStyleQuery(conditionText) {
|
|
65
|
+
const start = /style\(\s*(--[\w-]+)\s*:\s*/i.exec(conditionText);
|
|
66
|
+
if (!start || !start[1])
|
|
67
|
+
return;
|
|
68
|
+
let depth = 0;
|
|
69
|
+
for (let index = start.index + start[0].length;index < conditionText.length; index += 1) {
|
|
70
|
+
const character = conditionText[index];
|
|
71
|
+
if (character === "(")
|
|
72
|
+
depth += 1;
|
|
73
|
+
if (character === ")") {
|
|
74
|
+
if (depth === 0)
|
|
75
|
+
return {
|
|
76
|
+
index: start.index,
|
|
77
|
+
end: index + 1,
|
|
78
|
+
name: start[1],
|
|
79
|
+
value: conditionText.slice(start.index + start[0].length, index)
|
|
80
|
+
};
|
|
81
|
+
depth -= 1;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
function splitTopLevel(conditionText, operator) {
|
|
87
|
+
const parts = [];
|
|
88
|
+
let depth = 0;
|
|
89
|
+
let start = 0;
|
|
90
|
+
let index = 0;
|
|
91
|
+
while (index < conditionText.length) {
|
|
92
|
+
const character = conditionText[index];
|
|
93
|
+
if (character === "(") {
|
|
94
|
+
depth += 1;
|
|
95
|
+
index += 1;
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
if (character === ")") {
|
|
99
|
+
depth = Math.max(0, depth - 1);
|
|
100
|
+
index += 1;
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
if (depth === 0 && conditionText.slice(index, index + operator.length).toLowerCase() === operator && /\s/.test(conditionText[index - 1] ?? "") && /\s/.test(conditionText[index + operator.length] ?? "")) {
|
|
104
|
+
parts.push(conditionText.slice(start, index));
|
|
105
|
+
index += operator.length;
|
|
106
|
+
start = index;
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
index += 1;
|
|
110
|
+
}
|
|
111
|
+
parts.push(conditionText.slice(start));
|
|
112
|
+
return parts;
|
|
113
|
+
}
|
|
114
|
+
function evaluateLogicalContainerCondition(conditionText, width, remSize, inlineSize) {
|
|
115
|
+
if (!isFullyParsedContainerCondition(conditionText))
|
|
116
|
+
return false;
|
|
117
|
+
return evaluateParsedLogicalContainerCondition(conditionText, width, remSize, inlineSize);
|
|
118
|
+
}
|
|
119
|
+
function evaluateParsedLogicalContainerCondition(conditionText, width, remSize, inlineSize) {
|
|
120
|
+
const orParts = splitTopLevel(conditionText, "or");
|
|
121
|
+
if (orParts.length > 1)
|
|
122
|
+
return orParts.some((part) => evaluateParsedLogicalContainerCondition(part, width, remSize, inlineSize));
|
|
123
|
+
const andParts = splitTopLevel(conditionText, "and");
|
|
124
|
+
if (andParts.length > 1)
|
|
125
|
+
return andParts.every((part) => evaluateParsedLogicalContainerCondition(part, width, remSize, inlineSize));
|
|
126
|
+
const trimmed = conditionText.trim();
|
|
127
|
+
const unwrapped = unwrapRedundantParentheses(trimmed);
|
|
128
|
+
if (unwrapped !== trimmed)
|
|
129
|
+
return evaluateParsedLogicalContainerCondition(unwrapped, width, remSize, inlineSize);
|
|
130
|
+
const notPrefix = /^not\s+/i.exec(trimmed);
|
|
131
|
+
if (notPrefix)
|
|
132
|
+
return !evaluateParsedLogicalContainerCondition(trimmed.slice(notPrefix[0].length), width, remSize, inlineSize);
|
|
133
|
+
return evaluateContainerSizeConstraints(trimmed, width, remSize, inlineSize);
|
|
134
|
+
}
|
|
135
|
+
var containerSizeTermPattern = /^(?:(?:min|max)-(?:width|inline-size)|(?:width|inline-size))\s*:\s*(?:\d+(?:\.\d+)?|\.\d+)(?:px|rem)$/i;
|
|
136
|
+
var featureFirstRangePattern = /^(?:width|inline-size)\s*(?:>=|>|<=|<)\s*(?:\d+(?:\.\d+)?|\.\d+)(?:px|rem)$/i;
|
|
137
|
+
var valueFirstRangePattern = /^(?:(?:(?:\d+(?:\.\d+)?|\.\d+)(?:px|rem)\s*(?:<=|<)\s*(?:width|inline-size))(?:\s*(?:<=|<)\s*(?:\d+(?:\.\d+)?|\.\d+)(?:px|rem))?|(?:(?:\d+(?:\.\d+)?|\.\d+)(?:px|rem)\s*(?:>=|>)\s*(?:width|inline-size))(?:\s*(?:>=|>)\s*(?:\d+(?:\.\d+)?|\.\d+)(?:px|rem))?)$/i;
|
|
138
|
+
function isFullyParsedContainerCondition(conditionText) {
|
|
139
|
+
const trimmed = conditionText.trim();
|
|
140
|
+
if (!trimmed || !hasBalancedParentheses(trimmed))
|
|
141
|
+
return false;
|
|
142
|
+
return parseContainerCondition(trimmed);
|
|
143
|
+
}
|
|
144
|
+
function parseContainerCondition(conditionText, isTopLevelCondition = true) {
|
|
145
|
+
const original = conditionText.trim();
|
|
146
|
+
const trimmed = unwrapRedundantParentheses(original);
|
|
147
|
+
const wasGrouped = trimmed !== original;
|
|
148
|
+
const orParts = splitTopLevel(trimmed, "or");
|
|
149
|
+
const andParts = splitTopLevel(trimmed, "and");
|
|
150
|
+
if (orParts.length > 1 && andParts.length > 1)
|
|
151
|
+
return false;
|
|
152
|
+
if (orParts.length > 1)
|
|
153
|
+
return orParts.every((part) => parseContainerCondition(part, false));
|
|
154
|
+
if (andParts.length > 1)
|
|
155
|
+
return andParts.every((part) => parseContainerCondition(part, false));
|
|
156
|
+
const notPrefix = /^not\s+/i.exec(trimmed);
|
|
157
|
+
if (notPrefix) {
|
|
158
|
+
if (!isTopLevelCondition && !wasGrouped)
|
|
159
|
+
return false;
|
|
160
|
+
const operand = trimmed.slice(notPrefix[0].length).trim();
|
|
161
|
+
const unwrappedOperand = unwrapRedundantParentheses(operand);
|
|
162
|
+
return unwrappedOperand !== operand && parseContainerCondition(operand);
|
|
163
|
+
}
|
|
164
|
+
return wasGrouped && (containerSizeTermPattern.test(trimmed) || featureFirstRangePattern.test(trimmed) || valueFirstRangePattern.test(trimmed));
|
|
165
|
+
}
|
|
166
|
+
function hasBalancedParentheses(conditionText) {
|
|
167
|
+
let depth = 0;
|
|
168
|
+
for (const character of conditionText) {
|
|
169
|
+
if (character === "(")
|
|
170
|
+
depth += 1;
|
|
171
|
+
if (character === ")") {
|
|
172
|
+
depth -= 1;
|
|
173
|
+
if (depth < 0)
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return depth === 0;
|
|
178
|
+
}
|
|
179
|
+
function unwrapRedundantParentheses(conditionText) {
|
|
180
|
+
const trimmed = conditionText.trim();
|
|
181
|
+
if (!trimmed.startsWith("(") || !trimmed.endsWith(")"))
|
|
182
|
+
return trimmed;
|
|
183
|
+
const matchingClose = new Map;
|
|
184
|
+
const openPositions = [];
|
|
185
|
+
let depth = 0;
|
|
186
|
+
for (let index = 0;index < trimmed.length; index += 1) {
|
|
187
|
+
if (trimmed[index] === "(") {
|
|
188
|
+
openPositions.push(index);
|
|
189
|
+
depth += 1;
|
|
190
|
+
} else if (trimmed[index] === ")") {
|
|
191
|
+
const open = openPositions.pop();
|
|
192
|
+
if (open === undefined)
|
|
193
|
+
return trimmed;
|
|
194
|
+
matchingClose.set(open, index);
|
|
195
|
+
depth -= 1;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
if (depth !== 0)
|
|
199
|
+
return trimmed;
|
|
200
|
+
let start = 0;
|
|
201
|
+
let end = trimmed.length - 1;
|
|
202
|
+
while (start < end && matchingClose.get(start) === end) {
|
|
203
|
+
start += 1;
|
|
204
|
+
end -= 1;
|
|
205
|
+
while (/\s/.test(trimmed[start] ?? ""))
|
|
206
|
+
start += 1;
|
|
207
|
+
while (/\s/.test(trimmed[end] ?? ""))
|
|
208
|
+
end -= 1;
|
|
209
|
+
}
|
|
210
|
+
return start === 0 ? trimmed : trimmed.slice(start, end + 1).trim();
|
|
211
|
+
}
|
|
212
|
+
function hasUnsupportedContainerSizeQuery(conditionText) {
|
|
213
|
+
if (/(?:min-|max-)?(?:height|block-size)\b/i.test(conditionText))
|
|
214
|
+
return true;
|
|
215
|
+
if (/\baspect-ratio\b/i.test(conditionText))
|
|
216
|
+
return true;
|
|
217
|
+
if (/\borientation\s*:/i.test(conditionText))
|
|
218
|
+
return true;
|
|
219
|
+
const featureFirstUnitMatches = conditionText.matchAll(/(?:min-|max-)?(?:width|inline-size)\s*(?:>=|>|<=|<|:)\s*[\d.]+([a-z%]+)/gi);
|
|
220
|
+
const valueFirstUnitMatches = conditionText.matchAll(/[\d.]+([a-z%]+)\s*(?:>=|>|<=|<)\s*(?:width|inline-size)/gi);
|
|
221
|
+
return [...featureFirstUnitMatches, ...valueFirstUnitMatches].some((match) => !/^(?:px|rem)$/i.test(match[1]));
|
|
222
|
+
}
|
|
223
|
+
function evaluateRangeComparisons(conditionText, width, remSize) {
|
|
224
|
+
const featureFirstPattern = /(?:width|inline-size)\s*(>=|>|<=|<)\s*([\d.]+)(px|rem)/gi;
|
|
225
|
+
const valueFirstPattern = /([\d.]+)(px|rem)\s*(<=|<|>=|>)\s*(width|inline-size)/gi;
|
|
226
|
+
const comparisons = [];
|
|
227
|
+
for (const comparison of conditionText.matchAll(featureFirstPattern)) {
|
|
228
|
+
const operator = comparison[1];
|
|
229
|
+
const threshold = comparison[2];
|
|
230
|
+
const unit = comparison[3];
|
|
231
|
+
if (operator && threshold && unit)
|
|
232
|
+
comparisons.push({ operator, threshold, unit });
|
|
233
|
+
}
|
|
234
|
+
for (const comparison of conditionText.matchAll(valueFirstPattern)) {
|
|
235
|
+
const threshold = comparison[1];
|
|
236
|
+
const unit = comparison[2];
|
|
237
|
+
const operator = comparison[3] === "<=" ? ">=" : comparison[3] === "<" ? ">" : comparison[3] === ">=" ? "<=" : "<";
|
|
238
|
+
if (threshold && unit)
|
|
239
|
+
comparisons.push({ operator, threshold, unit });
|
|
240
|
+
}
|
|
241
|
+
if (comparisons.length === 0)
|
|
242
|
+
return;
|
|
243
|
+
const satisfiesAll = comparisons.every((comparison) => {
|
|
244
|
+
const { operator } = comparison;
|
|
245
|
+
const threshold = Number(comparison.threshold) * (comparison.unit.toLowerCase() === "rem" ? remSize : 1);
|
|
246
|
+
if (operator === ">=")
|
|
247
|
+
return width >= threshold;
|
|
248
|
+
if (operator === ">")
|
|
249
|
+
return width > threshold;
|
|
250
|
+
if (operator === "<=")
|
|
251
|
+
return width <= threshold;
|
|
252
|
+
return width < threshold;
|
|
253
|
+
});
|
|
254
|
+
return satisfiesAll;
|
|
255
|
+
}
|
|
256
|
+
function evaluateEqualityComparison(conditionText, width, remSize) {
|
|
257
|
+
const equalityPattern = /(?:^|[\s(])(?:width|inline-size)\s*:\s*([\d.]+)(px|rem)/gi;
|
|
258
|
+
const comparisons = [...conditionText.matchAll(equalityPattern)];
|
|
259
|
+
if (comparisons.length === 0)
|
|
260
|
+
return;
|
|
261
|
+
const satisfiesAll = comparisons.every((comparison) => {
|
|
262
|
+
const threshold = Number(comparison[1]) * (comparison[2].toLowerCase() === "rem" ? remSize : 1);
|
|
263
|
+
return width === threshold;
|
|
264
|
+
});
|
|
265
|
+
return satisfiesAll;
|
|
266
|
+
}
|
|
267
|
+
function evaluateContainerSizeConstraints(conditionText, width, remSize, inlineSize = width) {
|
|
268
|
+
const measuredSize = /\binline-size\b/i.test(conditionText) && !/\bwidth\b/i.test(conditionText) ? inlineSize : width;
|
|
269
|
+
if (/\bwidth\b/i.test(conditionText) && /\binline-size\b/i.test(conditionText) && /\band\b/i.test(conditionText)) {
|
|
270
|
+
return conditionText.split(/\s+and\s+/i).every((clause) => evaluateContainerSizeConstraints(clause, /\binline-size\b/i.test(clause) ? inlineSize : width, remSize, inlineSize));
|
|
271
|
+
}
|
|
272
|
+
const minimum = /min-(?:width|inline-size)\s*:\s*([\d.]+)(px|rem)/i.exec(conditionText);
|
|
273
|
+
const maximum = /max-(?:width|inline-size)\s*:\s*([\d.]+)(px|rem)/i.exec(conditionText);
|
|
274
|
+
const toPixels = (value) => Number(value[1]) * (value[2].toLowerCase() === "rem" ? remSize : 1);
|
|
275
|
+
const legacyMatches = (!minimum || measuredSize >= toPixels(minimum)) && (!maximum || measuredSize <= toPixels(maximum));
|
|
276
|
+
const rangeMatches = evaluateRangeComparisons(conditionText, measuredSize, remSize) ?? true;
|
|
277
|
+
const equalityMatches = evaluateEqualityComparison(conditionText, measuredSize, remSize) ?? true;
|
|
278
|
+
const hasSizeFeature = /\b(?:width|inline-size)\b/i.test(conditionText);
|
|
279
|
+
const hasRecognizedRange = /(?:width|inline-size)\s*(?:>=|>|<=|<)\s*[\d.]+(?:px|rem)/i.test(conditionText) || /[\d.]+(?:px|rem)\s*(?:<=|<|>=|>)\s*(?:width|inline-size)/i.test(conditionText);
|
|
280
|
+
const hasRecognizedEquality = /(?:width|inline-size)\s*:\s*[\d.]+(?:px|rem)/i.test(conditionText);
|
|
281
|
+
if (hasSizeFeature && !minimum && !maximum && !hasRecognizedRange && !hasRecognizedEquality)
|
|
282
|
+
return false;
|
|
283
|
+
const combinedMatches = legacyMatches && rangeMatches && equalityMatches;
|
|
284
|
+
return /^\s*not\b/i.test(conditionText) ? !combinedMatches : combinedMatches;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// src/_internal/text-direction-css.ts
|
|
288
|
+
function matchesDirectionStyleRule(element, getParentElement) {
|
|
289
|
+
const styleSheets = new Map;
|
|
290
|
+
for (const sheet of Array.from(element.ownerDocument.styleSheets))
|
|
291
|
+
styleSheets.set(sheet, null);
|
|
292
|
+
for (const sheet of Array.from(element.ownerDocument.adoptedStyleSheets ?? []))
|
|
293
|
+
styleSheets.set(sheet, null);
|
|
294
|
+
const root = element.getRootNode();
|
|
295
|
+
if (typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot) {
|
|
296
|
+
for (const sheet of root.adoptedStyleSheets)
|
|
297
|
+
styleSheets.set(sheet, root);
|
|
298
|
+
for (const styleElement of root.querySelectorAll("style")) {
|
|
299
|
+
if (styleElement.sheet)
|
|
300
|
+
styleSheets.set(styleElement.sheet, root);
|
|
301
|
+
}
|
|
302
|
+
for (const linkElement of root.querySelectorAll('link[rel~="stylesheet"]')) {
|
|
303
|
+
if (linkElement.sheet)
|
|
304
|
+
styleSheets.set(linkElement.sheet, root);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
for (const [sheet, fallbackRoot] of styleSheets) {
|
|
308
|
+
if (!isActiveStyleSheet(sheet))
|
|
309
|
+
continue;
|
|
310
|
+
let rules;
|
|
311
|
+
try {
|
|
312
|
+
rules = sheet.cssRules;
|
|
313
|
+
} catch {
|
|
314
|
+
continue;
|
|
315
|
+
}
|
|
316
|
+
if (matchesDirectionStyleRuleList(element, rules, getParentElement, [], getImplicitScopeRoot(sheet, fallbackRoot, element.ownerDocument.documentElement)))
|
|
317
|
+
return true;
|
|
318
|
+
}
|
|
319
|
+
return false;
|
|
320
|
+
}
|
|
321
|
+
function isActiveStyleSheet(sheet) {
|
|
322
|
+
if (sheet.disabled)
|
|
323
|
+
return false;
|
|
324
|
+
const mediaText = sheet.media?.mediaText;
|
|
325
|
+
if (!mediaText)
|
|
326
|
+
return true;
|
|
327
|
+
if (typeof matchMedia !== "function")
|
|
328
|
+
return true;
|
|
329
|
+
return matchMedia(mediaText).matches;
|
|
330
|
+
}
|
|
331
|
+
function getImplicitScopeRoot(sheet, fallbackRoot, documentRoot) {
|
|
332
|
+
const ownerNode = Reflect.get(sheet, "ownerNode");
|
|
333
|
+
if (!(ownerNode instanceof Element) || ownerNode.localName?.toLowerCase() !== "style") {
|
|
334
|
+
return typeof ShadowRoot !== "undefined" && fallbackRoot instanceof ShadowRoot ? fallbackRoot : documentRoot;
|
|
335
|
+
}
|
|
336
|
+
if (ownerNode.parentElement)
|
|
337
|
+
return ownerNode.parentElement;
|
|
338
|
+
const root = ownerNode.getRootNode();
|
|
339
|
+
return typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot ? root : typeof ShadowRoot !== "undefined" && fallbackRoot instanceof ShadowRoot ? fallbackRoot : null;
|
|
340
|
+
}
|
|
341
|
+
function matchesDirectionStyleRuleCached(element, cache, getParentElement) {
|
|
342
|
+
if (!getParentElement)
|
|
343
|
+
return false;
|
|
344
|
+
if (!cache)
|
|
345
|
+
return matchesDirectionStyleRule(element, getParentElement);
|
|
346
|
+
const cached = cache.get(element);
|
|
347
|
+
if (cached !== undefined)
|
|
348
|
+
return cached;
|
|
349
|
+
const matched = matchesDirectionStyleRule(element, getParentElement);
|
|
350
|
+
cache.set(element, matched);
|
|
351
|
+
return matched;
|
|
352
|
+
}
|
|
353
|
+
function matchesDirectionStyleRuleList(element, rules, getParentElement, scopes = [], implicitScopeRoot = null) {
|
|
354
|
+
for (const rule of Array.from(rules)) {
|
|
355
|
+
if (Reflect.get(rule, "type") === 3) {
|
|
356
|
+
const imported = Reflect.get(rule, "styleSheet");
|
|
357
|
+
if (imported) {
|
|
358
|
+
try {
|
|
359
|
+
const importedRules = Reflect.get(imported, "cssRules");
|
|
360
|
+
if (isCssRuleCollection(importedRules) && matchesDirectionStyleRuleList(element, importedRules, getParentElement, scopes, implicitScopeRoot))
|
|
361
|
+
return true;
|
|
362
|
+
} catch {}
|
|
363
|
+
}
|
|
364
|
+
continue;
|
|
365
|
+
}
|
|
366
|
+
if (isCssStyleRule(rule)) {
|
|
367
|
+
if (!rule.style.direction) {
|
|
368
|
+
const nestedRules2 = readNestedCssRules(rule);
|
|
369
|
+
if (nestedRules2 && matchesDirectionStyleRuleList(element, nestedRules2, getParentElement, scopes, implicitScopeRoot))
|
|
370
|
+
return true;
|
|
371
|
+
continue;
|
|
372
|
+
}
|
|
373
|
+
try {
|
|
374
|
+
const selectorText = resolveNestedSelector(rule);
|
|
375
|
+
if (selectorText && matchesScopedSelector(element, selectorText, scopes))
|
|
376
|
+
return true;
|
|
377
|
+
} catch {
|
|
378
|
+
continue;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
const nestedRules = readNestedCssRules(rule);
|
|
382
|
+
if (isScopeRule(rule)) {
|
|
383
|
+
const scope = createActiveScope(rule, element, scopes, implicitScopeRoot);
|
|
384
|
+
if (scope && nestedRules) {
|
|
385
|
+
if (matchesDirectionStyleRuleList(element, nestedRules, getParentElement, [...scopes, scope], implicitScopeRoot))
|
|
386
|
+
return true;
|
|
387
|
+
}
|
|
388
|
+
continue;
|
|
389
|
+
}
|
|
390
|
+
if (nestedRules && isConditionalRuleActive(rule, element, getParentElement) && matchesDirectionStyleRuleList(element, nestedRules, getParentElement, scopes, implicitScopeRoot)) {
|
|
391
|
+
return true;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
return false;
|
|
395
|
+
}
|
|
396
|
+
function readNestedCssRules(rule) {
|
|
397
|
+
if (!("cssRules" in rule))
|
|
398
|
+
return;
|
|
399
|
+
try {
|
|
400
|
+
const nestedRules = Reflect.get(rule, "cssRules");
|
|
401
|
+
return isCssRuleCollection(nestedRules) ? nestedRules : undefined;
|
|
402
|
+
} catch {
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
function isCssRuleCollection(value) {
|
|
407
|
+
if (typeof CSSRuleList !== "undefined" && value instanceof CSSRuleList)
|
|
408
|
+
return true;
|
|
409
|
+
if (Array.isArray(value))
|
|
410
|
+
return value.every(isCssRule);
|
|
411
|
+
if (typeof value !== "object" || value === null)
|
|
412
|
+
return false;
|
|
413
|
+
const iterator = Reflect.get(value, Symbol.iterator);
|
|
414
|
+
return typeof iterator === "function";
|
|
415
|
+
}
|
|
416
|
+
function isCssRule(value) {
|
|
417
|
+
return typeof value === "object" && value !== null && typeof Reflect.get(value, "cssText") === "string" && typeof Reflect.get(value, "type") === "number";
|
|
418
|
+
}
|
|
419
|
+
function isCssStyleRule(rule) {
|
|
420
|
+
return typeof Reflect.get(rule, "selectorText") === "string" && typeof Reflect.get(rule, "style") === "object" && Reflect.get(rule, "style") !== null;
|
|
421
|
+
}
|
|
422
|
+
function resolveNestedSelector(rule) {
|
|
423
|
+
let selector = rule.selectorText.trim();
|
|
424
|
+
let parentRule = Reflect.get(rule, "parentRule");
|
|
425
|
+
while (parentRule) {
|
|
426
|
+
if (isCssStyleRule(parentRule)) {
|
|
427
|
+
const parentSelector = parentRule.selectorText.trim();
|
|
428
|
+
if (!parentSelector)
|
|
429
|
+
return;
|
|
430
|
+
selector = combineNestedSelectors(parentSelector, selector);
|
|
431
|
+
if (!selector)
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
parentRule = Reflect.get(parentRule, "parentRule");
|
|
435
|
+
}
|
|
436
|
+
return selector;
|
|
437
|
+
}
|
|
438
|
+
function combineNestedSelectors(parentSelector, nestedSelector) {
|
|
439
|
+
const parentContext = splitSelectorList(parentSelector).length > 1 ? `:is(${parentSelector})` : parentSelector;
|
|
440
|
+
return splitSelectorList(nestedSelector).map((selector) => {
|
|
441
|
+
const resolved = replaceNestingReferences(selector, parentContext);
|
|
442
|
+
return resolved.replaced ? resolved.selector : `${parentContext} ${selector}`;
|
|
443
|
+
}).join(", ");
|
|
444
|
+
}
|
|
445
|
+
function replaceNestingReferences(selector, parentContext) {
|
|
446
|
+
let quote;
|
|
447
|
+
let replaced = false;
|
|
448
|
+
let resolved = "";
|
|
449
|
+
for (let index = 0;index < selector.length; index += 1) {
|
|
450
|
+
const character = selector[index];
|
|
451
|
+
if (character === "\\") {
|
|
452
|
+
resolved += character;
|
|
453
|
+
if (index + 1 < selector.length)
|
|
454
|
+
resolved += selector[++index];
|
|
455
|
+
continue;
|
|
456
|
+
}
|
|
457
|
+
if (quote !== undefined) {
|
|
458
|
+
resolved += character;
|
|
459
|
+
if (character === quote)
|
|
460
|
+
quote = undefined;
|
|
461
|
+
continue;
|
|
462
|
+
}
|
|
463
|
+
if (character === '"' || character === "'") {
|
|
464
|
+
quote = character;
|
|
465
|
+
resolved += character;
|
|
466
|
+
continue;
|
|
467
|
+
}
|
|
468
|
+
if (character === "&") {
|
|
469
|
+
resolved += parentContext;
|
|
470
|
+
replaced = true;
|
|
471
|
+
continue;
|
|
472
|
+
}
|
|
473
|
+
resolved += character;
|
|
474
|
+
}
|
|
475
|
+
return { selector: resolved, replaced };
|
|
476
|
+
}
|
|
477
|
+
function splitSelectorList(selectorText) {
|
|
478
|
+
const selectors = [];
|
|
479
|
+
let parenthesesDepth = 0;
|
|
480
|
+
let bracketDepth = 0;
|
|
481
|
+
let quote;
|
|
482
|
+
let start = 0;
|
|
483
|
+
for (let index = 0;index < selectorText.length; index += 1) {
|
|
484
|
+
const character = selectorText[index];
|
|
485
|
+
if (character === "\\") {
|
|
486
|
+
index += 1;
|
|
487
|
+
continue;
|
|
488
|
+
}
|
|
489
|
+
if (quote !== undefined) {
|
|
490
|
+
if (character === quote)
|
|
491
|
+
quote = undefined;
|
|
492
|
+
continue;
|
|
493
|
+
}
|
|
494
|
+
if (character === '"' || character === "'") {
|
|
495
|
+
quote = character;
|
|
496
|
+
continue;
|
|
497
|
+
}
|
|
498
|
+
if (character === "(")
|
|
499
|
+
parenthesesDepth += 1;
|
|
500
|
+
if (character === ")")
|
|
501
|
+
parenthesesDepth = Math.max(0, parenthesesDepth - 1);
|
|
502
|
+
if (character === "[")
|
|
503
|
+
bracketDepth += 1;
|
|
504
|
+
if (character === "]")
|
|
505
|
+
bracketDepth = Math.max(0, bracketDepth - 1);
|
|
506
|
+
if (character === "," && parenthesesDepth === 0 && bracketDepth === 0) {
|
|
507
|
+
const selector2 = selectorText.slice(start, index).trim();
|
|
508
|
+
if (selector2)
|
|
509
|
+
selectors.push(selector2);
|
|
510
|
+
start = index + 1;
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
const selector = selectorText.slice(start).trim();
|
|
514
|
+
if (selector)
|
|
515
|
+
selectors.push(selector);
|
|
516
|
+
return selectors;
|
|
517
|
+
}
|
|
518
|
+
function isConditionalRuleActive(rule, element, getParentElement) {
|
|
519
|
+
const conditionText = Reflect.get(rule, "conditionText");
|
|
520
|
+
if (typeof conditionText !== "string" || !conditionText.trim())
|
|
521
|
+
return true;
|
|
522
|
+
if (isContainerRule(rule))
|
|
523
|
+
return isContainerQueryActive(conditionText, element, rule, getParentElement);
|
|
524
|
+
if (isMediaRule(rule) && typeof matchMedia === "function") {
|
|
525
|
+
return matchMedia(conditionText).matches;
|
|
526
|
+
}
|
|
527
|
+
if (isSupportsRule(rule) && typeof CSS !== "undefined" && typeof CSS.supports === "function")
|
|
528
|
+
return CSS.supports(conditionText);
|
|
529
|
+
return true;
|
|
530
|
+
}
|
|
531
|
+
function isScopeRule(rule) {
|
|
532
|
+
if (rule.constructor.name === "CSSScopeRule")
|
|
533
|
+
return true;
|
|
534
|
+
const cssText = Reflect.get(rule, "cssText");
|
|
535
|
+
return typeof cssText === "string" && /^\s*@scope\b/i.test(cssText);
|
|
536
|
+
}
|
|
537
|
+
function createActiveScope(rule, element, parentScopes, implicitScopeRoot) {
|
|
538
|
+
const cssText = Reflect.get(rule, "cssText");
|
|
539
|
+
if (typeof cssText !== "string")
|
|
540
|
+
return null;
|
|
541
|
+
const prelude = parseScopePrelude(cssText);
|
|
542
|
+
if (!prelude)
|
|
543
|
+
return null;
|
|
544
|
+
const roots = findActiveScopeRoots(element, prelude, parentScopes, implicitScopeRoot);
|
|
545
|
+
return roots === null ? null : { roots };
|
|
546
|
+
}
|
|
547
|
+
function scopePseudoRootCandidates(parentScopes, implicitScopeRoot) {
|
|
548
|
+
if (parentScopes.length > 0)
|
|
549
|
+
return parentScopes.at(-1).roots;
|
|
550
|
+
return implicitScopeRoot ? [implicitScopeRoot] : [];
|
|
551
|
+
}
|
|
552
|
+
function findActiveScopeRoots(element, prelude, parentScopes, implicitScopeRoot) {
|
|
553
|
+
if (!selectorsAreValid(element, prelude.rootSelectors))
|
|
554
|
+
return null;
|
|
555
|
+
if (prelude.limitSelectors && !selectorsAreValid(element, prelude.limitSelectors))
|
|
556
|
+
return null;
|
|
557
|
+
if (prelude.rootSelectors.length === 0) {
|
|
558
|
+
const candidates = scopePseudoRootCandidates(parentScopes, implicitScopeRoot);
|
|
559
|
+
const roots2 = candidates.length > 0 ? candidates : [implicitScopeRoot ?? element.ownerDocument.documentElement];
|
|
560
|
+
return finalizeActiveScopeRoots(roots2.filter((root) => root.contains(element)), element, prelude, parentScopes);
|
|
561
|
+
}
|
|
562
|
+
const scopeRootSelectors = prelude.rootSelectors.filter(hasScopePseudoClass);
|
|
563
|
+
const ordinaryRootSelectors = prelude.rootSelectors.filter((selector) => !hasScopePseudoClass(selector));
|
|
564
|
+
const scopeRootCandidates = scopePseudoRootCandidates(parentScopes, implicitScopeRoot);
|
|
565
|
+
const roots = [
|
|
566
|
+
...findRelativeScopeRootMatches(element, scopeRootSelectors, scopeRootCandidates),
|
|
567
|
+
...findScopeMatches(element, ordinaryRootSelectors)
|
|
568
|
+
];
|
|
569
|
+
return finalizeActiveScopeRoots(roots, element, prelude, parentScopes);
|
|
570
|
+
}
|
|
571
|
+
function findRelativeScopeRootMatches(element, selectors, scopeRootCandidates) {
|
|
572
|
+
if (selectors.length === 0 || scopeRootCandidates.length === 0)
|
|
573
|
+
return [];
|
|
574
|
+
const parentScope = { roots: [...scopeRootCandidates] };
|
|
575
|
+
const hasExactScopeSelector = selectors.some(isExactScopeSelector);
|
|
576
|
+
const matches = [];
|
|
577
|
+
let current = element;
|
|
578
|
+
while (current) {
|
|
579
|
+
const currentElement = current;
|
|
580
|
+
if (selectors.some((selector) => matchesScopedSelector(currentElement, selector, [parentScope])))
|
|
581
|
+
matches.push(currentElement);
|
|
582
|
+
const parent = currentElement.parentElement;
|
|
583
|
+
if (parent) {
|
|
584
|
+
current = parent;
|
|
585
|
+
continue;
|
|
586
|
+
}
|
|
587
|
+
const root = currentElement.getRootNode();
|
|
588
|
+
if (typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot && hasExactScopeSelector && scopeRootCandidates.includes(root))
|
|
589
|
+
matches.push(root);
|
|
590
|
+
current = null;
|
|
591
|
+
}
|
|
592
|
+
return matches;
|
|
593
|
+
}
|
|
594
|
+
function isExactScopeSelector(selector) {
|
|
595
|
+
return selector.trim().toLowerCase() === ":scope";
|
|
596
|
+
}
|
|
597
|
+
function finalizeActiveScopeRoots(roots, element, prelude, parentScopes) {
|
|
598
|
+
const activeRoots = [];
|
|
599
|
+
for (const root of roots) {
|
|
600
|
+
if (!isWithinParentScopes(root, parentScopes))
|
|
601
|
+
continue;
|
|
602
|
+
if (prelude.limitSelectors && isWithinScopeLimit(element, root, prelude.limitSelectors)) {
|
|
603
|
+
continue;
|
|
604
|
+
}
|
|
605
|
+
activeRoots.push(root);
|
|
606
|
+
}
|
|
607
|
+
return activeRoots.length === 0 ? null : activeRoots;
|
|
608
|
+
}
|
|
609
|
+
function selectorsAreValid(element, selectors) {
|
|
610
|
+
try {
|
|
611
|
+
for (const selector of selectors)
|
|
612
|
+
element.matches(selector);
|
|
613
|
+
return true;
|
|
614
|
+
} catch {
|
|
615
|
+
return false;
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
function isWithinParentScopes(root, parentScopes) {
|
|
619
|
+
return parentScopes.every((scope) => scope.roots.some((parentRoot) => parentRoot.contains(root)));
|
|
620
|
+
}
|
|
621
|
+
function isWithinScopeLimit(element, root, limitSelectors) {
|
|
622
|
+
let current = element;
|
|
623
|
+
while (current) {
|
|
624
|
+
if (current === root)
|
|
625
|
+
break;
|
|
626
|
+
if (limitSelectors.some((selector) => hasScopePseudoClass(selector) ? matchesScopedSelector(current, selector, [{ roots: [root] }]) : matchesSelectorSafely(current, selector)))
|
|
627
|
+
return true;
|
|
628
|
+
current = current.parentElement;
|
|
629
|
+
}
|
|
630
|
+
return false;
|
|
631
|
+
}
|
|
632
|
+
function matchesSelectorSafely(element, selector) {
|
|
633
|
+
try {
|
|
634
|
+
return element.matches(selector);
|
|
635
|
+
} catch {
|
|
636
|
+
return false;
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
function normalizeScopeRelativeSelector(selector) {
|
|
640
|
+
return splitSelectorList(selector).map((part) => {
|
|
641
|
+
if (!part.includes("&") && !/^\s*[>+~]/.test(part))
|
|
642
|
+
return part;
|
|
643
|
+
const withScopeAlias = replaceNestingReferences(part, ":scope").selector;
|
|
644
|
+
return /^\s*[>+~]/.test(withScopeAlias) ? `:scope ${withScopeAlias}` : withScopeAlias;
|
|
645
|
+
}).join(", ");
|
|
646
|
+
}
|
|
647
|
+
function matchesScopedSelector(element, selector, scopes) {
|
|
648
|
+
const normalizedSelector = scopes.length > 0 ? normalizeScopeRelativeSelector(selector) : selector;
|
|
649
|
+
return splitSelectorList(normalizedSelector).some((item) => matchesScopedSelectorItem(element, item, scopes));
|
|
650
|
+
}
|
|
651
|
+
function matchesScopedSelectorItem(element, selector, scopes) {
|
|
652
|
+
if (!hasScopePseudoClass(selector))
|
|
653
|
+
return matchesSelectorSafely(element, selector);
|
|
654
|
+
if (scopes.length === 0)
|
|
655
|
+
return false;
|
|
656
|
+
const scope = scopes.at(-1);
|
|
657
|
+
if (!scope)
|
|
658
|
+
return false;
|
|
659
|
+
const outsideContext = splitScopeOutsideContext(selector);
|
|
660
|
+
const remainderSelector = outsideContext ? outsideContext.remainder : selector;
|
|
661
|
+
for (const root of scope.roots) {
|
|
662
|
+
try {
|
|
663
|
+
if (outsideContext) {
|
|
664
|
+
if (!(root instanceof Element))
|
|
665
|
+
continue;
|
|
666
|
+
if (!matchesOutsideScopeContext(root, outsideContext.before, outsideContext.combinator))
|
|
667
|
+
continue;
|
|
668
|
+
}
|
|
669
|
+
if (matchesRemainderAgainstScopeRoot(element, remainderSelector, root))
|
|
670
|
+
return true;
|
|
671
|
+
} catch {}
|
|
672
|
+
}
|
|
673
|
+
return false;
|
|
674
|
+
}
|
|
675
|
+
function splitScopeOutsideContext(selector) {
|
|
676
|
+
const scopeIndex = findScopePseudoClassIndex(selector, { topLevelOnly: true });
|
|
677
|
+
if (scopeIndex === null)
|
|
678
|
+
return null;
|
|
679
|
+
const beforeRaw = selector.slice(0, scopeIndex);
|
|
680
|
+
if (!beforeRaw.trim())
|
|
681
|
+
return null;
|
|
682
|
+
const trimmedEnd = beforeRaw.replace(/\s+$/, "");
|
|
683
|
+
const lastCharacter = trimmedEnd.at(-1);
|
|
684
|
+
if (lastCharacter === ">" || lastCharacter === "+" || lastCharacter === "~") {
|
|
685
|
+
const before2 = trimmedEnd.slice(0, -1).trim();
|
|
686
|
+
return before2 ? { before: before2, combinator: lastCharacter, remainder: selector.slice(scopeIndex) } : null;
|
|
687
|
+
}
|
|
688
|
+
if (!/\s$/.test(beforeRaw))
|
|
689
|
+
return null;
|
|
690
|
+
const before = trimmedEnd.trim();
|
|
691
|
+
return before ? { before, combinator: " ", remainder: selector.slice(scopeIndex) } : null;
|
|
692
|
+
}
|
|
693
|
+
function matchesOutsideScopeContext(root, before, combinator) {
|
|
694
|
+
if (combinator === " ")
|
|
695
|
+
return root.parentElement?.closest(before) != null;
|
|
696
|
+
if (combinator === ">")
|
|
697
|
+
return root.parentElement !== null && matchesSelectorSafely(root.parentElement, before);
|
|
698
|
+
if (combinator === "+") {
|
|
699
|
+
const sibling2 = root.previousElementSibling;
|
|
700
|
+
return sibling2 !== null && matchesSelectorSafely(sibling2, before);
|
|
701
|
+
}
|
|
702
|
+
let sibling = root.previousElementSibling;
|
|
703
|
+
while (sibling) {
|
|
704
|
+
if (matchesSelectorSafely(sibling, before))
|
|
705
|
+
return true;
|
|
706
|
+
sibling = sibling.previousElementSibling;
|
|
707
|
+
}
|
|
708
|
+
return false;
|
|
709
|
+
}
|
|
710
|
+
function matchesRemainderAgainstScopeRoot(element, selector, root) {
|
|
711
|
+
if (root.querySelector(":scope") === root) {
|
|
712
|
+
return Array.from(root.querySelectorAll(selector)).includes(element);
|
|
713
|
+
}
|
|
714
|
+
const clone = typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot ? null : root.cloneNode(true);
|
|
715
|
+
const cloneElement = clone instanceof Element ? clone : typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot ? (() => {
|
|
716
|
+
const wrapper = root.ownerDocument.createElement("div");
|
|
717
|
+
wrapper.append(...Array.from(root.children, (child) => child.cloneNode(true)));
|
|
718
|
+
return wrapper;
|
|
719
|
+
})() : null;
|
|
720
|
+
if (!cloneElement)
|
|
721
|
+
return false;
|
|
722
|
+
const marker = "data-cinder-scope-root";
|
|
723
|
+
const replacedSelector = replaceScopePseudoClass(selector, `[${marker}]`);
|
|
724
|
+
if (typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot && /^\[[^\]]+\][^\s>+~]/.test(replacedSelector))
|
|
725
|
+
return false;
|
|
726
|
+
cloneElement.setAttribute(marker, "true");
|
|
727
|
+
const path = [];
|
|
728
|
+
let current = element;
|
|
729
|
+
while (current && current !== root) {
|
|
730
|
+
const parent = current.parentElement;
|
|
731
|
+
if (!parent) {
|
|
732
|
+
if (typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot && current.getRootNode() === root)
|
|
733
|
+
path.unshift(Array.prototype.indexOf.call(root.children, current));
|
|
734
|
+
break;
|
|
735
|
+
}
|
|
736
|
+
path.unshift(Array.prototype.indexOf.call(parent.children, current));
|
|
737
|
+
current = parent;
|
|
738
|
+
}
|
|
739
|
+
if (current !== root && !(typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot && current?.getRootNode() === root))
|
|
740
|
+
return false;
|
|
741
|
+
let matchedCloneElement = cloneElement;
|
|
742
|
+
for (const index of path) {
|
|
743
|
+
const child = matchedCloneElement.children[index];
|
|
744
|
+
if (!child)
|
|
745
|
+
break;
|
|
746
|
+
matchedCloneElement = child;
|
|
747
|
+
}
|
|
748
|
+
return matchedCloneElement === cloneElement && cloneElement.matches(replacedSelector) || Array.from(cloneElement.querySelectorAll(replacedSelector)).includes(matchedCloneElement);
|
|
749
|
+
}
|
|
750
|
+
function replaceScopePseudoClass(selector, replacement) {
|
|
751
|
+
let result = "";
|
|
752
|
+
let quote = null;
|
|
753
|
+
let escaped = false;
|
|
754
|
+
let brackets = 0;
|
|
755
|
+
for (let index = 0;index < selector.length; index += 1) {
|
|
756
|
+
const character = selector[index];
|
|
757
|
+
if (escaped) {
|
|
758
|
+
result += character;
|
|
759
|
+
escaped = false;
|
|
760
|
+
continue;
|
|
761
|
+
}
|
|
762
|
+
if (character === "\\") {
|
|
763
|
+
result += character;
|
|
764
|
+
escaped = true;
|
|
765
|
+
continue;
|
|
766
|
+
}
|
|
767
|
+
if (quote) {
|
|
768
|
+
result += character;
|
|
769
|
+
if (character === quote)
|
|
770
|
+
quote = null;
|
|
771
|
+
continue;
|
|
772
|
+
}
|
|
773
|
+
if (character === '"' || character === "'") {
|
|
774
|
+
result += character;
|
|
775
|
+
quote = character;
|
|
776
|
+
continue;
|
|
777
|
+
}
|
|
778
|
+
if (character === "[") {
|
|
779
|
+
brackets += 1;
|
|
780
|
+
result += character;
|
|
781
|
+
continue;
|
|
782
|
+
}
|
|
783
|
+
if (character === "]") {
|
|
784
|
+
brackets = Math.max(0, brackets - 1);
|
|
785
|
+
result += character;
|
|
786
|
+
continue;
|
|
787
|
+
}
|
|
788
|
+
if (brackets === 0 && character === ":" && selector.slice(index + 1, index + 6).toLowerCase() === "scope" && !/[\w-]/.test(selector[index + 6] ?? "")) {
|
|
789
|
+
result += replacement;
|
|
790
|
+
index += 5;
|
|
791
|
+
continue;
|
|
792
|
+
}
|
|
793
|
+
result += character;
|
|
794
|
+
}
|
|
795
|
+
return result;
|
|
796
|
+
}
|
|
797
|
+
function findScopePseudoClassIndex(selector, options = {}) {
|
|
798
|
+
let quote = null;
|
|
799
|
+
let brackets = 0;
|
|
800
|
+
let parentheses = 0;
|
|
801
|
+
let escaped = false;
|
|
802
|
+
for (let index = 0;index < selector.length; index += 1) {
|
|
803
|
+
const character = selector[index];
|
|
804
|
+
if (escaped) {
|
|
805
|
+
escaped = false;
|
|
806
|
+
continue;
|
|
807
|
+
}
|
|
808
|
+
if (character === "\\") {
|
|
809
|
+
escaped = true;
|
|
810
|
+
continue;
|
|
811
|
+
}
|
|
812
|
+
if (quote) {
|
|
813
|
+
if (character === quote)
|
|
814
|
+
quote = null;
|
|
815
|
+
continue;
|
|
816
|
+
}
|
|
817
|
+
if (character === '"' || character === "'") {
|
|
818
|
+
quote = character;
|
|
819
|
+
continue;
|
|
820
|
+
}
|
|
821
|
+
if (character === "[") {
|
|
822
|
+
brackets += 1;
|
|
823
|
+
continue;
|
|
824
|
+
}
|
|
825
|
+
if (character === "]") {
|
|
826
|
+
brackets = Math.max(0, brackets - 1);
|
|
827
|
+
continue;
|
|
828
|
+
}
|
|
829
|
+
if (character === "(") {
|
|
830
|
+
parentheses += 1;
|
|
831
|
+
continue;
|
|
832
|
+
}
|
|
833
|
+
if (character === ")") {
|
|
834
|
+
parentheses = Math.max(0, parentheses - 1);
|
|
835
|
+
continue;
|
|
836
|
+
}
|
|
837
|
+
if (brackets === 0 && (!options.topLevelOnly || parentheses === 0) && character === ":" && selector.slice(index + 1, index + 6).toLowerCase() === "scope" && !/[\w-]/.test(selector[index + 6] ?? ""))
|
|
838
|
+
return index;
|
|
839
|
+
}
|
|
840
|
+
return null;
|
|
841
|
+
}
|
|
842
|
+
function hasScopePseudoClass(selector) {
|
|
843
|
+
return findScopePseudoClassIndex(selector) !== null;
|
|
844
|
+
}
|
|
845
|
+
function parseScopePrelude(cssText) {
|
|
846
|
+
const match = /^\s*@scope\b/i.exec(cssText);
|
|
847
|
+
if (!match)
|
|
848
|
+
return null;
|
|
849
|
+
const start = match[0].length;
|
|
850
|
+
let quote = null;
|
|
851
|
+
let escaped = false;
|
|
852
|
+
let parentheses = 0;
|
|
853
|
+
let brackets = 0;
|
|
854
|
+
let end = -1;
|
|
855
|
+
for (let index = start;index < cssText.length; index += 1) {
|
|
856
|
+
const character = cssText[index];
|
|
857
|
+
if (escaped) {
|
|
858
|
+
escaped = false;
|
|
859
|
+
continue;
|
|
860
|
+
}
|
|
861
|
+
if (character === "\\") {
|
|
862
|
+
escaped = true;
|
|
863
|
+
continue;
|
|
864
|
+
}
|
|
865
|
+
if (quote) {
|
|
866
|
+
if (character === quote)
|
|
867
|
+
quote = null;
|
|
868
|
+
continue;
|
|
869
|
+
}
|
|
870
|
+
if (character === '"' || character === "'")
|
|
871
|
+
quote = character;
|
|
872
|
+
else if (character === "(")
|
|
873
|
+
parentheses += 1;
|
|
874
|
+
else if (character === ")")
|
|
875
|
+
parentheses -= 1;
|
|
876
|
+
else if (character === "[")
|
|
877
|
+
brackets += 1;
|
|
878
|
+
else if (character === "]")
|
|
879
|
+
brackets -= 1;
|
|
880
|
+
else if (character === "{" && parentheses === 0 && brackets === 0) {
|
|
881
|
+
end = index;
|
|
882
|
+
break;
|
|
883
|
+
}
|
|
884
|
+
if (parentheses < 0 || brackets < 0)
|
|
885
|
+
return null;
|
|
886
|
+
}
|
|
887
|
+
if (end < 0 || quote || escaped || parentheses !== 0 || brackets !== 0)
|
|
888
|
+
return null;
|
|
889
|
+
const prelude = cssText.slice(start, end).trim();
|
|
890
|
+
const limitIndex = findScopeLimitKeyword(prelude);
|
|
891
|
+
const rootText = (limitIndex === null ? prelude : prelude.slice(0, limitIndex)).trim();
|
|
892
|
+
const limitText = limitIndex === null ? null : prelude.slice(limitIndex + 2).trim();
|
|
893
|
+
const rootSelectorText = unwrapScopeGroup(rootText);
|
|
894
|
+
if (rootSelectorText === null)
|
|
895
|
+
return null;
|
|
896
|
+
const rootSelectors = rootSelectorText ? splitScopeSelectors(rootSelectorText) : [];
|
|
897
|
+
if (rootSelectorText && rootSelectors.length === 0)
|
|
898
|
+
return null;
|
|
899
|
+
if (limitText === null)
|
|
900
|
+
return { rootSelectors, limitSelectors: null };
|
|
901
|
+
const limitSelectorText = unwrapScopeGroup(limitText);
|
|
902
|
+
if (limitSelectorText === null || !limitSelectorText)
|
|
903
|
+
return null;
|
|
904
|
+
const limitSelectors = splitScopeSelectors(limitSelectorText);
|
|
905
|
+
return limitSelectors.length > 0 ? { rootSelectors, limitSelectors } : null;
|
|
906
|
+
}
|
|
907
|
+
function findScopeLimitKeyword(prelude) {
|
|
908
|
+
let quote = null;
|
|
909
|
+
let escaped = false;
|
|
910
|
+
let parentheses = 0;
|
|
911
|
+
let brackets = 0;
|
|
912
|
+
for (let index = 0;index < prelude.length; index += 1) {
|
|
913
|
+
const character = prelude[index];
|
|
914
|
+
if (escaped) {
|
|
915
|
+
escaped = false;
|
|
916
|
+
continue;
|
|
917
|
+
}
|
|
918
|
+
if (character === "\\") {
|
|
919
|
+
escaped = true;
|
|
920
|
+
continue;
|
|
921
|
+
}
|
|
922
|
+
if (quote) {
|
|
923
|
+
if (character === quote)
|
|
924
|
+
quote = null;
|
|
925
|
+
continue;
|
|
926
|
+
}
|
|
927
|
+
if (character === '"' || character === "'")
|
|
928
|
+
quote = character;
|
|
929
|
+
else if (character === "(")
|
|
930
|
+
parentheses += 1;
|
|
931
|
+
else if (character === ")")
|
|
932
|
+
parentheses -= 1;
|
|
933
|
+
else if (character === "[")
|
|
934
|
+
brackets += 1;
|
|
935
|
+
else if (character === "]")
|
|
936
|
+
brackets -= 1;
|
|
937
|
+
if (parentheses < 0 || brackets < 0)
|
|
938
|
+
return null;
|
|
939
|
+
if (parentheses === 0 && brackets === 0 && prelude.slice(index, index + 2).toLowerCase() === "to" && !/[\w-]/.test(prelude[index - 1] ?? "") && !/[\w-]/.test(prelude[index + 2] ?? "")) {
|
|
940
|
+
const remainder = prelude.slice(index + 2);
|
|
941
|
+
const opening = remainder.search(/\S/);
|
|
942
|
+
if (opening >= 0 && remainder[opening] === "(")
|
|
943
|
+
return index;
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
return null;
|
|
947
|
+
}
|
|
948
|
+
function unwrapScopeGroup(value) {
|
|
949
|
+
if (!value)
|
|
950
|
+
return "";
|
|
951
|
+
if (value[0] !== "(")
|
|
952
|
+
return value;
|
|
953
|
+
const end = findScopeGroupEnd(value);
|
|
954
|
+
if (end < 0 || value.slice(end + 1).trim())
|
|
955
|
+
return null;
|
|
956
|
+
return value.slice(1, end).trim();
|
|
957
|
+
}
|
|
958
|
+
function findScopeGroupEnd(value) {
|
|
959
|
+
let depth = 0;
|
|
960
|
+
let brackets = 0;
|
|
961
|
+
let quote = null;
|
|
962
|
+
let escaped = false;
|
|
963
|
+
for (let index = 0;index < value.length; index += 1) {
|
|
964
|
+
const character = value[index];
|
|
965
|
+
if (escaped) {
|
|
966
|
+
escaped = false;
|
|
967
|
+
continue;
|
|
968
|
+
}
|
|
969
|
+
if (character === "\\") {
|
|
970
|
+
escaped = true;
|
|
971
|
+
continue;
|
|
972
|
+
}
|
|
973
|
+
if (quote) {
|
|
974
|
+
if (character === quote)
|
|
975
|
+
quote = null;
|
|
976
|
+
continue;
|
|
977
|
+
}
|
|
978
|
+
if (character === '"' || character === "'")
|
|
979
|
+
quote = character;
|
|
980
|
+
else if (character === "[")
|
|
981
|
+
brackets += 1;
|
|
982
|
+
else if (character === "]")
|
|
983
|
+
brackets -= 1;
|
|
984
|
+
else if (character === "(" && brackets === 0)
|
|
985
|
+
depth += 1;
|
|
986
|
+
else if (character === ")" && brackets === 0) {
|
|
987
|
+
depth -= 1;
|
|
988
|
+
if (depth === 0)
|
|
989
|
+
return index;
|
|
990
|
+
}
|
|
991
|
+
if (brackets < 0)
|
|
992
|
+
return -1;
|
|
993
|
+
}
|
|
994
|
+
return -1;
|
|
995
|
+
}
|
|
996
|
+
function findScopeMatches(element, selectors) {
|
|
997
|
+
if (selectors.length === 0)
|
|
998
|
+
return [];
|
|
999
|
+
const matches = [];
|
|
1000
|
+
let current = element;
|
|
1001
|
+
while (current) {
|
|
1002
|
+
const currentElement = current;
|
|
1003
|
+
if (selectors.some((selector) => matchesSelectorSafely(currentElement, selector)))
|
|
1004
|
+
matches.push(currentElement);
|
|
1005
|
+
current = currentElement.parentElement;
|
|
1006
|
+
}
|
|
1007
|
+
return matches;
|
|
1008
|
+
}
|
|
1009
|
+
function splitScopeSelectors(value) {
|
|
1010
|
+
const selectors = [];
|
|
1011
|
+
let parentheses = 0;
|
|
1012
|
+
let brackets = 0;
|
|
1013
|
+
let quote = null;
|
|
1014
|
+
let escaped = false;
|
|
1015
|
+
let start = 0;
|
|
1016
|
+
for (let index = 0;index < value.length; index += 1) {
|
|
1017
|
+
const character = value[index];
|
|
1018
|
+
if (escaped) {
|
|
1019
|
+
escaped = false;
|
|
1020
|
+
continue;
|
|
1021
|
+
}
|
|
1022
|
+
if (character === "\\") {
|
|
1023
|
+
escaped = true;
|
|
1024
|
+
continue;
|
|
1025
|
+
}
|
|
1026
|
+
if (quote) {
|
|
1027
|
+
if (character === quote)
|
|
1028
|
+
quote = null;
|
|
1029
|
+
continue;
|
|
1030
|
+
}
|
|
1031
|
+
if (character === '"' || character === "'")
|
|
1032
|
+
quote = character;
|
|
1033
|
+
else if (character === "(")
|
|
1034
|
+
parentheses += 1;
|
|
1035
|
+
else if (character === ")")
|
|
1036
|
+
parentheses -= 1;
|
|
1037
|
+
else if (character === "[")
|
|
1038
|
+
brackets += 1;
|
|
1039
|
+
else if (character === "]")
|
|
1040
|
+
brackets -= 1;
|
|
1041
|
+
else if (character === "," && parentheses === 0 && brackets === 0) {
|
|
1042
|
+
const selector2 = value.slice(start, index).trim();
|
|
1043
|
+
if (!selector2)
|
|
1044
|
+
return [];
|
|
1045
|
+
selectors.push(selector2);
|
|
1046
|
+
start = index + 1;
|
|
1047
|
+
}
|
|
1048
|
+
if (parentheses < 0 || brackets < 0)
|
|
1049
|
+
return [];
|
|
1050
|
+
}
|
|
1051
|
+
if (escaped || quote || parentheses !== 0 || brackets !== 0)
|
|
1052
|
+
return [];
|
|
1053
|
+
const selector = value.slice(start).trim();
|
|
1054
|
+
if (!selector)
|
|
1055
|
+
return [];
|
|
1056
|
+
selectors.push(selector);
|
|
1057
|
+
return selectors;
|
|
1058
|
+
}
|
|
1059
|
+
function resolveContainerQueryText(conditionText, rule, containerName) {
|
|
1060
|
+
const containerQuery = Reflect.get(rule, "containerQuery");
|
|
1061
|
+
if (typeof containerQuery === "string")
|
|
1062
|
+
return containerQuery;
|
|
1063
|
+
if (typeof containerName !== "string" || !containerName)
|
|
1064
|
+
return conditionText;
|
|
1065
|
+
if (!conditionText.startsWith(containerName))
|
|
1066
|
+
return conditionText;
|
|
1067
|
+
const rest = conditionText.slice(containerName.length);
|
|
1068
|
+
if (!/^\s/.test(rest))
|
|
1069
|
+
return conditionText;
|
|
1070
|
+
return rest.trimStart();
|
|
1071
|
+
}
|
|
1072
|
+
function isContainerConditionList(value) {
|
|
1073
|
+
if (!Array.isArray(value) || value.length === 0)
|
|
1074
|
+
return false;
|
|
1075
|
+
return value.every((entry) => typeof entry === "object" && entry !== null && typeof Reflect.get(entry, "name") === "string" && typeof Reflect.get(entry, "query") === "string");
|
|
1076
|
+
}
|
|
1077
|
+
function isContainerQueryActive(conditionText, element, rule, getParentElement) {
|
|
1078
|
+
if (typeof getComputedStyle !== "function")
|
|
1079
|
+
return false;
|
|
1080
|
+
const conditions = Reflect.get(rule, "conditions");
|
|
1081
|
+
if (isContainerConditionList(conditions))
|
|
1082
|
+
return conditions.some((condition) => isSingleContainerConditionActive(condition.query, condition.name, element, getParentElement));
|
|
1083
|
+
const containerName = Reflect.get(rule, "containerName");
|
|
1084
|
+
const queryText = resolveContainerQueryText(conditionText, rule, containerName);
|
|
1085
|
+
return isSingleContainerConditionActive(queryText, containerName, element, getParentElement);
|
|
1086
|
+
}
|
|
1087
|
+
function isSingleContainerConditionActive(queryText, containerName, element, getParentElement) {
|
|
1088
|
+
if (!queryText.trim())
|
|
1089
|
+
return false;
|
|
1090
|
+
const styleQuery = parseStyleQuery(queryText);
|
|
1091
|
+
if (styleQuery) {
|
|
1092
|
+
const remainder = (queryText.slice(0, styleQuery.index) + queryText.slice(styleQuery.end)).replace(/^\s*(?:and|or|not)\b/i, "").replace(/^\(|\)$/g, "").trim();
|
|
1093
|
+
if (remainder)
|
|
1094
|
+
return false;
|
|
1095
|
+
let ancestor = getParentElement(element);
|
|
1096
|
+
while (ancestor) {
|
|
1097
|
+
if (typeof containerName === "string" && containerName) {
|
|
1098
|
+
const computedStyle = getComputedStyle(ancestor);
|
|
1099
|
+
const name = computedStyle.containerName || computedStyle.getPropertyValue("container-name") || ancestor.style.containerName || ancestor.style.getPropertyValue("container-name");
|
|
1100
|
+
if (!name.split(/\s+/).includes(containerName)) {
|
|
1101
|
+
ancestor = getParentElement(ancestor);
|
|
1102
|
+
continue;
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
const value = getComputedStyle(ancestor).getPropertyValue(styleQuery.name).trim() || ancestor.style.getPropertyValue(styleQuery.name).trim();
|
|
1106
|
+
return /^\s*not\b/i.test(queryText) ? value !== styleQuery.value.trim() : value === styleQuery.value.trim();
|
|
1107
|
+
}
|
|
1108
|
+
return false;
|
|
1109
|
+
}
|
|
1110
|
+
const queriesPhysicalWidth = /(?:^|[\s(])(?:width|min-width|max-width)\s*[:<>=]/i.test(queryText) || /[\d.]+(?:px|rem)\s*(?:<=|<|>=|>)\s*width\b/i.test(queryText);
|
|
1111
|
+
let container = getParentElement(element);
|
|
1112
|
+
while (container) {
|
|
1113
|
+
const computedStyle = getComputedStyle(container);
|
|
1114
|
+
const type = computedStyle.containerType || computedStyle.getPropertyValue("container-type") || container.style.containerType || container.style.getPropertyValue("container-type");
|
|
1115
|
+
const name = computedStyle.containerName || computedStyle.getPropertyValue("container-name") || container.style.containerName || container.style.getPropertyValue("container-name");
|
|
1116
|
+
const writingMode2 = computedStyle.writingMode || computedStyle.getPropertyValue("writing-mode") || container.style.writingMode || container.style.getPropertyValue("writing-mode");
|
|
1117
|
+
if ((typeof containerName !== "string" || !containerName || name.split(/\s+/).includes(containerName)) && type && type !== "normal" && !(queriesPhysicalWidth && /^(?:vertical|sideways)-/i.test(writingMode2) && type === "inline-size")) {
|
|
1118
|
+
break;
|
|
1119
|
+
}
|
|
1120
|
+
container = getParentElement(container);
|
|
1121
|
+
}
|
|
1122
|
+
if (!container)
|
|
1123
|
+
return false;
|
|
1124
|
+
const computedContainerStyle = getComputedStyle(container);
|
|
1125
|
+
const readInset = (property, fallbackProperty) => {
|
|
1126
|
+
const camel = property.replace(/-([a-z])/g, (_, character) => character.toUpperCase());
|
|
1127
|
+
const fallbackCamel = fallbackProperty.replace(/-([a-z])/g, (_, character) => character.toUpperCase());
|
|
1128
|
+
const value = Reflect.get(computedContainerStyle, camel) || Reflect.get(container.style, camel) || computedContainerStyle.getPropertyValue(property).trim() || container.style.getPropertyValue(property).trim() || Reflect.get(computedContainerStyle, fallbackCamel) || Reflect.get(container.style, fallbackCamel) || computedContainerStyle.getPropertyValue(fallbackProperty).trim() || container.style.getPropertyValue(fallbackProperty).trim();
|
|
1129
|
+
const parsed = Number.parseFloat(value);
|
|
1130
|
+
return Number.isFinite(parsed) && parsed > 0 ? parsed : 0;
|
|
1131
|
+
};
|
|
1132
|
+
const writingMode = computedContainerStyle.writingMode || computedContainerStyle.getPropertyValue("writing-mode") || container.style.writingMode || container.style.getPropertyValue("writing-mode");
|
|
1133
|
+
const usesInlineSize = /(?:inline-size|min-inline-size|max-inline-size)/i.test(queryText);
|
|
1134
|
+
const isVerticalWritingMode = /^(?:vertical|sideways)-/i.test(writingMode);
|
|
1135
|
+
const verticalInlineAxis = usesInlineSize && isVerticalWritingMode;
|
|
1136
|
+
const physicalInsets = readInset("padding-left", "padding-inline-start") + readInset("padding-right", "padding-inline-end");
|
|
1137
|
+
const physicalBorders = readInset("border-left-width", "border-inline-start-width") + readInset("border-right-width", "border-inline-end-width");
|
|
1138
|
+
const inlineInsets = verticalInlineAxis ? readInset("padding-inline-start", "padding-top") + readInset("padding-inline-end", "padding-bottom") : physicalInsets;
|
|
1139
|
+
const inlineBorders = verticalInlineAxis ? readInset("border-inline-start-width", "border-top-width") + readInset("border-inline-end-width", "border-bottom-width") : physicalBorders;
|
|
1140
|
+
const readUsedContentSize = (axis, fallback, insets, borders) => {
|
|
1141
|
+
const parsed = Number.parseFloat(computedContainerStyle[axis]);
|
|
1142
|
+
if (!Number.isFinite(parsed))
|
|
1143
|
+
return fallback;
|
|
1144
|
+
const boxSizing = computedContainerStyle.boxSizing || container.style.boxSizing;
|
|
1145
|
+
return boxSizing === "border-box" ? Math.max(0, parsed - insets - borders) : parsed;
|
|
1146
|
+
};
|
|
1147
|
+
const physicalClientSize = container.clientWidth;
|
|
1148
|
+
const inlineClientSize = verticalInlineAxis ? container.clientHeight : physicalClientSize;
|
|
1149
|
+
const width = Math.max(0, readUsedContentSize("width", physicalClientSize > 0 ? physicalClientSize - physicalInsets : container.offsetWidth - physicalBorders - physicalInsets, physicalInsets, physicalBorders));
|
|
1150
|
+
const inlineSize = Math.max(0, readUsedContentSize(verticalInlineAxis ? "height" : "width", inlineClientSize > 0 ? inlineClientSize - inlineInsets : (verticalInlineAxis ? container.offsetHeight : container.offsetWidth) - inlineBorders - inlineInsets, inlineInsets, inlineBorders));
|
|
1151
|
+
const rootFontSize = Number.parseFloat(getComputedStyle(element.ownerDocument.documentElement).fontSize);
|
|
1152
|
+
const remSize = Number.isFinite(rootFontSize) && rootFontSize > 0 ? rootFontSize : 16;
|
|
1153
|
+
if (hasUnsupportedContainerSizeQuery(queryText))
|
|
1154
|
+
return false;
|
|
1155
|
+
return evaluateLogicalContainerCondition(queryText, width, remSize, inlineSize);
|
|
1156
|
+
}
|
|
1157
|
+
function isContainerRule(rule) {
|
|
1158
|
+
if (rule.constructor.name === "CSSContainerRule")
|
|
1159
|
+
return true;
|
|
1160
|
+
if (Reflect.get(rule, "type") !== 0)
|
|
1161
|
+
return false;
|
|
1162
|
+
const cssText = Reflect.get(rule, "cssText");
|
|
1163
|
+
return typeof cssText === "string" && /^\s*@container\b/i.test(cssText);
|
|
1164
|
+
}
|
|
1165
|
+
function isMediaRule(rule) {
|
|
1166
|
+
return typeof Reflect.get(rule, "media") === "object" && Reflect.get(rule, "media") !== null;
|
|
1167
|
+
}
|
|
1168
|
+
function isSupportsRule(rule) {
|
|
1169
|
+
return rule.constructor.name === "CSSSupportsRule" || Reflect.get(rule, "type") === 12;
|
|
1170
|
+
}
|
|
1171
|
+
function observeTextDirectionMediaQueries(element, onChange) {
|
|
1172
|
+
if (!element || typeof matchMedia !== "function")
|
|
1173
|
+
return;
|
|
1174
|
+
const sheets = new Set(Array.from(element.ownerDocument.styleSheets));
|
|
1175
|
+
for (const sheet of element.ownerDocument.adoptedStyleSheets ?? [])
|
|
1176
|
+
sheets.add(sheet);
|
|
1177
|
+
const root = element.getRootNode();
|
|
1178
|
+
if (typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot) {
|
|
1179
|
+
for (const sheet of root.adoptedStyleSheets)
|
|
1180
|
+
sheets.add(sheet);
|
|
1181
|
+
for (const style of root.querySelectorAll('style,link[rel~="stylesheet"]')) {
|
|
1182
|
+
const sheet = style.sheet;
|
|
1183
|
+
if (sheet)
|
|
1184
|
+
sheets.add(sheet);
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
const queries = new Set;
|
|
1188
|
+
const visitedSheets = new Set;
|
|
1189
|
+
const visit = (rules) => {
|
|
1190
|
+
for (const rule of Array.from(rules)) {
|
|
1191
|
+
if (Reflect.get(rule, "type") === 3) {
|
|
1192
|
+
try {
|
|
1193
|
+
const media = Reflect.get(rule, "media");
|
|
1194
|
+
const condition = media && Reflect.get(media, "mediaText");
|
|
1195
|
+
if (typeof condition === "string" && condition)
|
|
1196
|
+
queries.add(condition);
|
|
1197
|
+
} catch {}
|
|
1198
|
+
let imported;
|
|
1199
|
+
try {
|
|
1200
|
+
imported = Reflect.get(rule, "styleSheet");
|
|
1201
|
+
} catch {
|
|
1202
|
+
continue;
|
|
1203
|
+
}
|
|
1204
|
+
if (imported && !visitedSheets.has(imported)) {
|
|
1205
|
+
visitedSheets.add(imported);
|
|
1206
|
+
try {
|
|
1207
|
+
const importedRules = Reflect.get(imported, "cssRules");
|
|
1208
|
+
if (isCssRuleCollection(importedRules))
|
|
1209
|
+
visit(importedRules);
|
|
1210
|
+
} catch {}
|
|
1211
|
+
}
|
|
1212
|
+
continue;
|
|
1213
|
+
}
|
|
1214
|
+
if (isMediaRule(rule)) {
|
|
1215
|
+
const condition = Reflect.get(rule, "conditionText");
|
|
1216
|
+
if (typeof condition === "string" && condition)
|
|
1217
|
+
queries.add(condition);
|
|
1218
|
+
}
|
|
1219
|
+
const nested = readNestedCssRules(rule);
|
|
1220
|
+
if (nested)
|
|
1221
|
+
visit(nested);
|
|
1222
|
+
}
|
|
1223
|
+
};
|
|
1224
|
+
for (const sheet of sheets) {
|
|
1225
|
+
if (visitedSheets.has(sheet))
|
|
1226
|
+
continue;
|
|
1227
|
+
visitedSheets.add(sheet);
|
|
1228
|
+
try {
|
|
1229
|
+
visit(sheet.cssRules);
|
|
1230
|
+
} catch {}
|
|
1231
|
+
}
|
|
1232
|
+
const mediaQueries = [...queries].map((query) => matchMedia(query));
|
|
1233
|
+
const handler = () => onChange();
|
|
1234
|
+
for (const mediaQuery of mediaQueries)
|
|
1235
|
+
mediaQuery.addEventListener?.("change", handler);
|
|
1236
|
+
return () => {
|
|
1237
|
+
for (const mediaQuery of mediaQueries)
|
|
1238
|
+
mediaQuery.removeEventListener?.("change", handler);
|
|
1239
|
+
};
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
// src/_internal/text-direction.ts
|
|
1243
|
+
function elementDirectionStyleOverride(element) {
|
|
1244
|
+
if (!element)
|
|
1245
|
+
return;
|
|
1246
|
+
if (element.style.direction)
|
|
1247
|
+
return readComputedTextDirection(element);
|
|
1248
|
+
if (!matchesDirectionStyleRuleCached(element, undefined, composedParentElement))
|
|
1249
|
+
return;
|
|
1250
|
+
return readComputedTextDirection(element);
|
|
1251
|
+
}
|
|
1252
|
+
function resolveTextDirection(element, fallback, options) {
|
|
1253
|
+
const ignoreElementDirectionAttribute = options?.ignoreElementDirectionAttribute ?? false;
|
|
1254
|
+
const directionStyleRuleCache = new WeakMap;
|
|
1255
|
+
if (ignoreElementDirectionAttribute && element) {
|
|
1256
|
+
const styledDirection = readComputedTextDirection(element);
|
|
1257
|
+
const rootComputedDirection2 = readComputedTextDirection(element.ownerDocument.documentElement);
|
|
1258
|
+
const elementDirectionAttribute = element.getAttribute("dir")?.toLowerCase();
|
|
1259
|
+
const differsFromRootViaStyling = styledDirection !== rootComputedDirection2 && styledDirection !== elementDirectionAttribute;
|
|
1260
|
+
if (styledDirection && (hasElementDirectionStylingHint(element, directionStyleRuleCache) || differsFromRootViaStyling))
|
|
1261
|
+
return styledDirection;
|
|
1262
|
+
}
|
|
1263
|
+
let currentElement = ignoreElementDirectionAttribute ? element ? composedParentElement(element) : null : element ?? null;
|
|
1264
|
+
let documentDirection;
|
|
1265
|
+
let styledDirectionElement = null;
|
|
1266
|
+
while (currentElement) {
|
|
1267
|
+
if (!styledDirectionElement && currentElement !== currentElement.ownerDocument.documentElement && (Boolean(currentElement.style.direction) || matchesDirectionStyleRuleCached(currentElement, directionStyleRuleCache, composedParentElement))) {
|
|
1268
|
+
styledDirectionElement = currentElement;
|
|
1269
|
+
}
|
|
1270
|
+
const direction = currentElement.getAttribute("dir")?.toLowerCase();
|
|
1271
|
+
if (direction === "rtl" || direction === "ltr") {
|
|
1272
|
+
if (typeof getComputedStyle === "function" && styledDirectionElement) {
|
|
1273
|
+
const styledDirection2 = getComputedStyle(styledDirectionElement).direction;
|
|
1274
|
+
if (styledDirection2 === "rtl" || styledDirection2 === "ltr")
|
|
1275
|
+
return styledDirection2;
|
|
1276
|
+
}
|
|
1277
|
+
if (currentElement === currentElement.ownerDocument.documentElement) {
|
|
1278
|
+
documentDirection = direction;
|
|
1279
|
+
break;
|
|
1280
|
+
}
|
|
1281
|
+
return direction;
|
|
1282
|
+
}
|
|
1283
|
+
if (direction === "auto" && typeof getComputedStyle === "function") {
|
|
1284
|
+
const computedDirection2 = getComputedStyle(currentElement).direction;
|
|
1285
|
+
if (computedDirection2 === "rtl" || computedDirection2 === "ltr")
|
|
1286
|
+
return computedDirection2;
|
|
1287
|
+
}
|
|
1288
|
+
const styledDirection = currentElement.style.direction;
|
|
1289
|
+
if (!styledDirectionElement && (styledDirection === "rtl" || styledDirection === "ltr")) {
|
|
1290
|
+
styledDirectionElement = currentElement;
|
|
1291
|
+
}
|
|
1292
|
+
currentElement = composedParentElement(currentElement);
|
|
1293
|
+
}
|
|
1294
|
+
if (typeof getComputedStyle === "function" && styledDirectionElement) {
|
|
1295
|
+
const direction = getComputedStyle(styledDirectionElement).direction;
|
|
1296
|
+
if (direction === "rtl" || direction === "ltr")
|
|
1297
|
+
return direction;
|
|
1298
|
+
}
|
|
1299
|
+
const computedDirection = readComputedTextDirection(element);
|
|
1300
|
+
const rootComputedDirection = readComputedTextDirection(element?.ownerDocument.documentElement);
|
|
1301
|
+
if (!ignoreElementDirectionAttribute && computedDirection && computedDirection !== rootComputedDirection)
|
|
1302
|
+
return computedDirection;
|
|
1303
|
+
if (computedDirection && fallback && computedDirection !== fallback && hasDirectionStylingHint(element, false, directionStyleRuleCache)) {
|
|
1304
|
+
return computedDirection;
|
|
1305
|
+
}
|
|
1306
|
+
if (!fallback && computedDirection === "rtl")
|
|
1307
|
+
return computedDirection;
|
|
1308
|
+
if (fallback)
|
|
1309
|
+
return fallback;
|
|
1310
|
+
if (documentDirection)
|
|
1311
|
+
return documentDirection;
|
|
1312
|
+
return;
|
|
1313
|
+
}
|
|
1314
|
+
function hasElementDirectionStylingHint(element, cache) {
|
|
1315
|
+
return Boolean(element.style.direction) || matchesDirectionStyleRuleCached(element, cache, composedParentElement);
|
|
1316
|
+
}
|
|
1317
|
+
function readComputedTextDirection(element) {
|
|
1318
|
+
if (!element || typeof getComputedStyle !== "function")
|
|
1319
|
+
return;
|
|
1320
|
+
const direction = getComputedStyle(element).direction;
|
|
1321
|
+
return direction === "rtl" || direction === "ltr" ? direction : undefined;
|
|
1322
|
+
}
|
|
1323
|
+
function hasDirectionStylingHint(element, includeElement = false, cache) {
|
|
1324
|
+
let currentElement = includeElement ? element : element ? composedParentElement(element) : null;
|
|
1325
|
+
while (currentElement && currentElement !== currentElement.ownerDocument.documentElement) {
|
|
1326
|
+
if (currentElement.style.direction)
|
|
1327
|
+
return true;
|
|
1328
|
+
if (matchesDirectionStyleRuleCached(currentElement, cache, composedParentElement))
|
|
1329
|
+
return true;
|
|
1330
|
+
currentElement = composedParentElement(currentElement);
|
|
1331
|
+
}
|
|
1332
|
+
return false;
|
|
1333
|
+
}
|
|
1334
|
+
function composedParentElement(element) {
|
|
1335
|
+
if (element.parentElement)
|
|
1336
|
+
return element.parentElement;
|
|
1337
|
+
const root = element.getRootNode();
|
|
1338
|
+
return typeof ShadowRoot !== "undefined" && typeof HTMLElement !== "undefined" && root instanceof ShadowRoot && root.host instanceof HTMLElement ? root.host : null;
|
|
1339
|
+
}
|
|
1340
|
+
function isRightToLeftElement(element) {
|
|
1341
|
+
return resolveTextDirection(element) === "rtl";
|
|
1342
|
+
}
|
|
1343
|
+
function observeTextDirection(element, onChange) {
|
|
1344
|
+
if (!element || typeof MutationObserver === "undefined")
|
|
1345
|
+
return;
|
|
1346
|
+
const observedElement = element;
|
|
1347
|
+
const observer = new MutationObserver((mutations) => {
|
|
1348
|
+
if (mutations.some((mutation) => mutation.type === "attributes" && mutation.attributeName === "dir" || mutation.type === "childList")) {
|
|
1349
|
+
observeDirectionChain();
|
|
1350
|
+
}
|
|
1351
|
+
onChange();
|
|
1352
|
+
});
|
|
1353
|
+
function observeDirectionChain() {
|
|
1354
|
+
observer.disconnect();
|
|
1355
|
+
let currentElement = observedElement;
|
|
1356
|
+
while (currentElement) {
|
|
1357
|
+
const isAutoDirection = currentElement.getAttribute("dir")?.toLowerCase() === "auto";
|
|
1358
|
+
observer.observe(currentElement, {
|
|
1359
|
+
attributes: true,
|
|
1360
|
+
childList: true,
|
|
1361
|
+
characterData: isAutoDirection,
|
|
1362
|
+
subtree: isAutoDirection
|
|
1363
|
+
});
|
|
1364
|
+
currentElement = composedParentElement(currentElement);
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
observeDirectionChain();
|
|
1368
|
+
return () => observer.disconnect();
|
|
1369
|
+
}
|
|
1370
|
+
|
|
63
1371
|
// src/utilities/class-names.ts
|
|
64
1372
|
function classNames(...parts) {
|
|
65
1373
|
return parts.filter((part) => typeof part === "string" && part.length > 0).join(" ");
|
|
66
1374
|
}
|
|
67
1375
|
|
|
68
|
-
//
|
|
1376
|
+
// ../../node_modules/esm-env/true.js
|
|
1377
|
+
var true_default = true;
|
|
1378
|
+
// src/utilities/dev-warn.ts
|
|
1379
|
+
function devWarn(message, ...args) {
|
|
1380
|
+
if (!true_default)
|
|
1381
|
+
return;
|
|
1382
|
+
console.warn(message, ...args);
|
|
1383
|
+
}
|
|
1384
|
+
|
|
1385
|
+
// src/utilities/use-drag-scroll.svelte.ts
|
|
69
1386
|
import * as $ from "svelte/internal/client";
|
|
1387
|
+
|
|
1388
|
+
// src/utilities/drag-scroll-physics.ts
|
|
1389
|
+
var DRAG_FRICTION = 0.95;
|
|
1390
|
+
var DRAG_DAMPING = 20;
|
|
1391
|
+
var DRAG_SETTLE_VELOCITY_EPSILON = 0.01;
|
|
1392
|
+
function damp(current, target, dampingConstant, deltaTimeMs) {
|
|
1393
|
+
if (dampingConstant <= 0 || deltaTimeMs <= 0)
|
|
1394
|
+
return current;
|
|
1395
|
+
const t = 1 - Math.exp(-dampingConstant * (deltaTimeMs / 1000));
|
|
1396
|
+
return current + (target - current) * t;
|
|
1397
|
+
}
|
|
1398
|
+
function project(current, velocity, friction) {
|
|
1399
|
+
if (friction <= 0 || friction >= 1)
|
|
1400
|
+
return current;
|
|
1401
|
+
return current + velocity * friction / (1 - friction);
|
|
1402
|
+
}
|
|
1403
|
+
function dragSnap(distance, friction) {
|
|
1404
|
+
if (friction <= 0 || friction >= 1)
|
|
1405
|
+
return 0;
|
|
1406
|
+
return distance * (1 - friction) / friction;
|
|
1407
|
+
}
|
|
1408
|
+
function snapSelect(position, snapPositions) {
|
|
1409
|
+
return snapPositions.reduce((nearest, candidate) => {
|
|
1410
|
+
if (nearest === null)
|
|
1411
|
+
return candidate;
|
|
1412
|
+
return Math.abs(candidate - position) < Math.abs(nearest - position) ? candidate : nearest;
|
|
1413
|
+
}, null);
|
|
1414
|
+
}
|
|
1415
|
+
function shouldSnap(distance, snapportSize, mode = "mandatory") {
|
|
1416
|
+
if (mode === "mandatory")
|
|
1417
|
+
return true;
|
|
1418
|
+
if (snapportSize <= 0)
|
|
1419
|
+
return false;
|
|
1420
|
+
return Math.abs(distance) <= snapportSize / 3;
|
|
1421
|
+
}
|
|
1422
|
+
|
|
1423
|
+
// src/utilities/use-drag-scroll.svelte.ts
|
|
1424
|
+
var DRAG_THRESHOLD_PX = 10;
|
|
1425
|
+
function useDragScroll(options = {}) {
|
|
1426
|
+
const {
|
|
1427
|
+
enabled = () => true,
|
|
1428
|
+
snapMode = "mandatory",
|
|
1429
|
+
axis = "x",
|
|
1430
|
+
onSettle,
|
|
1431
|
+
getSnapPositions
|
|
1432
|
+
} = options;
|
|
1433
|
+
const scrollProperty = axis === "x" ? "scrollLeft" : "scrollTop";
|
|
1434
|
+
const clientSizeProperty = axis === "x" ? "clientWidth" : "clientHeight";
|
|
1435
|
+
const clientAxisProperty = axis === "x" ? "clientX" : "clientY";
|
|
1436
|
+
const movementAxisProperty = axis === "x" ? "movementX" : "movementY";
|
|
1437
|
+
return (node) => {
|
|
1438
|
+
let pointerId = null;
|
|
1439
|
+
let startClientPosition = 0;
|
|
1440
|
+
let target = 0;
|
|
1441
|
+
let virtualScroll = 0;
|
|
1442
|
+
let velocity = 0;
|
|
1443
|
+
let dragged = false;
|
|
1444
|
+
let rafId = null;
|
|
1445
|
+
let lastFrameTime = 0;
|
|
1446
|
+
let originalSnapType = "";
|
|
1447
|
+
let dragSuppressTimer = null;
|
|
1448
|
+
function tick(now) {
|
|
1449
|
+
const frameDeltaMs = lastFrameTime === 0 ? 16 : now - lastFrameTime;
|
|
1450
|
+
lastFrameTime = now;
|
|
1451
|
+
if (pointerId === null) {
|
|
1452
|
+
velocity *= DRAG_FRICTION;
|
|
1453
|
+
target += velocity;
|
|
1454
|
+
}
|
|
1455
|
+
virtualScroll = damp(virtualScroll, target, DRAG_DAMPING, frameDeltaMs);
|
|
1456
|
+
node[scrollProperty] = virtualScroll;
|
|
1457
|
+
const settled = pointerId === null && Math.abs(velocity) < DRAG_SETTLE_VELOCITY_EPSILON;
|
|
1458
|
+
if (settled) {
|
|
1459
|
+
rafId = null;
|
|
1460
|
+
lastFrameTime = 0;
|
|
1461
|
+
node.removeAttribute("data-cinder-dragging");
|
|
1462
|
+
restoreSnapType();
|
|
1463
|
+
onSettle?.();
|
|
1464
|
+
return;
|
|
1465
|
+
}
|
|
1466
|
+
rafId = requestAnimationFrame(tick);
|
|
1467
|
+
}
|
|
1468
|
+
function startTicker() {
|
|
1469
|
+
if (rafId !== null)
|
|
1470
|
+
return;
|
|
1471
|
+
lastFrameTime = 0;
|
|
1472
|
+
rafId = requestAnimationFrame(tick);
|
|
1473
|
+
}
|
|
1474
|
+
function stopTicker() {
|
|
1475
|
+
if (rafId !== null)
|
|
1476
|
+
cancelAnimationFrame(rafId);
|
|
1477
|
+
rafId = null;
|
|
1478
|
+
lastFrameTime = 0;
|
|
1479
|
+
}
|
|
1480
|
+
function suppressSnapType() {
|
|
1481
|
+
originalSnapType = node.style.scrollSnapType;
|
|
1482
|
+
node.style.scrollSnapType = "none";
|
|
1483
|
+
}
|
|
1484
|
+
function restoreSnapType() {
|
|
1485
|
+
node.style.scrollSnapType = originalSnapType;
|
|
1486
|
+
}
|
|
1487
|
+
function suppressNextClick() {
|
|
1488
|
+
node.setAttribute("data-cinder-dragged", "");
|
|
1489
|
+
if (dragSuppressTimer !== null)
|
|
1490
|
+
clearTimeout(dragSuppressTimer);
|
|
1491
|
+
dragSuppressTimer = setTimeout(() => {
|
|
1492
|
+
dragSuppressTimer = null;
|
|
1493
|
+
node.removeAttribute("data-cinder-dragged");
|
|
1494
|
+
}, 0);
|
|
1495
|
+
}
|
|
1496
|
+
function onClickCapture(event) {
|
|
1497
|
+
if (node.hasAttribute("data-cinder-dragged")) {
|
|
1498
|
+
event.preventDefault();
|
|
1499
|
+
event.stopPropagation();
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
function onPointerMove(event) {
|
|
1503
|
+
if (event.pointerId !== pointerId)
|
|
1504
|
+
return;
|
|
1505
|
+
const clientPosition = event[clientAxisProperty];
|
|
1506
|
+
const dragDistance = clientPosition - startClientPosition;
|
|
1507
|
+
if (!dragged && Math.abs(dragDistance) > DRAG_THRESHOLD_PX) {
|
|
1508
|
+
dragged = true;
|
|
1509
|
+
node.setAttribute("data-cinder-dragging", "");
|
|
1510
|
+
}
|
|
1511
|
+
if (!dragged)
|
|
1512
|
+
return;
|
|
1513
|
+
const scrollDelta = -event[movementAxisProperty];
|
|
1514
|
+
target += scrollDelta;
|
|
1515
|
+
velocity += scrollDelta;
|
|
1516
|
+
}
|
|
1517
|
+
function onPointerUp(event) {
|
|
1518
|
+
if (event.pointerId !== pointerId)
|
|
1519
|
+
return;
|
|
1520
|
+
window.removeEventListener("pointermove", onPointerMove);
|
|
1521
|
+
window.removeEventListener("pointerup", onPointerUp);
|
|
1522
|
+
window.removeEventListener("pointercancel", onPointerUp);
|
|
1523
|
+
if ("releasePointerCapture" in node && node.hasPointerCapture(event.pointerId)) {
|
|
1524
|
+
node.releasePointerCapture(event.pointerId);
|
|
1525
|
+
}
|
|
1526
|
+
pointerId = null;
|
|
1527
|
+
if (!dragged) {
|
|
1528
|
+
stopTicker();
|
|
1529
|
+
node.removeAttribute("data-cinder-dragging");
|
|
1530
|
+
restoreSnapType();
|
|
1531
|
+
return;
|
|
1532
|
+
}
|
|
1533
|
+
suppressNextClick();
|
|
1534
|
+
const snapPositions = getSnapPositions?.();
|
|
1535
|
+
if (snapPositions && snapPositions.length > 0) {
|
|
1536
|
+
const projected = project(target, velocity, DRAG_FRICTION);
|
|
1537
|
+
const snapTarget = snapSelect(projected, snapPositions);
|
|
1538
|
+
if (snapTarget !== null && shouldSnap(snapTarget - projected, node[clientSizeProperty], snapMode)) {
|
|
1539
|
+
velocity = dragSnap(snapTarget - target, DRAG_FRICTION);
|
|
1540
|
+
}
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
function onPointerDown(event) {
|
|
1544
|
+
if (event.pointerType !== "mouse")
|
|
1545
|
+
return;
|
|
1546
|
+
if (!enabled())
|
|
1547
|
+
return;
|
|
1548
|
+
pointerId = event.pointerId;
|
|
1549
|
+
startClientPosition = event[clientAxisProperty];
|
|
1550
|
+
const startScroll = node[scrollProperty];
|
|
1551
|
+
target = startScroll;
|
|
1552
|
+
virtualScroll = startScroll;
|
|
1553
|
+
velocity = 0;
|
|
1554
|
+
dragged = false;
|
|
1555
|
+
suppressSnapType();
|
|
1556
|
+
if ("setPointerCapture" in node)
|
|
1557
|
+
node.setPointerCapture(event.pointerId);
|
|
1558
|
+
window.addEventListener("pointermove", onPointerMove);
|
|
1559
|
+
window.addEventListener("pointerup", onPointerUp);
|
|
1560
|
+
window.addEventListener("pointercancel", onPointerUp);
|
|
1561
|
+
startTicker();
|
|
1562
|
+
}
|
|
1563
|
+
node.addEventListener("pointerdown", onPointerDown);
|
|
1564
|
+
node.addEventListener("click", onClickCapture, { capture: true });
|
|
1565
|
+
return () => {
|
|
1566
|
+
node.removeEventListener("pointerdown", onPointerDown);
|
|
1567
|
+
node.removeEventListener("click", onClickCapture, { capture: true });
|
|
1568
|
+
window.removeEventListener("pointermove", onPointerMove);
|
|
1569
|
+
window.removeEventListener("pointerup", onPointerUp);
|
|
1570
|
+
window.removeEventListener("pointercancel", onPointerUp);
|
|
1571
|
+
stopTicker();
|
|
1572
|
+
if (dragSuppressTimer !== null)
|
|
1573
|
+
clearTimeout(dragSuppressTimer);
|
|
1574
|
+
};
|
|
1575
|
+
};
|
|
1576
|
+
}
|
|
1577
|
+
|
|
1578
|
+
// src/utilities/use-fine-pointer.svelte.ts
|
|
1579
|
+
import * as $2 from "svelte/internal/client";
|
|
70
1580
|
import { MediaQuery } from "svelte/reactivity";
|
|
1581
|
+
function useFinePointer() {
|
|
1582
|
+
if (typeof window === "undefined" || typeof window.matchMedia !== "function") {
|
|
1583
|
+
return { current: false };
|
|
1584
|
+
}
|
|
1585
|
+
const query = new MediaQuery("(hover: hover) and (pointer: fine)", false);
|
|
1586
|
+
return {
|
|
1587
|
+
get current() {
|
|
1588
|
+
return query.current;
|
|
1589
|
+
}
|
|
1590
|
+
};
|
|
1591
|
+
}
|
|
1592
|
+
|
|
1593
|
+
// src/utilities/use-reduced-motion.svelte.ts
|
|
1594
|
+
import * as $3 from "svelte/internal/client";
|
|
1595
|
+
import { MediaQuery as MediaQuery2 } from "svelte/reactivity";
|
|
71
1596
|
function useReducedMotion() {
|
|
72
1597
|
if (typeof window === "undefined" || typeof window.matchMedia !== "function") {
|
|
73
1598
|
return { current: false };
|
|
74
1599
|
}
|
|
75
|
-
const query = new
|
|
1600
|
+
const query = new MediaQuery2("(prefers-reduced-motion: reduce)", false);
|
|
76
1601
|
return {
|
|
77
1602
|
get current() {
|
|
78
1603
|
return query.current;
|
|
@@ -81,7 +1606,7 @@ function useReducedMotion() {
|
|
|
81
1606
|
}
|
|
82
1607
|
|
|
83
1608
|
// src/utilities/use-resize-observer.svelte.ts
|
|
84
|
-
import * as $
|
|
1609
|
+
import * as $4 from "svelte/internal/client";
|
|
85
1610
|
function useResizeObserver(onResize, options = {}) {
|
|
86
1611
|
const { box, enabled = () => true } = options;
|
|
87
1612
|
return (node) => {
|
|
@@ -90,7 +1615,7 @@ function useResizeObserver(onResize, options = {}) {
|
|
|
90
1615
|
observer?.disconnect();
|
|
91
1616
|
observer = null;
|
|
92
1617
|
};
|
|
93
|
-
$
|
|
1618
|
+
$4.user_effect(() => {
|
|
94
1619
|
if (!enabled()) {
|
|
95
1620
|
disconnectObserver();
|
|
96
1621
|
return;
|
|
@@ -126,184 +1651,250 @@ var rest_excludes = new Set([
|
|
|
126
1651
|
"activeIndex",
|
|
127
1652
|
"autoplay",
|
|
128
1653
|
"autoplayInterval",
|
|
1654
|
+
"loop",
|
|
129
1655
|
"label",
|
|
130
1656
|
"description",
|
|
131
1657
|
"controlLabels",
|
|
132
|
-
"
|
|
1658
|
+
"indicators",
|
|
1659
|
+
"indicatorLimit",
|
|
1660
|
+
"slidesPerView",
|
|
1661
|
+
"gap",
|
|
1662
|
+
"align",
|
|
1663
|
+
"onSlideChange",
|
|
1664
|
+
"slide",
|
|
1665
|
+
"class",
|
|
1666
|
+
"onkeydown",
|
|
1667
|
+
"onmouseenter",
|
|
1668
|
+
"onmouseleave",
|
|
1669
|
+
"onfocusin",
|
|
1670
|
+
"onfocusout"
|
|
133
1671
|
]);
|
|
134
|
-
var root_1 = $
|
|
135
|
-
var root_2 = $
|
|
136
|
-
var root_3 = $
|
|
137
|
-
var root_4 = $
|
|
138
|
-
var root_5 = $
|
|
139
|
-
var root_6 = $
|
|
140
|
-
var root_7 = $
|
|
141
|
-
var root_8 = $
|
|
142
|
-
var root_9 = $
|
|
143
|
-
var root_10 = $
|
|
1672
|
+
var root_1 = $5.from_html(`<p class="cinder-carousel__sr-only"> </p>`);
|
|
1673
|
+
var root_2 = $5.from_html(`<img class="cinder-carousel__image"/>`);
|
|
1674
|
+
var root_3 = $5.from_html(`<h3 class="cinder-carousel__title"> </h3>`);
|
|
1675
|
+
var root_4 = $5.from_html(`<p class="cinder-carousel__description"> </p>`);
|
|
1676
|
+
var root_5 = $5.from_html(`<a class="cinder-carousel__link"><!> <!> <!> <!></a>`);
|
|
1677
|
+
var root_6 = $5.from_html(`<!> <!> <!> <!>`, 1);
|
|
1678
|
+
var root_7 = $5.from_html(`<article class="cinder-carousel__slide" role="group" aria-roledescription="slide"><!></article>`);
|
|
1679
|
+
var root_8 = $5.from_html(`<button type="button" class="cinder-carousel__control cinder-carousel__control--pause"> </button>`);
|
|
1680
|
+
var root_9 = $5.from_html(`<button type="button" class="cinder-carousel__dot"></button>`);
|
|
1681
|
+
var root_10 = $5.from_html(`<div class="cinder-carousel__dots" role="group"></div>`);
|
|
1682
|
+
var root_11 = $5.from_html(`<div class="cinder-carousel__counter" aria-hidden="true"> </div>`);
|
|
1683
|
+
var root_12 = $5.from_html(`<section><!> <p class="cinder-carousel__sr-only" aria-atomic="true"> </p> <div class="cinder-carousel__viewport" role="group" tabindex="0"><!></div> <div class="cinder-carousel__controls" role="group"><div class="cinder-carousel__nav" role="group"><button type="button" class="cinder-carousel__control"> </button> <button type="button" class="cinder-carousel__control"> </button></div> <!> <!></div></section>`);
|
|
144
1684
|
function Carousel($$anchor, $$props) {
|
|
145
|
-
const descriptionId = $
|
|
146
|
-
$
|
|
1685
|
+
const descriptionId = $5.props_id();
|
|
1686
|
+
$5.push($$props, true);
|
|
147
1687
|
const reducedMotion = useReducedMotion();
|
|
148
|
-
|
|
149
|
-
let
|
|
150
|
-
let
|
|
151
|
-
let
|
|
152
|
-
let
|
|
153
|
-
let
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
1688
|
+
const finePointer = useFinePointer();
|
|
1689
|
+
let activeIndex = $5.prop($$props, "activeIndex", 15, 0), autoplay = $5.prop($$props, "autoplay", 3, false), autoplayInterval = $5.prop($$props, "autoplayInterval", 3, 5000), loop = $5.prop($$props, "loop", 3, false), label = $5.prop($$props, "label", 3, "Carousel"), indicatorLimit = $5.prop($$props, "indicatorLimit", 3, 8), slidesPerView = $5.prop($$props, "slidesPerView", 3, 1), align = $5.prop($$props, "align", 3, "start"), rest = $5.rest_props($$props, rest_excludes);
|
|
1690
|
+
let isHovered = $5.state(false);
|
|
1691
|
+
let hasFocusWithin = $5.state(false);
|
|
1692
|
+
let userPaused = $5.state(false);
|
|
1693
|
+
let motion = $5.state($5.proxy({ kind: "idle" }));
|
|
1694
|
+
function setMotion(next) {
|
|
1695
|
+
const unchanged = $5.get(motion).kind === next.kind && ($5.get(motion).kind !== "programmatic" || next.kind === "programmatic" && $5.get(motion).target === next.target && $5.get(motion).source === next.source) && ($5.get(motion).kind !== "user" || next.kind === "user" && $5.get(motion).source === next.source);
|
|
1696
|
+
if (!unchanged)
|
|
1697
|
+
$5.set(motion, next, true);
|
|
1698
|
+
}
|
|
1699
|
+
let settledIndex = $5.state($5.proxy(untrack(() => $$props.slides.length < 1 ? 0 : Math.max(0, Math.min($$props.slides.length - 1, activeIndex())))));
|
|
1700
|
+
let visualIndex = $5.state($5.proxy(untrack(() => $5.get(settledIndex))));
|
|
1701
|
+
let viewportElement = $5.state(null);
|
|
158
1702
|
const activePointerIds = new SvelteSet;
|
|
159
1703
|
let nativeScrollEndTimer = null;
|
|
160
1704
|
let scrollFrame = null;
|
|
161
1705
|
let cachedViewportInlineSize = 0;
|
|
162
|
-
const clampedLength = $
|
|
1706
|
+
const clampedLength = $5.derived(() => $$props.slides.length);
|
|
163
1707
|
const initialSlideId = untrack(() => $$props.slides[Math.max(0, Math.min($$props.slides.length - 1, activeIndex()))]?.id ?? $$props.slides[0]?.id);
|
|
164
|
-
const initialSlideIndex = $
|
|
165
|
-
const currentIndex = $
|
|
166
|
-
if ($
|
|
1708
|
+
const initialSlideIndex = $5.derived(() => $$props.slides.length < 1 ? 0 : Math.max(0, $$props.slides.findIndex((slide) => slide.id === initialSlideId)));
|
|
1709
|
+
const currentIndex = $5.derived(() => {
|
|
1710
|
+
if ($5.get(clampedLength) < 1)
|
|
167
1711
|
return 0;
|
|
168
|
-
return Math.max(0, Math.min($
|
|
1712
|
+
return Math.max(0, Math.min($5.get(clampedLength) - 1, activeIndex()));
|
|
169
1713
|
});
|
|
170
|
-
let
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
if ($3.get(clampedLength) < 1) {
|
|
1714
|
+
let observedActiveIndex = $5.get(currentIndex);
|
|
1715
|
+
const displayIndex = $5.derived(() => $5.get(motion).kind === "user" ? $5.get(visualIndex) : $5.get(currentIndex));
|
|
1716
|
+
const slideIdentity = $5.derived(() => $$props.slides.map((slide) => slide.id).join("\x00"));
|
|
1717
|
+
let previousSlideIdentity = untrack(() => $5.get(slideIdentity));
|
|
1718
|
+
$5.user_effect(() => {
|
|
1719
|
+
if ($5.get(clampedLength) < 1) {
|
|
177
1720
|
if (activeIndex() !== 0)
|
|
178
1721
|
activeIndex(0);
|
|
179
1722
|
return;
|
|
180
1723
|
}
|
|
181
|
-
const normalizedIndex = Math.max(0, Math.min($
|
|
1724
|
+
const normalizedIndex = Math.max(0, Math.min($5.get(clampedLength) - 1, activeIndex()));
|
|
182
1725
|
if (activeIndex() !== normalizedIndex)
|
|
183
1726
|
activeIndex(normalizedIndex);
|
|
184
1727
|
});
|
|
185
|
-
const shouldAutoplay = $
|
|
186
|
-
const
|
|
187
|
-
|
|
1728
|
+
const shouldAutoplay = $5.derived(() => autoplay() && $5.get(clampedLength) > 1 && autoplayInterval() > 0 && !reducedMotion.current && !$5.get(isHovered) && !$5.get(hasFocusWithin) && activePointerIds.size === 0 && $5.get(motion).kind !== "user" && !$5.get(userPaused));
|
|
1729
|
+
const isMultiView = $5.derived(() => slidesPerView() !== 1);
|
|
1730
|
+
const visibleRangeSize = $5.derived(() => typeof slidesPerView() === "number" ? Math.max(1, Math.ceil(slidesPerView())) : 1);
|
|
1731
|
+
const rangeEnd = $5.derived(() => Math.min($5.get(clampedLength) - 1, $5.get(currentIndex) + $5.get(visibleRangeSize) - 1));
|
|
1732
|
+
function isSlideInRange(index) {
|
|
1733
|
+
return isInRangeOfAnchor(index, $5.get(currentIndex));
|
|
1734
|
+
}
|
|
1735
|
+
const effectiveLoop = $5.derived(() => loop() && !$5.get(isMultiView));
|
|
1736
|
+
const resolvedSlideSize = $5.derived(() => {
|
|
1737
|
+
if (!$5.get(isMultiView))
|
|
1738
|
+
return;
|
|
1739
|
+
if (slidesPerView() === "auto")
|
|
1740
|
+
return "auto";
|
|
1741
|
+
return `calc((100% - (${slidesPerView()} - 1) * var(--cinder-carousel-gap, var(--cinder-space-3))) / ${slidesPerView()})`;
|
|
1742
|
+
});
|
|
1743
|
+
$5.user_effect(() => {
|
|
1744
|
+
if (loop() && $5.get(isMultiView)) {
|
|
1745
|
+
devWarn("[cinder/Carousel] `loop` is not supported with `slidesPerView` greater than 1 yet; `loop` is being ignored.");
|
|
1746
|
+
}
|
|
1747
|
+
});
|
|
1748
|
+
const liveAnnouncement = $5.derived(() => {
|
|
1749
|
+
if (!$$props.slides[$5.get(currentIndex)])
|
|
188
1750
|
return "";
|
|
189
|
-
|
|
1751
|
+
if ($5.get(rangeEnd) > $5.get(currentIndex)) {
|
|
1752
|
+
return `Slides ${$5.get(currentIndex) + 1}–${$5.get(rangeEnd) + 1} of ${$5.get(clampedLength)}`;
|
|
1753
|
+
}
|
|
1754
|
+
return `Slide ${$5.get(currentIndex) + 1} of ${$5.get(clampedLength)}: ${$$props.slides[$5.get(currentIndex)].label}`;
|
|
190
1755
|
});
|
|
191
|
-
$
|
|
192
|
-
|
|
1756
|
+
const isAtStart = $5.derived(() => !$5.get(effectiveLoop) && $5.get(currentIndex) === 0);
|
|
1757
|
+
const isAtEnd = $5.derived(() => !$5.get(effectiveLoop) && $5.get(rangeEnd) === $5.get(clampedLength) - 1);
|
|
1758
|
+
const resolvedIndicators = $5.derived(() => $$props.indicators ?? ($5.get(clampedLength) > indicatorLimit() ? "counter" : "dots"));
|
|
1759
|
+
$5.user_effect(() => {
|
|
1760
|
+
if (!$5.get(shouldAutoplay))
|
|
193
1761
|
return;
|
|
194
1762
|
const timer = setInterval(() => {
|
|
195
|
-
if ($
|
|
1763
|
+
if ($5.get(clampedLength) < 2)
|
|
196
1764
|
return;
|
|
197
|
-
|
|
198
|
-
goNext(true);
|
|
199
|
-
if (programmaticTarget === null)
|
|
200
|
-
$3.set(isAutoplayTransitioning, false);
|
|
1765
|
+
goNext("autoplay");
|
|
201
1766
|
}, autoplayInterval());
|
|
202
1767
|
return () => clearInterval(timer);
|
|
203
1768
|
});
|
|
204
|
-
function goTo(index, immediate = false,
|
|
205
|
-
if ($
|
|
1769
|
+
function goTo(index, immediate = false, source = "control") {
|
|
1770
|
+
if ($5.get(clampedLength) < 1)
|
|
206
1771
|
return;
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
if (programmaticTarget !== null && $3.get(viewportElement) !== null) {
|
|
211
|
-
$3.set(settledIndex, nearestVisibleSlideIndex($3.get(viewportElement)), true);
|
|
1772
|
+
const nextIndex = $5.get(effectiveLoop) ? (index % $5.get(clampedLength) + $5.get(clampedLength)) % $5.get(clampedLength) : Math.max(0, Math.min($5.get(clampedLength) - 1, index));
|
|
1773
|
+
if ($5.get(motion).kind === "programmatic" && $5.get(viewportElement) !== null) {
|
|
1774
|
+
$5.set(settledIndex, nearestVisibleSlideIndex($5.get(viewportElement)), true);
|
|
212
1775
|
}
|
|
1776
|
+
const changed = nextIndex !== activeIndex();
|
|
213
1777
|
activeIndex(nextIndex);
|
|
214
|
-
scrollToActiveSlide(immediate ? "auto" : undefined);
|
|
1778
|
+
scrollToActiveSlide(immediate ? "auto" : undefined, source);
|
|
1779
|
+
if (changed) {
|
|
1780
|
+
const slide = $$props.slides[nextIndex];
|
|
1781
|
+
if (slide)
|
|
1782
|
+
$$props.onSlideChange?.(nextIndex, slide);
|
|
1783
|
+
}
|
|
215
1784
|
}
|
|
216
|
-
function goPrevious() {
|
|
217
|
-
const nextIndex = ($
|
|
218
|
-
const physicalDistance = Math.abs(initialSlideOrder(nextIndex) - initialSlideOrder($
|
|
219
|
-
goTo($
|
|
1785
|
+
function goPrevious(source = "control") {
|
|
1786
|
+
const nextIndex = ($5.get(currentIndex) - 1 + $5.get(clampedLength)) % $5.get(clampedLength);
|
|
1787
|
+
const physicalDistance = Math.abs(initialSlideOrder(nextIndex) - initialSlideOrder($5.get(currentIndex)));
|
|
1788
|
+
goTo($5.get(currentIndex) - 1, $5.get(clampedLength) > 2 && physicalDistance > 1, source);
|
|
220
1789
|
}
|
|
221
|
-
function goNext(
|
|
222
|
-
const nextIndex = ($
|
|
223
|
-
const physicalDistance = Math.abs(initialSlideOrder(nextIndex) - initialSlideOrder($
|
|
224
|
-
goTo($
|
|
1790
|
+
function goNext(source = "control") {
|
|
1791
|
+
const nextIndex = ($5.get(currentIndex) + 1) % $5.get(clampedLength);
|
|
1792
|
+
const physicalDistance = Math.abs(initialSlideOrder(nextIndex) - initialSlideOrder($5.get(currentIndex)));
|
|
1793
|
+
goTo($5.get(currentIndex) + 1, $5.get(clampedLength) > 2 && physicalDistance > 1, source);
|
|
225
1794
|
}
|
|
226
1795
|
function onKeydown(event2) {
|
|
227
|
-
|
|
1796
|
+
$$props.onkeydown?.(event2);
|
|
1797
|
+
if (event2.defaultPrevented)
|
|
1798
|
+
return;
|
|
1799
|
+
if ($5.get(clampedLength) < 2)
|
|
228
1800
|
return;
|
|
229
1801
|
if (event2.key === "ArrowLeft") {
|
|
230
1802
|
event2.preventDefault();
|
|
231
1803
|
focusCarouselRoot(event2);
|
|
232
|
-
goPrevious();
|
|
1804
|
+
goPrevious("keyboard");
|
|
233
1805
|
return;
|
|
234
1806
|
}
|
|
235
1807
|
if (event2.key === "ArrowRight") {
|
|
236
1808
|
event2.preventDefault();
|
|
237
1809
|
focusCarouselRoot(event2);
|
|
238
|
-
goNext();
|
|
1810
|
+
goNext("keyboard");
|
|
239
1811
|
return;
|
|
240
1812
|
}
|
|
241
1813
|
if (event2.key === "Home") {
|
|
242
1814
|
event2.preventDefault();
|
|
243
1815
|
focusCarouselRoot(event2);
|
|
244
|
-
goTo(0);
|
|
1816
|
+
goTo(0, undefined, "keyboard");
|
|
245
1817
|
return;
|
|
246
1818
|
}
|
|
247
1819
|
if (event2.key === "End") {
|
|
248
1820
|
event2.preventDefault();
|
|
249
1821
|
focusCarouselRoot(event2);
|
|
250
|
-
goTo($
|
|
1822
|
+
goTo($5.get(clampedLength) - 1, undefined, "keyboard");
|
|
251
1823
|
}
|
|
252
1824
|
}
|
|
253
1825
|
function focusCarouselRoot(event2) {
|
|
254
1826
|
const root = event2.currentTarget;
|
|
255
1827
|
const target = event2.target;
|
|
256
|
-
const activeSlide = $
|
|
1828
|
+
const activeSlide = $5.get(viewportElement)?.children[$5.get(currentIndex)];
|
|
257
1829
|
if (root instanceof HTMLElement && target !== root && target instanceof Node && root.contains(target) && activeSlide instanceof HTMLElement && activeSlide.contains(target)) {
|
|
258
1830
|
root.focus();
|
|
259
1831
|
}
|
|
260
1832
|
}
|
|
1833
|
+
function onMouseEnter(event2) {
|
|
1834
|
+
$$props.onmouseenter?.(event2);
|
|
1835
|
+
$5.set(isHovered, true);
|
|
1836
|
+
}
|
|
1837
|
+
function onMouseLeave(event2) {
|
|
1838
|
+
$$props.onmouseleave?.(event2);
|
|
1839
|
+
$5.set(isHovered, false);
|
|
1840
|
+
}
|
|
1841
|
+
function onFocusIn(event2) {
|
|
1842
|
+
$$props.onfocusin?.(event2);
|
|
1843
|
+
$5.set(hasFocusWithin, true);
|
|
1844
|
+
}
|
|
261
1845
|
function onFocusOut(event2) {
|
|
1846
|
+
$$props.onfocusout?.(event2);
|
|
262
1847
|
const nextFocus = event2.relatedTarget;
|
|
263
1848
|
if (nextFocus instanceof Node && event2.currentTarget instanceof HTMLElement) {
|
|
264
1849
|
if (event2.currentTarget.contains(nextFocus))
|
|
265
1850
|
return;
|
|
266
1851
|
}
|
|
267
|
-
$
|
|
1852
|
+
$5.set(hasFocusWithin, false);
|
|
268
1853
|
}
|
|
269
1854
|
function initialSlideOrder(index) {
|
|
270
1855
|
if ($$props.slides.length < 1)
|
|
271
1856
|
return 0;
|
|
272
|
-
return (index - $
|
|
1857
|
+
return (index - $5.get(initialSlideIndex) + $$props.slides.length) % $$props.slides.length;
|
|
1858
|
+
}
|
|
1859
|
+
function isInRangeOfAnchor(index, anchor) {
|
|
1860
|
+
const end = Math.min($5.get(clampedLength) - 1, anchor + $5.get(visibleRangeSize) - 1);
|
|
1861
|
+
return index >= anchor && index <= end;
|
|
273
1862
|
}
|
|
274
1863
|
function isInteractionLayoutSlide(index) {
|
|
275
|
-
if (index
|
|
1864
|
+
if (isInRangeOfAnchor(index, $5.get(currentIndex)) || isInRangeOfAnchor(index, $5.get(settledIndex)))
|
|
276
1865
|
return true;
|
|
277
|
-
if (
|
|
1866
|
+
if ($5.get(motion).kind === "idle")
|
|
278
1867
|
return false;
|
|
279
|
-
const currentOrder = initialSlideOrder($
|
|
280
|
-
const settledOrder = initialSlideOrder($
|
|
1868
|
+
const currentOrder = initialSlideOrder($5.get(currentIndex));
|
|
1869
|
+
const settledOrder = initialSlideOrder($5.get(settledIndex));
|
|
281
1870
|
const lowerBound = Math.max(0, Math.min(currentOrder, settledOrder) - 1);
|
|
282
|
-
const upperBound = Math.min($
|
|
1871
|
+
const upperBound = Math.min($5.get(clampedLength) - 1, Math.max(currentOrder, settledOrder) + 1);
|
|
283
1872
|
const slideOrder = initialSlideOrder(index);
|
|
284
1873
|
return slideOrder >= lowerBound && slideOrder <= upperBound;
|
|
285
1874
|
}
|
|
286
|
-
function
|
|
287
|
-
|
|
1875
|
+
function slideAnchor(rect) {
|
|
1876
|
+
return align() === "center" ? rect.left + rect.width / 2 : rect.left;
|
|
1877
|
+
}
|
|
1878
|
+
function scrollToActiveSlide(behavior, source = "external") {
|
|
1879
|
+
const viewport = $5.get(viewportElement);
|
|
288
1880
|
if (viewport === null)
|
|
289
1881
|
return;
|
|
290
|
-
const slide = viewport?.children[$
|
|
1882
|
+
const slide = viewport?.children[$5.get(currentIndex)];
|
|
291
1883
|
if (!(slide instanceof HTMLElement))
|
|
292
1884
|
return;
|
|
293
1885
|
const viewportRect = viewport.getBoundingClientRect();
|
|
294
1886
|
const slideRect = slide.getBoundingClientRect();
|
|
295
1887
|
if (viewportRect.width === 0 || slideRect.width === 0)
|
|
296
1888
|
return;
|
|
297
|
-
if (Math.abs(slideRect
|
|
298
|
-
|
|
299
|
-
$
|
|
300
|
-
deferredExternalIndex = null;
|
|
301
|
-
$3.set(isAutoplayTransitioning, false);
|
|
1889
|
+
if (Math.abs(slideAnchor(slideRect) - slideAnchor(viewportRect)) <= 1) {
|
|
1890
|
+
setMotion({ kind: "idle" });
|
|
1891
|
+
$5.set(settledIndex, $5.get(currentIndex), true);
|
|
302
1892
|
return;
|
|
303
1893
|
}
|
|
304
|
-
|
|
1894
|
+
setMotion({ kind: "programmatic", target: $5.get(currentIndex), source });
|
|
305
1895
|
const direction = typeof window !== "undefined" ? window.getComputedStyle(viewport).direction : "ltr";
|
|
306
|
-
const
|
|
1896
|
+
const centeringOffset = align() === "center" && direction !== "rtl" ? (viewportRect.width - slideRect.width) / 2 : 0;
|
|
1897
|
+
const destination = direction === "rtl" ? viewport.scrollLeft + slideRect.left - viewportRect.left : slide.offsetLeft - centeringOffset;
|
|
307
1898
|
if (typeof viewport.scrollTo === "function") {
|
|
308
1899
|
viewport.scrollTo({
|
|
309
1900
|
left: destination,
|
|
@@ -314,12 +1905,17 @@ function Carousel($$anchor, $$props) {
|
|
|
314
1905
|
}
|
|
315
1906
|
}
|
|
316
1907
|
function nearestVisibleSlideIndex(viewport) {
|
|
317
|
-
const
|
|
1908
|
+
const viewportRect = viewport.getBoundingClientRect();
|
|
1909
|
+
const computed = typeof window !== "undefined" ? window.getComputedStyle(viewport) : null;
|
|
1910
|
+
const scrollPaddingInlineStart = computed ? Number.parseFloat(computed.scrollPaddingInlineStart) : Number.NaN;
|
|
1911
|
+
const referencePoint = align() === "center" ? viewportRect.left + viewportRect.width / 2 : computed?.direction !== "rtl" && Number.isFinite(scrollPaddingInlineStart) ? viewportRect.left + scrollPaddingInlineStart : viewportRect.left;
|
|
318
1912
|
return [...viewport.children].reduce((nearestIndex, slide, index) => {
|
|
319
1913
|
const nearest = viewport.children[nearestIndex];
|
|
320
1914
|
if (!nearest)
|
|
321
1915
|
return index;
|
|
322
|
-
|
|
1916
|
+
const slidePoint = slideAnchor(slide.getBoundingClientRect());
|
|
1917
|
+
const nearestPoint = slideAnchor(nearest.getBoundingClientRect());
|
|
1918
|
+
return Math.abs(slidePoint - referencePoint) < Math.abs(nearestPoint - referencePoint) ? index : nearestIndex;
|
|
323
1919
|
}, 0);
|
|
324
1920
|
}
|
|
325
1921
|
const observeViewport = useResizeObserver((entries) => {
|
|
@@ -335,10 +1931,25 @@ function Carousel($$anchor, $$props) {
|
|
|
335
1931
|
if (inlineSize === cachedViewportInlineSize)
|
|
336
1932
|
return;
|
|
337
1933
|
cachedViewportInlineSize = inlineSize;
|
|
338
|
-
if (
|
|
1934
|
+
if (activePointerIds.size === 0 && $5.get(motion).kind !== "user") {
|
|
339
1935
|
scrollToActiveSlide("auto");
|
|
340
1936
|
}
|
|
341
1937
|
});
|
|
1938
|
+
function getSlideSnapPositions() {
|
|
1939
|
+
const viewport = $5.get(viewportElement);
|
|
1940
|
+
if (viewport === null)
|
|
1941
|
+
return [];
|
|
1942
|
+
return [...viewport.children].map((child2) => {
|
|
1943
|
+
const slide = child2;
|
|
1944
|
+
if (align() !== "center")
|
|
1945
|
+
return slide.offsetLeft;
|
|
1946
|
+
return slide.offsetLeft - (viewport.clientWidth - slide.offsetWidth) / 2;
|
|
1947
|
+
});
|
|
1948
|
+
}
|
|
1949
|
+
const dragScroll = useDragScroll({
|
|
1950
|
+
enabled: () => finePointer.current && !reducedMotion.current,
|
|
1951
|
+
getSnapPositions: getSlideSnapPositions
|
|
1952
|
+
});
|
|
342
1953
|
function removePointerEndListeners() {
|
|
343
1954
|
if (typeof window === "undefined")
|
|
344
1955
|
return;
|
|
@@ -347,36 +1958,62 @@ function Carousel($$anchor, $$props) {
|
|
|
347
1958
|
}
|
|
348
1959
|
function finishPointerInteraction(event2) {
|
|
349
1960
|
if (event2.type === "pointercancel") {
|
|
350
|
-
|
|
1961
|
+
if ($5.get(motion).kind !== "user")
|
|
1962
|
+
observedActiveIndex = $5.get(currentIndex);
|
|
1963
|
+
setMotion({ kind: "user", source: "touch" });
|
|
1964
|
+
scheduleFallbackSettle();
|
|
351
1965
|
}
|
|
352
1966
|
activePointerIds.delete(event2.pointerId);
|
|
353
1967
|
if (activePointerIds.size > 0)
|
|
354
1968
|
return;
|
|
355
|
-
$3.set(isInteracting, false);
|
|
356
1969
|
removePointerEndListeners();
|
|
357
|
-
if ($
|
|
1970
|
+
if ($5.get(motion).kind === "user")
|
|
358
1971
|
scheduleNativeScrollEnd();
|
|
359
1972
|
}
|
|
1973
|
+
function handleSettle() {
|
|
1974
|
+
if (nativeScrollEndTimer !== null) {
|
|
1975
|
+
clearTimeout(nativeScrollEndTimer);
|
|
1976
|
+
nativeScrollEndTimer = null;
|
|
1977
|
+
}
|
|
1978
|
+
if (activePointerIds.size > 0)
|
|
1979
|
+
return;
|
|
1980
|
+
if ($5.get(motion).kind !== "user")
|
|
1981
|
+
return;
|
|
1982
|
+
setMotion({ kind: "idle" });
|
|
1983
|
+
if ($5.get(viewportElement) === null)
|
|
1984
|
+
return;
|
|
1985
|
+
if ($5.get(currentIndex) !== observedActiveIndex) {
|
|
1986
|
+
$5.set(settledIndex, $5.get(currentIndex), true);
|
|
1987
|
+
$5.set(visualIndex, $5.get(currentIndex), true);
|
|
1988
|
+
scrollToActiveSlide("auto");
|
|
1989
|
+
return;
|
|
1990
|
+
}
|
|
1991
|
+
const nextIndex = nearestVisibleSlideIndex($5.get(viewportElement));
|
|
1992
|
+
$5.set(settledIndex, nextIndex, true);
|
|
1993
|
+
$5.set(visualIndex, nextIndex, true);
|
|
1994
|
+
if (nextIndex !== $5.get(currentIndex) && nextIndex >= 0 && nextIndex < $5.get(clampedLength)) {
|
|
1995
|
+
transferFocusFromOutgoingSlide();
|
|
1996
|
+
activeIndex(nextIndex);
|
|
1997
|
+
const slide = $$props.slides[nextIndex];
|
|
1998
|
+
if (slide)
|
|
1999
|
+
$$props.onSlideChange?.(nextIndex, slide);
|
|
2000
|
+
}
|
|
2001
|
+
}
|
|
360
2002
|
function scheduleNativeScrollEnd() {
|
|
361
|
-
$
|
|
2003
|
+
if ($5.get(viewportElement) !== null && "onscrollend" in $5.get(viewportElement))
|
|
2004
|
+
return;
|
|
2005
|
+
scheduleFallbackSettle();
|
|
2006
|
+
}
|
|
2007
|
+
function scheduleFallbackSettle() {
|
|
362
2008
|
if (nativeScrollEndTimer !== null)
|
|
363
2009
|
clearTimeout(nativeScrollEndTimer);
|
|
364
|
-
nativeScrollEndTimer = setTimeout(
|
|
365
|
-
nativeScrollEndTimer = null;
|
|
366
|
-
if (activePointerIds.size > 0)
|
|
367
|
-
return;
|
|
368
|
-
$3.set(isNativeScrolling, false);
|
|
369
|
-
$3.set(settledIndex, $3.get(viewportElement) ? nearestVisibleSlideIndex($3.get(viewportElement)) : $3.get(currentIndex), true);
|
|
370
|
-
if (programmaticTarget === null)
|
|
371
|
-
$3.set(isAutoplayTransitioning, false);
|
|
372
|
-
}, 100);
|
|
2010
|
+
nativeScrollEndTimer = setTimeout(handleSettle, 100);
|
|
373
2011
|
}
|
|
374
2012
|
function onPointerDown(event2) {
|
|
375
2013
|
if (event2.pointerType !== "touch" && event2.pointerType !== "pen")
|
|
376
2014
|
return;
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
$3.set(isInteracting, true);
|
|
2015
|
+
if ($5.get(motion).kind === "programmatic")
|
|
2016
|
+
setMotion({ kind: "idle" });
|
|
380
2017
|
activePointerIds.add(event2.pointerId);
|
|
381
2018
|
removePointerEndListeners();
|
|
382
2019
|
window.addEventListener("pointerup", finishPointerInteraction);
|
|
@@ -386,25 +2023,24 @@ function Carousel($$anchor, $$props) {
|
|
|
386
2023
|
const isHorizontallyDominant = Math.abs(event2.deltaX) > Math.abs(event2.deltaY);
|
|
387
2024
|
const isShiftScroll = event2.shiftKey && Math.abs(event2.deltaY) > 0;
|
|
388
2025
|
if (isHorizontallyDominant || isShiftScroll) {
|
|
389
|
-
|
|
390
|
-
|
|
2026
|
+
if ($5.get(motion).kind !== "user")
|
|
2027
|
+
observedActiveIndex = $5.get(currentIndex);
|
|
2028
|
+
setMotion({ kind: "user", source: "wheel" });
|
|
391
2029
|
scheduleNativeScrollEnd();
|
|
392
2030
|
}
|
|
393
2031
|
}
|
|
394
2032
|
function onWindowBlur() {
|
|
395
|
-
const
|
|
396
|
-
const
|
|
2033
|
+
const hadPointers = activePointerIds.size > 0;
|
|
2034
|
+
const wasUserMotion = $5.get(motion).kind === "user";
|
|
397
2035
|
activePointerIds.clear();
|
|
398
|
-
$3.set(isInteracting, false);
|
|
399
2036
|
removePointerEndListeners();
|
|
400
|
-
if (
|
|
401
|
-
|
|
402
|
-
if (
|
|
403
|
-
|
|
404
|
-
$3.set(isAutoplayTransitioning, false);
|
|
2037
|
+
if (wasUserMotion)
|
|
2038
|
+
scheduleFallbackSettle();
|
|
2039
|
+
if (hadPointers && $5.get(motion).kind === "programmatic") {
|
|
2040
|
+
setMotion({ kind: "idle" });
|
|
405
2041
|
}
|
|
406
2042
|
}
|
|
407
|
-
$
|
|
2043
|
+
$5.user_effect(() => {
|
|
408
2044
|
if (typeof window === "undefined")
|
|
409
2045
|
return;
|
|
410
2046
|
window.addEventListener("blur", onWindowBlur);
|
|
@@ -418,349 +2054,380 @@ function Carousel($$anchor, $$props) {
|
|
|
418
2054
|
cancelAnimationFrame(scrollFrame);
|
|
419
2055
|
});
|
|
420
2056
|
function onViewportScroll() {
|
|
421
|
-
const viewport = $
|
|
422
|
-
if ($
|
|
2057
|
+
const viewport = $5.get(viewportElement);
|
|
2058
|
+
if ($5.get(clampedLength) < 2 || viewport === null)
|
|
2059
|
+
return;
|
|
2060
|
+
if ($5.get(motion).kind === "programmatic") {
|
|
2061
|
+
if (scrollFrame !== null)
|
|
2062
|
+
return;
|
|
2063
|
+
scrollFrame = requestAnimationFrame(() => {
|
|
2064
|
+
scrollFrame = null;
|
|
2065
|
+
const nextIndex = nearestVisibleSlideIndex(viewport);
|
|
2066
|
+
$5.set(visualIndex, nextIndex, true);
|
|
2067
|
+
if ($5.get(motion).kind === "programmatic" && nextIndex === $5.get(motion).target) {
|
|
2068
|
+
$5.set(settledIndex, nextIndex, true);
|
|
2069
|
+
setMotion({ kind: "idle" });
|
|
2070
|
+
}
|
|
2071
|
+
});
|
|
423
2072
|
return;
|
|
2073
|
+
}
|
|
2074
|
+
if ($5.get(motion).kind !== "user") {
|
|
2075
|
+
const source = viewport.hasAttribute("data-cinder-dragging") ? "drag" : "touch";
|
|
2076
|
+
setMotion({ kind: "user", source });
|
|
2077
|
+
observedActiveIndex = $5.get(currentIndex);
|
|
2078
|
+
}
|
|
424
2079
|
scheduleNativeScrollEnd();
|
|
425
2080
|
if (scrollFrame !== null)
|
|
426
2081
|
return;
|
|
427
2082
|
scrollFrame = requestAnimationFrame(() => {
|
|
428
2083
|
scrollFrame = null;
|
|
429
|
-
|
|
430
|
-
if (programmaticTarget !== null) {
|
|
431
|
-
if (nextIndex === programmaticTarget) {
|
|
432
|
-
programmaticTarget = null;
|
|
433
|
-
$3.set(settledIndex, nextIndex, true);
|
|
434
|
-
$3.set(isAutoplayTransitioning, false);
|
|
435
|
-
if (deferredExternalIndex === nextIndex)
|
|
436
|
-
deferredExternalIndex = null;
|
|
437
|
-
}
|
|
438
|
-
return;
|
|
439
|
-
}
|
|
440
|
-
if (nextIndex !== $3.get(currentIndex) && nextIndex >= 0 && nextIndex < $3.get(clampedLength)) {
|
|
441
|
-
if (deferredExternalIndex !== null)
|
|
442
|
-
return;
|
|
443
|
-
transferFocusFromOutgoingSlide();
|
|
444
|
-
internalActiveIndexUpdate = nextIndex;
|
|
445
|
-
activeIndex(nextIndex);
|
|
446
|
-
}
|
|
2084
|
+
$5.set(visualIndex, nearestVisibleSlideIndex(viewport), true);
|
|
447
2085
|
});
|
|
448
2086
|
}
|
|
449
2087
|
function transferFocusFromOutgoingSlide() {
|
|
450
2088
|
if (typeof document === "undefined")
|
|
451
2089
|
return;
|
|
452
2090
|
const activeElement = document.activeElement;
|
|
453
|
-
const outgoingSlide = $
|
|
2091
|
+
const outgoingSlide = $5.get(viewportElement)?.children[$5.get(currentIndex)];
|
|
454
2092
|
if (activeElement instanceof Node && outgoingSlide instanceof HTMLElement && outgoingSlide.contains(activeElement)) {
|
|
455
|
-
$
|
|
2093
|
+
$5.get(viewportElement)?.focus();
|
|
456
2094
|
}
|
|
457
2095
|
}
|
|
458
|
-
$
|
|
459
|
-
if ($
|
|
2096
|
+
$5.user_effect(() => {
|
|
2097
|
+
if ($5.get(viewportElement) === null || $5.get(clampedLength) < 1)
|
|
460
2098
|
return;
|
|
461
|
-
if ($
|
|
2099
|
+
if ($5.get(motion).kind === "user" || activePointerIds.size > 0)
|
|
462
2100
|
return;
|
|
463
|
-
const identityChanged = $
|
|
464
|
-
previousSlideIdentity = $
|
|
2101
|
+
const identityChanged = $5.get(slideIdentity) !== previousSlideIdentity;
|
|
2102
|
+
previousSlideIdentity = $5.get(slideIdentity);
|
|
465
2103
|
if (identityChanged) {
|
|
466
|
-
$
|
|
2104
|
+
$5.set(settledIndex, nearestVisibleSlideIndex($5.get(viewportElement)), true);
|
|
467
2105
|
scrollToActiveSlide("auto");
|
|
468
2106
|
return;
|
|
469
2107
|
}
|
|
470
2108
|
scrollToActiveSlide();
|
|
471
2109
|
});
|
|
472
|
-
$
|
|
473
|
-
const
|
|
474
|
-
if (
|
|
2110
|
+
$5.user_effect(() => {
|
|
2111
|
+
const viewport = $5.get(viewportElement);
|
|
2112
|
+
if (viewport === null || !("onscrollend" in viewport))
|
|
475
2113
|
return;
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
observedActiveIndex = index;
|
|
479
|
-
if (!isInternalUpdate && ($3.get(isInteracting) || $3.get(isNativeScrolling))) {
|
|
480
|
-
deferredExternalIndex = index;
|
|
481
|
-
}
|
|
2114
|
+
viewport.addEventListener("scrollend", handleSettle);
|
|
2115
|
+
return () => viewport.removeEventListener("scrollend", handleSettle);
|
|
482
2116
|
});
|
|
483
|
-
$
|
|
484
|
-
const viewport = $
|
|
485
|
-
if (viewport === null
|
|
2117
|
+
$5.user_effect(() => {
|
|
2118
|
+
const viewport = $5.get(viewportElement);
|
|
2119
|
+
if (viewport === null)
|
|
486
2120
|
return;
|
|
487
|
-
|
|
488
|
-
if ($
|
|
2121
|
+
return observeTextDirection(viewport, () => {
|
|
2122
|
+
if ($5.get(motion).kind === "user" || activePointerIds.size > 0)
|
|
489
2123
|
return;
|
|
490
2124
|
scrollToActiveSlide("auto");
|
|
491
2125
|
});
|
|
492
|
-
let ancestor = viewport;
|
|
493
|
-
while (ancestor !== null) {
|
|
494
|
-
observer.observe(ancestor, { attributes: true, attributeFilter: ["dir"] });
|
|
495
|
-
ancestor = ancestor.parentElement;
|
|
496
|
-
}
|
|
497
|
-
return () => observer.disconnect();
|
|
498
2126
|
});
|
|
499
|
-
var section =
|
|
500
|
-
|
|
501
|
-
var event_handler_1 = () => $3.set(isHovered, false);
|
|
502
|
-
var event_handler_2 = () => $3.set(hasFocusWithin, true);
|
|
503
|
-
$3.attribute_effect(section, ($0) => ({
|
|
2127
|
+
var section = root_12();
|
|
2128
|
+
$5.attribute_effect(section, ($0) => ({
|
|
504
2129
|
...rest,
|
|
505
2130
|
class: $0,
|
|
506
2131
|
"aria-roledescription": "carousel",
|
|
507
2132
|
"aria-label": label(),
|
|
508
2133
|
"aria-describedby": $$props.description ? descriptionId : undefined,
|
|
509
2134
|
tabindex: "0",
|
|
2135
|
+
"data-cinder-align": align() === "center" ? "center" : undefined,
|
|
510
2136
|
onkeydown: onKeydown,
|
|
511
|
-
onmouseenter:
|
|
512
|
-
onmouseleave:
|
|
513
|
-
onfocusin:
|
|
514
|
-
onfocusout: onFocusOut
|
|
2137
|
+
onmouseenter: onMouseEnter,
|
|
2138
|
+
onmouseleave: onMouseLeave,
|
|
2139
|
+
onfocusin: onFocusIn,
|
|
2140
|
+
onfocusout: onFocusOut,
|
|
2141
|
+
[$5.STYLE]: {
|
|
2142
|
+
"--cinder-carousel-slide-size": $5.get(resolvedSlideSize),
|
|
2143
|
+
"--cinder-carousel-gap": $5.get(isMultiView) ? $$props.gap : undefined
|
|
2144
|
+
}
|
|
515
2145
|
}), [() => classNames("cinder-carousel", $$props.class)]);
|
|
516
|
-
var node = $
|
|
2146
|
+
var node = $5.child(section);
|
|
517
2147
|
{
|
|
518
2148
|
var consequent = ($$anchor2) => {
|
|
519
2149
|
var p = root_1();
|
|
520
|
-
var text = $
|
|
521
|
-
$
|
|
522
|
-
$
|
|
523
|
-
$
|
|
524
|
-
$
|
|
2150
|
+
var text = $5.child(p, true);
|
|
2151
|
+
$5.reset(p);
|
|
2152
|
+
$5.template_effect(() => {
|
|
2153
|
+
$5.set_attribute(p, "id", descriptionId);
|
|
2154
|
+
$5.set_text(text, $$props.description);
|
|
525
2155
|
});
|
|
526
|
-
$
|
|
2156
|
+
$5.append($$anchor2, p);
|
|
527
2157
|
};
|
|
528
|
-
$
|
|
2158
|
+
$5.if(node, ($$render) => {
|
|
529
2159
|
if ($$props.description)
|
|
530
2160
|
$$render(consequent);
|
|
531
2161
|
});
|
|
532
2162
|
}
|
|
533
|
-
var p_1 = $
|
|
534
|
-
var text_1 = $
|
|
535
|
-
$
|
|
536
|
-
var div = $
|
|
537
|
-
|
|
2163
|
+
var p_1 = $5.sibling(node, 2);
|
|
2164
|
+
var text_1 = $5.child(p_1, true);
|
|
2165
|
+
$5.reset(p_1);
|
|
2166
|
+
var div = $5.sibling(p_1, 2);
|
|
2167
|
+
let styles;
|
|
2168
|
+
var node_1 = $5.child(div);
|
|
538
2169
|
{
|
|
539
|
-
var
|
|
540
|
-
var fragment = $
|
|
541
|
-
var node_2 = $
|
|
542
|
-
$
|
|
2170
|
+
var consequent_11 = ($$anchor2) => {
|
|
2171
|
+
var fragment = $5.comment();
|
|
2172
|
+
var node_2 = $5.first_child(fragment);
|
|
2173
|
+
$5.each(node_2, 19, () => $$props.slides, (slide) => slide.id, ($$anchor3, slide, index) => {
|
|
543
2174
|
var article = root_7();
|
|
544
|
-
let
|
|
545
|
-
var node_3 = $
|
|
2175
|
+
let styles_1;
|
|
2176
|
+
var node_3 = $5.child(article);
|
|
546
2177
|
{
|
|
547
|
-
var
|
|
2178
|
+
var consequent_1 = ($$anchor4) => {
|
|
2179
|
+
var fragment_1 = $5.comment();
|
|
2180
|
+
var node_4 = $5.first_child(fragment_1);
|
|
2181
|
+
{
|
|
2182
|
+
let $0 = $5.derived(() => ({ index: $5.get(index), active: isSlideInRange($5.get(index)) }));
|
|
2183
|
+
$5.snippet(node_4, () => $$props.slide, () => $5.get(slide), () => $5.get($0));
|
|
2184
|
+
}
|
|
2185
|
+
$5.append($$anchor4, fragment_1);
|
|
2186
|
+
};
|
|
2187
|
+
var consequent_6 = ($$anchor4) => {
|
|
548
2188
|
var a = root_5();
|
|
549
|
-
var
|
|
2189
|
+
var node_5 = $5.child(a);
|
|
550
2190
|
{
|
|
551
|
-
var
|
|
2191
|
+
var consequent_2 = ($$anchor5) => {
|
|
552
2192
|
var img = root_2();
|
|
553
|
-
$
|
|
554
|
-
$
|
|
555
|
-
$
|
|
556
|
-
$
|
|
557
|
-
});
|
|
558
|
-
$
|
|
2193
|
+
$5.template_effect(($0) => {
|
|
2194
|
+
$5.set_attribute(img, "src", $5.get(slide).imageSrc);
|
|
2195
|
+
$5.set_attribute(img, "alt", $5.get(slide).imageAlt ?? $5.get(slide).title ?? $5.get(slide).label);
|
|
2196
|
+
$5.set_attribute(img, "loading", $0);
|
|
2197
|
+
}, [() => isSlideInRange($5.get(index)) ? "eager" : "lazy"]);
|
|
2198
|
+
$5.append($$anchor5, img);
|
|
559
2199
|
};
|
|
560
|
-
$
|
|
561
|
-
if ($
|
|
562
|
-
$$render(
|
|
2200
|
+
$5.if(node_5, ($$render) => {
|
|
2201
|
+
if ($5.get(slide).imageSrc)
|
|
2202
|
+
$$render(consequent_2);
|
|
563
2203
|
});
|
|
564
2204
|
}
|
|
565
|
-
var
|
|
2205
|
+
var node_6 = $5.sibling(node_5, 2);
|
|
566
2206
|
{
|
|
567
|
-
var
|
|
2207
|
+
var consequent_3 = ($$anchor5) => {
|
|
568
2208
|
var h3 = root_3();
|
|
569
|
-
var text_2 = $
|
|
570
|
-
$
|
|
571
|
-
$
|
|
572
|
-
$
|
|
2209
|
+
var text_2 = $5.child(h3, true);
|
|
2210
|
+
$5.reset(h3);
|
|
2211
|
+
$5.template_effect(() => $5.set_text(text_2, $5.get(slide).title));
|
|
2212
|
+
$5.append($$anchor5, h3);
|
|
573
2213
|
};
|
|
574
|
-
$
|
|
575
|
-
if ($
|
|
576
|
-
$$render(
|
|
2214
|
+
$5.if(node_6, ($$render) => {
|
|
2215
|
+
if ($5.get(slide).title)
|
|
2216
|
+
$$render(consequent_3);
|
|
577
2217
|
});
|
|
578
2218
|
}
|
|
579
|
-
var
|
|
2219
|
+
var node_7 = $5.sibling(node_6, 2);
|
|
580
2220
|
{
|
|
581
|
-
var
|
|
2221
|
+
var consequent_4 = ($$anchor5) => {
|
|
582
2222
|
var p_2 = root_4();
|
|
583
|
-
var text_3 = $
|
|
584
|
-
$
|
|
585
|
-
$
|
|
586
|
-
$
|
|
2223
|
+
var text_3 = $5.child(p_2, true);
|
|
2224
|
+
$5.reset(p_2);
|
|
2225
|
+
$5.template_effect(() => $5.set_text(text_3, $5.get(slide).description));
|
|
2226
|
+
$5.append($$anchor5, p_2);
|
|
587
2227
|
};
|
|
588
|
-
$
|
|
589
|
-
if ($
|
|
590
|
-
$$render(
|
|
2228
|
+
$5.if(node_7, ($$render) => {
|
|
2229
|
+
if ($5.get(slide).description)
|
|
2230
|
+
$$render(consequent_4);
|
|
591
2231
|
});
|
|
592
2232
|
}
|
|
593
|
-
var
|
|
2233
|
+
var node_8 = $5.sibling(node_7, 2);
|
|
594
2234
|
{
|
|
595
|
-
var
|
|
2235
|
+
var consequent_5 = ($$anchor5) => {
|
|
596
2236
|
var p_3 = root_4();
|
|
597
|
-
var text_4 = $
|
|
598
|
-
$
|
|
599
|
-
$
|
|
600
|
-
$
|
|
2237
|
+
var text_4 = $5.child(p_3, true);
|
|
2238
|
+
$5.reset(p_3);
|
|
2239
|
+
$5.template_effect(() => $5.set_text(text_4, $5.get(slide).label));
|
|
2240
|
+
$5.append($$anchor5, p_3);
|
|
601
2241
|
};
|
|
602
|
-
$
|
|
603
|
-
if (!$
|
|
604
|
-
$$render(
|
|
2242
|
+
$5.if(node_8, ($$render) => {
|
|
2243
|
+
if (!$5.get(slide).imageSrc && !$5.get(slide).title && !$5.get(slide).description)
|
|
2244
|
+
$$render(consequent_5);
|
|
605
2245
|
});
|
|
606
2246
|
}
|
|
607
|
-
$
|
|
608
|
-
$
|
|
609
|
-
$
|
|
2247
|
+
$5.reset(a);
|
|
2248
|
+
$5.template_effect(() => $5.set_attribute(a, "href", $5.get(slide).href));
|
|
2249
|
+
$5.append($$anchor4, a);
|
|
610
2250
|
};
|
|
611
2251
|
var alternate = ($$anchor4) => {
|
|
612
|
-
var
|
|
613
|
-
var
|
|
2252
|
+
var fragment_2 = root_6();
|
|
2253
|
+
var node_9 = $5.first_child(fragment_2);
|
|
614
2254
|
{
|
|
615
|
-
var
|
|
2255
|
+
var consequent_7 = ($$anchor5) => {
|
|
616
2256
|
var img_1 = root_2();
|
|
617
|
-
$
|
|
618
|
-
$
|
|
619
|
-
$
|
|
620
|
-
$
|
|
621
|
-
});
|
|
622
|
-
$
|
|
2257
|
+
$5.template_effect(($0) => {
|
|
2258
|
+
$5.set_attribute(img_1, "src", $5.get(slide).imageSrc);
|
|
2259
|
+
$5.set_attribute(img_1, "alt", $5.get(slide).imageAlt ?? $5.get(slide).title ?? $5.get(slide).label);
|
|
2260
|
+
$5.set_attribute(img_1, "loading", $0);
|
|
2261
|
+
}, [() => isSlideInRange($5.get(index)) ? "eager" : "lazy"]);
|
|
2262
|
+
$5.append($$anchor5, img_1);
|
|
623
2263
|
};
|
|
624
|
-
$
|
|
625
|
-
if ($
|
|
626
|
-
$$render(
|
|
2264
|
+
$5.if(node_9, ($$render) => {
|
|
2265
|
+
if ($5.get(slide).imageSrc)
|
|
2266
|
+
$$render(consequent_7);
|
|
627
2267
|
});
|
|
628
2268
|
}
|
|
629
|
-
var
|
|
2269
|
+
var node_10 = $5.sibling(node_9, 2);
|
|
630
2270
|
{
|
|
631
|
-
var
|
|
2271
|
+
var consequent_8 = ($$anchor5) => {
|
|
632
2272
|
var h3_1 = root_3();
|
|
633
|
-
var text_5 = $
|
|
634
|
-
$
|
|
635
|
-
$
|
|
636
|
-
$
|
|
2273
|
+
var text_5 = $5.child(h3_1, true);
|
|
2274
|
+
$5.reset(h3_1);
|
|
2275
|
+
$5.template_effect(() => $5.set_text(text_5, $5.get(slide).title));
|
|
2276
|
+
$5.append($$anchor5, h3_1);
|
|
637
2277
|
};
|
|
638
|
-
$
|
|
639
|
-
if ($
|
|
640
|
-
$$render(
|
|
2278
|
+
$5.if(node_10, ($$render) => {
|
|
2279
|
+
if ($5.get(slide).title)
|
|
2280
|
+
$$render(consequent_8);
|
|
641
2281
|
});
|
|
642
2282
|
}
|
|
643
|
-
var
|
|
2283
|
+
var node_11 = $5.sibling(node_10, 2);
|
|
644
2284
|
{
|
|
645
|
-
var
|
|
2285
|
+
var consequent_9 = ($$anchor5) => {
|
|
646
2286
|
var p_4 = root_4();
|
|
647
|
-
var text_6 = $
|
|
648
|
-
$
|
|
649
|
-
$
|
|
650
|
-
$
|
|
2287
|
+
var text_6 = $5.child(p_4, true);
|
|
2288
|
+
$5.reset(p_4);
|
|
2289
|
+
$5.template_effect(() => $5.set_text(text_6, $5.get(slide).description));
|
|
2290
|
+
$5.append($$anchor5, p_4);
|
|
651
2291
|
};
|
|
652
|
-
$
|
|
653
|
-
if ($
|
|
654
|
-
$$render(
|
|
2292
|
+
$5.if(node_11, ($$render) => {
|
|
2293
|
+
if ($5.get(slide).description)
|
|
2294
|
+
$$render(consequent_9);
|
|
655
2295
|
});
|
|
656
2296
|
}
|
|
657
|
-
var
|
|
2297
|
+
var node_12 = $5.sibling(node_11, 2);
|
|
658
2298
|
{
|
|
659
|
-
var
|
|
2299
|
+
var consequent_10 = ($$anchor5) => {
|
|
660
2300
|
var p_5 = root_4();
|
|
661
|
-
var text_7 = $
|
|
662
|
-
$
|
|
663
|
-
$
|
|
664
|
-
$
|
|
2301
|
+
var text_7 = $5.child(p_5, true);
|
|
2302
|
+
$5.reset(p_5);
|
|
2303
|
+
$5.template_effect(() => $5.set_text(text_7, $5.get(slide).label));
|
|
2304
|
+
$5.append($$anchor5, p_5);
|
|
665
2305
|
};
|
|
666
|
-
$
|
|
667
|
-
if (!$
|
|
668
|
-
$$render(
|
|
2306
|
+
$5.if(node_12, ($$render) => {
|
|
2307
|
+
if (!$5.get(slide).imageSrc && !$5.get(slide).title && !$5.get(slide).description)
|
|
2308
|
+
$$render(consequent_10);
|
|
669
2309
|
});
|
|
670
2310
|
}
|
|
671
|
-
$
|
|
2311
|
+
$5.append($$anchor4, fragment_2);
|
|
672
2312
|
};
|
|
673
|
-
$
|
|
674
|
-
if (
|
|
675
|
-
$$render(
|
|
2313
|
+
$5.if(node_3, ($$render) => {
|
|
2314
|
+
if ($$props.slide)
|
|
2315
|
+
$$render(consequent_1);
|
|
2316
|
+
else if ($5.get(slide).href)
|
|
2317
|
+
$$render(consequent_6, 1);
|
|
676
2318
|
else
|
|
677
2319
|
$$render(alternate, -1);
|
|
678
2320
|
});
|
|
679
2321
|
}
|
|
680
|
-
$
|
|
681
|
-
$
|
|
682
|
-
$
|
|
683
|
-
$
|
|
684
|
-
article.inert = $
|
|
685
|
-
$
|
|
686
|
-
|
|
2322
|
+
$5.reset(article);
|
|
2323
|
+
$5.template_effect(($0, $1, $22, $32) => {
|
|
2324
|
+
$5.set_attribute(article, "aria-label", `${$5.get(index) + 1} of ${$$props.slides.length}: ${$5.get(slide).label}`);
|
|
2325
|
+
$5.set_attribute(article, "aria-hidden", $0);
|
|
2326
|
+
article.inert = $1;
|
|
2327
|
+
$5.set_attribute(article, "data-cinder-collapsed", $22);
|
|
2328
|
+
styles_1 = $5.set_style(article, "", styles_1, $32);
|
|
687
2329
|
}, [
|
|
688
|
-
() =>
|
|
689
|
-
() => (
|
|
2330
|
+
() => isSlideInRange($5.get(index)) ? undefined : "true",
|
|
2331
|
+
() => !isSlideInRange($5.get(index)),
|
|
2332
|
+
() => !isInteractionLayoutSlide($5.get(index)) ? "" : undefined,
|
|
2333
|
+
() => ({ order: initialSlideOrder($5.get(index)) })
|
|
690
2334
|
]);
|
|
691
|
-
$
|
|
2335
|
+
$5.append($$anchor3, article);
|
|
692
2336
|
});
|
|
693
|
-
$
|
|
2337
|
+
$5.append($$anchor2, fragment);
|
|
694
2338
|
};
|
|
695
|
-
$
|
|
2339
|
+
$5.if(node_1, ($$render) => {
|
|
696
2340
|
if ($$props.slides.length > 0)
|
|
697
|
-
$$render(
|
|
2341
|
+
$$render(consequent_11);
|
|
698
2342
|
});
|
|
699
2343
|
}
|
|
700
|
-
$
|
|
701
|
-
$
|
|
702
|
-
$
|
|
703
|
-
|
|
704
|
-
var
|
|
705
|
-
var
|
|
706
|
-
var
|
|
707
|
-
$
|
|
708
|
-
|
|
709
|
-
var
|
|
710
|
-
$
|
|
711
|
-
$
|
|
712
|
-
|
|
2344
|
+
$5.reset(div);
|
|
2345
|
+
$5.bind_this(div, ($$value) => $5.set(viewportElement, $$value), () => $5.get(viewportElement));
|
|
2346
|
+
$5.attach(div, () => observeViewport);
|
|
2347
|
+
$5.attach(div, () => dragScroll);
|
|
2348
|
+
var div_1 = $5.sibling(div, 2);
|
|
2349
|
+
var div_2 = $5.child(div_1);
|
|
2350
|
+
var button = $5.child(div_2);
|
|
2351
|
+
var text_8 = $5.child(button, true);
|
|
2352
|
+
$5.reset(button);
|
|
2353
|
+
var button_1 = $5.sibling(button, 2);
|
|
2354
|
+
var text_9 = $5.child(button_1, true);
|
|
2355
|
+
$5.reset(button_1);
|
|
2356
|
+
$5.reset(div_2);
|
|
2357
|
+
var node_13 = $5.sibling(div_2, 2);
|
|
713
2358
|
{
|
|
714
|
-
var
|
|
2359
|
+
var consequent_12 = ($$anchor2) => {
|
|
715
2360
|
var button_2 = root_8();
|
|
716
|
-
var text_10 = $
|
|
717
|
-
$
|
|
718
|
-
$
|
|
719
|
-
$
|
|
720
|
-
$
|
|
2361
|
+
var text_10 = $5.child(button_2, true);
|
|
2362
|
+
$5.reset(button_2);
|
|
2363
|
+
$5.template_effect(() => {
|
|
2364
|
+
$5.set_attribute(button_2, "aria-pressed", $5.get(userPaused));
|
|
2365
|
+
$5.set_text(text_10, $5.get(userPaused) ? $$props.controlLabels?.play ?? "Play" : $$props.controlLabels?.pause ?? "Pause");
|
|
721
2366
|
});
|
|
722
|
-
$
|
|
723
|
-
$
|
|
2367
|
+
$5.delegated("click", button_2, () => $5.set(userPaused, !$5.get(userPaused)));
|
|
2368
|
+
$5.append($$anchor2, button_2);
|
|
724
2369
|
};
|
|
725
|
-
$
|
|
2370
|
+
$5.if(node_13, ($$render) => {
|
|
726
2371
|
if (autoplay() && !reducedMotion.current)
|
|
727
|
-
$$render(
|
|
2372
|
+
$$render(consequent_12);
|
|
728
2373
|
});
|
|
729
2374
|
}
|
|
730
|
-
var
|
|
731
|
-
|
|
732
|
-
var
|
|
733
|
-
|
|
734
|
-
$
|
|
735
|
-
|
|
2375
|
+
var node_14 = $5.sibling(node_13, 2);
|
|
2376
|
+
{
|
|
2377
|
+
var consequent_13 = ($$anchor2) => {
|
|
2378
|
+
var div_3 = root_10();
|
|
2379
|
+
$5.each(div_3, 23, () => $$props.slides, (slide) => slide.id, ($$anchor3, slide, index) => {
|
|
2380
|
+
var button_3 = root_9();
|
|
2381
|
+
$5.template_effect(() => {
|
|
2382
|
+
$5.set_attribute(button_3, "aria-label", `Go to ${$5.get(slide).label}`);
|
|
2383
|
+
$5.set_attribute(button_3, "aria-current", $5.get(index) === $5.get(displayIndex) ? "true" : undefined);
|
|
2384
|
+
});
|
|
2385
|
+
$5.delegated("click", button_3, () => goTo($5.get(index), undefined, "control"));
|
|
2386
|
+
$5.append($$anchor3, button_3);
|
|
2387
|
+
});
|
|
2388
|
+
$5.reset(div_3);
|
|
2389
|
+
$5.template_effect(() => $5.set_attribute(div_3, "aria-label", $$props.controlLabels?.picker ?? "Choose slide"));
|
|
2390
|
+
$5.append($$anchor2, div_3);
|
|
2391
|
+
};
|
|
2392
|
+
var consequent_14 = ($$anchor2) => {
|
|
2393
|
+
var div_4 = root_11();
|
|
2394
|
+
var text_11 = $5.child(div_4);
|
|
2395
|
+
$5.reset(div_4);
|
|
2396
|
+
$5.template_effect(() => $5.set_text(text_11, `${$5.get(displayIndex) + 1} / ${$5.get(clampedLength) ?? ""}`));
|
|
2397
|
+
$5.append($$anchor2, div_4);
|
|
2398
|
+
};
|
|
2399
|
+
$5.if(node_14, ($$render) => {
|
|
2400
|
+
if ($5.get(resolvedIndicators) === "dots")
|
|
2401
|
+
$$render(consequent_13);
|
|
2402
|
+
else if ($5.get(resolvedIndicators) === "counter")
|
|
2403
|
+
$$render(consequent_14, 1);
|
|
736
2404
|
});
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
$
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
$
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
$
|
|
748
|
-
$
|
|
749
|
-
button.disabled = $$props.slides.length < 2;
|
|
750
|
-
$
|
|
751
|
-
button_1.disabled = $$props.slides.length < 2;
|
|
752
|
-
$
|
|
753
|
-
$3.set_attribute(div_3, "aria-label", $$props.controlLabels?.picker ?? "Choose slide");
|
|
2405
|
+
}
|
|
2406
|
+
$5.reset(div_1);
|
|
2407
|
+
$5.reset(section);
|
|
2408
|
+
$5.template_effect(() => {
|
|
2409
|
+
$5.set_attribute(p_1, "aria-live", $5.get(shouldAutoplay) || $5.get(motion).kind === "programmatic" && $5.get(motion).source === "autoplay" ? "off" : "polite");
|
|
2410
|
+
$5.set_text(text_1, $5.get(liveAnnouncement));
|
|
2411
|
+
$5.set_attribute(div, "aria-label", `${label()} slides`);
|
|
2412
|
+
styles = $5.set_style(div, "", styles, {
|
|
2413
|
+
gap: $5.get(isMultiView) ? "var(--cinder-carousel-gap, var(--cinder-space-3))" : undefined
|
|
2414
|
+
});
|
|
2415
|
+
$5.set_attribute(div_1, "aria-label", `${label()} controls`);
|
|
2416
|
+
$5.set_attribute(div_2, "aria-label", `${label()} navigation`);
|
|
2417
|
+
button.disabled = $$props.slides.length < 2 || $5.get(isAtStart);
|
|
2418
|
+
$5.set_text(text_8, $$props.controlLabels?.previous ?? "Previous");
|
|
2419
|
+
button_1.disabled = $$props.slides.length < 2 || $5.get(isAtEnd);
|
|
2420
|
+
$5.set_text(text_9, $$props.controlLabels?.next ?? "Next");
|
|
754
2421
|
});
|
|
755
|
-
$
|
|
756
|
-
$
|
|
757
|
-
$
|
|
758
|
-
$
|
|
759
|
-
$
|
|
760
|
-
$
|
|
761
|
-
$
|
|
762
|
-
}
|
|
763
|
-
$
|
|
2422
|
+
$5.event("scroll", div, onViewportScroll);
|
|
2423
|
+
$5.delegated("pointerdown", div, onPointerDown);
|
|
2424
|
+
$5.event("wheel", div, onWheel);
|
|
2425
|
+
$5.delegated("click", button, () => goPrevious("control"));
|
|
2426
|
+
$5.delegated("click", button_1, () => goNext("control"));
|
|
2427
|
+
$5.append($$anchor, section);
|
|
2428
|
+
$5.pop();
|
|
2429
|
+
}
|
|
2430
|
+
$5.delegate(["pointerdown", "click"]);
|
|
764
2431
|
|
|
765
2432
|
// src/components/carousel/index.ts
|
|
766
2433
|
var carousel_default = Carousel;
|
|
@@ -769,4 +2436,4 @@ export {
|
|
|
769
2436
|
Carousel
|
|
770
2437
|
};
|
|
771
2438
|
|
|
772
|
-
//# debugId=
|
|
2439
|
+
//# debugId=785DC8738586284D64756E2164756E21
|