@dot-system/css-utility 0.1.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 @@
1
+ @layer dots-css-utility, dots-css-utility.core;
package/es/index.js ADDED
@@ -0,0 +1,6 @@
1
+ import { cva } from "./js/cva";
2
+ import { clsx } from "./js/clsx";
3
+ import { cn } from "./js/cn";
4
+ import { dotMerge } from "./js/dotMerge";
5
+ import { csv } from "./js/csv";
6
+ export { cva, clsx, cn, dotMerge, csv };
package/es/js/clsx.js ADDED
@@ -0,0 +1,4 @@
1
+ import baseClsx from "clsx";
2
+ export const clsx = function () {
3
+ return baseClsx(...arguments);
4
+ };
package/es/js/cn.js ADDED
@@ -0,0 +1,5 @@
1
+ import { clsx } from "clsx";
2
+ import { dotMerge } from "./dotMerge";
3
+ export const cn = function () {
4
+ return dotMerge(clsx(...arguments));
5
+ };
package/es/js/csv.js ADDED
@@ -0,0 +1,29 @@
1
+ // const buttonSlots = createSlotVariants({
2
+ // root: cva("d-inline-flex d-items-center", {
3
+ // variants: {
4
+ // size: {
5
+ // sm: "d-h-8 d-px-3",
6
+ // lg: "d-h-12 d-px-6"
7
+ // }
8
+ // }
9
+ // }),
10
+ // icon: cva("", {
11
+ // variants: {
12
+ // size: {
13
+ // sm: "d-w-3",
14
+ // lg: "d-w-5"
15
+ // }
16
+ // }
17
+ // })
18
+ // })
19
+ export const csv = function (slots) {
20
+ return props => {
21
+ const result = {};
22
+
23
+ for (const key in slots) {
24
+ result[key] = slots[key](props);
25
+ }
26
+
27
+ return result;
28
+ };
29
+ };
package/es/js/cva.js ADDED
@@ -0,0 +1,4 @@
1
+ import { cva as baseCva } from "class-variance-authority";
2
+ export const cva = function () {
3
+ return baseCva(...arguments);
4
+ };
@@ -0,0 +1,43 @@
1
+ import { createTailwindMerge, getDefaultConfig } from "tailwind-merge";
2
+ /**
3
+ * dotMerge is a custom tailwind-merge instance for d- prefixed utilities.
4
+ *
5
+ * It uses the default Tailwind config but applies all conflict detection
6
+ * and merging rules to classes that use the d- prefix instead of the default prefix.
7
+ *
8
+ * How it works:
9
+ * 1. Takes the default Tailwind class groups (position, display, padding, etc.)
10
+ * 2. Prefixes all class names with "d-"
11
+ * 3. Applies the same conflict resolution rules
12
+ *
13
+ * Example: cn('d-fixed', 'd-relative') → 'd-relative'
14
+ */
15
+
16
+ export const dotMerge = createTailwindMerge(() => {
17
+ const config = getDefaultConfig();
18
+ const transformedClassGroups = Object.fromEntries(Object.entries(config.classGroups).map(_ref => {
19
+ let [groupId, matchers] = _ref;
20
+ return [groupId, matchers.map(matcher => {
21
+ if (typeof matcher === "string") {
22
+ return `d-${matcher}`;
23
+ }
24
+
25
+ if (matcher instanceof RegExp) {
26
+ const source = matcher.source.replace(/^\^/, "");
27
+ return new RegExp(`^d-${source}`, matcher.flags);
28
+ }
29
+
30
+ if (typeof matcher === "object") {
31
+ return Object.fromEntries(Object.entries(matcher).map(_ref2 => {
32
+ let [key, value] = _ref2;
33
+ return [`d-${key}`, value];
34
+ }));
35
+ }
36
+
37
+ return matcher;
38
+ })];
39
+ }));
40
+ return { ...config,
41
+ classGroups: transformedClassGroups
42
+ };
43
+ });