windly-ui 1.0.5 → 1.0.7

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/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "windly-ui",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "builder": {
5
5
  "@nuxt/module-builder": "1.0.2",
6
6
  "unbuild": "3.6.1"
@@ -123,9 +123,9 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
123
123
  textColor: string;
124
124
  disable: boolean;
125
125
  color: string;
126
- backgroundColor: string;
127
126
  flat: boolean;
128
127
  bordered: boolean;
128
+ backgroundColor: string;
129
129
  borderRadius: string;
130
130
  multiDate: boolean;
131
131
  rangeDate: boolean;
@@ -123,9 +123,9 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
123
123
  textColor: string;
124
124
  disable: boolean;
125
125
  color: string;
126
- backgroundColor: string;
127
126
  flat: boolean;
128
127
  bordered: boolean;
128
+ backgroundColor: string;
129
129
  borderRadius: string;
130
130
  multiDate: boolean;
131
131
  rangeDate: boolean;
@@ -1,5 +1,6 @@
1
1
  type Separator = "none" | "horizontal" | "vertical" | "cell";
2
2
  type Rounded = "none" | "sm" | "md" | "lg" | "xl";
3
+ type Align = "left" | "center" | "right";
3
4
  type __VLS_Props = {
4
5
  flat?: boolean;
5
6
  bordered?: boolean;
@@ -8,6 +9,7 @@ type __VLS_Props = {
8
9
  hover?: boolean;
9
10
  rounded?: Rounded;
10
11
  separator?: Separator;
12
+ align?: Align;
11
13
  borderColor?: string;
12
14
  bgColor?: string;
13
15
  };
@@ -25,6 +27,7 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {},
25
27
  rounded: Rounded;
26
28
  borderColor: string;
27
29
  separator: Separator;
30
+ align: Align;
28
31
  flat: boolean;
29
32
  bordered: boolean;
30
33
  striped: boolean;
@@ -8,6 +8,7 @@ const props = defineProps({
8
8
  hover: { type: Boolean, required: false, default: true },
9
9
  rounded: { type: String, required: false, default: "md" },
10
10
  separator: { type: String, required: false, default: "horizontal" },
11
+ align: { type: String, required: false, default: "left" },
11
12
  borderColor: { type: String, required: false, default: "border-gray-200 dark:border-gray-700" },
12
13
  bgColor: { type: String, required: false, default: "bg-white dark:bg-gray-900" }
13
14
  });
@@ -21,26 +22,51 @@ const roundedClass = computed(() => {
21
22
  };
22
23
  return map[props.rounded];
23
24
  });
25
+ const alignmentClass = computed(() => {
26
+ switch (props.align) {
27
+ case "center":
28
+ return "[&_:where(th)]:text-center [&_:where(td)]:text-center";
29
+ case "right":
30
+ return "[&_:where(th)]:text-right [&_:where(td)]:text-right";
31
+ default:
32
+ return "[&_:where(th)]:text-left [&_:where(td)]:text-left";
33
+ }
34
+ });
35
+ const isHex = (val) => val.startsWith("#");
36
+ const wrapperStyle = computed(() => {
37
+ const style = {};
38
+ if (isHex(props.bgColor)) {
39
+ style.backgroundColor = props.bgColor;
40
+ }
41
+ if (props.bordered && isHex(props.borderColor)) {
42
+ style.borderColor = props.borderColor;
43
+ }
44
+ return style;
45
+ });
24
46
  const wrapperClass = computed(() => [
25
47
  "w-full overflow-x-auto",
26
48
  roundedClass.value,
27
- props.bordered ? `border ${props.borderColor}` : "",
49
+ props.bordered ? "border" : "",
50
+ props.bordered && !isHex(props.borderColor) ? props.borderColor : "",
28
51
  props.flat ? "shadow-none" : "shadow-sm",
29
- props.bgColor
52
+ !isHex(props.bgColor) ? props.bgColor : ""
30
53
  ]);
54
+ const separatorBorderClass = computed(
55
+ () => !isHex(props.borderColor) ? props.borderColor : ""
56
+ );
31
57
  const separatorClass = computed(() => {
32
58
  switch (props.separator) {
33
59
  case "vertical":
34
60
  return [
35
61
  "[&_th]:border-r",
36
62
  "[&_td]:border-r",
37
- props.borderColor
63
+ separatorBorderClass.value
38
64
  ];
39
65
  case "cell":
40
66
  return [
41
67
  "[&_th]:border",
42
68
  "[&_td]:border",
43
- props.borderColor
69
+ separatorBorderClass.value
44
70
  ];
45
71
  case "none":
46
72
  return [];
@@ -48,21 +74,42 @@ const separatorClass = computed(() => {
48
74
  default:
49
75
  return [
50
76
  "[&_tr]:border-b",
51
- props.borderColor
77
+ separatorBorderClass.value
52
78
  ];
53
79
  }
54
80
  });
81
+ const spacingClass = computed(
82
+ () => props.dense ? [
83
+ "[&_:where(th)]:px-3",
84
+ "[&_:where(th)]:py-2",
85
+ "[&_:where(td)]:px-3",
86
+ "[&_:where(td)]:py-2"
87
+ ] : [
88
+ "[&_:where(th)]:px-4",
89
+ "[&_:where(th)]:py-3",
90
+ "[&_:where(td)]:px-4",
91
+ "[&_:where(td)]:py-3"
92
+ ]
93
+ );
55
94
  const tableClass = computed(() => [
56
- "w-full border-collapse",
95
+ "w-full border-collapse text-sm",
96
+ alignmentClass.value,
57
97
  separatorClass.value
58
98
  ]);
59
99
  const headerClass = computed(() => [
60
- "bg-gray-50 dark:bg-gray-800"
100
+ "bg-gray-50 dark:bg-gray-800",
101
+ "text-gray-700 dark:text-gray-200",
102
+ "[&_:where(th)]:font-semibold",
103
+ "[&_:where(th)]:whitespace-nowrap",
104
+ spacingClass.value
61
105
  ]);
62
106
  const bodyClass = computed(() => [
63
- props.striped ? "[&_tr:nth-child(even)]:bg-gray-50 dark:[&_tr:nth-child(even)]:bg-gray-800/40" : "",
64
- props.hover ? "[&_tr:hover]:bg-gray-100 dark:[&_tr:hover]:bg-gray-700" : "",
65
- props.dense ? "[&_td]:py-2 [&_th]:py-2" : "[&_td]:py-3 [&_th]:py-3"
107
+ "text-gray-900 dark:text-gray-100",
108
+ props.striped ? "[&_:where(tr:nth-child(even))]:bg-gray-50 dark:[&_:where(tr:nth-child(even))]:bg-gray-800/40" : "",
109
+ props.hover ? "[&_:where(tr:hover)]:bg-gray-100 dark:[&_:where(tr:hover)]:bg-gray-700/60" : "",
110
+ spacingClass.value,
111
+ "[&_:where(th)]:align-middle",
112
+ "[&_:where(td)]:align-middle"
66
113
  ]);
67
114
  const footerClass = computed(() => [
68
115
  "bg-gray-50 dark:bg-gray-900"
@@ -70,21 +117,15 @@ const footerClass = computed(() => [
70
117
  </script>
71
118
 
72
119
  <template>
73
- <div :class="wrapperClass">
120
+ <div :class="wrapperClass" :style="wrapperStyle">
74
121
  <table :class="tableClass">
75
- <thead
76
- v-if="$slots.header"
77
- :class="headerClass"
78
- >
122
+ <thead v-if="$slots.header" :class="headerClass">
79
123
  <slot name="header" />
80
124
  </thead>
81
125
  <tbody :class="bodyClass">
82
126
  <slot />
83
127
  </tbody>
84
- <tfoot
85
- v-if="$slots.footer"
86
- :class="footerClass"
87
- >
128
+ <tfoot v-if="$slots.footer" :class="footerClass">
88
129
  <slot name="footer" />
89
130
  </tfoot>
90
131
  </table>
@@ -1,5 +1,6 @@
1
1
  type Separator = "none" | "horizontal" | "vertical" | "cell";
2
2
  type Rounded = "none" | "sm" | "md" | "lg" | "xl";
3
+ type Align = "left" | "center" | "right";
3
4
  type __VLS_Props = {
4
5
  flat?: boolean;
5
6
  bordered?: boolean;
@@ -8,6 +9,7 @@ type __VLS_Props = {
8
9
  hover?: boolean;
9
10
  rounded?: Rounded;
10
11
  separator?: Separator;
12
+ align?: Align;
11
13
  borderColor?: string;
12
14
  bgColor?: string;
13
15
  };
@@ -25,6 +27,7 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {},
25
27
  rounded: Rounded;
26
28
  borderColor: string;
27
29
  separator: Separator;
30
+ align: Align;
28
31
  flat: boolean;
29
32
  bordered: boolean;
30
33
  striped: boolean;
@@ -2,15 +2,15 @@ import type { ExtractPropTypes } from "vue";
2
2
  import { uiProps } from "./uiProps.js";
3
3
  type UiProps = ExtractPropTypes<typeof uiProps>;
4
4
  export declare function useUiClasses(props: Partial<UiProps>): {
5
- contentClass: import("vue").Ref<string, string>;
6
- contentStyle: import("vue").Ref<string, string>;
7
- textColor: import("vue").Ref<string, string>;
8
- disable: import("vue").Ref<boolean, boolean>;
9
- loading: import("vue").Ref<boolean, boolean>;
10
- color: import("vue").Ref<string, string>;
11
- rounded: import("vue").Ref<string, string>;
12
- size: import("vue").Ref<string, string>;
13
- iconSize: import("vue").Ref<string, string>;
5
+ contentClass: any;
6
+ contentStyle: any;
7
+ textColor: any;
8
+ disable: any;
9
+ loading: any;
10
+ color: any;
11
+ rounded: any;
12
+ size: any;
13
+ iconSize: any;
14
14
  roundedClass: {
15
15
  none: string;
16
16
  xs: string;
@@ -32,8 +32,8 @@ export declare function useUiClasses(props: Partial<UiProps>): {
32
32
  lg: string;
33
33
  xl: string;
34
34
  };
35
- colorClass: import("vue").ComputedRef<string>;
36
- computedContentClass: import("vue").ComputedRef<string>;
35
+ colorClass: import("vue").ComputedRef<any>;
36
+ computedContentClass: import("vue").ComputedRef<any>;
37
37
  isColorDark: (color: string) => boolean;
38
38
  isHex: (color: string) => boolean;
39
39
  isTailwindColor: (color: string) => boolean;
@@ -1,6 +1,6 @@
1
- import { computed, toRefs } from "vue";
1
+ import { computed, reactive, toRefs } from "vue";
2
2
  export function useUiClasses(props) {
3
- const safeProps = {
3
+ const safeProps = reactive({
4
4
  contentClass: "",
5
5
  contentStyle: "",
6
6
  textColor: "",
@@ -11,7 +11,7 @@ export function useUiClasses(props) {
11
11
  size: "md",
12
12
  iconSize: "md",
13
13
  ...props
14
- };
14
+ });
15
15
  const {
16
16
  contentClass,
17
17
  contentStyle,
@@ -1850,6 +1850,29 @@
1850
1850
  <!-- Table-->
1851
1851
  <DocSection title="UITable" sub-title="Data grid / table with rows, columns, and sorting.">
1852
1852
  <DocComponent title="Basic Table" caption="A simple table with headers and rows.">
1853
+ <UITable bordered striped borderColor="purple-500" rounded="xl" separator="none">
1854
+ <template #header>
1855
+ <tr class="text-purple-600 bg-purple-100 dark:bg-purple-900 dark:text-purple-400">
1856
+ <th>User</th>
1857
+ <th>Email</th>
1858
+ <th>Role</th>
1859
+ <th>Status</th>
1860
+ <th class="text-right">Actions</th>
1861
+ </tr>
1862
+ </template>
1863
+
1864
+ <tr v-for="user in users" :key="user.id">
1865
+ <td>{{ user.name }}</td>
1866
+ <td>{{ user.email }}</td>
1867
+ <td>{{ user.role }}</td>
1868
+ <td>
1869
+ <UIBadge :color="user.active ? 'green-400' : 'red-400'" />
1870
+ </td>
1871
+ <td class="text-right">
1872
+ <UIButton dense size="sm" label="Edit" color="amber-300" />
1873
+ </td>
1874
+ </tr>
1875
+ </UITable>
1853
1876
  <UITable bordered>
1854
1877
  <tr>
1855
1878
  <th class="px-4 py-3 text-left">Name</th>
@@ -2529,6 +2552,64 @@ const breadcrumbs = ref([
2529
2552
  caption: "Current page"
2530
2553
  }
2531
2554
  ]);
2555
+ const users = [
2556
+ {
2557
+ id: 1,
2558
+ name: "John Doe",
2559
+ email: "john.doe@example.com",
2560
+ role: "Admin",
2561
+ active: true
2562
+ },
2563
+ {
2564
+ id: 2,
2565
+ name: "Jane Smith",
2566
+ email: "jane.smith@example.com",
2567
+ role: "User",
2568
+ active: false
2569
+ },
2570
+ {
2571
+ id: 3,
2572
+ name: "Michael Johnson",
2573
+ email: "michael.johnson@example.com",
2574
+ role: "Editor",
2575
+ active: true
2576
+ },
2577
+ {
2578
+ id: 4,
2579
+ name: "Emily Davis",
2580
+ email: "emily.davis@example.com",
2581
+ role: "User",
2582
+ active: true
2583
+ },
2584
+ {
2585
+ id: 5,
2586
+ name: "David Wilson",
2587
+ email: "david.wilson@example.com",
2588
+ role: "Moderator",
2589
+ active: false
2590
+ },
2591
+ {
2592
+ id: 6,
2593
+ name: "Sarah Brown",
2594
+ email: "sarah.brown@example.com",
2595
+ role: "Admin",
2596
+ active: true
2597
+ },
2598
+ {
2599
+ id: 7,
2600
+ name: "Chris Taylor",
2601
+ email: "chris.taylor@example.com",
2602
+ role: "User",
2603
+ active: false
2604
+ },
2605
+ {
2606
+ id: 8,
2607
+ name: "Olivia Martinez",
2608
+ email: "olivia.martinez@example.com",
2609
+ role: "Editor",
2610
+ active: true
2611
+ }
2612
+ ];
2532
2613
  const step = ref(0);
2533
2614
  </script>
2534
2615
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "windly-ui",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "type": "module",
5
5
  "main": "./dist/module.mjs",
6
6
  "exports": {