@adapttable/naive-ui 0.1.3 → 0.2.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.
Files changed (93) hide show
  1. package/README.md +14 -0
  2. package/dist/assistant-Cv8df2ti.js +355 -0
  3. package/dist/assistant-Cv8df2ti.js.map +1 -0
  4. package/dist/assistant-D6mc-LJl.cjs +378 -0
  5. package/dist/assistant-D6mc-LJl.cjs.map +1 -0
  6. package/dist/assistant.cjs +5 -358
  7. package/dist/assistant.js +1 -354
  8. package/dist/column-menu-DdWVP1hz.d.cts +23 -0
  9. package/dist/column-menu-DdWVP1hz.d.cts.map +1 -0
  10. package/dist/column-menu-DdWVP1hz.d.ts +23 -0
  11. package/dist/column-menu-DdWVP1hz.d.ts.map +1 -0
  12. package/dist/column-menu.d.cts +2 -23
  13. package/dist/column-menu.d.ts +2 -23
  14. package/dist/command-palette-vIegnqVo.js +112 -0
  15. package/dist/command-palette-vIegnqVo.js.map +1 -0
  16. package/dist/command-palette-ztI3qI2V.cjs +117 -0
  17. package/dist/command-palette-ztI3qI2V.cjs.map +1 -0
  18. package/dist/command-palette.cjs +2 -112
  19. package/dist/command-palette.js +1 -111
  20. package/dist/context-menu-BbhrjTZr.cjs +145 -0
  21. package/dist/context-menu-BbhrjTZr.cjs.map +1 -0
  22. package/dist/context-menu-DjYIQXhY.js +140 -0
  23. package/dist/context-menu-DjYIQXhY.js.map +1 -0
  24. package/dist/context-menu.cjs +2 -140
  25. package/dist/context-menu.js +1 -139
  26. package/dist/features.cjs +217 -0
  27. package/dist/features.d.cts +40 -0
  28. package/dist/features.d.ts +40 -0
  29. package/dist/features.js +36 -0
  30. package/dist/filters-BJ48GzqJ.d.ts +66 -0
  31. package/dist/filters-BJ48GzqJ.d.ts.map +1 -0
  32. package/dist/filters-C6DvAZ_T.d.cts +66 -0
  33. package/dist/filters-C6DvAZ_T.d.cts.map +1 -0
  34. package/dist/filters.d.cts +2 -66
  35. package/dist/filters.d.ts +2 -66
  36. package/dist/grouping-panel-BPaPG49S.cjs +151 -0
  37. package/dist/grouping-panel-BPaPG49S.cjs.map +1 -0
  38. package/dist/grouping-panel-CYUPSa0u.js +146 -0
  39. package/dist/grouping-panel-CYUPSa0u.js.map +1 -0
  40. package/dist/grouping-panel.cjs +3 -146
  41. package/dist/grouping-panel.js +2 -145
  42. package/dist/header-filters-CQg6clum.d.cts +52 -0
  43. package/dist/header-filters-CQg6clum.d.cts.map +1 -0
  44. package/dist/header-filters-CQg6clum.d.ts +52 -0
  45. package/dist/header-filters-CQg6clum.d.ts.map +1 -0
  46. package/dist/header-filters.d.cts +2 -52
  47. package/dist/header-filters.d.ts +2 -52
  48. package/dist/index.cjs +1 -1
  49. package/dist/index.js +1 -1
  50. package/dist/{mobile-Bc3-31-b.cjs → mobile-C2JUs6b_.cjs} +3 -2
  51. package/dist/mobile-C2JUs6b_.cjs.map +1 -0
  52. package/dist/{mobile-Dlwq8dB7.js → mobile-CC3NeIRK.js} +4 -3
  53. package/dist/mobile-CC3NeIRK.js.map +1 -0
  54. package/dist/preset.cjs +5 -5
  55. package/dist/preset.js +5 -5
  56. package/dist/renderers.cjs +1 -1
  57. package/dist/renderers.d.cts.map +1 -1
  58. package/dist/renderers.d.ts.map +1 -1
  59. package/dist/renderers.js +1 -1
  60. package/dist/row-reorder-BNYYEL8w.js +186 -0
  61. package/dist/row-reorder-BNYYEL8w.js.map +1 -0
  62. package/dist/row-reorder-BRySq2FF.cjs +191 -0
  63. package/dist/row-reorder-BRySq2FF.cjs.map +1 -0
  64. package/dist/row-reorder.cjs +2 -185
  65. package/dist/row-reorder.js +1 -185
  66. package/dist/side-panel-Bf4zBlYZ.cjs +64 -0
  67. package/dist/side-panel-Bf4zBlYZ.cjs.map +1 -0
  68. package/dist/side-panel-CLTgXUnb.js +59 -0
  69. package/dist/side-panel-CLTgXUnb.js.map +1 -0
  70. package/dist/side-panel.cjs +2 -59
  71. package/dist/side-panel.js +1 -58
  72. package/dist/styles.css +39 -39
  73. package/package.json +14 -3
  74. package/dist/assistant.cjs.map +0 -1
  75. package/dist/assistant.js.map +0 -1
  76. package/dist/column-menu.d.cts.map +0 -1
  77. package/dist/column-menu.d.ts.map +0 -1
  78. package/dist/command-palette.cjs.map +0 -1
  79. package/dist/command-palette.js.map +0 -1
  80. package/dist/context-menu.cjs.map +0 -1
  81. package/dist/context-menu.js.map +0 -1
  82. package/dist/filters.d.cts.map +0 -1
  83. package/dist/filters.d.ts.map +0 -1
  84. package/dist/grouping-panel.cjs.map +0 -1
  85. package/dist/grouping-panel.js.map +0 -1
  86. package/dist/header-filters.d.cts.map +0 -1
  87. package/dist/header-filters.d.ts.map +0 -1
  88. package/dist/mobile-Bc3-31-b.cjs.map +0 -1
  89. package/dist/mobile-Dlwq8dB7.js.map +0 -1
  90. package/dist/row-reorder.cjs.map +0 -1
  91. package/dist/row-reorder.js.map +0 -1
  92. package/dist/side-panel.cjs.map +0 -1
  93. package/dist/side-panel.js.map +0 -1
