@weni/unnnic-system 3.28.2-alpha.2 → 3.28.2-alpha.3
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/dist/index.d.ts +324 -8
- package/dist/style.css +1 -1
- package/dist/unnnic.mjs +6322 -6189
- package/dist/unnnic.umd.js +28 -28
- package/package.json +1 -1
- package/src/components/Table/Table.vue +21 -2
- package/src/components/Table/TableRow.vue +28 -3
- package/src/components/index.ts +13 -0
- package/src/components/ui/table/Table.vue +29 -0
- package/src/components/ui/table/TableBody.vue +14 -0
- package/src/components/ui/table/TableCell.vue +28 -0
- package/src/components/ui/table/TableHead.vue +27 -0
- package/src/components/ui/table/TableHeader.vue +24 -0
- package/src/components/ui/table/TableRow.vue +47 -0
- package/src/components/ui/table/index.ts +6 -0
- package/src/stories/Table.stories.js +75 -2
package/package.json
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
|
+
<UiTable v-if="version === '2'">
|
|
3
|
+
<slot />
|
|
4
|
+
</UiTable>
|
|
5
|
+
|
|
2
6
|
<div
|
|
3
|
-
v-
|
|
7
|
+
v-else
|
|
4
8
|
class="unnnic-table"
|
|
5
9
|
>
|
|
6
10
|
<div class="header">
|
|
@@ -28,15 +32,30 @@
|
|
|
28
32
|
</template>
|
|
29
33
|
|
|
30
34
|
<script>
|
|
35
|
+
import { computed } from 'vue';
|
|
36
|
+
import { Table as UiTable } from '@/components/ui/table';
|
|
37
|
+
|
|
31
38
|
export default {
|
|
32
39
|
name: 'UnnnicTable',
|
|
33
40
|
|
|
34
|
-
components: {
|
|
41
|
+
components: {
|
|
42
|
+
UiTable,
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
provide() {
|
|
46
|
+
return {
|
|
47
|
+
unnnicTableVersion: computed(() => this.version),
|
|
48
|
+
};
|
|
49
|
+
},
|
|
35
50
|
|
|
36
51
|
props: {
|
|
37
52
|
items: {
|
|
38
53
|
type: Array,
|
|
39
54
|
},
|
|
55
|
+
version: {
|
|
56
|
+
type: String,
|
|
57
|
+
default: '1',
|
|
58
|
+
},
|
|
40
59
|
},
|
|
41
60
|
|
|
42
61
|
data() {
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
2
|
+
<UiTableRow
|
|
3
|
+
v-if="isVersion2"
|
|
4
|
+
v-bind="$attrs"
|
|
5
|
+
>
|
|
6
|
+
<slot />
|
|
7
|
+
</UiTableRow>
|
|
8
|
+
|
|
9
|
+
<div
|
|
10
|
+
v-else
|
|
11
|
+
class="table-row"
|
|
12
|
+
v-bind="$attrs"
|
|
13
|
+
>
|
|
3
14
|
<template
|
|
4
15
|
v-for="(header, index) in headers"
|
|
5
16
|
:key="header.id"
|
|
@@ -26,17 +37,31 @@
|
|
|
26
37
|
</template>
|
|
27
38
|
|
|
28
39
|
<script>
|
|
40
|
+
import { computed, inject, unref } from 'vue';
|
|
41
|
+
import UiTableRow from '@/components/ui/table/TableRow.vue';
|
|
42
|
+
|
|
29
43
|
export default {
|
|
30
44
|
name: 'UnnnicTableRow',
|
|
31
45
|
|
|
46
|
+
components: {
|
|
47
|
+
UiTableRow,
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
inheritAttrs: false,
|
|
51
|
+
|
|
32
52
|
props: {
|
|
33
53
|
headers: {
|
|
34
54
|
type: Array,
|
|
35
55
|
},
|
|
36
56
|
},
|
|
37
57
|
|
|
38
|
-
|
|
39
|
-
|
|
58
|
+
setup() {
|
|
59
|
+
const tableVersion = inject('unnnicTableVersion', '1');
|
|
60
|
+
const isVersion2 = computed(() => unref(tableVersion) === '2');
|
|
61
|
+
|
|
62
|
+
return {
|
|
63
|
+
isVersion2,
|
|
64
|
+
};
|
|
40
65
|
},
|
|
41
66
|
};
|
|
42
67
|
</script>
|
package/src/components/index.ts
CHANGED
|
@@ -10,6 +10,7 @@ import sidebar from './Sidebar/index.vue';
|
|
|
10
10
|
import sidebarItem from './Sidebar/SidebarItem.vue';
|
|
11
11
|
import table from './Table/Table.vue';
|
|
12
12
|
import tableRow from './Table/TableRow.vue';
|
|
13
|
+
import { TableBody, TableCell, TableHead, TableHeader } from './ui/table';
|
|
13
14
|
import dropdown from './Dropdown/Dropdown.vue';
|
|
14
15
|
import dropdownItem from './Dropdown/DropdownItem.vue';
|
|
15
16
|
import avatarIcon from './AvatarIcon/AvatarIcon.vue';
|
|
@@ -138,6 +139,10 @@ export const components: ComponentsMap = {
|
|
|
138
139
|
unnnicSidebarItem: sidebarItem,
|
|
139
140
|
unnnicTable: table,
|
|
140
141
|
unnnicTableRow: tableRow,
|
|
142
|
+
unnnicTableBody: TableBody,
|
|
143
|
+
unnnicTableCell: TableCell,
|
|
144
|
+
unnnicTableHead: TableHead,
|
|
145
|
+
unnnicTableHeader: TableHeader,
|
|
141
146
|
unnnicAvatarIcon: avatarIcon,
|
|
142
147
|
unnnicIcon: icon,
|
|
143
148
|
unnnicIconSvg: icon,
|
|
@@ -261,6 +266,10 @@ export const unnnicSidebar = sidebar;
|
|
|
261
266
|
export const unnnicSidebarItem = sidebarItem;
|
|
262
267
|
export const unnnicTable = table;
|
|
263
268
|
export const unnnicTableRow = tableRow;
|
|
269
|
+
export const unnnicTableBody = TableBody;
|
|
270
|
+
export const unnnicTableCell = TableCell;
|
|
271
|
+
export const unnnicTableHead = TableHead;
|
|
272
|
+
export const unnnicTableHeader = TableHeader;
|
|
264
273
|
export const unnnicDropdown = dropdown as VueComponent;
|
|
265
274
|
export const unnnicDropdownItem = dropdownItem;
|
|
266
275
|
export const unnnicAvatarIcon = avatarIcon;
|
|
@@ -383,6 +392,10 @@ export const UnnnicSidebar = sidebar;
|
|
|
383
392
|
export const UnnnicSidebarItem = sidebarItem;
|
|
384
393
|
export const UnnnicTable = table;
|
|
385
394
|
export const UnnnicTableRow = tableRow;
|
|
395
|
+
export const UnnnicTableBody = TableBody;
|
|
396
|
+
export const UnnnicTableCell = TableCell;
|
|
397
|
+
export const UnnnicTableHead = TableHead;
|
|
398
|
+
export const UnnnicTableHeader = TableHeader;
|
|
386
399
|
export const UnnnicDropdown = dropdown as VueComponent;
|
|
387
400
|
export const UnnnicDropdownItem = dropdownItem;
|
|
388
401
|
export const UnnnicAvatarIcon = avatarIcon;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { HTMLAttributes } from 'vue';
|
|
3
|
+
import { cn } from '@/lib/utils';
|
|
4
|
+
|
|
5
|
+
const props = defineProps<{
|
|
6
|
+
class?: HTMLAttributes['class'];
|
|
7
|
+
}>();
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<template>
|
|
11
|
+
<div class="relative w-full overflow-auto">
|
|
12
|
+
<table :class="cn('unnnic-table', props.class)">
|
|
13
|
+
<slot />
|
|
14
|
+
</table>
|
|
15
|
+
</div>
|
|
16
|
+
</template>
|
|
17
|
+
|
|
18
|
+
<style lang="scss" scoped>
|
|
19
|
+
@use '@/assets/scss/unnnic' as *;
|
|
20
|
+
|
|
21
|
+
.unnnic-table {
|
|
22
|
+
border-collapse: collapse;
|
|
23
|
+
width: 100%;
|
|
24
|
+
caption-side: bottom;
|
|
25
|
+
|
|
26
|
+
@include unnnic-font-body;
|
|
27
|
+
color: $unnnic-color-fg-base;
|
|
28
|
+
}
|
|
29
|
+
</style>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { HTMLAttributes } from 'vue';
|
|
3
|
+
import { cn } from '@/lib/utils';
|
|
4
|
+
|
|
5
|
+
const props = defineProps<{
|
|
6
|
+
class?: HTMLAttributes['class'];
|
|
7
|
+
}>();
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<template>
|
|
11
|
+
<tbody :class="cn(props.class)">
|
|
12
|
+
<slot />
|
|
13
|
+
</tbody>
|
|
14
|
+
</template>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { HTMLAttributes } from 'vue';
|
|
3
|
+
import { cn } from '@/lib/utils';
|
|
4
|
+
|
|
5
|
+
const props = defineProps<{
|
|
6
|
+
class?: HTMLAttributes['class'];
|
|
7
|
+
}>();
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<template>
|
|
11
|
+
<td :class="cn('unnnic-table-cell', props.class)">
|
|
12
|
+
<slot />
|
|
13
|
+
</td>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<style lang="scss" scoped>
|
|
17
|
+
@use '@/assets/scss/unnnic' as *;
|
|
18
|
+
|
|
19
|
+
.unnnic-table-cell {
|
|
20
|
+
vertical-align: middle;
|
|
21
|
+
|
|
22
|
+
padding: $unnnic-space-4 0;
|
|
23
|
+
|
|
24
|
+
&:not(:last-child) {
|
|
25
|
+
padding-right: $unnnic-space-4;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
</style>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { HTMLAttributes } from 'vue';
|
|
3
|
+
import { cn } from '@/lib/utils';
|
|
4
|
+
|
|
5
|
+
const props = defineProps<{
|
|
6
|
+
class?: HTMLAttributes['class'];
|
|
7
|
+
}>();
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<template>
|
|
11
|
+
<th :class="cn('unnnic-table-head', props.class)">
|
|
12
|
+
<slot />
|
|
13
|
+
</th>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<style lang="scss" scoped>
|
|
17
|
+
@use '@/assets/scss/unnnic' as *;
|
|
18
|
+
|
|
19
|
+
.unnnic-table-head {
|
|
20
|
+
@include unnnic-font-caption-1;
|
|
21
|
+
color: $unnnic-color-fg-base;
|
|
22
|
+
text-align: left;
|
|
23
|
+
align-items: center;
|
|
24
|
+
|
|
25
|
+
pointer-events: none;
|
|
26
|
+
}
|
|
27
|
+
</style>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { HTMLAttributes } from 'vue';
|
|
3
|
+
import { cn } from '@/lib/utils';
|
|
4
|
+
|
|
5
|
+
const props = defineProps<{
|
|
6
|
+
class?: HTMLAttributes['class'];
|
|
7
|
+
}>();
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<template>
|
|
11
|
+
<thead :class="cn('unnnic-table-header', props.class)">
|
|
12
|
+
<slot />
|
|
13
|
+
</thead>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<style lang="scss" scoped>
|
|
17
|
+
@use '@/assets/scss/unnnic' as *;
|
|
18
|
+
|
|
19
|
+
.unnnic-table-header {
|
|
20
|
+
* {
|
|
21
|
+
padding-bottom: $unnnic-space-2;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
</style>
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { HTMLAttributes } from 'vue';
|
|
3
|
+
import { computed, useAttrs } from 'vue';
|
|
4
|
+
import { cn } from '@/lib/utils';
|
|
5
|
+
|
|
6
|
+
const props = defineProps<{
|
|
7
|
+
class?: HTMLAttributes['class'];
|
|
8
|
+
}>();
|
|
9
|
+
|
|
10
|
+
const attrs = useAttrs();
|
|
11
|
+
const isClickable = computed(() => Boolean(attrs.onClick));
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<template>
|
|
15
|
+
<tr
|
|
16
|
+
:class="
|
|
17
|
+
cn(
|
|
18
|
+
'unnnic-table-row',
|
|
19
|
+
'transition-colors data-[state=selected]:bg-muted',
|
|
20
|
+
isClickable && 'cursor-pointer',
|
|
21
|
+
props.class,
|
|
22
|
+
)
|
|
23
|
+
"
|
|
24
|
+
>
|
|
25
|
+
<slot />
|
|
26
|
+
</tr>
|
|
27
|
+
</template>
|
|
28
|
+
|
|
29
|
+
<style lang="scss" scoped>
|
|
30
|
+
@use '@/assets/scss/unnnic' as *;
|
|
31
|
+
|
|
32
|
+
.unnnic-table-row {
|
|
33
|
+
& > :first-child {
|
|
34
|
+
padding-left: $unnnic-space-3;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
& > :last-child {
|
|
38
|
+
padding-right: $unnnic-space-3;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
border-bottom: 1px solid $unnnic-color-border-base;
|
|
42
|
+
|
|
43
|
+
&:hover {
|
|
44
|
+
background-color: $unnnic-color-bg-soft;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
</style>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as Table } from './Table.vue';
|
|
2
|
+
export { default as TableBody } from './TableBody.vue';
|
|
3
|
+
export { default as TableCell } from './TableCell.vue';
|
|
4
|
+
export { default as TableHead } from './TableHead.vue';
|
|
5
|
+
export { default as TableHeader } from './TableHeader.vue';
|
|
6
|
+
export { default as TableRow } from './TableRow.vue';
|
|
@@ -2,11 +2,24 @@ import unnnicTable from '../components/Table/Table.vue';
|
|
|
2
2
|
import unnnicTableRow from '../components/Table/TableRow.vue';
|
|
3
3
|
import unnnicButton from '../components/Button/Button.vue';
|
|
4
4
|
import unnnicCheckbox from '../components/Checkbox/Checkbox.vue';
|
|
5
|
+
import {
|
|
6
|
+
TableHeader,
|
|
7
|
+
TableBody,
|
|
8
|
+
TableHead,
|
|
9
|
+
TableCell,
|
|
10
|
+
} from '@/components/ui/table';
|
|
11
|
+
import UnnnicTag from '@/components/Tag/Tag.vue';
|
|
12
|
+
import { action } from 'storybook/actions';
|
|
5
13
|
|
|
6
14
|
export default {
|
|
7
15
|
title: 'example/Table',
|
|
8
16
|
component: unnnicTable,
|
|
9
|
-
argTypes: {
|
|
17
|
+
argTypes: {
|
|
18
|
+
version: {
|
|
19
|
+
control: { type: 'select' },
|
|
20
|
+
options: ['1', '2'],
|
|
21
|
+
},
|
|
22
|
+
},
|
|
10
23
|
};
|
|
11
24
|
|
|
12
25
|
const Template = (args, { argTypes }) => ({
|
|
@@ -21,6 +34,7 @@ const Template = (args, { argTypes }) => ({
|
|
|
21
34
|
<div>
|
|
22
35
|
<unnnic-table
|
|
23
36
|
v-bind="$props"
|
|
37
|
+
version="1"
|
|
24
38
|
:items="table.items"
|
|
25
39
|
:style="{ maxHeight: '280px', maxWidth: '800px', }"
|
|
26
40
|
>
|
|
@@ -142,4 +156,63 @@ const Template = (args, { argTypes }) => ({
|
|
|
142
156
|
});
|
|
143
157
|
|
|
144
158
|
export const Default = Template.bind({});
|
|
145
|
-
Default.args = {
|
|
159
|
+
Default.args = {
|
|
160
|
+
version: '1',
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
export const Version2 = {
|
|
164
|
+
render: () => ({
|
|
165
|
+
components: {
|
|
166
|
+
unnnicTable,
|
|
167
|
+
unnnicTableRow,
|
|
168
|
+
TableHeader,
|
|
169
|
+
TableBody,
|
|
170
|
+
TableHead,
|
|
171
|
+
TableCell,
|
|
172
|
+
UnnnicTag,
|
|
173
|
+
},
|
|
174
|
+
setup() {
|
|
175
|
+
return {
|
|
176
|
+
onRowClick: action('click'),
|
|
177
|
+
};
|
|
178
|
+
},
|
|
179
|
+
template: `
|
|
180
|
+
<unnnic-table version="2">
|
|
181
|
+
<TableHeader>
|
|
182
|
+
<unnnic-table-row>
|
|
183
|
+
<TableHead>
|
|
184
|
+
Invoice
|
|
185
|
+
</TableHead>
|
|
186
|
+
<TableHead>Status</TableHead>
|
|
187
|
+
<TableHead>Method</TableHead>
|
|
188
|
+
<TableHead>
|
|
189
|
+
Amount
|
|
190
|
+
</TableHead>
|
|
191
|
+
</unnnic-table-row>
|
|
192
|
+
</TableHeader>
|
|
193
|
+
<TableBody>
|
|
194
|
+
<unnnic-table-row>
|
|
195
|
+
<TableCell>
|
|
196
|
+
INV001
|
|
197
|
+
</TableCell>
|
|
198
|
+
<TableCell><UnnnicTag scheme="green" text="Paid" /></TableCell>
|
|
199
|
+
<TableCell>Credit Card</TableCell>
|
|
200
|
+
<TableCell>
|
|
201
|
+
$250.00
|
|
202
|
+
</TableCell>
|
|
203
|
+
</unnnic-table-row>
|
|
204
|
+
<unnnic-table-row @click="onRowClick">
|
|
205
|
+
<TableCell>
|
|
206
|
+
INV002
|
|
207
|
+
</TableCell>
|
|
208
|
+
<TableCell><UnnnicTag scheme="red" text="Pending" /></TableCell>
|
|
209
|
+
<TableCell>Bank Transfer</TableCell>
|
|
210
|
+
<TableCell>
|
|
211
|
+
$199.00
|
|
212
|
+
</TableCell>
|
|
213
|
+
</unnnic-table-row>
|
|
214
|
+
</TableBody>
|
|
215
|
+
</unnnic-table>
|
|
216
|
+
`,
|
|
217
|
+
}),
|
|
218
|
+
};
|