@lobehub/ui 5.43.1 → 5.45.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/es/base-ui/Accordion/atoms.mjs +8 -3
- package/es/base-ui/Accordion/atoms.mjs.map +1 -1
- package/es/base-ui/Accordion/style.d.mts +1 -0
- package/es/base-ui/Accordion/style.mjs +10 -0
- package/es/base-ui/Accordion/style.mjs.map +1 -1
- package/es/base-ui/Accordion/type.d.mts +1 -1
- package/es/base-ui/ContextMenu/ContextMenuHost.mjs +5 -1
- package/es/base-ui/ContextMenu/ContextMenuHost.mjs.map +1 -1
- package/es/base-ui/ContextMenu/ContextMenuTrigger.d.mts +3 -1
- package/es/base-ui/ContextMenu/ContextMenuTrigger.mjs +7 -3
- package/es/base-ui/ContextMenu/ContextMenuTrigger.mjs.map +1 -1
- package/es/base-ui/ContextMenu/store.d.mts +3 -1
- package/es/base-ui/ContextMenu/store.mjs +6 -2
- package/es/base-ui/ContextMenu/store.mjs.map +1 -1
- package/es/base-ui/DropdownMenu/DropdownMenu.mjs +6 -2
- package/es/base-ui/DropdownMenu/DropdownMenu.mjs.map +1 -1
- package/es/base-ui/DropdownMenu/atoms.d.mts +4 -2
- package/es/base-ui/DropdownMenu/atoms.mjs +17 -5
- package/es/base-ui/DropdownMenu/atoms.mjs.map +1 -1
- package/es/base-ui/DropdownMenu/sharedStyle.mjs +26 -3
- package/es/base-ui/DropdownMenu/sharedStyle.mjs.map +1 -1
- package/es/base-ui/DropdownMenu/type.d.mts +3 -1
- package/es/base-ui/ScrollArea/atoms.mjs +4 -4
- package/es/base-ui/ScrollArea/atoms.mjs.map +1 -1
- package/es/base-ui/Select/Select.mjs +1 -3
- package/es/base-ui/Select/Select.mjs.map +1 -1
- package/es/base-ui/Select/hooks.mjs +1 -40
- package/es/base-ui/Select/hooks.mjs.map +1 -1
- package/es/base-ui/Select/parts.mjs +20 -18
- package/es/base-ui/Select/parts.mjs.map +1 -1
- package/es/base-ui/Select/renderOptions.mjs +1 -2
- package/es/base-ui/Select/renderOptions.mjs.map +1 -1
- package/es/base-ui/Select/style.mjs +2 -4
- package/es/base-ui/Select/style.mjs.map +1 -1
- package/es/base-ui/Select/type.d.mts +3 -3
- package/es/base-ui/index.d.mts +4 -2
- package/es/base-ui/index.mjs +1 -1
- package/es/base-ui/virtual/MenuVirtualList.d.mts +3 -0
- package/es/base-ui/virtual/MenuVirtualList.mjs +28 -0
- package/es/base-ui/virtual/MenuVirtualList.mjs.map +1 -0
- package/es/base-ui/virtual/VirtualScrollArea.d.mts +3 -0
- package/es/base-ui/virtual/VirtualScrollArea.mjs +82 -0
- package/es/base-ui/virtual/VirtualScrollArea.mjs.map +1 -0
- package/es/base-ui/virtual/index.d.mts +5 -0
- package/es/base-ui/virtual/type.d.mts +26 -0
- package/es/base-ui/virtual/useMenuVirtualList.d.mts +3 -0
- package/es/base-ui/virtual/useMenuVirtualList.mjs +256 -0
- package/es/base-ui/virtual/useMenuVirtualList.mjs.map +1 -0
- package/es/index.d.mts +1 -1
- package/es/index.mjs +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style.mjs","names":["lobeStaticStylish"],"sources":["../../../src/base-ui/Select/style.ts"],"sourcesContent":["import { createStaticStyles, cx } from 'antd-style';\nimport { cva } from 'class-variance-authority';\n\nimport { controlHeight } from '@/base-ui/controlSize';\nimport { focusRing } from '@/base-ui/focusRing';\nimport { lobeStaticStylish } from '@/styles';\n\nexport const styles = createStaticStyles(({ css, cssVar }) => ({\n arrow: css`\n display: flex;\n width: 12px;\n height: 6px;\n\n & > svg {\n width: 100%;\n height: 100%;\n }\n `,\n borderless: cx(\n lobeStaticStylish.variantBorderless,\n css`\n --lobe-select-open-bg: ${cssVar.colorFillTertiary};\n --lobe-select-readonly-bg: color-mix(in srgb, ${cssVar.colorFillTertiary} 70%, transparent);\n --lobe-select-disabled-bg: color-mix(in srgb, ${cssVar.colorFillTertiary} 55%, transparent);\n `,\n ),\n clear: css`\n display: inline-flex;\n align-items: center;\n\n color: ${cssVar.colorTextTertiary};\n\n opacity: 0;\n\n transition: opacity 150ms ${cssVar.motionEaseOut};\n\n &:hover {\n color: ${cssVar.colorTextSecondary};\n }\n `,\n empty: css``,\n filled: cx(\n lobeStaticStylish.variantFilled,\n css`\n --lobe-select-open-bg: ${cssVar.colorFillSecondary};\n --lobe-select-readonly-bg: color-mix(in srgb, ${cssVar.colorFillTertiary} 70%, transparent);\n --lobe-select-disabled-bg: color-mix(in srgb, ${cssVar.colorFillTertiary} 55%, transparent);\n `,\n ),\n group: css``,\n groupLabel: css``,\n icon: css`\n display: inline-flex;\n align-items: center;\n transition: transform 150ms ${cssVar.motionEaseOut};\n\n &[data-popup-open] {\n transform: rotate(180deg);\n }\n `,\n item: css``,\n itemBoldSelected: css`\n &[data-selected] {\n font-weight: 600;\n }\n `,\n itemIndicator: css`\n display: inline-flex;\n align-items: center;\n justify-content: center;\n\n margin-inline-start: auto;\n padding-inline-start: 8px;\n\n color: ${cssVar.colorPrimary};\n `,\n itemText: css``,\n list: css`\n overflow-y: auto;\n flex: 1;\n\n min-height: 0;\n padding-block: 0;\n `,\n listWithSearch: css`\n padding-block-start: 4px;\n `,\n outlined: cx(\n lobeStaticStylish.variantOutlined,\n css`\n --lobe-select-open-bg: ${cssVar.colorFillTertiary};\n --lobe-select-readonly-bg: color-mix(in srgb, ${cssVar.colorBgContainer} 75%, transparent);\n --lobe-select-disabled-bg: color-mix(in srgb, ${cssVar.colorBgContainer} 60%, transparent);\n `,\n ),\n popup: css`\n --lobe-select-available-height: min(\n var(--available-height),\n var(--lobe-select-popup-max-height, var(--available-height))\n );\n\n max-height: var(--lobe-select-available-height);\n\n transform-origin: var(--transform-origin);\n\n display: flex;\n flex-direction: column;\n\n box-sizing: border-box;\n\n transition:\n opacity 150ms ${cssVar.motionEaseOut},\n transform 150ms ${cssVar.motionEaseOut};\n\n &[data-starting-style],\n &[data-ending-style] {\n transform: scaleY(0.92);\n opacity: 0;\n }\n `,\n positioner: css`\n z-index: 1100;\n outline: none;\n `,\n prefix: css`\n display: inline-flex;\n align-items: center;\n color: ${cssVar.colorTextSecondary};\n `,\n scrollArrow: css`\n cursor: default;\n\n display: flex;\n align-items: center;\n justify-content: center;\n\n height: 16px;\n\n color: ${cssVar.colorTextSecondary};\n\n background: ${cssVar.colorBgElevated};\n `,\n search: css`\n cursor: text;\n\n display: flex;\n align-items: center;\n\n min-height: 36px;\n margin-inline: -4px;\n padding-block: 8px;\n padding-inline: 12px;\n border-block-end: 1px solid ${cssVar.colorFillSecondary};\n `,\n searchInput: css`\n flex: 1;\n\n min-width: 0;\n padding-block: 0;\n padding-inline: 4px;\n border: 0;\n\n font-size: 14px;\n line-height: 20px;\n color: ${cssVar.colorText};\n\n background: transparent;\n outline: none;\n\n &::placeholder {\n color: ${cssVar.colorTextPlaceholder};\n }\n `,\n shadow: lobeStaticStylish.shadow,\n suffix: css`\n display: inline-flex;\n gap: 6px;\n align-items: center;\n color: ${cssVar.colorTextSecondary};\n `,\n tag: css`\n display: inline-flex;\n align-items: center;\n\n max-width: 100%;\n padding-block: 0;\n padding-inline: 6px;\n border-radius: ${cssVar.borderRadiusSM};\n\n font-size: 12px;\n line-height: 20px;\n color: ${cssVar.colorText};\n\n background: ${cssVar.colorFillTertiary};\n `,\n tagClose: css`\n cursor: pointer;\n\n display: inline-flex;\n align-items: center;\n justify-content: center;\n\n margin-inline-start: 4px;\n\n color: ${cssVar.colorTextSecondary};\n\n transition: opacity 150ms ${cssVar.motionEaseOut};\n `,\n tags: css`\n display: flex;\n flex-wrap: wrap;\n gap: 4px;\n align-items: center;\n `,\n tagsValue: css`\n /* No growing, so an empty trigger leaves the inline input the full width — but it must\n still shrink, or the tags stay at max-content and run off the trigger instead of wrapping. */\n flex: 0 1 auto;\n `,\n tagsSearch: css`\n display: flex;\n flex: 1;\n min-width: 48px;\n `,\n trigger: css`\n cursor: pointer;\n user-select: none;\n\n display: inline-flex;\n gap: 8px;\n align-items: center;\n\n box-sizing: border-box;\n width: 100%;\n border: 1px solid transparent;\n border-radius: ${cssVar.borderRadius};\n\n font-family: inherit;\n color: ${cssVar.colorText};\n\n background: transparent;\n outline: none;\n\n transition: all 150ms ${cssVar.motionEaseOut};\n\n &:not([data-disabled], [data-readonly])[data-popup-open],\n &:not([data-disabled], [data-readonly])[data-open],\n &:not([data-disabled], [data-readonly])[data-state='open'],\n &:not([data-disabled], [data-readonly])[aria-expanded='true'] {\n background: var(--lobe-select-open-bg, ${cssVar.colorFillTertiary});\n }\n\n ${focusRing};\n\n &:hover [data-role='lobe-select-clear'] {\n opacity: 1;\n }\n\n &[data-placeholder] [data-role='lobe-select-clear'] {\n pointer-events: none;\n opacity: 0;\n }\n\n &[data-disabled] {\n cursor: not-allowed;\n color: ${cssVar.colorTextDisabled};\n background: var(--lobe-select-disabled-bg, transparent);\n\n &:hover {\n background: var(--lobe-select-disabled-bg, transparent);\n }\n }\n\n &[data-readonly] {\n cursor: default;\n color: ${cssVar.colorTextSecondary};\n background: var(--lobe-select-readonly-bg, transparent);\n\n &:hover {\n background: var(--lobe-select-readonly-bg, transparent);\n }\n }\n\n &[data-disabled] [data-role='lobe-select-clear'] {\n pointer-events: none;\n opacity: 0;\n }\n `,\n triggerLarge: css`\n min-height: ${controlHeight.large}px;\n padding-block: 6px;\n padding-inline: 12px;\n\n font-size: 16px;\n line-height: 24px;\n `,\n triggerMiddle: css`\n min-height: ${controlHeight.middle}px;\n padding-block: 4px;\n padding-inline: 11px;\n\n font-size: 14px;\n line-height: 20px;\n `,\n triggerSmall: css`\n min-height: ${controlHeight.small}px;\n padding-block: 0;\n padding-inline: 8px;\n\n font-size: 12px;\n line-height: 18px;\n `,\n value: css`\n display: flex;\n flex: 1;\n flex-wrap: wrap;\n gap: 4px;\n align-items: center;\n\n min-width: 0;\n\n color: inherit;\n\n &[data-placeholder] {\n color: ${cssVar.colorTextPlaceholder};\n }\n `,\n valueText: css`\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n `,\n}));\n\nexport const triggerVariants = cva(styles.trigger, {\n defaultVariants: {\n shadow: false,\n size: 'middle',\n variant: 'outlined',\n },\n variants: {\n shadow: {\n false: null,\n true: styles.shadow,\n },\n size: {\n large: styles.triggerLarge,\n middle: styles.triggerMiddle,\n small: styles.triggerSmall,\n },\n variant: {\n borderless: styles.borderless,\n filled: styles.filled,\n outlined: styles.outlined,\n },\n },\n});\n"],"mappings":";;;;;;AAOA,MAAa,SAAS,oBAAoB,EAAE,KAAK,cAAc;CAC7D,OAAO,GAAG;;;;;;;;;;CAUV,YAAY,GACVA,cAAkB,mBAClB,GAAG;+BACwB,OAAO,kBAAkB;sDACF,OAAO,kBAAkB;sDACzB,OAAO,kBAAkB;KAE7E;CACA,OAAO,GAAG;;;;aAIC,OAAO,kBAAkB;;;;gCAIN,OAAO,cAAc;;;eAGtC,OAAO,mBAAmB;;;CAGvC,OAAO,GAAG;CACV,QAAQ,GACNA,cAAkB,eAClB,GAAG;+BACwB,OAAO,mBAAmB;sDACH,OAAO,kBAAkB;sDACzB,OAAO,kBAAkB;KAE7E;CACA,OAAO,GAAG;CACV,YAAY,GAAG;CACf,MAAM,GAAG;;;kCAGuB,OAAO,cAAc;;;;;;CAMrD,MAAM,GAAG;CACT,kBAAkB,GAAG;;;;;CAKrB,eAAe,GAAG;;;;;;;;aAQP,OAAO,aAAa;;CAE/B,UAAU,GAAG;CACb,MAAM,GAAG;;;;;;;CAOT,gBAAgB,GAAG;;;CAGnB,UAAU,GACRA,cAAkB,iBAClB,GAAG;+BACwB,OAAO,kBAAkB;sDACF,OAAO,iBAAiB;sDACxB,OAAO,iBAAiB;KAE5E;CACA,OAAO,GAAG;;;;;;;;;;;;;;;;sBAgBU,OAAO,cAAc;wBACnB,OAAO,cAAc;;;;;;;;CAQ3C,YAAY,GAAG;;;;CAIf,QAAQ,GAAG;;;aAGA,OAAO,mBAAmB;;CAErC,aAAa,GAAG;;;;;;;;;aASL,OAAO,mBAAmB;;kBAErB,OAAO,gBAAgB;;CAEvC,QAAQ,GAAG;;;;;;;;;;kCAUqB,OAAO,mBAAmB;;CAE1D,aAAa,GAAG;;;;;;;;;;aAUL,OAAO,UAAU;;;;;;eAMf,OAAO,qBAAqB;;;CAGzC,QAAQA,cAAkB;CAC1B,QAAQ,GAAG;;;;aAIA,OAAO,mBAAmB;;CAErC,KAAK,GAAG;;;;;;;qBAOW,OAAO,eAAe;;;;aAI9B,OAAO,UAAU;;kBAEZ,OAAO,kBAAkB;;CAEzC,UAAU,GAAG;;;;;;;;;aASF,OAAO,mBAAmB;;gCAEP,OAAO,cAAc;;CAEnD,MAAM,GAAG;;;;;;CAMT,WAAW,GAAG;;;;;CAKd,YAAY,GAAG;;;;;CAKf,SAAS,GAAG;;;;;;;;;;;qBAWO,OAAO,aAAa;;;aAG5B,OAAO,UAAU;;;;;4BAKF,OAAO,cAAc;;;;;;+CAMF,OAAO,kBAAkB;;;MAGlE,UAAU;;;;;;;;;;;;;eAaD,OAAO,kBAAkB;;;;;;;;;;eAUzB,OAAO,mBAAmB;;;;;;;;;;;;;CAavC,cAAc,GAAG;kBACD,cAAc,MAAM;;;;;;;CAOpC,eAAe,GAAG;kBACF,cAAc,OAAO;;;;;;;CAOrC,cAAc,GAAG;kBACD,cAAc,MAAM;;;;;;;CAOpC,OAAO,GAAG;;;;;;;;;;;;eAYG,OAAO,qBAAqB;;;CAGzC,WAAW,GAAG;;;;;AAKhB,EAAE;AAEF,MAAa,kBAAkB,IAAI,OAAO,SAAS;CACjD,iBAAiB;EACf,QAAQ;EACR,MAAM;EACN,SAAS;CACX;CACA,UAAU;EACR,QAAQ;GACN,OAAO;GACP,MAAM,OAAO;EACf;EACA,MAAM;GACJ,OAAO,OAAO;GACd,QAAQ,OAAO;GACf,OAAO,OAAO;EAChB;EACA,SAAS;GACP,YAAY,OAAO;GACnB,QAAQ,OAAO;GACf,UAAU,OAAO;EACnB;CACF;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"style.mjs","names":["lobeStaticStylish"],"sources":["../../../src/base-ui/Select/style.ts"],"sourcesContent":["import { createStaticStyles, cx } from 'antd-style';\nimport { cva } from 'class-variance-authority';\n\nimport { controlHeight } from '@/base-ui/controlSize';\nimport { focusRing } from '@/base-ui/focusRing';\nimport { lobeStaticStylish } from '@/styles';\n\nexport const styles = createStaticStyles(({ css, cssVar }) => ({\n arrow: css`\n display: flex;\n width: 12px;\n height: 6px;\n\n & > svg {\n width: 100%;\n height: 100%;\n }\n `,\n borderless: cx(\n lobeStaticStylish.variantBorderless,\n css`\n --lobe-select-open-bg: ${cssVar.colorFillTertiary};\n --lobe-select-readonly-bg: color-mix(in srgb, ${cssVar.colorFillTertiary} 70%, transparent);\n --lobe-select-disabled-bg: color-mix(in srgb, ${cssVar.colorFillTertiary} 55%, transparent);\n `,\n ),\n clear: css`\n display: inline-flex;\n align-items: center;\n\n color: ${cssVar.colorTextTertiary};\n\n opacity: 0;\n\n transition: opacity 150ms ${cssVar.motionEaseOut};\n\n &:hover {\n color: ${cssVar.colorTextSecondary};\n }\n `,\n empty: css``,\n filled: cx(\n lobeStaticStylish.variantFilled,\n css`\n --lobe-select-open-bg: ${cssVar.colorFillSecondary};\n --lobe-select-readonly-bg: color-mix(in srgb, ${cssVar.colorFillTertiary} 70%, transparent);\n --lobe-select-disabled-bg: color-mix(in srgb, ${cssVar.colorFillTertiary} 55%, transparent);\n `,\n ),\n group: css``,\n groupLabel: css``,\n icon: css`\n display: inline-flex;\n align-items: center;\n transition: transform 150ms ${cssVar.motionEaseOut};\n\n &[data-popup-open] {\n transform: rotate(180deg);\n }\n `,\n item: css``,\n itemBoldSelected: css`\n &[data-selected] {\n font-weight: 600;\n }\n `,\n itemIndicator: css`\n display: inline-flex;\n align-items: center;\n justify-content: center;\n\n margin-inline-start: auto;\n padding-inline-start: 8px;\n\n color: ${cssVar.colorPrimary};\n `,\n itemText: css``,\n list: css`\n overflow-y: auto;\n flex: 1;\n min-height: 0;\n padding-block: 0;\n `,\n listWithSearch: css`\n padding-block-start: 4px;\n `,\n outlined: cx(\n lobeStaticStylish.variantOutlined,\n css`\n --lobe-select-open-bg: ${cssVar.colorFillTertiary};\n --lobe-select-readonly-bg: color-mix(in srgb, ${cssVar.colorBgContainer} 75%, transparent);\n --lobe-select-disabled-bg: color-mix(in srgb, ${cssVar.colorBgContainer} 60%, transparent);\n `,\n ),\n popup: css`\n --lobe-select-available-height: min(\n var(--available-height),\n var(--lobe-select-popup-max-height, var(--available-height))\n );\n\n transform-origin: var(--transform-origin);\n\n display: flex;\n flex-direction: column;\n\n box-sizing: border-box;\n max-height: var(--lobe-select-available-height);\n\n transition:\n opacity 150ms ${cssVar.motionEaseOut},\n transform 150ms ${cssVar.motionEaseOut};\n\n &[data-starting-style],\n &[data-ending-style] {\n transform: scaleY(0.92);\n opacity: 0;\n }\n `,\n positioner: css`\n z-index: 1100;\n outline: none;\n `,\n prefix: css`\n display: inline-flex;\n align-items: center;\n color: ${cssVar.colorTextSecondary};\n `,\n scrollArrow: css`\n cursor: default;\n\n display: flex;\n align-items: center;\n justify-content: center;\n\n height: 16px;\n\n color: ${cssVar.colorTextSecondary};\n\n background: ${cssVar.colorBgElevated};\n `,\n search: css`\n cursor: text;\n\n display: flex;\n align-items: center;\n\n min-height: 36px;\n margin-inline: calc(-1 * var(--lobe-menu-popup-padding));\n padding-block: 8px;\n padding-inline: 12px;\n border-block-end: 1px solid ${cssVar.colorFillSecondary};\n `,\n searchInput: css`\n flex: 1;\n\n min-width: 0;\n padding-block: 0;\n padding-inline: 4px;\n border: 0;\n\n font-size: 14px;\n line-height: 20px;\n color: ${cssVar.colorText};\n\n background: transparent;\n outline: none;\n\n &::placeholder {\n color: ${cssVar.colorTextPlaceholder};\n }\n `,\n shadow: lobeStaticStylish.shadow,\n suffix: css`\n display: inline-flex;\n gap: 6px;\n align-items: center;\n color: ${cssVar.colorTextSecondary};\n `,\n tag: css`\n display: inline-flex;\n align-items: center;\n\n max-width: 100%;\n padding-block: 0;\n padding-inline: 6px;\n border-radius: ${cssVar.borderRadiusSM};\n\n font-size: 12px;\n line-height: 20px;\n color: ${cssVar.colorText};\n\n background: ${cssVar.colorFillTertiary};\n `,\n tagClose: css`\n cursor: pointer;\n\n display: inline-flex;\n align-items: center;\n justify-content: center;\n\n margin-inline-start: 4px;\n\n color: ${cssVar.colorTextSecondary};\n\n transition: opacity 150ms ${cssVar.motionEaseOut};\n `,\n tags: css`\n display: flex;\n flex-wrap: wrap;\n gap: 4px;\n align-items: center;\n `,\n tagsValue: css`\n /* No growing, so an empty trigger leaves the inline input the full width — but it must\n still shrink, or the tags stay at max-content and run off the trigger instead of wrapping. */\n flex: 0 1 auto;\n `,\n tagsSearch: css`\n display: flex;\n flex: 1;\n min-width: 48px;\n `,\n trigger: css`\n cursor: pointer;\n user-select: none;\n\n display: inline-flex;\n gap: 8px;\n align-items: center;\n\n box-sizing: border-box;\n width: 100%;\n border: 1px solid transparent;\n border-radius: ${cssVar.borderRadius};\n\n font-family: inherit;\n color: ${cssVar.colorText};\n\n background: transparent;\n outline: none;\n\n transition: all 150ms ${cssVar.motionEaseOut};\n\n &:not([data-disabled], [data-readonly])[data-popup-open],\n &:not([data-disabled], [data-readonly])[data-open],\n &:not([data-disabled], [data-readonly])[data-state='open'],\n &:not([data-disabled], [data-readonly])[aria-expanded='true'] {\n background: var(--lobe-select-open-bg, ${cssVar.colorFillTertiary});\n }\n\n ${focusRing};\n\n &:hover [data-role='lobe-select-clear'] {\n opacity: 1;\n }\n\n &[data-placeholder] [data-role='lobe-select-clear'] {\n pointer-events: none;\n opacity: 0;\n }\n\n &[data-disabled] {\n cursor: not-allowed;\n color: ${cssVar.colorTextDisabled};\n background: var(--lobe-select-disabled-bg, transparent);\n\n &:hover {\n background: var(--lobe-select-disabled-bg, transparent);\n }\n }\n\n &[data-readonly] {\n cursor: default;\n color: ${cssVar.colorTextSecondary};\n background: var(--lobe-select-readonly-bg, transparent);\n\n &:hover {\n background: var(--lobe-select-readonly-bg, transparent);\n }\n }\n\n &[data-disabled] [data-role='lobe-select-clear'] {\n pointer-events: none;\n opacity: 0;\n }\n `,\n triggerLarge: css`\n min-height: ${controlHeight.large}px;\n padding-block: 6px;\n padding-inline: 12px;\n\n font-size: 16px;\n line-height: 24px;\n `,\n triggerMiddle: css`\n min-height: ${controlHeight.middle}px;\n padding-block: 4px;\n padding-inline: 11px;\n\n font-size: 14px;\n line-height: 20px;\n `,\n triggerSmall: css`\n min-height: ${controlHeight.small}px;\n padding-block: 0;\n padding-inline: 8px;\n\n font-size: 12px;\n line-height: 18px;\n `,\n value: css`\n display: flex;\n flex: 1;\n flex-wrap: wrap;\n gap: 4px;\n align-items: center;\n\n min-width: 0;\n\n color: inherit;\n\n &[data-placeholder] {\n color: ${cssVar.colorTextPlaceholder};\n }\n `,\n valueText: css`\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n `,\n}));\n\nexport const triggerVariants = cva(styles.trigger, {\n defaultVariants: {\n shadow: false,\n size: 'middle',\n variant: 'outlined',\n },\n variants: {\n shadow: {\n false: null,\n true: styles.shadow,\n },\n size: {\n large: styles.triggerLarge,\n middle: styles.triggerMiddle,\n small: styles.triggerSmall,\n },\n variant: {\n borderless: styles.borderless,\n filled: styles.filled,\n outlined: styles.outlined,\n },\n },\n});\n"],"mappings":";;;;;;AAOA,MAAa,SAAS,oBAAoB,EAAE,KAAK,cAAc;CAC7D,OAAO,GAAG;;;;;;;;;;CAUV,YAAY,GACVA,cAAkB,mBAClB,GAAG;+BACwB,OAAO,kBAAkB;sDACF,OAAO,kBAAkB;sDACzB,OAAO,kBAAkB;KAE7E;CACA,OAAO,GAAG;;;;aAIC,OAAO,kBAAkB;;;;gCAIN,OAAO,cAAc;;;eAGtC,OAAO,mBAAmB;;;CAGvC,OAAO,GAAG;CACV,QAAQ,GACNA,cAAkB,eAClB,GAAG;+BACwB,OAAO,mBAAmB;sDACH,OAAO,kBAAkB;sDACzB,OAAO,kBAAkB;KAE7E;CACA,OAAO,GAAG;CACV,YAAY,GAAG;CACf,MAAM,GAAG;;;kCAGuB,OAAO,cAAc;;;;;;CAMrD,MAAM,GAAG;CACT,kBAAkB,GAAG;;;;;CAKrB,eAAe,GAAG;;;;;;;;aAQP,OAAO,aAAa;;CAE/B,UAAU,GAAG;CACb,MAAM,GAAG;;;;;;CAMT,gBAAgB,GAAG;;;CAGnB,UAAU,GACRA,cAAkB,iBAClB,GAAG;+BACwB,OAAO,kBAAkB;sDACF,OAAO,iBAAiB;sDACxB,OAAO,iBAAiB;KAE5E;CACA,OAAO,GAAG;;;;;;;;;;;;;;;sBAeU,OAAO,cAAc;wBACnB,OAAO,cAAc;;;;;;;;CAQ3C,YAAY,GAAG;;;;CAIf,QAAQ,GAAG;;;aAGA,OAAO,mBAAmB;;CAErC,aAAa,GAAG;;;;;;;;;aASL,OAAO,mBAAmB;;kBAErB,OAAO,gBAAgB;;CAEvC,QAAQ,GAAG;;;;;;;;;;kCAUqB,OAAO,mBAAmB;;CAE1D,aAAa,GAAG;;;;;;;;;;aAUL,OAAO,UAAU;;;;;;eAMf,OAAO,qBAAqB;;;CAGzC,QAAQA,cAAkB;CAC1B,QAAQ,GAAG;;;;aAIA,OAAO,mBAAmB;;CAErC,KAAK,GAAG;;;;;;;qBAOW,OAAO,eAAe;;;;aAI9B,OAAO,UAAU;;kBAEZ,OAAO,kBAAkB;;CAEzC,UAAU,GAAG;;;;;;;;;aASF,OAAO,mBAAmB;;gCAEP,OAAO,cAAc;;CAEnD,MAAM,GAAG;;;;;;CAMT,WAAW,GAAG;;;;;CAKd,YAAY,GAAG;;;;;CAKf,SAAS,GAAG;;;;;;;;;;;qBAWO,OAAO,aAAa;;;aAG5B,OAAO,UAAU;;;;;4BAKF,OAAO,cAAc;;;;;;+CAMF,OAAO,kBAAkB;;;MAGlE,UAAU;;;;;;;;;;;;;eAaD,OAAO,kBAAkB;;;;;;;;;;eAUzB,OAAO,mBAAmB;;;;;;;;;;;;;CAavC,cAAc,GAAG;kBACD,cAAc,MAAM;;;;;;;CAOpC,eAAe,GAAG;kBACF,cAAc,OAAO;;;;;;;CAOrC,cAAc,GAAG;kBACD,cAAc,MAAM;;;;;;;CAOpC,OAAO,GAAG;;;;;;;;;;;;eAYG,OAAO,qBAAqB;;;CAGzC,WAAW,GAAG;;;;;AAKhB,EAAE;AAEF,MAAa,kBAAkB,IAAI,OAAO,SAAS;CACjD,iBAAiB;EACf,QAAQ;EACR,MAAM;EACN,SAAS;CACX;CACA,UAAU;EACR,QAAQ;GACN,OAAO;GACP,MAAM,OAAO;EACf;EACA,MAAM;GACJ,OAAO,OAAO;GACd,QAAQ,OAAO;GACf,OAAO,OAAO;EAChB;EACA,SAAS;GACP,YAAY,OAAO;GACnB,QAAQ,OAAO;GACf,UAAU,OAAO;EACnB;CACF;AACF,CAAC"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { IconProps } from "../../Icon/type.mjs";
|
|
2
2
|
import "../../Icon/index.mjs";
|
|
3
|
+
import { VirtualListProps } from "../virtual/type.mjs";
|
|
4
|
+
import "../virtual/index.mjs";
|
|
3
5
|
import { CSSProperties, ReactNode } from "react";
|
|
4
6
|
import { SelectRootChangeEventDetails } from "@base-ui/react/select";
|
|
5
7
|
//#region src/base-ui/Select/type.d.ts
|
|
@@ -46,7 +48,7 @@ interface SelectClassNames {
|
|
|
46
48
|
trigger?: string;
|
|
47
49
|
value?: string;
|
|
48
50
|
}
|
|
49
|
-
interface SelectProps<Value = string> {
|
|
51
|
+
interface SelectProps<Value = string> extends Pick<VirtualListProps, 'virtual' | 'listItemHeight'> {
|
|
50
52
|
allowClear?: boolean;
|
|
51
53
|
autoFocus?: boolean;
|
|
52
54
|
/**
|
|
@@ -69,7 +71,6 @@ interface SelectProps<Value = string> {
|
|
|
69
71
|
* @default 512
|
|
70
72
|
*/
|
|
71
73
|
listHeight?: number;
|
|
72
|
-
listItemHeight?: number;
|
|
73
74
|
loading?: boolean;
|
|
74
75
|
mode?: 'multiple' | 'tags';
|
|
75
76
|
name?: string;
|
|
@@ -103,7 +104,6 @@ interface SelectProps<Value = string> {
|
|
|
103
104
|
tokenSeparators?: string[];
|
|
104
105
|
value?: Value | Value[] | null;
|
|
105
106
|
variant?: SelectVariant;
|
|
106
|
-
virtual?: boolean;
|
|
107
107
|
}
|
|
108
108
|
//#endregion
|
|
109
109
|
export { SelectBehaviorVariant, SelectClassNames, SelectIndicatorVariant, SelectOption, SelectOptionGroup, SelectOptions, SelectProps, type SelectRootChangeEventDetails, SelectSize, SelectVariant };
|
package/es/base-ui/index.d.mts
CHANGED
|
@@ -6,6 +6,9 @@ import { ActionIconClassNames, ActionIconOutdent, ActionIconProps, ActionIconSiz
|
|
|
6
6
|
import ActionIcon from "./ActionIcon/ActionIcon.mjs";
|
|
7
7
|
import { styles as styles$1 } from "./ActionIcon/style.mjs";
|
|
8
8
|
import "./ActionIcon/index.mjs";
|
|
9
|
+
import { VirtualListProps } from "./virtual/type.mjs";
|
|
10
|
+
import { ScrollAreaContent, ScrollAreaContentProps, ScrollAreaCorner, ScrollAreaCornerProps, ScrollAreaRoot, ScrollAreaRootProps, ScrollAreaScrollbar, ScrollAreaScrollbarProps, ScrollAreaThumb, ScrollAreaThumbProps, ScrollAreaViewport, ScrollAreaViewportProps } from "./ScrollArea/atoms.mjs";
|
|
11
|
+
import "./virtual/index.mjs";
|
|
9
12
|
import { IconSpaceMode } from "../Menu/renderUtils.mjs";
|
|
10
13
|
import { renderDropdownMenuItems } from "./DropdownMenu/renderItems.mjs";
|
|
11
14
|
import { DropdownItem, DropdownMenuCheckboxItem, DropdownMenuPlacement, DropdownMenuProps, DropdownMenuSwitchItem as DropdownMenuSwitchItem$1 } from "./DropdownMenu/type.mjs";
|
|
@@ -27,7 +30,6 @@ import Popover from "./Popover/Popover.mjs";
|
|
|
27
30
|
import PopoverGroup from "./Popover/PopoverGroup.mjs";
|
|
28
31
|
import { usePopoverPortalContainer } from "./Popover/PopoverPortal.mjs";
|
|
29
32
|
import "./Popover/index.mjs";
|
|
30
|
-
import { ScrollAreaContent, ScrollAreaContentProps, ScrollAreaCorner, ScrollAreaCornerProps, ScrollAreaRoot, ScrollAreaRootProps, ScrollAreaScrollbar, ScrollAreaScrollbarProps, ScrollAreaThumb, ScrollAreaThumbProps, ScrollAreaViewport, ScrollAreaViewportProps } from "./ScrollArea/atoms.mjs";
|
|
31
33
|
import { ScrollAreaProps } from "./ScrollArea/type.mjs";
|
|
32
34
|
import { ScrollArea } from "./ScrollArea/ScrollArea.mjs";
|
|
33
35
|
import "./ScrollArea/index.mjs";
|
|
@@ -148,4 +150,4 @@ import { styles as styles$12 } from "./ToggleGroup/style.mjs";
|
|
|
148
150
|
import { ToggleGroupItem, ToggleGroupItemIcon, ToggleGroupItemLabel, ToggleGroupItemProps, ToggleGroupRoot, ToggleGroupRootProps } from "./ToggleGroup/atoms.mjs";
|
|
149
151
|
import ToggleGroup from "./ToggleGroup/ToggleGroup.mjs";
|
|
150
152
|
import "./ToggleGroup/index.mjs";
|
|
151
|
-
export { Accordion, type AccordionClassNames, AccordionHeader, type AccordionHeaderProps, type AccordionIndicatorPlacement, AccordionItem, type AccordionItemProps, type AccordionItemType, AccordionPanel, type AccordionPanelProps, type AccordionProps, AccordionRoot, type AccordionRootProps, type AccordionStyles, AccordionTrigger, type AccordionTriggerProps, type AccordionVariant, ActionIcon, type ActionIconClassNames, type ActionIconOutdent, type ActionIconProps, type ActionIconSize, type ActionIconStyles, type ActionIconVariant, Alert, type AlertClassNames, type AlertCloseConfig, type AlertProps, type AlertRef, type AlertStyles, type AlertType, type AlertVariant, AutoComplete, type AutoCompleteOption, type AutoCompleteProps, Avatar, type AvatarClassNames, AvatarGroup, type AvatarGroupItemType, type AvatarGroupProps, type AvatarProps, type AvatarStyles, type BaseModalProps, Button, type ButtonIconPosition, type ButtonOutdent, type ButtonProps, type ButtonShape, type ButtonSize, type ButtonType, Checkbox, CheckboxGroup, type CheckboxGroupOption, type CheckboxGroupProps, type CheckboxProps, type CheckboxShape, type ContextMenuCheckboxItem, ContextMenuHost, type ContextMenuInterceptor, type ContextMenuItem, ContextMenuTrigger, type ControlSize, DraggablePanel, DraggablePanelBody, type DraggablePanelBodyProps, DraggablePanelContainer, type DraggablePanelContainerProps, DraggablePanelContent, type DraggablePanelContentProps, DraggablePanelFooter, type DraggablePanelFooterProps, DraggablePanelHandle, type DraggablePanelHandleProps, DraggablePanelHeader, type DraggablePanelHeaderProps, type DraggablePanelPlacement, type DraggablePanelProps, DraggablePanelRoot, type DraggablePanelRootProps, type DraggablePanelSize, DraggablePanelToggle, type DraggablePanelToggleProps, Drawer, DrawerBackdrop, type DrawerBackdropProps, DrawerClose, type DrawerCloseProps, DrawerContent, type DrawerContentProps, DrawerDescription, type DrawerDescriptionProps, DrawerFooter, type DrawerFooterProps, DrawerHeader, type DrawerHeaderProps, type DrawerPlacement, DrawerPopup, type DrawerPopupProps, DrawerPortal, type DrawerPortalProps, type DrawerProps, type DrawerPush, DrawerRoot, type DrawerRootProps, type DrawerSemanticNames, type DrawerSemanticStyles, DrawerTitle, type DrawerTitleProps, DrawerTrigger, type DrawerTriggerProps, type DropdownItem, DropdownMenu, type DropdownMenuCheckboxItem, DropdownMenuCheckboxItemIndicator, DropdownMenuCheckboxItemPrimitive, type DropdownMenuCheckboxItemProps, DropdownMenuFooter, type DropdownMenuFooterProps, DropdownMenuGroup, DropdownMenuGroupLabel, type DropdownMenuGroupLabelProps, DropdownMenuHeader, type DropdownMenuHeaderProps, DropdownMenuItem, DropdownMenuItemContent, type DropdownMenuItemContentProps, DropdownMenuItemDesc, type DropdownMenuItemDescProps, DropdownMenuItemExtra, type DropdownMenuItemExtraProps, DropdownMenuItemIcon, type DropdownMenuItemIconProps, DropdownMenuItemLabel, DropdownMenuItemLabelGroup, type DropdownMenuItemLabelGroupProps, type DropdownMenuItemLabelProps, type DropdownMenuItemProps, type DropdownMenuPlacement, DropdownMenuPopup, type DropdownMenuPopupProps, DropdownMenuPortal, type DropdownMenuPortalProps, DropdownMenuPositioner, type DropdownMenuPositionerProps, type DropdownMenuProps, DropdownMenuRoot, DropdownMenuScrollViewport, type DropdownMenuScrollViewportProps, DropdownMenuSeparator, type DropdownMenuSeparatorProps, DropdownMenuSubmenuArrow, type DropdownMenuSubmenuArrowProps, DropdownMenuSubmenuRoot, DropdownMenuSubmenuTrigger, type DropdownMenuSubmenuTriggerProps, DropdownMenuSwitchItem, type DropdownMenuSwitchItemProps, type DropdownMenuSwitchItem$1 as DropdownMenuSwitchItemType, DropdownMenuTrigger, type DropdownMenuTriggerProps, type FloatingCollisionPadding, FloatingPanel, type FloatingPanelOffset, type FloatingPanelPlacement, type FloatingPanelProps, FloatingSheet, type FloatingSheetProps, Form, type FormContextValue, FormDivider, type FormDividerProps, FormField, type FormFieldProps, FormFlatGroup, type FormFlatGroupProps, FormFooter, type FormFooterProps, FormGroup, type FormGroupItemType, type FormGroupProps, type FormLayout, type FormProps, FormSubmitFooter, type FormSubmitFooterProps, FormTitle, type FormTitleProps, type FormValues, type FormVariant, type IconSpaceMode, type ImperativeModalProps, Input, type InputClassNames, InputNumber, type InputNumberProps, InputOTP, type InputOTPProps, InputPassword, type InputPasswordProps, type InputProps, type InputSize, type InputStyles, type InputVariant, type ItemsType, Modal, ModalBackdrop, type ModalBackdropProps, ModalClose, type ModalCloseProps, type ModalComponentProps, type ModalConfirmConfig, ModalContent, type ModalContentProps, ModalContext, type ModalContextValue, ModalDescription, type ModalDescriptionProps, ModalFooter, type ModalFooterProps, ModalHeader, type ModalHeaderProps, ModalHost, type ModalHostProps, type ModalInstance, ModalPopup, type ModalPopupProps, ModalPortal, type ModalPortalProps, ModalRoot, type ModalRootProps, type ModalSystem, ModalTitle, type ModalTitleProps, ModalTrigger, type ModalTriggerProps, ModalViewport, type ModalViewportProps, Popover, PopoverArrow, type PopoverArrowAtomProps, PopoverArrowIcon, PopoverBackdrop, type PopoverBackdropProps, type PopoverContextValue, PopoverGroup, type PopoverGroupHandle, type PopoverGroupItem, type PopoverPlacement, PopoverPopup, type PopoverPopupAtomProps, type PopoverPopupProps, PopoverPortal, type PopoverPortalAtomProps, type PopoverPortalProps, PopoverPositioner, type PopoverPositionerAtomProps, type PopoverPositionerProps, type PopoverProps, PopoverProvider, PopoverRoot, type PopoverTrigger, type PopoverTriggerComponentProps, PopoverTriggerElement, type PopoverTriggerElementProps, PopoverViewport, type PopoverViewportAtomProps, Radio, RadioGroup, type RadioGroupOption, type RadioGroupProps, type RadioProps, ScrollArea, ScrollAreaContent, type ScrollAreaContentProps, ScrollAreaCorner, type ScrollAreaCornerProps, type ScrollAreaProps, ScrollAreaRoot, type ScrollAreaRootProps, ScrollAreaScrollbar, type ScrollAreaScrollbarProps, ScrollAreaThumb, type ScrollAreaThumbProps, ScrollAreaViewport, type ScrollAreaViewportProps, Segmented, type SegmentedClassNames, SegmentedIndicator, type SegmentedIndicatorProps, SegmentedItem, SegmentedItemIcon, SegmentedItemLabel, type SegmentedItemProps, type SegmentedOption, type SegmentedOptions, type SegmentedOrientation, type SegmentedProps, SegmentedRoot, type SegmentedRootProps, type SegmentedSize, type SegmentedStyles, type SegmentedVariant, Select, SelectArrow, type SelectArrowProps, SelectBackdrop, type SelectBehaviorVariant, type SelectClassNames, SelectGroup, SelectGroupLabel, type SelectGroupLabelProps, type SelectGroupProps, SelectIcon, type SelectIconProps, type SelectIndicatorVariant, SelectItem, SelectItemIndicator, type SelectItemIndicatorProps, type SelectItemProps, SelectItemText, type SelectItemTextProps, SelectList, type SelectListProps, type SelectOption, type SelectOptionGroup, type SelectOptions, SelectPopup, type SelectPopupProps, SelectPortal, type SelectPortalProps, SelectPositioner, type SelectPositionerProps, type SelectProps, SelectRoot, type SelectRootChangeEventDetails, SelectScrollDownArrow, type SelectScrollDownArrowProps, SelectScrollUpArrow, type SelectScrollUpArrowProps, SelectSeparator, type SelectSize, SelectTrigger, type SelectTriggerProps, SelectValue, type SelectValueProps, type SelectVariant, Skeleton, type SkeletonAnimation, SkeletonAvatar, type SkeletonAvatarProps, type SkeletonProps, SkeletonText, type SkeletonTextProps, Slider, type SliderProps, SliderWithInput, type SliderWithInputProps, _default as SplitButton, type SplitButtonMenuProps, type SplitButtonProps, Switch, type SwitchChangeEventHandler, type SwitchClassNames, type SwitchClickEventHandler, type SwitchContextType, SwitchIcon, type SwitchIconPosition, type SwitchIconProps, type SwitchProps, SwitchRoot, type SwitchRootProps, type SwitchSize, type SwitchStyles, SwitchThumb, type SwitchThumbProps, Tabs, type TabsClassNames, TabsIndicator, type TabsIndicatorProps, type TabsItem, TabsList, type TabsListProps, type TabsOrientation, TabsPanel, type TabsPanelProps, type TabsProps, TabsRoot, type TabsRootProps, type TabsSize, type TabsStyles, TabsTab, type TabsTabProps, type TabsVariant, Tag, type TagClassNames, type TagProps, type TagShape, type TagSize, type TagStyles, type TagVariant, Text, TextArea, type TextAreaAutoSize, type TextAreaProps, type TextClassNames, type TextProps, type TextStyles, type ToastAPI, ToastHost, type ToastHostProps, type ToastInstance, type ToastOptions, type ToastPosition, type ToastPromiseOptions, type ToastProps, type ToastType, ToggleGroup, type ToggleGroupClassNames, ToggleGroupItem, ToggleGroupItemIcon, ToggleGroupItemLabel, type ToggleGroupItemProps, type ToggleGroupOption, type ToggleGroupProps, ToggleGroupRoot, type ToggleGroupRootProps, type ToggleGroupSize, type ToggleGroupStyles, type ToggleGroupVariant, Tooltip, TooltipGroup, type TooltipGroupProps, type TooltipPlacement, type TooltipPopupComponentProps, type TooltipPortalProps, type TooltipPositionerProps, type TooltipProps, type TooltipTriggerComponentProps, styles as accordionStyles, styles$1 as actionIconStyles, styles$2 as alertStyles, styles$3 as autoCompleteStyles, backdropTransition, buttonPaddingInline, styles$4 as buttonStyles, styles$5 as checkboxStyles, closeContextMenu, colorsPreset, colorsPresetSystem, confirmModal, controlHeight, createModal, createModalSystem, drawerBackdropTransition, getDrawerMotionConfig, getFloatingCollisionPadding, styles$6 as inputStyles, rootVariants as inputVariants, modalMotionConfig, parseTrigger, presetColors, presetSystemColors, styles$7 as radioStyles, renderDropdownMenuItems, setContextMenuInterceptor, setFloatingCollisionPadding, showContextMenu, styles$8 as sliderStyles, styles$9 as switchStyles, styles$10 as tabsStyles, groupStyles as textGroupStyles, styles$11 as textStyles, variants as textVariants, toast, styles$12 as toggleGroupStyles, updateContextMenuItems, useAccordionContext, useDraggablePanelContext, useDrawerActions, useDrawerOpen, useFormContext, useModalActions, useModalContext, useModalOpen, usePopoverContext, usePopoverGroupHandle, usePopoverPortalContainer, useSwitchContext, useTabsContext, useToast };
|
|
153
|
+
export { Accordion, type AccordionClassNames, AccordionHeader, type AccordionHeaderProps, type AccordionIndicatorPlacement, AccordionItem, type AccordionItemProps, type AccordionItemType, AccordionPanel, type AccordionPanelProps, type AccordionProps, AccordionRoot, type AccordionRootProps, type AccordionStyles, AccordionTrigger, type AccordionTriggerProps, type AccordionVariant, ActionIcon, type ActionIconClassNames, type ActionIconOutdent, type ActionIconProps, type ActionIconSize, type ActionIconStyles, type ActionIconVariant, Alert, type AlertClassNames, type AlertCloseConfig, type AlertProps, type AlertRef, type AlertStyles, type AlertType, type AlertVariant, AutoComplete, type AutoCompleteOption, type AutoCompleteProps, Avatar, type AvatarClassNames, AvatarGroup, type AvatarGroupItemType, type AvatarGroupProps, type AvatarProps, type AvatarStyles, type BaseModalProps, Button, type ButtonIconPosition, type ButtonOutdent, type ButtonProps, type ButtonShape, type ButtonSize, type ButtonType, Checkbox, CheckboxGroup, type CheckboxGroupOption, type CheckboxGroupProps, type CheckboxProps, type CheckboxShape, type ContextMenuCheckboxItem, ContextMenuHost, type ContextMenuInterceptor, type ContextMenuItem, ContextMenuTrigger, type ControlSize, DraggablePanel, DraggablePanelBody, type DraggablePanelBodyProps, DraggablePanelContainer, type DraggablePanelContainerProps, DraggablePanelContent, type DraggablePanelContentProps, DraggablePanelFooter, type DraggablePanelFooterProps, DraggablePanelHandle, type DraggablePanelHandleProps, DraggablePanelHeader, type DraggablePanelHeaderProps, type DraggablePanelPlacement, type DraggablePanelProps, DraggablePanelRoot, type DraggablePanelRootProps, type DraggablePanelSize, DraggablePanelToggle, type DraggablePanelToggleProps, Drawer, DrawerBackdrop, type DrawerBackdropProps, DrawerClose, type DrawerCloseProps, DrawerContent, type DrawerContentProps, DrawerDescription, type DrawerDescriptionProps, DrawerFooter, type DrawerFooterProps, DrawerHeader, type DrawerHeaderProps, type DrawerPlacement, DrawerPopup, type DrawerPopupProps, DrawerPortal, type DrawerPortalProps, type DrawerProps, type DrawerPush, DrawerRoot, type DrawerRootProps, type DrawerSemanticNames, type DrawerSemanticStyles, DrawerTitle, type DrawerTitleProps, DrawerTrigger, type DrawerTriggerProps, type DropdownItem, DropdownMenu, type DropdownMenuCheckboxItem, DropdownMenuCheckboxItemIndicator, DropdownMenuCheckboxItemPrimitive, type DropdownMenuCheckboxItemProps, DropdownMenuFooter, type DropdownMenuFooterProps, DropdownMenuGroup, DropdownMenuGroupLabel, type DropdownMenuGroupLabelProps, DropdownMenuHeader, type DropdownMenuHeaderProps, DropdownMenuItem, DropdownMenuItemContent, type DropdownMenuItemContentProps, DropdownMenuItemDesc, type DropdownMenuItemDescProps, DropdownMenuItemExtra, type DropdownMenuItemExtraProps, DropdownMenuItemIcon, type DropdownMenuItemIconProps, DropdownMenuItemLabel, DropdownMenuItemLabelGroup, type DropdownMenuItemLabelGroupProps, type DropdownMenuItemLabelProps, type DropdownMenuItemProps, type DropdownMenuPlacement, DropdownMenuPopup, type DropdownMenuPopupProps, DropdownMenuPortal, type DropdownMenuPortalProps, DropdownMenuPositioner, type DropdownMenuPositionerProps, type DropdownMenuProps, DropdownMenuRoot, DropdownMenuScrollViewport, type DropdownMenuScrollViewportProps, DropdownMenuSeparator, type DropdownMenuSeparatorProps, DropdownMenuSubmenuArrow, type DropdownMenuSubmenuArrowProps, DropdownMenuSubmenuRoot, DropdownMenuSubmenuTrigger, type DropdownMenuSubmenuTriggerProps, DropdownMenuSwitchItem, type DropdownMenuSwitchItemProps, type DropdownMenuSwitchItem$1 as DropdownMenuSwitchItemType, DropdownMenuTrigger, type DropdownMenuTriggerProps, type FloatingCollisionPadding, FloatingPanel, type FloatingPanelOffset, type FloatingPanelPlacement, type FloatingPanelProps, FloatingSheet, type FloatingSheetProps, Form, type FormContextValue, FormDivider, type FormDividerProps, FormField, type FormFieldProps, FormFlatGroup, type FormFlatGroupProps, FormFooter, type FormFooterProps, FormGroup, type FormGroupItemType, type FormGroupProps, type FormLayout, type FormProps, FormSubmitFooter, type FormSubmitFooterProps, FormTitle, type FormTitleProps, type FormValues, type FormVariant, type IconSpaceMode, type ImperativeModalProps, Input, type InputClassNames, InputNumber, type InputNumberProps, InputOTP, type InputOTPProps, InputPassword, type InputPasswordProps, type InputProps, type InputSize, type InputStyles, type InputVariant, type ItemsType, Modal, ModalBackdrop, type ModalBackdropProps, ModalClose, type ModalCloseProps, type ModalComponentProps, type ModalConfirmConfig, ModalContent, type ModalContentProps, ModalContext, type ModalContextValue, ModalDescription, type ModalDescriptionProps, ModalFooter, type ModalFooterProps, ModalHeader, type ModalHeaderProps, ModalHost, type ModalHostProps, type ModalInstance, ModalPopup, type ModalPopupProps, ModalPortal, type ModalPortalProps, ModalRoot, type ModalRootProps, type ModalSystem, ModalTitle, type ModalTitleProps, ModalTrigger, type ModalTriggerProps, ModalViewport, type ModalViewportProps, Popover, PopoverArrow, type PopoverArrowAtomProps, PopoverArrowIcon, PopoverBackdrop, type PopoverBackdropProps, type PopoverContextValue, PopoverGroup, type PopoverGroupHandle, type PopoverGroupItem, type PopoverPlacement, PopoverPopup, type PopoverPopupAtomProps, type PopoverPopupProps, PopoverPortal, type PopoverPortalAtomProps, type PopoverPortalProps, PopoverPositioner, type PopoverPositionerAtomProps, type PopoverPositionerProps, type PopoverProps, PopoverProvider, PopoverRoot, type PopoverTrigger, type PopoverTriggerComponentProps, PopoverTriggerElement, type PopoverTriggerElementProps, PopoverViewport, type PopoverViewportAtomProps, Radio, RadioGroup, type RadioGroupOption, type RadioGroupProps, type RadioProps, ScrollArea, ScrollAreaContent, type ScrollAreaContentProps, ScrollAreaCorner, type ScrollAreaCornerProps, type ScrollAreaProps, ScrollAreaRoot, type ScrollAreaRootProps, ScrollAreaScrollbar, type ScrollAreaScrollbarProps, ScrollAreaThumb, type ScrollAreaThumbProps, ScrollAreaViewport, type ScrollAreaViewportProps, Segmented, type SegmentedClassNames, SegmentedIndicator, type SegmentedIndicatorProps, SegmentedItem, SegmentedItemIcon, SegmentedItemLabel, type SegmentedItemProps, type SegmentedOption, type SegmentedOptions, type SegmentedOrientation, type SegmentedProps, SegmentedRoot, type SegmentedRootProps, type SegmentedSize, type SegmentedStyles, type SegmentedVariant, Select, SelectArrow, type SelectArrowProps, SelectBackdrop, type SelectBehaviorVariant, type SelectClassNames, SelectGroup, SelectGroupLabel, type SelectGroupLabelProps, type SelectGroupProps, SelectIcon, type SelectIconProps, type SelectIndicatorVariant, SelectItem, SelectItemIndicator, type SelectItemIndicatorProps, type SelectItemProps, SelectItemText, type SelectItemTextProps, SelectList, type SelectListProps, type SelectOption, type SelectOptionGroup, type SelectOptions, SelectPopup, type SelectPopupProps, SelectPortal, type SelectPortalProps, SelectPositioner, type SelectPositionerProps, type SelectProps, SelectRoot, type SelectRootChangeEventDetails, SelectScrollDownArrow, type SelectScrollDownArrowProps, SelectScrollUpArrow, type SelectScrollUpArrowProps, SelectSeparator, type SelectSize, SelectTrigger, type SelectTriggerProps, SelectValue, type SelectValueProps, type SelectVariant, Skeleton, type SkeletonAnimation, SkeletonAvatar, type SkeletonAvatarProps, type SkeletonProps, SkeletonText, type SkeletonTextProps, Slider, type SliderProps, SliderWithInput, type SliderWithInputProps, _default as SplitButton, type SplitButtonMenuProps, type SplitButtonProps, Switch, type SwitchChangeEventHandler, type SwitchClassNames, type SwitchClickEventHandler, type SwitchContextType, SwitchIcon, type SwitchIconPosition, type SwitchIconProps, type SwitchProps, SwitchRoot, type SwitchRootProps, type SwitchSize, type SwitchStyles, SwitchThumb, type SwitchThumbProps, Tabs, type TabsClassNames, TabsIndicator, type TabsIndicatorProps, type TabsItem, TabsList, type TabsListProps, type TabsOrientation, TabsPanel, type TabsPanelProps, type TabsProps, TabsRoot, type TabsRootProps, type TabsSize, type TabsStyles, TabsTab, type TabsTabProps, type TabsVariant, Tag, type TagClassNames, type TagProps, type TagShape, type TagSize, type TagStyles, type TagVariant, Text, TextArea, type TextAreaAutoSize, type TextAreaProps, type TextClassNames, type TextProps, type TextStyles, type ToastAPI, ToastHost, type ToastHostProps, type ToastInstance, type ToastOptions, type ToastPosition, type ToastPromiseOptions, type ToastProps, type ToastType, ToggleGroup, type ToggleGroupClassNames, ToggleGroupItem, ToggleGroupItemIcon, ToggleGroupItemLabel, type ToggleGroupItemProps, type ToggleGroupOption, type ToggleGroupProps, ToggleGroupRoot, type ToggleGroupRootProps, type ToggleGroupSize, type ToggleGroupStyles, type ToggleGroupVariant, Tooltip, TooltipGroup, type TooltipGroupProps, type TooltipPlacement, type TooltipPopupComponentProps, type TooltipPortalProps, type TooltipPositionerProps, type TooltipProps, type TooltipTriggerComponentProps, type VirtualListProps, styles as accordionStyles, styles$1 as actionIconStyles, styles$2 as alertStyles, styles$3 as autoCompleteStyles, backdropTransition, buttonPaddingInline, styles$4 as buttonStyles, styles$5 as checkboxStyles, closeContextMenu, colorsPreset, colorsPresetSystem, confirmModal, controlHeight, createModal, createModalSystem, drawerBackdropTransition, getDrawerMotionConfig, getFloatingCollisionPadding, styles$6 as inputStyles, rootVariants as inputVariants, modalMotionConfig, parseTrigger, presetColors, presetSystemColors, styles$7 as radioStyles, renderDropdownMenuItems, setContextMenuInterceptor, setFloatingCollisionPadding, showContextMenu, styles$8 as sliderStyles, styles$9 as switchStyles, styles$10 as tabsStyles, groupStyles as textGroupStyles, styles$11 as textStyles, variants as textVariants, toast, styles$12 as toggleGroupStyles, updateContextMenuItems, useAccordionContext, useDraggablePanelContext, useDrawerActions, useDrawerOpen, useFormContext, useModalActions, useModalContext, useModalOpen, usePopoverContext, usePopoverGroupHandle, usePopoverPortalContainer, useSwitchContext, useTabsContext, useToast };
|
package/es/base-ui/index.mjs
CHANGED
|
@@ -7,6 +7,7 @@ import Button from "./Button/Button.mjs";
|
|
|
7
7
|
import { styles as styles$9 } from "./Switch/style.mjs";
|
|
8
8
|
import { SwitchIcon, SwitchRoot, SwitchThumb, useSwitchContext } from "./Switch/atoms.mjs";
|
|
9
9
|
import Switch from "./Switch/Switch.mjs";
|
|
10
|
+
import { ScrollAreaContent, ScrollAreaCorner, ScrollAreaRoot, ScrollAreaScrollbar, ScrollAreaThumb, ScrollAreaViewport } from "./ScrollArea/atoms.mjs";
|
|
10
11
|
import { DropdownMenuCheckboxItemIndicator, DropdownMenuCheckboxItemPrimitive, DropdownMenuFooter, DropdownMenuGroup, DropdownMenuGroupLabel, DropdownMenuHeader, DropdownMenuItem, DropdownMenuItemContent, DropdownMenuItemDesc, DropdownMenuItemExtra, DropdownMenuItemIcon, DropdownMenuItemLabel, DropdownMenuItemLabelGroup, DropdownMenuPopup, DropdownMenuPortal, DropdownMenuPositioner, DropdownMenuRoot, DropdownMenuScrollViewport, DropdownMenuSeparator, DropdownMenuSubmenuArrow, DropdownMenuSubmenuRoot, DropdownMenuSubmenuTrigger, DropdownMenuSwitchItem, DropdownMenuTrigger } from "./DropdownMenu/atoms.mjs";
|
|
11
12
|
import { parseTrigger } from "../utils/parseTrigger.mjs";
|
|
12
13
|
import { renderDropdownMenuItems } from "./DropdownMenu/renderItems.mjs";
|
|
@@ -28,7 +29,6 @@ import SkeletonAvatar from "./Skeleton/SkeletonAvatar.mjs";
|
|
|
28
29
|
import SkeletonText from "./Skeleton/SkeletonText.mjs";
|
|
29
30
|
import Skeleton from "./Skeleton/index.mjs";
|
|
30
31
|
import { ToastHost, toast, useToast } from "./Toast/imperative.mjs";
|
|
31
|
-
import { ScrollAreaContent, ScrollAreaCorner, ScrollAreaRoot, ScrollAreaScrollbar, ScrollAreaThumb, ScrollAreaViewport } from "./ScrollArea/atoms.mjs";
|
|
32
32
|
import { ScrollArea } from "./ScrollArea/ScrollArea.mjs";
|
|
33
33
|
import { styles } from "./Accordion/style.mjs";
|
|
34
34
|
import { AccordionHeader, AccordionItem, AccordionPanel, AccordionRoot, AccordionTrigger, useAccordionContext } from "./Accordion/atoms.mjs";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { VirtualScrollArea } from "./VirtualScrollArea.mjs";
|
|
3
|
+
import { useMenuVirtualList } from "./useMenuVirtualList.mjs";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
//#region src/base-ui/virtual/MenuVirtualList.tsx
|
|
6
|
+
const MenuVirtualList = ({ children, getItemLabel, keepMounted, ...rest }) => {
|
|
7
|
+
const { keepMountedIndices, viewportProps, viewportRef, virtualChildren, virtualizerRef } = useMenuVirtualList({
|
|
8
|
+
children,
|
|
9
|
+
enabled: true,
|
|
10
|
+
getItemLabel,
|
|
11
|
+
keepMounted
|
|
12
|
+
});
|
|
13
|
+
return /* @__PURE__ */ jsx(VirtualScrollArea, {
|
|
14
|
+
...rest,
|
|
15
|
+
keepMounted: keepMountedIndices,
|
|
16
|
+
viewportProps: {
|
|
17
|
+
ref: viewportRef,
|
|
18
|
+
...viewportProps
|
|
19
|
+
},
|
|
20
|
+
virtualizerRef,
|
|
21
|
+
children: virtualChildren
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
MenuVirtualList.displayName = "MenuVirtualList";
|
|
25
|
+
//#endregion
|
|
26
|
+
export { MenuVirtualList };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=MenuVirtualList.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MenuVirtualList.mjs","names":[],"sources":["../../../src/base-ui/virtual/MenuVirtualList.tsx"],"sourcesContent":["'use client';\n\nimport { type ReactNode } from 'react';\n\nimport type { VirtualListProps } from './type';\nimport { useMenuVirtualList } from './useMenuVirtualList';\nimport { VirtualScrollArea, type VirtualScrollAreaProps } from './VirtualScrollArea';\n\nexport interface MenuVirtualListProps\n extends\n Omit<VirtualScrollAreaProps, 'viewport' | 'viewportProps' | 'virtualizerRef'>,\n Pick<VirtualListProps, 'getItemLabel' | 'keepMounted'> {\n children: ReactNode;\n}\n\nexport const MenuVirtualList = ({\n children,\n getItemLabel,\n keepMounted,\n ...rest\n}: MenuVirtualListProps) => {\n const { keepMountedIndices, viewportProps, viewportRef, virtualChildren, virtualizerRef } =\n useMenuVirtualList({ children, enabled: true, getItemLabel, keepMounted });\n\n return (\n <VirtualScrollArea\n {...rest}\n keepMounted={keepMountedIndices}\n viewportProps={{ ref: viewportRef, ...viewportProps }}\n virtualizerRef={virtualizerRef}\n >\n {virtualChildren}\n </VirtualScrollArea>\n );\n};\n\nMenuVirtualList.displayName = 'MenuVirtualList';\n"],"mappings":";;;;;AAeA,MAAa,mBAAmB,EAC9B,UACA,cACA,aACA,GAAG,WACuB;CAC1B,MAAM,EAAE,oBAAoB,eAAe,aAAa,iBAAiB,mBACvE,mBAAmB;EAAE;EAAU,SAAS;EAAM;EAAc;CAAY,CAAC;CAE3E,OACE,oBAAC,mBAAD;EACE,GAAI;EACJ,aAAa;EACb,eAAe;GAAE,KAAK;GAAa,GAAG;EAAc;EACpC;EAEf,UAAA;CACgB,CAAA;AAEvB;AAEA,gBAAgB,cAAc"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { ScrollAreaRoot, ScrollAreaScrollbar, ScrollAreaThumb, ScrollAreaViewport } from "../ScrollArea/atoms.mjs";
|
|
3
|
+
import { cloneElement, useCallback, useEffect, useRef } from "react";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { createStaticStyles, cx } from "antd-style";
|
|
6
|
+
import { useMergeRefs } from "react-merge-refs";
|
|
7
|
+
import { Virtualizer } from "virtua";
|
|
8
|
+
//#region src/base-ui/virtual/VirtualScrollArea.tsx
|
|
9
|
+
const styles = createStaticStyles(({ css }) => ({
|
|
10
|
+
root: css`
|
|
11
|
+
display: flex;
|
|
12
|
+
flex: 1;
|
|
13
|
+
flex-direction: column;
|
|
14
|
+
|
|
15
|
+
min-height: 0;
|
|
16
|
+
margin-inline: calc(-1 * var(--lobe-virtual-scroll-inset, 0px));
|
|
17
|
+
`,
|
|
18
|
+
viewport: css`
|
|
19
|
+
flex: 1;
|
|
20
|
+
height: auto;
|
|
21
|
+
min-height: 0;
|
|
22
|
+
padding-inline: var(--lobe-virtual-scroll-inset, 0);
|
|
23
|
+
`
|
|
24
|
+
}));
|
|
25
|
+
const INITIAL_ROW_COUNT = 20;
|
|
26
|
+
const VirtualScrollArea = ({ children, className, itemSize, keepMounted, viewport, viewportProps, virtualizerRef, ...rest }) => {
|
|
27
|
+
const viewportRef = useRef(null);
|
|
28
|
+
const mergedViewportRef = useMergeRefs([viewportRef, viewportProps?.ref]);
|
|
29
|
+
const list = /* @__PURE__ */ jsx(Virtualizer, {
|
|
30
|
+
itemSize,
|
|
31
|
+
keepMounted,
|
|
32
|
+
ref: virtualizerRef,
|
|
33
|
+
scrollRef: viewportRef,
|
|
34
|
+
ssrCount: INITIAL_ROW_COUNT,
|
|
35
|
+
children
|
|
36
|
+
});
|
|
37
|
+
const viewportElement = /* @__PURE__ */ jsx(ScrollAreaViewport, {
|
|
38
|
+
tabIndex: -1,
|
|
39
|
+
...viewportProps,
|
|
40
|
+
className: cx(styles.viewport, viewportProps?.className),
|
|
41
|
+
ref: mergedViewportRef
|
|
42
|
+
});
|
|
43
|
+
return /* @__PURE__ */ jsxs(ScrollAreaRoot, {
|
|
44
|
+
"data-virtual": "",
|
|
45
|
+
...rest,
|
|
46
|
+
className: cx(styles.root, className),
|
|
47
|
+
children: [cloneElement(viewport ?? viewportElement, {
|
|
48
|
+
children: list,
|
|
49
|
+
...viewport && { render: viewportElement }
|
|
50
|
+
}), /* @__PURE__ */ jsx(ScrollAreaScrollbar, { children: /* @__PURE__ */ jsx(ScrollAreaThumb, {}) })]
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
VirtualScrollArea.displayName = "VirtualScrollArea";
|
|
54
|
+
function usePointerScrollGuard() {
|
|
55
|
+
const pointerScrollRef = useRef(false);
|
|
56
|
+
const timeoutRef = useRef(null);
|
|
57
|
+
const markPointerScroll = useCallback(() => {
|
|
58
|
+
pointerScrollRef.current = true;
|
|
59
|
+
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
60
|
+
timeoutRef.current = setTimeout(() => {
|
|
61
|
+
pointerScrollRef.current = false;
|
|
62
|
+
}, 120);
|
|
63
|
+
}, []);
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
return () => {
|
|
66
|
+
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
67
|
+
};
|
|
68
|
+
}, []);
|
|
69
|
+
return {
|
|
70
|
+
markPointerScroll,
|
|
71
|
+
pointerScrollRef,
|
|
72
|
+
scrollGuardProps: {
|
|
73
|
+
onPointerDown: markPointerScroll,
|
|
74
|
+
onTouchMove: markPointerScroll,
|
|
75
|
+
onWheel: markPointerScroll
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
//#endregion
|
|
80
|
+
export { VirtualScrollArea, usePointerScrollGuard };
|
|
81
|
+
|
|
82
|
+
//# sourceMappingURL=VirtualScrollArea.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VirtualScrollArea.mjs","names":[],"sources":["../../../src/base-ui/virtual/VirtualScrollArea.tsx"],"sourcesContent":["'use client';\n\nimport { createStaticStyles, cx } from 'antd-style';\nimport {\n cloneElement,\n type ReactElement,\n type ReactNode,\n type Ref,\n useCallback,\n useEffect,\n useRef,\n} from 'react';\nimport { useMergeRefs } from 'react-merge-refs';\nimport { Virtualizer, type VirtualizerHandle } from 'virtua';\n\nimport {\n ScrollAreaRoot,\n type ScrollAreaRootProps,\n ScrollAreaScrollbar,\n ScrollAreaThumb,\n ScrollAreaViewport,\n type ScrollAreaViewportProps,\n} from '@/base-ui/ScrollArea/atoms';\n\n// `--lobe-virtual-scroll-inset` is the inline padding of the box the scroll area sits in: the\n// root bleeds out by it so the scrollbar hugs that box's edge, and the viewport pads the rows back.\nconst styles = createStaticStyles(({ css }) => ({\n root: css`\n display: flex;\n flex: 1;\n flex-direction: column;\n\n min-height: 0;\n margin-inline: calc(-1 * var(--lobe-virtual-scroll-inset, 0px));\n `,\n viewport: css`\n flex: 1;\n height: auto;\n min-height: 0;\n padding-inline: var(--lobe-virtual-scroll-inset, 0);\n `,\n}));\n\n// Rows mounted on the very first render, before the viewport is measured, so Base UI's\n// list navigation sees the leading rows (not a pinned footer item) when it focuses on open.\nconst INITIAL_ROW_COUNT = 20;\n\nexport interface VirtualScrollAreaProps extends Omit<ScrollAreaRootProps, 'children'> {\n children: ReactNode;\n itemSize?: number;\n keepMounted?: readonly number[];\n /**\n * Element that owns the scrolling box (e.g. a Base UI `Select.List`); it is rendered\n * through the ScrollArea viewport so its own props and role win.\n */\n viewport?: ReactElement<{ children?: ReactNode; render?: ReactElement }>;\n viewportProps?: ScrollAreaViewportProps;\n virtualizerRef?: Ref<VirtualizerHandle>;\n}\n\nexport const VirtualScrollArea = ({\n children,\n className,\n itemSize,\n keepMounted,\n viewport,\n viewportProps,\n virtualizerRef,\n ...rest\n}: VirtualScrollAreaProps) => {\n const viewportRef = useRef<HTMLDivElement | null>(null);\n const mergedViewportRef = useMergeRefs([viewportRef, viewportProps?.ref]);\n\n const list = (\n <Virtualizer\n itemSize={itemSize}\n keepMounted={keepMounted}\n ref={virtualizerRef}\n scrollRef={viewportRef}\n ssrCount={INITIAL_ROW_COUNT}\n >\n {children}\n </Virtualizer>\n );\n const viewportElement = (\n <ScrollAreaViewport\n tabIndex={-1}\n {...viewportProps}\n className={cx(styles.viewport, viewportProps?.className as string)}\n ref={mergedViewportRef}\n />\n );\n\n return (\n <ScrollAreaRoot data-virtual=\"\" {...rest} className={cx(styles.root, className as string)}>\n {cloneElement(viewport ?? viewportElement, {\n children: list,\n ...(viewport && { render: viewportElement }),\n })}\n <ScrollAreaScrollbar>\n <ScrollAreaThumb />\n </ScrollAreaScrollbar>\n </ScrollAreaRoot>\n );\n};\n\nVirtualScrollArea.displayName = 'VirtualScrollArea';\n\n// Base UI scrolls the highlighted item into view after focusing it; while the pointer drives\n// the scroll that would yank the list back, so callers consult `pointerScrollRef` first.\nexport function usePointerScrollGuard() {\n const pointerScrollRef = useRef(false);\n const timeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const markPointerScroll = useCallback(() => {\n pointerScrollRef.current = true;\n if (timeoutRef.current) clearTimeout(timeoutRef.current);\n timeoutRef.current = setTimeout(() => {\n pointerScrollRef.current = false;\n }, 120);\n }, []);\n\n useEffect(() => {\n return () => {\n if (timeoutRef.current) clearTimeout(timeoutRef.current);\n };\n }, []);\n\n return {\n markPointerScroll,\n pointerScrollRef,\n scrollGuardProps: {\n onPointerDown: markPointerScroll,\n onTouchMove: markPointerScroll,\n onWheel: markPointerScroll,\n },\n };\n}\n"],"mappings":";;;;;;;;AA0BA,MAAM,SAAS,oBAAoB,EAAE,WAAW;CAC9C,MAAM,GAAG;;;;;;;;CAQT,UAAU,GAAG;;;;;;AAMf,EAAE;AAIF,MAAM,oBAAoB;AAe1B,MAAa,qBAAqB,EAChC,UACA,WACA,UACA,aACA,UACA,eACA,gBACA,GAAG,WACyB;CAC5B,MAAM,cAAc,OAA8B,IAAI;CACtD,MAAM,oBAAoB,aAAa,CAAC,aAAa,eAAe,GAAG,CAAC;CAExE,MAAM,OACJ,oBAAC,aAAD;EACY;EACG;EACb,KAAK;EACL,WAAW;EACX,UAAU;EAET;CACU,CAAA;CAEf,MAAM,kBACJ,oBAAC,oBAAD;EACE,UAAU;EACV,GAAI;EACJ,WAAW,GAAG,OAAO,UAAU,eAAe,SAAmB;EACjE,KAAK;CACN,CAAA;CAGH,OACE,qBAAC,gBAAD;EAAgB,gBAAa;EAAG,GAAI;EAAM,WAAW,GAAG,OAAO,MAAM,SAAmB;EAAxF,UAAA,CACG,aAAa,YAAY,iBAAiB;GACzC,UAAU;GACV,GAAI,YAAY,EAAE,QAAQ,gBAAgB;EAC5C,CAAC,GACD,oBAAC,qBAAD,EAAA,UACE,oBAAC,iBAAD,CAAkB,CAAA,EACC,CAAA,CACP;;AAEpB;AAEA,kBAAkB,cAAc;AAIhC,SAAgB,wBAAwB;CACtC,MAAM,mBAAmB,OAAO,KAAK;CACrC,MAAM,aAAa,OAA6C,IAAI;CAEpE,MAAM,oBAAoB,kBAAkB;EAC1C,iBAAiB,UAAU;EAC3B,IAAI,WAAW,SAAS,aAAa,WAAW,OAAO;EACvD,WAAW,UAAU,iBAAiB;GACpC,iBAAiB,UAAU;EAC7B,GAAG,GAAG;CACR,GAAG,CAAC,CAAC;CAEL,gBAAgB;EACd,aAAa;GACX,IAAI,WAAW,SAAS,aAAa,WAAW,OAAO;EACzD;CACF,GAAG,CAAC,CAAC;CAEL,OAAO;EACL;EACA;EACA,kBAAkB;GAChB,eAAe;GACf,aAAa;GACb,SAAS;EACX;CACF;AACF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ReactElement } from "react";
|
|
2
|
+
//#region src/base-ui/virtual/type.d.ts
|
|
3
|
+
interface VirtualListProps {
|
|
4
|
+
/**
|
|
5
|
+
* Typeahead label for a child row. Defaults to the row's `label` prop, then `aria-label`,
|
|
6
|
+
* then the flattened text of its children.
|
|
7
|
+
*/
|
|
8
|
+
getItemLabel?: (child: ReactElement, index: number) => string | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Extra child indices to keep mounted while virtualized, on top of the highlighted row.
|
|
11
|
+
*/
|
|
12
|
+
keepMounted?: readonly number[];
|
|
13
|
+
/**
|
|
14
|
+
* Row height hint for the virtualizer; rows are still measured after mount.
|
|
15
|
+
*/
|
|
16
|
+
listItemHeight?: number;
|
|
17
|
+
/**
|
|
18
|
+
* Only mount the rows near the scroll position. Use for long flat lists (hundreds of rows);
|
|
19
|
+
* groups and submenus keep working but are kept mounted as one row.
|
|
20
|
+
* @default false
|
|
21
|
+
*/
|
|
22
|
+
virtual?: boolean;
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { VirtualListProps };
|
|
26
|
+
//# sourceMappingURL=type.d.mts.map
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { usePointerScrollGuard } from "./VirtualScrollArea.mjs";
|
|
3
|
+
import { Children, cloneElement, isValidElement, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
4
|
+
//#region src/base-ui/virtual/useMenuVirtualList.tsx
|
|
5
|
+
const LIST_ITEM_SELECTOR = "[role^=\"menuitem\"], [role=\"option\"]";
|
|
6
|
+
const INDEX_ATTRIBUTE = "data-virtual-index";
|
|
7
|
+
const MAX_JUMP_FRAMES = 60;
|
|
8
|
+
const flattenText = (node) => {
|
|
9
|
+
if (node == null || typeof node === "boolean") return "";
|
|
10
|
+
if (typeof node === "string" || typeof node === "number") return String(node);
|
|
11
|
+
if (Array.isArray(node)) return node.map(flattenText).join("");
|
|
12
|
+
if (isValidElement(node)) return flattenText(node.props.children);
|
|
13
|
+
return "";
|
|
14
|
+
};
|
|
15
|
+
const readEntry = (child, index, getItemLabel) => {
|
|
16
|
+
if (!isValidElement(child)) return {
|
|
17
|
+
disabled: true,
|
|
18
|
+
label: ""
|
|
19
|
+
};
|
|
20
|
+
const props = child.props;
|
|
21
|
+
const label = getItemLabel?.(child, index) ?? props.label ?? props["aria-label"] ?? flattenText(props.children);
|
|
22
|
+
return {
|
|
23
|
+
disabled: Boolean(props.disabled) || props["aria-disabled"] === true || props["aria-disabled"] === "true",
|
|
24
|
+
label: label.trim()
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
const findMatch = (entries, query, startIndex) => {
|
|
28
|
+
if (entries.length === 0) return -1;
|
|
29
|
+
const lowerQuery = query.toLowerCase();
|
|
30
|
+
const start = (startIndex % entries.length + entries.length) % entries.length;
|
|
31
|
+
for (let offset = 0; offset < entries.length; offset += 1) {
|
|
32
|
+
const index = (start + offset) % entries.length;
|
|
33
|
+
const entry = entries[index];
|
|
34
|
+
if (!entry.disabled && entry.label.toLowerCase().startsWith(lowerQuery)) return index;
|
|
35
|
+
}
|
|
36
|
+
return -1;
|
|
37
|
+
};
|
|
38
|
+
const findEdge = (entries, fromEnd) => {
|
|
39
|
+
if (fromEnd) {
|
|
40
|
+
for (let index = entries.length - 1; index >= 0; index -= 1) if (!entries[index].disabled) return index;
|
|
41
|
+
return -1;
|
|
42
|
+
}
|
|
43
|
+
return entries.findIndex((entry) => !entry.disabled);
|
|
44
|
+
};
|
|
45
|
+
function useMenuVirtualList({ children, enabled, getItemLabel, keepMounted, typeaheadResetMs = 500 }) {
|
|
46
|
+
const viewportRef = useRef(null);
|
|
47
|
+
const virtualizerRef = useRef(null);
|
|
48
|
+
const focusedItemRef = useRef(null);
|
|
49
|
+
const activeIndexRef = useRef(null);
|
|
50
|
+
const [activeIndex, setActiveIndex] = useState(null);
|
|
51
|
+
const jumpTargetRef = useRef(null);
|
|
52
|
+
const [jumpTarget, setJumpTarget] = useState(null);
|
|
53
|
+
const { pointerScrollRef, scrollGuardProps } = usePointerScrollGuard();
|
|
54
|
+
const entries = useMemo(() => enabled ? Children.map(children, (child, index) => readEntry(child, index, getItemLabel)) ?? [] : [], [
|
|
55
|
+
children,
|
|
56
|
+
enabled,
|
|
57
|
+
getItemLabel
|
|
58
|
+
]);
|
|
59
|
+
const guardScrollIntoView = useCallback((item) => {
|
|
60
|
+
if (Object.hasOwn(item, "scrollIntoView")) return;
|
|
61
|
+
item.scrollIntoView = (...args) => {
|
|
62
|
+
if (!pointerScrollRef.current) HTMLElement.prototype.scrollIntoView.call(item, ...args);
|
|
63
|
+
};
|
|
64
|
+
}, [pointerScrollRef]);
|
|
65
|
+
const parkFocus = useCallback(() => {
|
|
66
|
+
const viewport = viewportRef.current;
|
|
67
|
+
if (viewport && !viewport.contains(document.activeElement)) viewport.focus({ preventScroll: true });
|
|
68
|
+
}, []);
|
|
69
|
+
const settleScrollRef = useRef(-1);
|
|
70
|
+
const focusJumpTarget = useCallback(() => {
|
|
71
|
+
const index = jumpTargetRef.current;
|
|
72
|
+
const viewport = viewportRef.current;
|
|
73
|
+
if (index === null || !viewport) return false;
|
|
74
|
+
parkFocus();
|
|
75
|
+
const scrollTop = viewport.scrollTop;
|
|
76
|
+
const settled = scrollTop === settleScrollRef.current;
|
|
77
|
+
settleScrollRef.current = scrollTop;
|
|
78
|
+
if (!settled) return false;
|
|
79
|
+
const child = viewport.querySelector(`[${INDEX_ATTRIBUTE}="${index}"]`);
|
|
80
|
+
const target = child && (child.matches(LIST_ITEM_SELECTOR) ? child : child.querySelector(LIST_ITEM_SELECTOR));
|
|
81
|
+
if (!target) return false;
|
|
82
|
+
guardScrollIntoView(target);
|
|
83
|
+
focusedItemRef.current = target;
|
|
84
|
+
target.focus({ preventScroll: true });
|
|
85
|
+
return true;
|
|
86
|
+
}, [guardScrollIntoView, parkFocus]);
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
const viewport = viewportRef.current;
|
|
89
|
+
if (!enabled || !viewport) return;
|
|
90
|
+
const observer = new MutationObserver(() => {
|
|
91
|
+
if (jumpTargetRef.current !== null) {
|
|
92
|
+
focusJumpTarget();
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const focusedItem = focusedItemRef.current;
|
|
96
|
+
const active = document.activeElement;
|
|
97
|
+
if (focusedItem && !focusedItem.isConnected && active === document.body) {
|
|
98
|
+
focusedItemRef.current = null;
|
|
99
|
+
viewport.focus({ preventScroll: true });
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
if (focusedItem && active === focusedItem) focusedItem.dispatchEvent(new FocusEvent("focusin", { bubbles: true }));
|
|
103
|
+
});
|
|
104
|
+
observer.observe(viewport, {
|
|
105
|
+
childList: true,
|
|
106
|
+
subtree: true
|
|
107
|
+
});
|
|
108
|
+
return () => observer.disconnect();
|
|
109
|
+
}, [enabled, focusJumpTarget]);
|
|
110
|
+
const jumpFrameRef = useRef(null);
|
|
111
|
+
useEffect(() => {
|
|
112
|
+
return () => {
|
|
113
|
+
if (jumpFrameRef.current !== null) cancelAnimationFrame(jumpFrameRef.current);
|
|
114
|
+
};
|
|
115
|
+
}, []);
|
|
116
|
+
const jumpTo = useCallback((index) => {
|
|
117
|
+
activeIndexRef.current = index;
|
|
118
|
+
jumpTargetRef.current = index;
|
|
119
|
+
setActiveIndex(index);
|
|
120
|
+
setJumpTarget(index);
|
|
121
|
+
viewportRef.current?.focus({ preventScroll: true });
|
|
122
|
+
settleScrollRef.current = -1;
|
|
123
|
+
virtualizerRef.current?.scrollToIndex(index, { align: "nearest" });
|
|
124
|
+
if (jumpFrameRef.current !== null) cancelAnimationFrame(jumpFrameRef.current);
|
|
125
|
+
let frames = 0;
|
|
126
|
+
const kick = () => {
|
|
127
|
+
jumpFrameRef.current = null;
|
|
128
|
+
focusJumpTarget();
|
|
129
|
+
frames += 1;
|
|
130
|
+
if (jumpTargetRef.current !== null && frames < MAX_JUMP_FRAMES) jumpFrameRef.current = requestAnimationFrame(kick);
|
|
131
|
+
else if (jumpTargetRef.current !== null) {
|
|
132
|
+
jumpTargetRef.current = null;
|
|
133
|
+
setJumpTarget(null);
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
jumpFrameRef.current = requestAnimationFrame(kick);
|
|
137
|
+
}, [focusJumpTarget]);
|
|
138
|
+
const queryRef = useRef("");
|
|
139
|
+
const lastMatchRef = useRef(null);
|
|
140
|
+
const resetTimeoutRef = useRef(null);
|
|
141
|
+
const resetQuery = useCallback(() => {
|
|
142
|
+
queryRef.current = "";
|
|
143
|
+
if (resetTimeoutRef.current) clearTimeout(resetTimeoutRef.current);
|
|
144
|
+
resetTimeoutRef.current = null;
|
|
145
|
+
}, []);
|
|
146
|
+
useEffect(() => {
|
|
147
|
+
return () => {
|
|
148
|
+
if (resetTimeoutRef.current) clearTimeout(resetTimeoutRef.current);
|
|
149
|
+
};
|
|
150
|
+
}, []);
|
|
151
|
+
const handleKeyDownCapture = useCallback((event) => {
|
|
152
|
+
if (!enabled || entries.length === 0) return;
|
|
153
|
+
if (event.target instanceof HTMLElement && event.target.matches("input, textarea")) return;
|
|
154
|
+
if (event.key === "Home" || event.key === "End") {
|
|
155
|
+
const fromEnd = event.key === "End";
|
|
156
|
+
const index = findEdge(entries, fromEnd);
|
|
157
|
+
if (index === -1) return;
|
|
158
|
+
event.preventDefault();
|
|
159
|
+
event.stopPropagation();
|
|
160
|
+
resetQuery();
|
|
161
|
+
jumpTo(index);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
if (event.key.length !== 1 || event.ctrlKey || event.metaKey || event.altKey) return;
|
|
165
|
+
if (event.key === " " && queryRef.current === "") return;
|
|
166
|
+
event.preventDefault();
|
|
167
|
+
event.stopPropagation();
|
|
168
|
+
const isNewSession = queryRef.current === "";
|
|
169
|
+
if (entries.every((entry) => entry.disabled || entry.label[0]?.toLowerCase() !== entry.label[1]?.toLowerCase()) && queryRef.current === event.key) queryRef.current = "";
|
|
170
|
+
queryRef.current += event.key;
|
|
171
|
+
if (resetTimeoutRef.current) clearTimeout(resetTimeoutRef.current);
|
|
172
|
+
resetTimeoutRef.current = setTimeout(resetQuery, typeaheadResetMs);
|
|
173
|
+
const previous = isNewSession || queryRef.current.length === 1 ? activeIndexRef.current ?? lastMatchRef.current ?? -1 : lastMatchRef.current ?? activeIndexRef.current ?? -1;
|
|
174
|
+
const startIndex = queryRef.current.length === 1 ? previous + 1 : previous;
|
|
175
|
+
const index = findMatch(entries, queryRef.current, startIndex);
|
|
176
|
+
if (index !== -1) {
|
|
177
|
+
lastMatchRef.current = index;
|
|
178
|
+
jumpTo(index);
|
|
179
|
+
} else if (event.key !== " ") resetQuery();
|
|
180
|
+
}, [
|
|
181
|
+
enabled,
|
|
182
|
+
entries,
|
|
183
|
+
jumpTo,
|
|
184
|
+
resetQuery,
|
|
185
|
+
typeaheadResetMs
|
|
186
|
+
]);
|
|
187
|
+
const virtualChildren = useMemo(() => {
|
|
188
|
+
if (!enabled) return children;
|
|
189
|
+
return Children.map(children, (child, index) => {
|
|
190
|
+
if (!isValidElement(child)) return child;
|
|
191
|
+
const { onFocus } = child.props;
|
|
192
|
+
return cloneElement(child, {
|
|
193
|
+
[INDEX_ATTRIBUTE]: index,
|
|
194
|
+
onFocus: (event) => {
|
|
195
|
+
onFocus?.(event);
|
|
196
|
+
const item = event.target.closest(LIST_ITEM_SELECTOR);
|
|
197
|
+
if (item && event.currentTarget.contains(item)) {
|
|
198
|
+
focusedItemRef.current = item;
|
|
199
|
+
guardScrollIntoView(item);
|
|
200
|
+
}
|
|
201
|
+
activeIndexRef.current = index;
|
|
202
|
+
setActiveIndex(index);
|
|
203
|
+
if (jumpTargetRef.current === index) {
|
|
204
|
+
jumpTargetRef.current = null;
|
|
205
|
+
setJumpTarget(null);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
}, [
|
|
211
|
+
children,
|
|
212
|
+
enabled,
|
|
213
|
+
guardScrollIntoView
|
|
214
|
+
]);
|
|
215
|
+
const keepMountedIndices = useMemo(() => {
|
|
216
|
+
if (!enabled) return void 0;
|
|
217
|
+
const count = Children.count(children);
|
|
218
|
+
const indices = new Set(keepMounted);
|
|
219
|
+
if (activeIndex !== null) indices.add(activeIndex);
|
|
220
|
+
if (jumpTarget !== null) indices.add(jumpTarget);
|
|
221
|
+
const inRange = [...indices].filter((index) => index >= 0 && index < count);
|
|
222
|
+
return inRange.length ? inRange : void 0;
|
|
223
|
+
}, [
|
|
224
|
+
activeIndex,
|
|
225
|
+
children,
|
|
226
|
+
enabled,
|
|
227
|
+
jumpTarget,
|
|
228
|
+
keepMounted
|
|
229
|
+
]);
|
|
230
|
+
const handleBlur = useCallback((event) => {
|
|
231
|
+
if (jumpTargetRef.current === null) return;
|
|
232
|
+
const viewport = viewportRef.current;
|
|
233
|
+
if (!viewport) return;
|
|
234
|
+
if (event.relatedTarget && viewport.contains(event.relatedTarget)) return;
|
|
235
|
+
viewport.focus({ preventScroll: true });
|
|
236
|
+
}, []);
|
|
237
|
+
return {
|
|
238
|
+
keepMountedIndices,
|
|
239
|
+
viewportProps: useMemo(() => ({
|
|
240
|
+
...scrollGuardProps,
|
|
241
|
+
onBlur: handleBlur,
|
|
242
|
+
onKeyDownCapture: handleKeyDownCapture
|
|
243
|
+
}), [
|
|
244
|
+
handleBlur,
|
|
245
|
+
handleKeyDownCapture,
|
|
246
|
+
scrollGuardProps
|
|
247
|
+
]),
|
|
248
|
+
viewportRef,
|
|
249
|
+
virtualChildren,
|
|
250
|
+
virtualizerRef
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
//#endregion
|
|
254
|
+
export { findEdge, findMatch, flattenText, useMenuVirtualList };
|
|
255
|
+
|
|
256
|
+
//# sourceMappingURL=useMenuVirtualList.mjs.map
|