@@ -0,0 +1,145 @@
1
+ const require_button = require("./button-CaakTzYM.cjs");
2
+ let _adapttable_vue_adapter = require("@adapttable/vue/adapter");
3
+ let _adapttable_vue_features = require("@adapttable/vue/features");
4
+ let vue = require("vue");
5
+ let naive_ui = require("naive-ui");
6
+ //#region src/actions/NaiveContextMenuSurface.ts
7
+ /** Native surfaces apply the shared core's menu-navigation decisions. */
8
+ const NaiveContextMenuSurface = /*#__PURE__*/ (0, vue.defineComponent)((props) => {
9
+ const active = (0, _adapttable_vue_adapter.useScopeActivity)();
10
+ const card = (0, vue.shallowRef)(null);
11
+ const navigation = (0, _adapttable_vue_adapter.createMenuNavigation)();
12
+ const root = () => card.value ? require_button.htmlRoot(card.value) : null;
13
+ const entries = () => {
14
+ const panel = root();
15
+ return [...panel?.querySelectorAll("[role=\"menuitem\"]") ?? []].filter((item) => item.closest("[role=\"menu\"]") === panel);
16
+ };
17
+ (0, vue.watch)([
18
+ card,
19
+ active,
20
+ () => props.at
21
+ ], ([, live], _previous, cleanup) => {
22
+ navigation.reset();
23
+ if (!live) return;
24
+ let current = true;
25
+ (0, vue.nextTick)(() => {
26
+ if (current && active.value) entries().find((item) => item.getAttribute("aria-disabled") !== "true")?.focus({ preventScroll: true });
27
+ });
28
+ cleanup(() => {
29
+ current = false;
30
+ });
31
+ }, { flush: "post" });
32
+ const keydown = (event) => {
33
+ const panel = root();
34
+ if (!active.value || !panel || !(event.target instanceof Element) || event.target.closest("[role=\"menu\"]") !== panel) return;
35
+ const items = entries();
36
+ const focusTargets = items;
37
+ const action = navigation.key(event, items.map((item) => ({
38
+ label: item.textContent ?? "",
39
+ disabled: item.getAttribute("aria-disabled") === "true"
40
+ })), focusTargets.indexOf(panel.ownerDocument.activeElement));
41
+ if (!action) return;
42
+ if (action.kind !== "close" || action.key !== "Tab") event.preventDefault();
43
+ event.stopPropagation();
44
+ if (action.kind === "close") props.onClose();
45
+ else items[action.index]?.focus({ preventScroll: true });
46
+ };
47
+ return () => {
48
+ const at = props.at;
49
+ const close = () => {
50
+ if (active.value && props.at === at) props.onClose();
51
+ };
52
+ return (0, vue.h)(naive_ui.NPopover, {
53
+ trigger: "manual",
54
+ show: active.value,
55
+ x: at.x,
56
+ y: at.y,
57
+ to: props.container ?? false,
58
+ raw: true,
59
+ showArrow: false,
60
+ placement: "bottom-start",
61
+ onClickoutside: close
62
+ }, { default: () => (0, vue.h)(naive_ui.NCard, {
63
+ ref: card,
64
+ size: "small",
65
+ role: "menu",
66
+ tabindex: -1,
67
+ "aria-label": props.label,
68
+ "data-adapttable-part": "context-menu",
69
+ class: ["adapttable-naive-context-menu", props.className],
70
+ onKeydown: keydown,
71
+ contentStyle: {
72
+ display: "flex",
73
+ flexDirection: "column",
74
+ gap: "4px"
75
+ },
76
+ style: {
77
+ maxWidth: "90vw",
78
+ maxHeight: "80dvh",
79
+ overflow: "auto"
80
+ }
81
+ }, { default: () => props.children }) });
82
+ };
83
+ }, {
84
+ name: "NaiveContextMenuSurface",
85
+ props: {
86
+ at: { type: Object },
87
+ anchorRef: { type: Object },
88
+ label: { type: String },
89
+ onClose: { type: Function },
90
+ container: { type: Object },
91
+ children: {
92
+ type: [
93
+ String,
94
+ Number,
95
+ Boolean,
96
+ Array,
97
+ Object
98
+ ],
99
+ default: void 0
100
+ },
101
+ className: { type: String }
102
+ }
103
+ });
104
+ //#endregion
105
+ //#region src/context-menu.ts
106
+ function contextSlots(names = {}) {
107
+ return {
108
+ Surface: (props) => (0, vue.h)(NaiveContextMenuSurface, props),
109
+ Item: ({ item, onSelect }) => require_button.naiveButton({
110
+ role: "menuitem",
111
+ tabindex: -1,
112
+ disabled: item.disabled,
113
+ "aria-disabled": item.disabled,
114
+ "data-danger": item.danger ? "" : void 0,
115
+ "data-adapttable-part": "context-menu-item",
116
+ class: names.contextMenuItem,
117
+ onClick: onSelect
118
+ }, item.label),
119
+ Separator: () => (0, vue.h)(naive_ui.NDivider, {
120
+ role: "separator",
121
+ "data-adapttable-part": "context-menu-separator",
122
+ class: names.contextMenuSeparator
123
+ })
124
+ };
125
+ }
126
+ function contextMenu(options = true) {
127
+ return (0, _adapttable_vue_adapter.extendFeature)((0, _adapttable_vue_features.contextMenu)(options), [(0, _adapttable_vue_adapter.slotRender)(_adapttable_vue_adapter.CONTEXT_MENU_CONTROL, (props) => (0, vue.h)(_adapttable_vue_adapter.ContextMenuChrome, {
128
+ items: props.model.items,
129
+ at: props.model.at,
130
+ onClose: props.model.close,
131
+ labels: props.labels,
132
+ className: props.classNames?.contextMenu,
133
+ container: props.container,
134
+ slots: contextSlots(props.classNames)
135
+ }))]);
136
+ }
137
+ //#endregion
138
+ Object.defineProperty(exports, "contextMenu", {
139
+ enumerable: true,
140
+ get: function() {
141
+ return contextMenu;
142
+ }
143
+ });
144
+
145
+ //# sourceMappingURL=context-menu-BbhrjTZr.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-menu-BbhrjTZr.cjs","names":["useScopeActivity","shallowRef","createMenuNavigation","htmlRoot","nextTick","h","NPopover","NCard","h","naiveButton","NDivider","extendFeature","bindingContextMenu","slotRender","CONTEXT_MENU_CONTROL","ContextMenuChrome"],"sources":["../src/actions/NaiveContextMenuSurface.ts","../src/context-menu.ts"],"sourcesContent":["import {\n type ContextMenuSurfaceProps,\n createMenuNavigation,\n useScopeActivity,\n} from \"@adapttable/vue/adapter\";\nimport { NCard, NPopover } from \"naive-ui\";\nimport {\n type ComponentPublicInstance,\n defineComponent,\n h,\n nextTick,\n type PropType,\n shallowRef,\n type VNodeChild,\n watch,\n} from \"vue\";\n\nimport { htmlRoot } from \"../controls/elementTarget\";\n/** Native surfaces apply the shared core's menu-navigation decisions. */\nexport const NaiveContextMenuSurface = /*#__PURE__*/ defineComponent(\n (props: ContextMenuSurfaceProps<VNodeChild>) => {\n const active = useScopeActivity();\n const card = shallowRef<ComponentPublicInstance | null>(null);\n const navigation = createMenuNavigation();\n const root = () => (card.value ? htmlRoot(card.value) : null);\n const entries = () => {\n const panel = root();\n return [\n ...(panel?.querySelectorAll<HTMLElement>('[role=\"menuitem\"]') ?? []),\n ].filter((item) => item.closest('[role=\"menu\"]') === panel);\n };\n watch(\n [card, active, () => props.at],\n ([, live], _previous, cleanup) => {\n navigation.reset();\n if (!live) return;\n let current = true;\n void nextTick(() => {\n if (current && active.value)\n entries()\n .find((item) => item.getAttribute(\"aria-disabled\") !== \"true\")\n ?.focus({ preventScroll: true });\n });\n cleanup(() => {\n current = false;\n });\n },\n { flush: \"post\" }\n );\n const keydown = (event: KeyboardEvent) => {\n const panel = root();\n if (\n !active.value ||\n !panel ||\n !(event.target instanceof Element) ||\n event.target.closest('[role=\"menu\"]') !== panel\n )\n return;\n const items = entries();\n const focusTargets: readonly (EventTarget | null | undefined)[] = items;\n const action = navigation.key(\n event,\n items.map((item) => ({\n label: item.textContent ?? \"\",\n disabled: item.getAttribute(\"aria-disabled\") === \"true\",\n })),\n focusTargets.indexOf(panel.ownerDocument.activeElement)\n );\n if (!action) return;\n if (action.kind !== \"close\" || action.key !== \"Tab\")\n event.preventDefault();\n event.stopPropagation();\n if (action.kind === \"close\") props.onClose();\n else items[action.index]?.focus({ preventScroll: true });\n };\n return () => {\n const at = props.at;\n const close = () => {\n if (active.value && props.at === at) props.onClose();\n };\n return h(\n NPopover,\n {\n trigger: \"manual\",\n show: active.value,\n x: at.x,\n y: at.y,\n to: props.container ?? false,\n raw: true,\n showArrow: false,\n placement: \"bottom-start\",\n onClickoutside: close,\n },\n {\n default: () =>\n h(\n NCard,\n {\n ref: card,\n size: \"small\",\n role: \"menu\",\n tabindex: -1,\n \"aria-label\": props.label,\n \"data-adapttable-part\": \"context-menu\",\n class: [\"adapttable-naive-context-menu\", props.className],\n onKeydown: keydown,\n contentStyle: {\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"4px\",\n },\n style: {\n maxWidth: \"90vw\",\n maxHeight: \"80dvh\",\n overflow: \"auto\",\n },\n },\n { default: () => props.children }\n ),\n }\n );\n };\n },\n {\n name: \"NaiveContextMenuSurface\",\n props: {\n at: {\n type: Object as PropType<ContextMenuSurfaceProps<VNodeChild>[\"at\"]>,\n },\n anchorRef: {\n type: Object as PropType<\n ContextMenuSurfaceProps<VNodeChild>[\"anchorRef\"]\n >,\n },\n label: {\n type: String as PropType<ContextMenuSurfaceProps<VNodeChild>[\"label\"]>,\n },\n onClose: {\n type: Function as PropType<\n ContextMenuSurfaceProps<VNodeChild>[\"onClose\"]\n >,\n },\n container: {\n type: Object as PropType<\n ContextMenuSurfaceProps<VNodeChild>[\"container\"]\n >,\n },\n children: {\n type: [String, Number, Boolean, Array, Object] as PropType<\n ContextMenuSurfaceProps<VNodeChild>[\"children\"]\n >,\n default: undefined,\n },\n className: {\n type: String as PropType<\n ContextMenuSurfaceProps<VNodeChild>[\"className\"]\n >,\n },\n },\n }\n);\n","import type { TableFeature } from \"@adapttable/vue\";\nimport {\n CONTEXT_MENU_CONTROL,\n ContextMenuChrome,\n type ContextMenuSlots,\n extendFeature,\n slotRender,\n} from \"@adapttable/vue/adapter\";\nimport {\n contextMenu as bindingContextMenu,\n type ContextMenuOptions,\n} from \"@adapttable/vue/features\";\nimport { NDivider } from \"naive-ui\";\nimport { h } from \"vue\";\n\nimport { NaiveContextMenuSurface } from \"./actions/NaiveContextMenuSurface\";\nimport { naiveButton } from \"./controls/button\";\nfunction contextSlots(\n names: Readonly<Record<string, string | undefined>> = {}\n): ContextMenuSlots {\n return {\n Surface: (props) => h(NaiveContextMenuSurface, props),\n Item: ({ item, onSelect }) =>\n naiveButton(\n {\n role: \"menuitem\",\n tabindex: -1,\n disabled: item.disabled,\n \"aria-disabled\": item.disabled,\n \"data-danger\": item.danger ? \"\" : undefined,\n \"data-adapttable-part\": \"context-menu-item\",\n class: names.contextMenuItem,\n onClick: onSelect,\n },\n item.label\n ),\n Separator: () =>\n h(NDivider, {\n role: \"separator\",\n \"data-adapttable-part\": \"context-menu-separator\",\n class: names.contextMenuSeparator,\n }),\n };\n}\nexport function contextMenu<TRow>(\n options: boolean | ContextMenuOptions<TRow> = true\n): TableFeature<TRow> {\n return extendFeature(bindingContextMenu<TRow>(options), [\n slotRender(CONTEXT_MENU_CONTROL, (props) =>\n h(ContextMenuChrome, {\n items: props.model.items,\n at: props.model.at,\n onClose: props.model.close,\n labels: props.labels,\n className: props.classNames?.contextMenu,\n container: props.container,\n slots: contextSlots(props.classNames),\n })\n ),\n ]);\n}\nexport type { ContextMenuOptions } from \"@adapttable/vue/features\";\n"],"mappings":";;;;;;;AAmBA,MAAa,0BAAwC,eAAA,GAAA,IAAA,gBAAA,EAClD,UAA+C;CAC9C,MAAM,UAAA,GAASA,wBAAAA,iBAAAA,CAAiB;CAChC,MAAM,QAAA,GAAOC,IAAAA,WAAAA,CAA2C,IAAI;CAC5D,MAAM,cAAA,GAAaC,wBAAAA,qBAAAA,CAAqB;CACxC,MAAM,aAAc,KAAK,QAAQC,eAAAA,SAAS,KAAK,KAAK,IAAI;CACxD,MAAM,gBAAgB;EACpB,MAAM,QAAQ,KAAK;EACn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ACF;AACA,SAAgB,YACd,UAA8C,MAC1B;CACpB,QAAA,GAAOC,wBAAAA,cAAAA,EAAAA,GAAcC,yBAAAA,YAAAA,CAAyB,OAAO,GAAG,EAAA,GACtDC,wBAAAA,WAAAA,CAAWC,wBAAAA,uBAAuB,WAAA,GAChCN,IAAAA,EAAAA,CAAEO,wBAAAA,mBAAmB;EACnB,OAAO,MAAM,MAAM;EACnB,IAAI,MAAM,MAAM;EAChB,SAAS,MAAM,MAAM;EACrB,QAAQ,MAAM;EACd,WAAW,MAAM,YAAY;EAC7B,WAAW,MAAM;EACjB,OAAO,aAAa,MAAM,UAAU;CACtC,CAAC,CACH,CACF,CAAC;AACH"}
@@ -0,0 +1,140 @@
1
+ import { r as htmlRoot, t as naiveButton } from "./button-BxXdDW7A.js";
2
+ import { CONTEXT_MENU_CONTROL, ContextMenuChrome, createMenuNavigation, extendFeature, slotRender, useScopeActivity } from "@adapttable/vue/adapter";
3
+ import { contextMenu } from "@adapttable/vue/features";
4
+ import { defineComponent, h, nextTick, shallowRef, watch } from "vue";
5
+ import { NCard, NDivider, NPopover } from "naive-ui";
6
+ //#region src/actions/NaiveContextMenuSurface.ts
7
+ /** Native surfaces apply the shared core's menu-navigation decisions. */
8
+ const NaiveContextMenuSurface = /*#__PURE__*/ defineComponent((props) => {
9
+ const active = useScopeActivity();
10
+ const card = shallowRef(null);
11
+ const navigation = createMenuNavigation();
12
+ const root = () => card.value ? htmlRoot(card.value) : null;
13
+ const entries = () => {
14
+ const panel = root();
15
+ return [...panel?.querySelectorAll("[role=\"menuitem\"]") ?? []].filter((item) => item.closest("[role=\"menu\"]") === panel);
16
+ };
17
+ watch([
18
+ card,
19
+ active,
20
+ () => props.at
21
+ ], ([, live], _previous, cleanup) => {
22
+ navigation.reset();
23
+ if (!live) return;
24
+ let current = true;
25
+ nextTick(() => {
26
+ if (current && active.value) entries().find((item) => item.getAttribute("aria-disabled") !== "true")?.focus({ preventScroll: true });
27
+ });
28
+ cleanup(() => {
29
+ current = false;
30
+ });
31
+ }, { flush: "post" });
32
+ const keydown = (event) => {
33
+ const panel = root();
34
+ if (!active.value || !panel || !(event.target instanceof Element) || event.target.closest("[role=\"menu\"]") !== panel) return;
35
+ const items = entries();
36
+ const focusTargets = items;
37
+ const action = navigation.key(event, items.map((item) => ({
38
+ label: item.textContent ?? "",
39
+ disabled: item.getAttribute("aria-disabled") === "true"
40
+ })), focusTargets.indexOf(panel.ownerDocument.activeElement));
41
+ if (!action) return;
42
+ if (action.kind !== "close" || action.key !== "Tab") event.preventDefault();
43
+ event.stopPropagation();
44
+ if (action.kind === "close") props.onClose();
45
+ else items[action.index]?.focus({ preventScroll: true });
46
+ };
47
+ return () => {
48
+ const at = props.at;
49
+ const close = () => {
50
+ if (active.value && props.at === at) props.onClose();
51
+ };
52
+ return h(NPopover, {
53
+ trigger: "manual",
54
+ show: active.value,
55
+ x: at.x,
56
+ y: at.y,
57
+ to: props.container ?? false,
58
+ raw: true,
59
+ showArrow: false,
60
+ placement: "bottom-start",
61
+ onClickoutside: close
62
+ }, { default: () => h(NCard, {
63
+ ref: card,
64
+ size: "small",
65
+ role: "menu",
66
+ tabindex: -1,
67
+ "aria-label": props.label,
68
+ "data-adapttable-part": "context-menu",
69
+ class: ["adapttable-naive-context-menu", props.className],
70
+ onKeydown: keydown,
71
+ contentStyle: {
72
+ display: "flex",
73
+ flexDirection: "column",
74
+ gap: "4px"
75
+ },
76
+ style: {
77
+ maxWidth: "90vw",
78
+ maxHeight: "80dvh",
79
+ overflow: "auto"
80
+ }
81
+ }, { default: () => props.children }) });
82
+ };
83
+ }, {
84
+ name: "NaiveContextMenuSurface",
85
+ props: {
86
+ at: { type: Object },
87
+ anchorRef: { type: Object },
88
+ label: { type: String },
89
+ onClose: { type: Function },
90
+ container: { type: Object },
91
+ children: {
92
+ type: [
93
+ String,
94
+ Number,
95
+ Boolean,
96
+ Array,
97
+ Object
98
+ ],
99
+ default: void 0
100
+ },
101
+ className: { type: String }
102
+ }
103
+ });
104
+ //#endregion
105
+ //#region src/context-menu.ts
106
+ function contextSlots(names = {}) {
107
+ return {
108
+ Surface: (props) => h(NaiveContextMenuSurface, props),
109
+ Item: ({ item, onSelect }) => naiveButton({
110
+ role: "menuitem",
111
+ tabindex: -1,
112
+ disabled: item.disabled,
113
+ "aria-disabled": item.disabled,
114
+ "data-danger": item.danger ? "" : void 0,
115
+ "data-adapttable-part": "context-menu-item",
116
+ class: names.contextMenuItem,
117
+ onClick: onSelect
118
+ }, item.label),
119
+ Separator: () => h(NDivider, {
120
+ role: "separator",
121
+ "data-adapttable-part": "context-menu-separator",
122
+ class: names.contextMenuSeparator
123
+ })
124
+ };
125
+ }
126
+ function contextMenu$1(options = true) {
127
+ return extendFeature(contextMenu(options), [slotRender(CONTEXT_MENU_CONTROL, (props) => h(ContextMenuChrome, {
128
+ items: props.model.items,
129
+ at: props.model.at,
130
+ onClose: props.model.close,
131
+ labels: props.labels,
132
+ className: props.classNames?.contextMenu,
133
+ container: props.container,
134
+ slots: contextSlots(props.classNames)
135
+ }))]);
136
+ }
137
+ //#endregion
138
+ export { contextMenu$1 as t };
139
+
140
+ //# sourceMappingURL=context-menu-DjYIQXhY.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-menu-DjYIQXhY.js","names":["contextMenu","bindingContextMenu"],"sources":["../src/actions/NaiveContextMenuSurface.ts","../src/context-menu.ts"],"sourcesContent":["import {\n type ContextMenuSurfaceProps,\n createMenuNavigation,\n useScopeActivity,\n} from \"@adapttable/vue/adapter\";\nimport { NCard, NPopover } from \"naive-ui\";\nimport {\n type ComponentPublicInstance,\n defineComponent,\n h,\n nextTick,\n type PropType,\n shallowRef,\n type VNodeChild,\n watch,\n} from \"vue\";\n\nimport { htmlRoot } from \"../controls/elementTarget\";\n/** Native surfaces apply the shared core's menu-navigation decisions. */\nexport const NaiveContextMenuSurface = /*#__PURE__*/ defineComponent(\n (props: ContextMenuSurfaceProps<VNodeChild>) => {\n const active = useScopeActivity();\n const card = shallowRef<ComponentPublicInstance | null>(null);\n const navigation = createMenuNavigation();\n const root = () => (card.value ? htmlRoot(card.value) : null);\n const entries = () => {\n const panel = root();\n return [\n ...(panel?.querySelectorAll<HTMLElement>('[role=\"menuitem\"]') ?? []),\n ].filter((item) => item.closest('[role=\"menu\"]') === panel);\n };\n watch(\n [card, active, () => props.at],\n ([, live], _previous, cleanup) => {\n navigation.reset();\n if (!live) return;\n let current = true;\n void nextTick(() => {\n if (current && active.value)\n entries()\n .find((item) => item.getAttribute(\"aria-disabled\") !== \"true\")\n ?.focus({ preventScroll: true });\n });\n cleanup(() => {\n current = false;\n });\n },\n { flush: \"post\" }\n );\n const keydown = (event: KeyboardEvent) => {\n const panel = root();\n if (\n !active.value ||\n !panel ||\n !(event.target instanceof Element) ||\n event.target.closest('[role=\"menu\"]') !== panel\n )\n return;\n const items = entries();\n const focusTargets: readonly (EventTarget | null | undefined)[] = items;\n const action = navigation.key(\n event,\n items.map((item) => ({\n label: item.textContent ?? \"\",\n disabled: item.getAttribute(\"aria-disabled\") === \"true\",\n })),\n focusTargets.indexOf(panel.ownerDocument.activeElement)\n );\n if (!action) return;\n if (action.kind !== \"close\" || action.key !== \"Tab\")\n event.preventDefault();\n event.stopPropagation();\n if (action.kind === \"close\") props.onClose();\n else items[action.index]?.focus({ preventScroll: true });\n };\n return () => {\n const at = props.at;\n const close = () => {\n if (active.value && props.at === at) props.onClose();\n };\n return h(\n NPopover,\n {\n trigger: \"manual\",\n show: active.value,\n x: at.x,\n y: at.y,\n to: props.container ?? false,\n raw: true,\n showArrow: false,\n placement: \"bottom-start\",\n onClickoutside: close,\n },\n {\n default: () =>\n h(\n NCard,\n {\n ref: card,\n size: \"small\",\n role: \"menu\",\n tabindex: -1,\n \"aria-label\": props.label,\n \"data-adapttable-part\": \"context-menu\",\n class: [\"adapttable-naive-context-menu\", props.className],\n onKeydown: keydown,\n contentStyle: {\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"4px\",\n },\n style: {\n maxWidth: \"90vw\",\n maxHeight: \"80dvh\",\n overflow: \"auto\",\n },\n },\n { default: () => props.children }\n ),\n }\n );\n };\n },\n {\n name: \"NaiveContextMenuSurface\",\n props: {\n at: {\n type: Object as PropType<ContextMenuSurfaceProps<VNodeChild>[\"at\"]>,\n },\n anchorRef: {\n type: Object as PropType<\n ContextMenuSurfaceProps<VNodeChild>[\"anchorRef\"]\n >,\n },\n label: {\n type: String as PropType<ContextMenuSurfaceProps<VNodeChild>[\"label\"]>,\n },\n onClose: {\n type: Function as PropType<\n ContextMenuSurfaceProps<VNodeChild>[\"onClose\"]\n >,\n },\n container: {\n type: Object as PropType<\n ContextMenuSurfaceProps<VNodeChild>[\"container\"]\n >,\n },\n children: {\n type: [String, Number, Boolean, Array, Object] as PropType<\n ContextMenuSurfaceProps<VNodeChild>[\"children\"]\n >,\n default: undefined,\n },\n className: {\n type: String as PropType<\n ContextMenuSurfaceProps<VNodeChild>[\"className\"]\n >,\n },\n },\n }\n);\n","import type { TableFeature } from \"@adapttable/vue\";\nimport {\n CONTEXT_MENU_CONTROL,\n ContextMenuChrome,\n type ContextMenuSlots,\n extendFeature,\n slotRender,\n} from \"@adapttable/vue/adapter\";\nimport {\n contextMenu as bindingContextMenu,\n type ContextMenuOptions,\n} from \"@adapttable/vue/features\";\nimport { NDivider } from \"naive-ui\";\nimport { h } from \"vue\";\n\nimport { NaiveContextMenuSurface } from \"./actions/NaiveContextMenuSurface\";\nimport { naiveButton } from \"./controls/button\";\nfunction contextSlots(\n names: Readonly<Record<string, string | undefined>> = {}\n): ContextMenuSlots {\n return {\n Surface: (props) => h(NaiveContextMenuSurface, props),\n Item: ({ item, onSelect }) =>\n naiveButton(\n {\n role: \"menuitem\",\n tabindex: -1,\n disabled: item.disabled,\n \"aria-disabled\": item.disabled,\n \"data-danger\": item.danger ? \"\" : undefined,\n \"data-adapttable-part\": \"context-menu-item\",\n class: names.contextMenuItem,\n onClick: onSelect,\n },\n item.label\n ),\n Separator: () =>\n h(NDivider, {\n role: \"separator\",\n \"data-adapttable-part\": \"context-menu-separator\",\n class: names.contextMenuSeparator,\n }),\n };\n}\nexport function contextMenu<TRow>(\n options: boolean | ContextMenuOptions<TRow> = true\n): TableFeature<TRow> {\n return extendFeature(bindingContextMenu<TRow>(options), [\n slotRender(CONTEXT_MENU_CONTROL, (props) =>\n h(ContextMenuChrome, {\n items: props.model.items,\n at: props.model.at,\n onClose: props.model.close,\n labels: props.labels,\n className: props.classNames?.contextMenu,\n container: props.container,\n slots: contextSlots(props.classNames),\n })\n ),\n ]);\n}\nexport type { ContextMenuOptions } from \"@adapttable/vue/features\";\n"],"mappings":";;;;;;;AAmBA,MAAa,0BAAwC,+BAClD,UAA+C;CAC9C,MAAM,SAAS,iBAAiB;CAChC,MAAM,OAAO,WAA2C,IAAI;CAC5D,MAAM,aAAa,qBAAqB;CACxC,MAAM,aAAc,KAAK,QAAQ,SAAS,KAAK,KAAK,IAAI;CACxD,MAAM,gBAAgB;EACpB,MAAM,QAAQ,KAAK;EACnB,OAAO,CACL,GAAI,OAAO,iBAA8B,qBAAmB,KAAK,CAAC,CACpE,CAAC,CAAC,QAAQ,SAAS,KAAK,QAAQ,iBAAe,MAAM,KAAK;CAC5D;CACA,MACE;EAAC;EAAM;QAAc,MAAM;CAAE,IAC5B,GAAG,OAAO,WAAW,YAAY;EAChC,WAAW,MAAM;EACjB,IAAI,CAAC,MAAM;EACX,IAAI,UAAU;EACd,eAAoB;GAClB,IAAI,WAAW,OAAO,OACpB,QAAQ,CAAC,CACN,MAAM,SAAS,KAAK,aAAa,eAAe,MAAM,MAAM,CAAC,EAC5D,MAAM,EAAE,eAAe,KAAK,CAAC;EACrC,CAAC;EACD,cAAc;GACZ,UAAU;EACZ,CAAC;CACH,GACA,EAAE,OAAO,OAAO,CAClB;CACA,MAAM,WAAW,UAAyB;EACxC,MAAM,QAAQ,KAAK;EACnB,IACE,CAAC,OAAO,SACR,CAAC,SACD,EAAE,MAAM,kBAAkB,YAC1B,MAAM,OAA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;IAAQ;IAAS;IAAO;GAAM;GAG7C,SAAS,KAAA;EACX;EACA,WAAW,EACT,MAAM,OAGR;CACF;AACF,CACF;;;AC/IA,SAAS,aACP,QAAsD,CAAC,GACrC;CAClB,OAAO;EACL,UAAU,UAAU,EAAE,yBAAyB,KAAK;EACpD,OAAO,EAAE,MAAM,eACb,YACE;GACE,MAAM;GACN,UAAU;GACV,UAAU,KAAK;GACf,iBAAiB,KAAK;GACtB,eAAe,KAAK,SAAS,KAAK,KAAA;GAClC,wBAAwB;GACxB,OAAO,MAAM;GACb,SAAS;EACX,GACA,KAAK,KACP;EACF,iBACE,EAAE,UAAU;GACV,MAAM;GACN,wBAAwB;GACxB,OAAO,MAAM;EACf,CAAC;CACL;AACF;AACA,SAAgBA,cACd,UAA8C,MAC1B;CACpB,OAAO,cAAcC,YAAyB,OAAO,GAAG,CACtD,WAAW,uBAAuB,UAChC,EAAE,mBAAmB;EACnB,OAAO,MAAM,MAAM;EACnB,IAAI,MAAM,MAAM;EAChB,SAAS,MAAM,MAAM;EACrB,QAAQ,MAAM;EACd,WAAW,MAAM,YAAY;EAC7B,WAAW,MAAM;EACjB,OAAO,aAAa,MAAM,UAAU;CACtC,CAAC,CACH,CACF,CAAC;AACH"}
@@ -1,141 +1,3 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_button = require("./button-CaakTzYM.cjs");
3
- let _adapttable_vue_adapter = require("@adapttable/vue/adapter");
4
- let _adapttable_vue_features = require("@adapttable/vue/features");
5
- let vue = require("vue");
6
- let naive_ui = require("naive-ui");
7
- //#region src/actions/NaiveContextMenuSurface.ts
8
- /** Native surfaces apply the shared core's menu-navigation decisions. */
9
- const NaiveContextMenuSurface = /*#__PURE__*/ (0, vue.defineComponent)((props) => {
10
- const active = (0, _adapttable_vue_adapter.useScopeActivity)();
11
- const card = (0, vue.shallowRef)(null);
12
- const navigation = (0, _adapttable_vue_adapter.createMenuNavigation)();
13
- const root = () => card.value ? require_button.htmlRoot(card.value) : null;
14
- const entries = () => {
15
- const panel = root();
16
- return [...panel?.querySelectorAll("[role=\"menuitem\"]") ?? []].filter((item) => item.closest("[role=\"menu\"]") === panel);
17
- };
18
- (0, vue.watch)([
19
- card,
20
- active,
21
- () => props.at
22
- ], ([, live], _previous, cleanup) => {
23
- navigation.reset();
24
- if (!live) return;
25
- let current = true;
26
- (0, vue.nextTick)(() => {
27
- if (current && active.value) entries().find((item) => item.getAttribute("aria-disabled") !== "true")?.focus({ preventScroll: true });
28
- });
29
- cleanup(() => {
30
- current = false;
31
- });
32
- }, { flush: "post" });
33
- const keydown = (event) => {
34
- const panel = root();
35
- if (!active.value || !panel || !(event.target instanceof Element) || event.target.closest("[role=\"menu\"]") !== panel) return;
36
- const items = entries();
37
- const focusTargets = items;
38
- const action = navigation.key(event, items.map((item) => ({
39
- label: item.textContent ?? "",
40
- disabled: item.getAttribute("aria-disabled") === "true"
41
- })), focusTargets.indexOf(panel.ownerDocument.activeElement));
42
- if (!action) return;
43
- if (action.kind !== "close" || action.key !== "Tab") event.preventDefault();
44
- event.stopPropagation();
45
- if (action.kind === "close") props.onClose();
46
- else items[action.index]?.focus({ preventScroll: true });
47
- };
48
- return () => {
49
- const at = props.at;
50
- const close = () => {
51
- if (active.value && props.at === at) props.onClose();
52
- };
53
- return (0, vue.h)(naive_ui.NPopover, {
54
- trigger: "manual",
55
- show: active.value,
56
- x: at.x,
57
- y: at.y,
58
- to: props.container ?? false,
59
- raw: true,
60
- showArrow: false,
61
- placement: "bottom-start",
62
- onClickoutside: close
63
- }, { default: () => (0, vue.h)(naive_ui.NCard, {
64
- ref: card,
65
- size: "small",
66
- role: "menu",
67
- tabindex: -1,
68
- "aria-label": props.label,
69
- "data-adapttable-part": "context-menu",
70
- class: ["adapttable-naive-context-menu", props.className],
71
- onKeydown: keydown,
72
- contentStyle: {
73
- display: "flex",
74
- flexDirection: "column",
75
- gap: "4px"
76
- },
77
- style: {
78
- maxWidth: "90vw",
79
- maxHeight: "80dvh",
80
- overflow: "auto"
81
- }
82
- }, { default: () => props.children }) });
83
- };
84
- }, {
85
- name: "NaiveContextMenuSurface",
86
- props: {
87
- at: { type: Object },
88
- anchorRef: { type: Object },
89
- label: { type: String },
90
- onClose: { type: Function },
91
- container: { type: Object },
92
- children: {
93
- type: [
94
- String,
95
- Number,
96
- Boolean,
97
- Array,
98
- Object
99
- ],
100
- default: void 0
101
- },
102
- className: { type: String }
103
- }
104
- });
105
- //#endregion
106
- //#region src/context-menu.ts
107
- function contextSlots(names = {}) {
108
- return {
109
- Surface: (props) => (0, vue.h)(NaiveContextMenuSurface, props),
110
- Item: ({ item, onSelect }) => require_button.naiveButton({
111
- role: "menuitem",
112
- tabindex: -1,
113
- disabled: item.disabled,
114
- "aria-disabled": item.disabled,
115
- "data-danger": item.danger ? "" : void 0,
116
- "data-adapttable-part": "context-menu-item",
117
- class: names.contextMenuItem,
118
- onClick: onSelect
119
- }, item.label),
120
- Separator: () => (0, vue.h)(naive_ui.NDivider, {
121
- role: "separator",
122
- "data-adapttable-part": "context-menu-separator",
123
- class: names.contextMenuSeparator
124
- })
125
- };
126
- }
127
- function contextMenu(options = true) {
128
- return (0, _adapttable_vue_adapter.extendFeature)((0, _adapttable_vue_features.contextMenu)(options), [(0, _adapttable_vue_adapter.slotRender)(_adapttable_vue_adapter.CONTEXT_MENU_CONTROL, (props) => (0, vue.h)(_adapttable_vue_adapter.ContextMenuChrome, {
129
- items: props.model.items,
130
- at: props.model.at,
131
- onClose: props.model.close,
132
- labels: props.labels,
133
- className: props.classNames?.contextMenu,
134
- container: props.container,
135
- slots: contextSlots(props.classNames)
136
- }))]);
137
- }
138
- //#endregion
139
- exports.contextMenu = contextMenu;
140
-
141
- //# sourceMappingURL=context-menu.cjs.map
2
+ const require_context_menu = require("./context-menu-BbhrjTZr.cjs");
3
+ exports.contextMenu = require_context_menu.contextMenu;
@@ -1,140 +1,2 @@
1
- import { r as htmlRoot, t as naiveButton } from "./button-BxXdDW7A.js";
2
- import { CONTEXT_MENU_CONTROL, ContextMenuChrome, createMenuNavigation, extendFeature, slotRender, useScopeActivity } from "@adapttable/vue/adapter";
3
- import { contextMenu as contextMenu$1 } from "@adapttable/vue/features";
4
- import { defineComponent, h, nextTick, shallowRef, watch } from "vue";
5
- import { NCard, NDivider, NPopover } from "naive-ui";
6
- //#region src/actions/NaiveContextMenuSurface.ts
7
- /** Native surfaces apply the shared core's menu-navigation decisions. */
8
- const NaiveContextMenuSurface = /*#__PURE__*/ defineComponent((props) => {
9
- const active = useScopeActivity();
10
- const card = shallowRef(null);
11
- const navigation = createMenuNavigation();
12
- const root = () => card.value ? htmlRoot(card.value) : null;
13
- const entries = () => {
14
- const panel = root();
15
- return [...panel?.querySelectorAll("[role=\"menuitem\"]") ?? []].filter((item) => item.closest("[role=\"menu\"]") === panel);
16
- };
17
- watch([
18
- card,
19
- active,
20
- () => props.at
21
- ], ([, live], _previous, cleanup) => {
22
- navigation.reset();
23
- if (!live) return;
24
- let current = true;
25
- nextTick(() => {
26
- if (current && active.value) entries().find((item) => item.getAttribute("aria-disabled") !== "true")?.focus({ preventScroll: true });
27
- });
28
- cleanup(() => {
29
- current = false;
30
- });
31
- }, { flush: "post" });
32
- const keydown = (event) => {
33
- const panel = root();
34
- if (!active.value || !panel || !(event.target instanceof Element) || event.target.closest("[role=\"menu\"]") !== panel) return;
35
- const items = entries();
36
- const focusTargets = items;
37
- const action = navigation.key(event, items.map((item) => ({
38
- label: item.textContent ?? "",
39
- disabled: item.getAttribute("aria-disabled") === "true"
40
- })), focusTargets.indexOf(panel.ownerDocument.activeElement));
41
- if (!action) return;
42
- if (action.kind !== "close" || action.key !== "Tab") event.preventDefault();
43
- event.stopPropagation();
44
- if (action.kind === "close") props.onClose();
45
- else items[action.index]?.focus({ preventScroll: true });
46
- };
47
- return () => {
48
- const at = props.at;
49
- const close = () => {
50
- if (active.value && props.at === at) props.onClose();
51
- };
52
- return h(NPopover, {
53
- trigger: "manual",
54
- show: active.value,
55
- x: at.x,
56
- y: at.y,
57
- to: props.container ?? false,
58
- raw: true,
59
- showArrow: false,
60
- placement: "bottom-start",
61
- onClickoutside: close
62
- }, { default: () => h(NCard, {
63
- ref: card,
64
- size: "small",
65
- role: "menu",
66
- tabindex: -1,
67
- "aria-label": props.label,
68
- "data-adapttable-part": "context-menu",
69
- class: ["adapttable-naive-context-menu", props.className],
70
- onKeydown: keydown,
71
- contentStyle: {
72
- display: "flex",
73
- flexDirection: "column",
74
- gap: "4px"
75
- },
76
- style: {
77
- maxWidth: "90vw",
78
- maxHeight: "80dvh",
79
- overflow: "auto"
80
- }
81
- }, { default: () => props.children }) });
82
- };
83
- }, {
84
- name: "NaiveContextMenuSurface",
85
- props: {
86
- at: { type: Object },
87
- anchorRef: { type: Object },
88
- label: { type: String },
89
- onClose: { type: Function },
90
- container: { type: Object },
91
- children: {
92
- type: [
93
- String,
94
- Number,
95
- Boolean,
96
- Array,
97
- Object
98
- ],
99
- default: void 0
100
- },
101
- className: { type: String }
102
- }
103
- });
104
- //#endregion
105
- //#region src/context-menu.ts
106
- function contextSlots(names = {}) {
107
- return {
108
- Surface: (props) => h(NaiveContextMenuSurface, props),
109
- Item: ({ item, onSelect }) => naiveButton({
110
- role: "menuitem",
111
- tabindex: -1,
112
- disabled: item.disabled,
113
- "aria-disabled": item.disabled,
114
- "data-danger": item.danger ? "" : void 0,
115
- "data-adapttable-part": "context-menu-item",
116
- class: names.contextMenuItem,
117
- onClick: onSelect
118
- }, item.label),
119
- Separator: () => h(NDivider, {
120
- role: "separator",
121
- "data-adapttable-part": "context-menu-separator",
122
- class: names.contextMenuSeparator
123
- })
124
- };
125
- }
126
- function contextMenu(options = true) {
127
- return extendFeature(contextMenu$1(options), [slotRender(CONTEXT_MENU_CONTROL, (props) => h(ContextMenuChrome, {
128
- items: props.model.items,
129
- at: props.model.at,
130
- onClose: props.model.close,
131
- labels: props.labels,
132
- className: props.classNames?.contextMenu,
133
- container: props.container,
134
- slots: contextSlots(props.classNames)
135
- }))]);
136
- }
137
- //#endregion
1
+ import { t as contextMenu } from "./context-menu-DjYIQXhY.js";
138
2
  export { contextMenu };
139
-
140
- //# sourceMappingURL=context-menu.js.map