windly-ui 1.0.4 → 1.0.6

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.4",
3
+ "version": "1.0.6",
4
4
  "builder": {
5
5
  "@nuxt/module-builder": "1.0.2",
6
6
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -13,7 +13,7 @@ const module$1 = defineNuxtModule({
13
13
  pages.push({
14
14
  name: "windly-ui-docs",
15
15
  path: "/_windly-ui",
16
- file: resolver.resolve("./docs/index.vue")
16
+ file: resolver.resolve("./runtime/docs/index.vue")
17
17
  });
18
18
  });
19
19
  nuxt.hook("tailwindcss:config", (config) => {
@@ -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;
@@ -0,0 +1,28 @@
1
+ declare const _default: typeof __VLS_export;
2
+ export default _default;
3
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
4
+ type __VLS_WithSlots<T, S> = T & (new () => {
5
+ $slots: S;
6
+ });
7
+ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
8
+ title: {
9
+ type: StringConstructor;
10
+ };
11
+ caption: {
12
+ type: StringConstructor;
13
+ default: string;
14
+ };
15
+ }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
16
+ title: {
17
+ type: StringConstructor;
18
+ };
19
+ caption: {
20
+ type: StringConstructor;
21
+ default: string;
22
+ };
23
+ }>> & Readonly<{}>, {
24
+ caption: string;
25
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
26
+ type __VLS_Slots = {
27
+ default?: ((props: {}) => any) | undefined;
28
+ };
@@ -0,0 +1,34 @@
1
+ <script setup>
2
+ const props = defineProps({
3
+ title: {
4
+ type: String
5
+ },
6
+ caption: {
7
+ type: String,
8
+ default: ""
9
+ }
10
+ });
11
+ const sectionId = props.title.split(" ").join("-").toLocaleLowerCase();
12
+ const copySectionLink = async () => {
13
+ const url = `${window.location.origin}${window.location.pathname}#${sectionId}`;
14
+ try {
15
+ await navigator.clipboard.writeText(url);
16
+ console.log("Link copied:", url);
17
+ } catch (err) {
18
+ console.error("Failed to copy link", err);
19
+ }
20
+ };
21
+ </script>
22
+
23
+ <template>
24
+ <div :id="sectionId" class="flex flex-col my-10">
25
+ <h4 class="text-3xl font-semibold text-gray-700 cursor-pointer" @click="copySectionLink"># {{title}}</h4>
26
+ <div v-if="caption" class="text-md font-light mt-2 text-gray-800 pl-7">{{caption}}</div>
27
+ <div class="my-6">
28
+ <UICodeBlock :title="title">
29
+ <slot />
30
+ </UICodeBlock>
31
+ </div>
32
+ <hr/>
33
+ </div>
34
+ </template>
@@ -0,0 +1,28 @@
1
+ declare const _default: typeof __VLS_export;
2
+ export default _default;
3
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
4
+ type __VLS_WithSlots<T, S> = T & (new () => {
5
+ $slots: S;
6
+ });
7
+ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
8
+ title: {
9
+ type: StringConstructor;
10
+ };
11
+ caption: {
12
+ type: StringConstructor;
13
+ default: string;
14
+ };
15
+ }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
16
+ title: {
17
+ type: StringConstructor;
18
+ };
19
+ caption: {
20
+ type: StringConstructor;
21
+ default: string;
22
+ };
23
+ }>> & Readonly<{}>, {
24
+ caption: string;
25
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
26
+ type __VLS_Slots = {
27
+ default?: ((props: {}) => any) | undefined;
28
+ };
@@ -0,0 +1,3 @@
1
+ declare const _default: typeof __VLS_export;
2
+ export default _default;
3
+ declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;