@mekari/pixel3-table 0.0.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.
@@ -0,0 +1,37 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ // src/modules/table.props.ts
5
+ var tableProps = {
6
+ isHoverable: {
7
+ type: Boolean,
8
+ default: true
9
+ }
10
+ };
11
+ var tableHeadProps = {
12
+ isFixed: {
13
+ type: Boolean
14
+ }
15
+ };
16
+ var tableCellProps = {
17
+ as: {
18
+ type: String,
19
+ default: "th"
20
+ },
21
+ isFixed: {
22
+ type: Boolean
23
+ }
24
+ };
25
+ var tableContainerProps = {
26
+ hasShadow: {
27
+ type: Boolean
28
+ }
29
+ };
30
+
31
+ export {
32
+ __name,
33
+ tableProps,
34
+ tableHeadProps,
35
+ tableCellProps,
36
+ tableContainerProps
37
+ };
@@ -0,0 +1,187 @@
1
+ import {
2
+ __name,
3
+ tableCellProps,
4
+ tableContainerProps,
5
+ tableHeadProps,
6
+ tableProps
7
+ } from "./chunk-3GSGQUM7.mjs";
8
+
9
+ // src/table.tsx
10
+ import { isVNode as _isVNode, createVNode as _createVNode } from "vue";
11
+ import { defineComponent, ref, onMounted } from "vue";
12
+ import { tableRecipe, tableContainerRecipe } from "@mekari/pixel3-styled-system/recipes";
13
+ function _isSlot(s) {
14
+ return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !_isVNode(s);
15
+ }
16
+ __name(_isSlot, "_isSlot");
17
+ var MpTable = defineComponent({
18
+ name: "MpTable",
19
+ props: tableProps,
20
+ setup(props, {
21
+ slots
22
+ }) {
23
+ const classes = tableRecipe();
24
+ return () => {
25
+ const children = slots.default && slots.default();
26
+ const {
27
+ isHoverable
28
+ } = props;
29
+ return _createVNode("table", {
30
+ "class": classes,
31
+ "data-pixel-component": "MpTable",
32
+ "data-table-hoverable": isHoverable ? true : void 0
33
+ }, [children]);
34
+ };
35
+ }
36
+ });
37
+ var MpTableHead = defineComponent({
38
+ name: "MpTableHead",
39
+ props: tableHeadProps,
40
+ setup(props, {
41
+ slots
42
+ }) {
43
+ return () => {
44
+ const children = slots.default && slots.default();
45
+ const {
46
+ isFixed
47
+ } = props;
48
+ return _createVNode("thead", {
49
+ "data-pixel-component": "MpTableHead",
50
+ "data-table-head-fixed": isFixed ? true : void 0
51
+ }, [children]);
52
+ };
53
+ }
54
+ });
55
+ var MpTableBody = defineComponent({
56
+ name: "MpTableBody",
57
+ setup(props, {
58
+ slots
59
+ }) {
60
+ return () => {
61
+ const children = slots.default && slots.default();
62
+ return _createVNode("tbody", {
63
+ "data-pixel-component": "MpTableBody"
64
+ }, [children]);
65
+ };
66
+ }
67
+ });
68
+ var MpTableRow = defineComponent({
69
+ name: "MpTableRow",
70
+ setup(props, {
71
+ slots
72
+ }) {
73
+ return () => {
74
+ const children = slots.default && slots.default();
75
+ return _createVNode("tr", {
76
+ "data-pixel-component": "MpTableRow"
77
+ }, [children]);
78
+ };
79
+ }
80
+ });
81
+ var MpTableCell = defineComponent({
82
+ name: "MpTableCell",
83
+ props: tableCellProps,
84
+ setup(props, {
85
+ slots
86
+ }) {
87
+ return () => {
88
+ const children = slots.default && slots.default();
89
+ const {
90
+ as: Component,
91
+ isFixed
92
+ } = props;
93
+ return _createVNode(Component, {
94
+ "data-pixel-component": "MpTableCell",
95
+ "data-table-cell-fixed": isFixed ? true : void 0
96
+ }, _isSlot(children) ? children : {
97
+ default: () => [children]
98
+ });
99
+ };
100
+ }
101
+ });
102
+ var MpTableContainer = defineComponent({
103
+ name: "MpTableContainer",
104
+ props: tableContainerProps,
105
+ emits: ["scroll"],
106
+ setup(props, {
107
+ slots,
108
+ emit
109
+ }) {
110
+ const classes = tableContainerRecipe();
111
+ const showLeftShadow = ref(false);
112
+ const showRightShadow = ref(false);
113
+ const tableContainer = ref(null);
114
+ onMounted(() => {
115
+ if (props.hasShadow) {
116
+ handleShadow(tableContainer.value);
117
+ }
118
+ });
119
+ const setShadowStyle = /* @__PURE__ */ __name((clientWidth, scrollWidth, scrollLeft) => {
120
+ const isScrollRightEnd = Math.round(scrollLeft) >= scrollWidth - clientWidth;
121
+ const isScrollLeftEnd = scrollLeft === 0;
122
+ const isScrollBoth = !isScrollLeftEnd && !isScrollRightEnd;
123
+ if (isScrollLeftEnd) {
124
+ showRightShadow.value = true;
125
+ showLeftShadow.value = false;
126
+ }
127
+ if (isScrollBoth) {
128
+ showRightShadow.value = true;
129
+ showLeftShadow.value = true;
130
+ }
131
+ if (isScrollRightEnd) {
132
+ showRightShadow.value = false;
133
+ showLeftShadow.value = true;
134
+ }
135
+ }, "setShadowStyle");
136
+ const handleShadow = /* @__PURE__ */ __name((el) => {
137
+ const element = el;
138
+ if (element) {
139
+ const {
140
+ clientWidth,
141
+ scrollWidth,
142
+ scrollLeft
143
+ } = element;
144
+ const isHorizontalScroll = clientWidth < scrollWidth;
145
+ if (isHorizontalScroll) {
146
+ setShadowStyle(clientWidth, scrollWidth, scrollLeft);
147
+ } else {
148
+ showRightShadow.value = false;
149
+ showLeftShadow.value = false;
150
+ }
151
+ }
152
+ }, "handleShadow");
153
+ const onScroll = /* @__PURE__ */ __name((e) => {
154
+ if (props.hasShadow) {
155
+ handleShadow(e.target);
156
+ emit("scroll", e);
157
+ }
158
+ }, "onScroll");
159
+ return () => {
160
+ const children = slots.default && slots.default();
161
+ const {
162
+ hasShadow
163
+ } = props;
164
+ return _createVNode("div", {
165
+ "class": classes,
166
+ "data-pixel-component": "MpTableContainer",
167
+ "data-table-has-left-shadow": showLeftShadow.value ? true : void 0,
168
+ "data-table-has-right-shadow": showRightShadow.value ? true : void 0
169
+ }, [_createVNode("div", {
170
+ "ref": tableContainer,
171
+ "onScroll": onScroll,
172
+ "style": {
173
+ overflowX: hasShadow ? "scroll" : void 0
174
+ }
175
+ }, [children])]);
176
+ };
177
+ }
178
+ });
179
+
180
+ export {
181
+ MpTable,
182
+ MpTableHead,
183
+ MpTableBody,
184
+ MpTableRow,
185
+ MpTableCell,
186
+ MpTableContainer
187
+ };
@@ -0,0 +1,2 @@
1
+ export { MpTable, MpTableBody, MpTableCell, MpTableContainer, MpTableHead, MpTableRow } from './table.mjs';
2
+ import 'vue';
@@ -0,0 +1,2 @@
1
+ export { MpTable, MpTableBody, MpTableCell, MpTableContainer, MpTableHead, MpTableRow } from './table.js';
2
+ import 'vue';
package/dist/index.js ADDED
@@ -0,0 +1,240 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/index.tsx
22
+ var src_exports = {};
23
+ __export(src_exports, {
24
+ MpTable: () => MpTable,
25
+ MpTableBody: () => MpTableBody,
26
+ MpTableCell: () => MpTableCell,
27
+ MpTableContainer: () => MpTableContainer,
28
+ MpTableHead: () => MpTableHead,
29
+ MpTableRow: () => MpTableRow
30
+ });
31
+ module.exports = __toCommonJS(src_exports);
32
+
33
+ // src/table.tsx
34
+ var import_vue = require("vue");
35
+ var import_vue2 = require("vue");
36
+ var import_recipes = require("@mekari/pixel3-styled-system/recipes");
37
+
38
+ // src/modules/table.props.ts
39
+ var tableProps = {
40
+ isHoverable: {
41
+ type: Boolean,
42
+ default: true
43
+ }
44
+ };
45
+ var tableHeadProps = {
46
+ isFixed: {
47
+ type: Boolean
48
+ }
49
+ };
50
+ var tableCellProps = {
51
+ as: {
52
+ type: String,
53
+ default: "th"
54
+ },
55
+ isFixed: {
56
+ type: Boolean
57
+ }
58
+ };
59
+ var tableContainerProps = {
60
+ hasShadow: {
61
+ type: Boolean
62
+ }
63
+ };
64
+
65
+ // src/table.tsx
66
+ function _isSlot(s) {
67
+ return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !(0, import_vue.isVNode)(s);
68
+ }
69
+ __name(_isSlot, "_isSlot");
70
+ var MpTable = (0, import_vue2.defineComponent)({
71
+ name: "MpTable",
72
+ props: tableProps,
73
+ setup(props, {
74
+ slots
75
+ }) {
76
+ const classes = (0, import_recipes.tableRecipe)();
77
+ return () => {
78
+ const children = slots.default && slots.default();
79
+ const {
80
+ isHoverable
81
+ } = props;
82
+ return (0, import_vue.createVNode)("table", {
83
+ "class": classes,
84
+ "data-pixel-component": "MpTable",
85
+ "data-table-hoverable": isHoverable ? true : void 0
86
+ }, [children]);
87
+ };
88
+ }
89
+ });
90
+ var MpTableHead = (0, import_vue2.defineComponent)({
91
+ name: "MpTableHead",
92
+ props: tableHeadProps,
93
+ setup(props, {
94
+ slots
95
+ }) {
96
+ return () => {
97
+ const children = slots.default && slots.default();
98
+ const {
99
+ isFixed
100
+ } = props;
101
+ return (0, import_vue.createVNode)("thead", {
102
+ "data-pixel-component": "MpTableHead",
103
+ "data-table-head-fixed": isFixed ? true : void 0
104
+ }, [children]);
105
+ };
106
+ }
107
+ });
108
+ var MpTableBody = (0, import_vue2.defineComponent)({
109
+ name: "MpTableBody",
110
+ setup(props, {
111
+ slots
112
+ }) {
113
+ return () => {
114
+ const children = slots.default && slots.default();
115
+ return (0, import_vue.createVNode)("tbody", {
116
+ "data-pixel-component": "MpTableBody"
117
+ }, [children]);
118
+ };
119
+ }
120
+ });
121
+ var MpTableRow = (0, import_vue2.defineComponent)({
122
+ name: "MpTableRow",
123
+ setup(props, {
124
+ slots
125
+ }) {
126
+ return () => {
127
+ const children = slots.default && slots.default();
128
+ return (0, import_vue.createVNode)("tr", {
129
+ "data-pixel-component": "MpTableRow"
130
+ }, [children]);
131
+ };
132
+ }
133
+ });
134
+ var MpTableCell = (0, import_vue2.defineComponent)({
135
+ name: "MpTableCell",
136
+ props: tableCellProps,
137
+ setup(props, {
138
+ slots
139
+ }) {
140
+ return () => {
141
+ const children = slots.default && slots.default();
142
+ const {
143
+ as: Component,
144
+ isFixed
145
+ } = props;
146
+ return (0, import_vue.createVNode)(Component, {
147
+ "data-pixel-component": "MpTableCell",
148
+ "data-table-cell-fixed": isFixed ? true : void 0
149
+ }, _isSlot(children) ? children : {
150
+ default: () => [children]
151
+ });
152
+ };
153
+ }
154
+ });
155
+ var MpTableContainer = (0, import_vue2.defineComponent)({
156
+ name: "MpTableContainer",
157
+ props: tableContainerProps,
158
+ emits: ["scroll"],
159
+ setup(props, {
160
+ slots,
161
+ emit
162
+ }) {
163
+ const classes = (0, import_recipes.tableContainerRecipe)();
164
+ const showLeftShadow = (0, import_vue2.ref)(false);
165
+ const showRightShadow = (0, import_vue2.ref)(false);
166
+ const tableContainer = (0, import_vue2.ref)(null);
167
+ (0, import_vue2.onMounted)(() => {
168
+ if (props.hasShadow) {
169
+ handleShadow(tableContainer.value);
170
+ }
171
+ });
172
+ const setShadowStyle = /* @__PURE__ */ __name((clientWidth, scrollWidth, scrollLeft) => {
173
+ const isScrollRightEnd = Math.round(scrollLeft) >= scrollWidth - clientWidth;
174
+ const isScrollLeftEnd = scrollLeft === 0;
175
+ const isScrollBoth = !isScrollLeftEnd && !isScrollRightEnd;
176
+ if (isScrollLeftEnd) {
177
+ showRightShadow.value = true;
178
+ showLeftShadow.value = false;
179
+ }
180
+ if (isScrollBoth) {
181
+ showRightShadow.value = true;
182
+ showLeftShadow.value = true;
183
+ }
184
+ if (isScrollRightEnd) {
185
+ showRightShadow.value = false;
186
+ showLeftShadow.value = true;
187
+ }
188
+ }, "setShadowStyle");
189
+ const handleShadow = /* @__PURE__ */ __name((el) => {
190
+ const element = el;
191
+ if (element) {
192
+ const {
193
+ clientWidth,
194
+ scrollWidth,
195
+ scrollLeft
196
+ } = element;
197
+ const isHorizontalScroll = clientWidth < scrollWidth;
198
+ if (isHorizontalScroll) {
199
+ setShadowStyle(clientWidth, scrollWidth, scrollLeft);
200
+ } else {
201
+ showRightShadow.value = false;
202
+ showLeftShadow.value = false;
203
+ }
204
+ }
205
+ }, "handleShadow");
206
+ const onScroll = /* @__PURE__ */ __name((e) => {
207
+ if (props.hasShadow) {
208
+ handleShadow(e.target);
209
+ emit("scroll", e);
210
+ }
211
+ }, "onScroll");
212
+ return () => {
213
+ const children = slots.default && slots.default();
214
+ const {
215
+ hasShadow
216
+ } = props;
217
+ return (0, import_vue.createVNode)("div", {
218
+ "class": classes,
219
+ "data-pixel-component": "MpTableContainer",
220
+ "data-table-has-left-shadow": showLeftShadow.value ? true : void 0,
221
+ "data-table-has-right-shadow": showRightShadow.value ? true : void 0
222
+ }, [(0, import_vue.createVNode)("div", {
223
+ "ref": tableContainer,
224
+ "onScroll": onScroll,
225
+ "style": {
226
+ overflowX: hasShadow ? "scroll" : void 0
227
+ }
228
+ }, [children])]);
229
+ };
230
+ }
231
+ });
232
+ // Annotate the CommonJS export names for ESM import in node:
233
+ 0 && (module.exports = {
234
+ MpTable,
235
+ MpTableBody,
236
+ MpTableCell,
237
+ MpTableContainer,
238
+ MpTableHead,
239
+ MpTableRow
240
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,17 @@
1
+ import {
2
+ MpTable,
3
+ MpTableBody,
4
+ MpTableCell,
5
+ MpTableContainer,
6
+ MpTableHead,
7
+ MpTableRow
8
+ } from "./chunk-WI56UCYK.mjs";
9
+ import "./chunk-3GSGQUM7.mjs";
10
+ export {
11
+ MpTable,
12
+ MpTableBody,
13
+ MpTableCell,
14
+ MpTableContainer,
15
+ MpTableHead,
16
+ MpTableRow
17
+ };
@@ -0,0 +1 @@
1
+ {"inputs":{"src/modules/table.props.ts":{"bytes":567,"imports":[],"format":"esm"},"src/table.tsx":{"bytes":5014,"imports":[{"path":"vue","kind":"import-statement","external":true},{"path":"vue","kind":"import-statement","external":true},{"path":"@mekari/pixel3-styled-system/recipes","kind":"import-statement","external":true},{"path":"src/modules/table.props.ts","kind":"import-statement","original":"./modules/table.props"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/index.tsx":{"bytes":188,"imports":[{"path":"src/table.tsx","kind":"import-statement","original":"./table"}],"format":"esm"}},"outputs":{"dist/index.js":{"imports":[{"path":"vue","kind":"require-call","external":true},{"path":"vue","kind":"require-call","external":true},{"path":"@mekari/pixel3-styled-system/recipes","kind":"require-call","external":true}],"exports":[],"entryPoint":"src/index.tsx","inputs":{"src/index.tsx":{"bytesInOutput":297},"src/table.tsx":{"bytesInOutput":4969},"src/modules/table.props.ts":{"bytesInOutput":319}},"bytes":6739},"dist/table.js":{"imports":[{"path":"vue","kind":"require-call","external":true},{"path":"vue","kind":"require-call","external":true},{"path":"@mekari/pixel3-styled-system/recipes","kind":"require-call","external":true}],"exports":[],"entryPoint":"src/table.tsx","inputs":{"src/table.tsx":{"bytesInOutput":5272},"src/modules/table.props.ts":{"bytesInOutput":319}},"bytes":6727},"dist/modules/table.props.js":{"imports":[],"exports":[],"entryPoint":"src/modules/table.props.ts","inputs":{"src/modules/table.props.ts":{"bytesInOutput":598}},"bytes":1591}}}
@@ -0,0 +1 @@
1
+ {"inputs":{"src/modules/table.props.ts":{"bytes":567,"imports":[],"format":"esm"},"src/table.tsx":{"bytes":5014,"imports":[{"path":"vue","kind":"import-statement","external":true},{"path":"vue","kind":"import-statement","external":true},{"path":"@mekari/pixel3-styled-system/recipes","kind":"import-statement","external":true},{"path":"src/modules/table.props.ts","kind":"import-statement","original":"./modules/table.props"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/index.tsx":{"bytes":188,"imports":[{"path":"src/table.tsx","kind":"import-statement","original":"./table"}],"format":"esm"}},"outputs":{"dist/index.mjs":{"imports":[{"path":"dist/chunk-WI56UCYK.mjs","kind":"import-statement"},{"path":"dist/chunk-3GSGQUM7.mjs","kind":"import-statement"}],"exports":["MpTable","MpTableBody","MpTableCell","MpTableContainer","MpTableHead","MpTableRow"],"entryPoint":"src/index.tsx","inputs":{"src/index.tsx":{"bytesInOutput":0}},"bytes":261},"dist/table.mjs":{"imports":[{"path":"dist/chunk-WI56UCYK.mjs","kind":"import-statement"},{"path":"dist/chunk-3GSGQUM7.mjs","kind":"import-statement"}],"exports":["MpTable","MpTableBody","MpTableCell","MpTableContainer","MpTableHead","MpTableRow"],"entryPoint":"src/table.tsx","inputs":{},"bytes":261},"dist/chunk-WI56UCYK.mjs":{"imports":[{"path":"dist/chunk-3GSGQUM7.mjs","kind":"import-statement"},{"path":"vue","kind":"import-statement","external":true},{"path":"vue","kind":"import-statement","external":true},{"path":"@mekari/pixel3-styled-system/recipes","kind":"import-statement","external":true}],"exports":["MpTable","MpTableBody","MpTableCell","MpTableContainer","MpTableHead","MpTableRow"],"inputs":{"src/table.tsx":{"bytesInOutput":4719}},"bytes":4961},"dist/modules/table.props.mjs":{"imports":[{"path":"dist/chunk-3GSGQUM7.mjs","kind":"import-statement"}],"exports":["tableCellProps","tableContainerProps","tableHeadProps","tableProps"],"entryPoint":"src/modules/table.props.ts","inputs":{},"bytes":197},"dist/chunk-3GSGQUM7.mjs":{"imports":[],"exports":["__name","tableCellProps","tableContainerProps","tableHeadProps","tableProps"],"inputs":{"src/modules/table.props.ts":{"bytesInOutput":319}},"bytes":574}}}
@@ -0,0 +1,29 @@
1
+ import { PropType } from 'vue';
2
+
3
+ declare const tableProps: {
4
+ isHoverable: {
5
+ type: BooleanConstructor;
6
+ default: boolean;
7
+ };
8
+ };
9
+ declare const tableHeadProps: {
10
+ isFixed: {
11
+ type: BooleanConstructor;
12
+ };
13
+ };
14
+ declare const tableCellProps: {
15
+ as: {
16
+ type: PropType<keyof HTMLElementTagNameMap>;
17
+ default: string;
18
+ };
19
+ isFixed: {
20
+ type: BooleanConstructor;
21
+ };
22
+ };
23
+ declare const tableContainerProps: {
24
+ hasShadow: {
25
+ type: BooleanConstructor;
26
+ };
27
+ };
28
+
29
+ export { tableCellProps, tableContainerProps, tableHeadProps, tableProps };
@@ -0,0 +1,29 @@
1
+ import { PropType } from 'vue';
2
+
3
+ declare const tableProps: {
4
+ isHoverable: {
5
+ type: BooleanConstructor;
6
+ default: boolean;
7
+ };
8
+ };
9
+ declare const tableHeadProps: {
10
+ isFixed: {
11
+ type: BooleanConstructor;
12
+ };
13
+ };
14
+ declare const tableCellProps: {
15
+ as: {
16
+ type: PropType<keyof HTMLElementTagNameMap>;
17
+ default: string;
18
+ };
19
+ isFixed: {
20
+ type: BooleanConstructor;
21
+ };
22
+ };
23
+ declare const tableContainerProps: {
24
+ hasShadow: {
25
+ type: BooleanConstructor;
26
+ };
27
+ };
28
+
29
+ export { tableCellProps, tableContainerProps, tableHeadProps, tableProps };
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/modules/table.props.ts
21
+ var table_props_exports = {};
22
+ __export(table_props_exports, {
23
+ tableCellProps: () => tableCellProps,
24
+ tableContainerProps: () => tableContainerProps,
25
+ tableHeadProps: () => tableHeadProps,
26
+ tableProps: () => tableProps
27
+ });
28
+ module.exports = __toCommonJS(table_props_exports);
29
+ var tableProps = {
30
+ isHoverable: {
31
+ type: Boolean,
32
+ default: true
33
+ }
34
+ };
35
+ var tableHeadProps = {
36
+ isFixed: {
37
+ type: Boolean
38
+ }
39
+ };
40
+ var tableCellProps = {
41
+ as: {
42
+ type: String,
43
+ default: "th"
44
+ },
45
+ isFixed: {
46
+ type: Boolean
47
+ }
48
+ };
49
+ var tableContainerProps = {
50
+ hasShadow: {
51
+ type: Boolean
52
+ }
53
+ };
54
+ // Annotate the CommonJS export names for ESM import in node:
55
+ 0 && (module.exports = {
56
+ tableCellProps,
57
+ tableContainerProps,
58
+ tableHeadProps,
59
+ tableProps
60
+ });
@@ -0,0 +1,12 @@
1
+ import {
2
+ tableCellProps,
3
+ tableContainerProps,
4
+ tableHeadProps,
5
+ tableProps
6
+ } from "../chunk-3GSGQUM7.mjs";
7
+ export {
8
+ tableCellProps,
9
+ tableContainerProps,
10
+ tableHeadProps,
11
+ tableProps
12
+ };
@@ -0,0 +1,63 @@
1
+ import * as vue from 'vue';
2
+
3
+ declare const MpTable: vue.DefineComponent<{
4
+ isHoverable: {
5
+ type: BooleanConstructor;
6
+ default: boolean;
7
+ };
8
+ }, () => JSX.Element, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
9
+ isHoverable: {
10
+ type: BooleanConstructor;
11
+ default: boolean;
12
+ };
13
+ }>>, {
14
+ isHoverable: boolean;
15
+ }, {}>;
16
+ declare const MpTableHead: vue.DefineComponent<{
17
+ isFixed: {
18
+ type: BooleanConstructor;
19
+ };
20
+ }, () => JSX.Element, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
21
+ isFixed: {
22
+ type: BooleanConstructor;
23
+ };
24
+ }>>, {
25
+ isFixed: boolean;
26
+ }, {}>;
27
+ declare const MpTableBody: vue.DefineComponent<{}, () => JSX.Element, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{}>>, {}, {}>;
28
+ declare const MpTableRow: vue.DefineComponent<{}, () => JSX.Element, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{}>>, {}, {}>;
29
+ declare const MpTableCell: vue.DefineComponent<{
30
+ as: {
31
+ type: vue.PropType<keyof HTMLElementTagNameMap>;
32
+ default: string;
33
+ };
34
+ isFixed: {
35
+ type: BooleanConstructor;
36
+ };
37
+ }, () => JSX.Element, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
38
+ as: {
39
+ type: vue.PropType<keyof HTMLElementTagNameMap>;
40
+ default: string;
41
+ };
42
+ isFixed: {
43
+ type: BooleanConstructor;
44
+ };
45
+ }>>, {
46
+ isFixed: boolean;
47
+ as: keyof HTMLElementTagNameMap;
48
+ }, {}>;
49
+ declare const MpTableContainer: vue.DefineComponent<{
50
+ hasShadow: {
51
+ type: BooleanConstructor;
52
+ };
53
+ }, () => JSX.Element, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, "scroll"[], "scroll", vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
54
+ hasShadow: {
55
+ type: BooleanConstructor;
56
+ };
57
+ }>> & {
58
+ onScroll?: ((...args: any[]) => any) | undefined;
59
+ }, {
60
+ hasShadow: boolean;
61
+ }, {}>;
62
+
63
+ export { MpTable, MpTableBody, MpTableCell, MpTableContainer, MpTableHead, MpTableRow };
@@ -0,0 +1,63 @@
1
+ import * as vue from 'vue';
2
+
3
+ declare const MpTable: vue.DefineComponent<{
4
+ isHoverable: {
5
+ type: BooleanConstructor;
6
+ default: boolean;
7
+ };
8
+ }, () => JSX.Element, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
9
+ isHoverable: {
10
+ type: BooleanConstructor;
11
+ default: boolean;
12
+ };
13
+ }>>, {
14
+ isHoverable: boolean;
15
+ }, {}>;
16
+ declare const MpTableHead: vue.DefineComponent<{
17
+ isFixed: {
18
+ type: BooleanConstructor;
19
+ };
20
+ }, () => JSX.Element, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
21
+ isFixed: {
22
+ type: BooleanConstructor;
23
+ };
24
+ }>>, {
25
+ isFixed: boolean;
26
+ }, {}>;
27
+ declare const MpTableBody: vue.DefineComponent<{}, () => JSX.Element, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{}>>, {}, {}>;
28
+ declare const MpTableRow: vue.DefineComponent<{}, () => JSX.Element, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{}>>, {}, {}>;
29
+ declare const MpTableCell: vue.DefineComponent<{
30
+ as: {
31
+ type: vue.PropType<keyof HTMLElementTagNameMap>;
32
+ default: string;
33
+ };
34
+ isFixed: {
35
+ type: BooleanConstructor;
36
+ };
37
+ }, () => JSX.Element, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
38
+ as: {
39
+ type: vue.PropType<keyof HTMLElementTagNameMap>;
40
+ default: string;
41
+ };
42
+ isFixed: {
43
+ type: BooleanConstructor;
44
+ };
45
+ }>>, {
46
+ isFixed: boolean;
47
+ as: keyof HTMLElementTagNameMap;
48
+ }, {}>;
49
+ declare const MpTableContainer: vue.DefineComponent<{
50
+ hasShadow: {
51
+ type: BooleanConstructor;
52
+ };
53
+ }, () => JSX.Element, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, "scroll"[], "scroll", vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
54
+ hasShadow: {
55
+ type: BooleanConstructor;
56
+ };
57
+ }>> & {
58
+ onScroll?: ((...args: any[]) => any) | undefined;
59
+ }, {
60
+ hasShadow: boolean;
61
+ }, {}>;
62
+
63
+ export { MpTable, MpTableBody, MpTableCell, MpTableContainer, MpTableHead, MpTableRow };
package/dist/table.js ADDED
@@ -0,0 +1,238 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/table.tsx
22
+ var table_exports = {};
23
+ __export(table_exports, {
24
+ MpTable: () => MpTable,
25
+ MpTableBody: () => MpTableBody,
26
+ MpTableCell: () => MpTableCell,
27
+ MpTableContainer: () => MpTableContainer,
28
+ MpTableHead: () => MpTableHead,
29
+ MpTableRow: () => MpTableRow
30
+ });
31
+ module.exports = __toCommonJS(table_exports);
32
+ var import_vue = require("vue");
33
+ var import_vue2 = require("vue");
34
+ var import_recipes = require("@mekari/pixel3-styled-system/recipes");
35
+
36
+ // src/modules/table.props.ts
37
+ var tableProps = {
38
+ isHoverable: {
39
+ type: Boolean,
40
+ default: true
41
+ }
42
+ };
43
+ var tableHeadProps = {
44
+ isFixed: {
45
+ type: Boolean
46
+ }
47
+ };
48
+ var tableCellProps = {
49
+ as: {
50
+ type: String,
51
+ default: "th"
52
+ },
53
+ isFixed: {
54
+ type: Boolean
55
+ }
56
+ };
57
+ var tableContainerProps = {
58
+ hasShadow: {
59
+ type: Boolean
60
+ }
61
+ };
62
+
63
+ // src/table.tsx
64
+ function _isSlot(s) {
65
+ return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !(0, import_vue.isVNode)(s);
66
+ }
67
+ __name(_isSlot, "_isSlot");
68
+ var MpTable = (0, import_vue2.defineComponent)({
69
+ name: "MpTable",
70
+ props: tableProps,
71
+ setup(props, {
72
+ slots
73
+ }) {
74
+ const classes = (0, import_recipes.tableRecipe)();
75
+ return () => {
76
+ const children = slots.default && slots.default();
77
+ const {
78
+ isHoverable
79
+ } = props;
80
+ return (0, import_vue.createVNode)("table", {
81
+ "class": classes,
82
+ "data-pixel-component": "MpTable",
83
+ "data-table-hoverable": isHoverable ? true : void 0
84
+ }, [children]);
85
+ };
86
+ }
87
+ });
88
+ var MpTableHead = (0, import_vue2.defineComponent)({
89
+ name: "MpTableHead",
90
+ props: tableHeadProps,
91
+ setup(props, {
92
+ slots
93
+ }) {
94
+ return () => {
95
+ const children = slots.default && slots.default();
96
+ const {
97
+ isFixed
98
+ } = props;
99
+ return (0, import_vue.createVNode)("thead", {
100
+ "data-pixel-component": "MpTableHead",
101
+ "data-table-head-fixed": isFixed ? true : void 0
102
+ }, [children]);
103
+ };
104
+ }
105
+ });
106
+ var MpTableBody = (0, import_vue2.defineComponent)({
107
+ name: "MpTableBody",
108
+ setup(props, {
109
+ slots
110
+ }) {
111
+ return () => {
112
+ const children = slots.default && slots.default();
113
+ return (0, import_vue.createVNode)("tbody", {
114
+ "data-pixel-component": "MpTableBody"
115
+ }, [children]);
116
+ };
117
+ }
118
+ });
119
+ var MpTableRow = (0, import_vue2.defineComponent)({
120
+ name: "MpTableRow",
121
+ setup(props, {
122
+ slots
123
+ }) {
124
+ return () => {
125
+ const children = slots.default && slots.default();
126
+ return (0, import_vue.createVNode)("tr", {
127
+ "data-pixel-component": "MpTableRow"
128
+ }, [children]);
129
+ };
130
+ }
131
+ });
132
+ var MpTableCell = (0, import_vue2.defineComponent)({
133
+ name: "MpTableCell",
134
+ props: tableCellProps,
135
+ setup(props, {
136
+ slots
137
+ }) {
138
+ return () => {
139
+ const children = slots.default && slots.default();
140
+ const {
141
+ as: Component,
142
+ isFixed
143
+ } = props;
144
+ return (0, import_vue.createVNode)(Component, {
145
+ "data-pixel-component": "MpTableCell",
146
+ "data-table-cell-fixed": isFixed ? true : void 0
147
+ }, _isSlot(children) ? children : {
148
+ default: () => [children]
149
+ });
150
+ };
151
+ }
152
+ });
153
+ var MpTableContainer = (0, import_vue2.defineComponent)({
154
+ name: "MpTableContainer",
155
+ props: tableContainerProps,
156
+ emits: ["scroll"],
157
+ setup(props, {
158
+ slots,
159
+ emit
160
+ }) {
161
+ const classes = (0, import_recipes.tableContainerRecipe)();
162
+ const showLeftShadow = (0, import_vue2.ref)(false);
163
+ const showRightShadow = (0, import_vue2.ref)(false);
164
+ const tableContainer = (0, import_vue2.ref)(null);
165
+ (0, import_vue2.onMounted)(() => {
166
+ if (props.hasShadow) {
167
+ handleShadow(tableContainer.value);
168
+ }
169
+ });
170
+ const setShadowStyle = /* @__PURE__ */ __name((clientWidth, scrollWidth, scrollLeft) => {
171
+ const isScrollRightEnd = Math.round(scrollLeft) >= scrollWidth - clientWidth;
172
+ const isScrollLeftEnd = scrollLeft === 0;
173
+ const isScrollBoth = !isScrollLeftEnd && !isScrollRightEnd;
174
+ if (isScrollLeftEnd) {
175
+ showRightShadow.value = true;
176
+ showLeftShadow.value = false;
177
+ }
178
+ if (isScrollBoth) {
179
+ showRightShadow.value = true;
180
+ showLeftShadow.value = true;
181
+ }
182
+ if (isScrollRightEnd) {
183
+ showRightShadow.value = false;
184
+ showLeftShadow.value = true;
185
+ }
186
+ }, "setShadowStyle");
187
+ const handleShadow = /* @__PURE__ */ __name((el) => {
188
+ const element = el;
189
+ if (element) {
190
+ const {
191
+ clientWidth,
192
+ scrollWidth,
193
+ scrollLeft
194
+ } = element;
195
+ const isHorizontalScroll = clientWidth < scrollWidth;
196
+ if (isHorizontalScroll) {
197
+ setShadowStyle(clientWidth, scrollWidth, scrollLeft);
198
+ } else {
199
+ showRightShadow.value = false;
200
+ showLeftShadow.value = false;
201
+ }
202
+ }
203
+ }, "handleShadow");
204
+ const onScroll = /* @__PURE__ */ __name((e) => {
205
+ if (props.hasShadow) {
206
+ handleShadow(e.target);
207
+ emit("scroll", e);
208
+ }
209
+ }, "onScroll");
210
+ return () => {
211
+ const children = slots.default && slots.default();
212
+ const {
213
+ hasShadow
214
+ } = props;
215
+ return (0, import_vue.createVNode)("div", {
216
+ "class": classes,
217
+ "data-pixel-component": "MpTableContainer",
218
+ "data-table-has-left-shadow": showLeftShadow.value ? true : void 0,
219
+ "data-table-has-right-shadow": showRightShadow.value ? true : void 0
220
+ }, [(0, import_vue.createVNode)("div", {
221
+ "ref": tableContainer,
222
+ "onScroll": onScroll,
223
+ "style": {
224
+ overflowX: hasShadow ? "scroll" : void 0
225
+ }
226
+ }, [children])]);
227
+ };
228
+ }
229
+ });
230
+ // Annotate the CommonJS export names for ESM import in node:
231
+ 0 && (module.exports = {
232
+ MpTable,
233
+ MpTableBody,
234
+ MpTableCell,
235
+ MpTableContainer,
236
+ MpTableHead,
237
+ MpTableRow
238
+ });
package/dist/table.mjs ADDED
@@ -0,0 +1,17 @@
1
+ import {
2
+ MpTable,
3
+ MpTableBody,
4
+ MpTableCell,
5
+ MpTableContainer,
6
+ MpTableHead,
7
+ MpTableRow
8
+ } from "./chunk-WI56UCYK.mjs";
9
+ import "./chunk-3GSGQUM7.mjs";
10
+ export {
11
+ MpTable,
12
+ MpTableBody,
13
+ MpTableCell,
14
+ MpTableContainer,
15
+ MpTableHead,
16
+ MpTableRow
17
+ };
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@mekari/pixel3-table",
3
+ "description": "Table component for mekari pixel 3",
4
+ "version": "0.0.0",
5
+ "main": "dist/index.js",
6
+ "license": "MIT",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "dependencies": {
11
+ "@mekari/pixel3-styled-system": "0.0.0"
12
+ },
13
+ "peerDependencies": {
14
+ "vue": "^3.3.7"
15
+ },
16
+ "devDependencies": {
17
+ "vue": "^3.3.7"
18
+ },
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
22
+ "module": "dist/index.mjs",
23
+ "types": "dist/index.d.ts",
24
+ "exports": {
25
+ ".": {
26
+ "types": "./dist/index.d.ts",
27
+ "require": "./dist/index.js",
28
+ "default": "./dist/index.mjs"
29
+ }
30
+ },
31
+ "scripts": {
32
+ "clean": "rimraf dist .turbo",
33
+ "build": "tsup && pnpm build:types",
34
+ "build:fast": "tsup",
35
+ "build:types": "tsup src --dts-only",
36
+ "build:external": "tsup src/index.tsx --external",
37
+ "types:check": "tsc --noEmit",
38
+ "replace-config": "clean-package",
39
+ "restore-config": "clean-package restore"
40
+ }
41
+ }