@duskmoon-dev/components 0.2.1 → 0.3.1

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.
Files changed (50) hide show
  1. package/README.md +33 -5
  2. package/dist/classes/index.d.ts +1 -0
  3. package/dist/classes/index.js +100 -15
  4. package/dist/classes/markdown.d.ts +9 -0
  5. package/dist/components/alert/Alert.types.d.ts +1 -1
  6. package/dist/components/alert/index.js +6 -0
  7. package/dist/components/auto-complete/AutoComplete.types.d.ts +1 -1
  8. package/dist/components/auto-complete/index.js +3 -0
  9. package/dist/components/badge/Badge.types.d.ts +1 -1
  10. package/dist/components/badge/index.js +4 -0
  11. package/dist/components/button/Button.types.d.ts +1 -1
  12. package/dist/components/button/index.js +3 -0
  13. package/dist/components/checkbox/Checkbox.types.d.ts +1 -1
  14. package/dist/components/checkbox/index.js +8 -1
  15. package/dist/components/divider/Divider.types.d.ts +1 -1
  16. package/dist/components/divider/index.js +8 -2
  17. package/dist/components/dm-drawer/index.js +3 -0
  18. package/dist/components/dm-page-header/index.js +3 -0
  19. package/dist/components/dm-pro-table/index.js +3 -0
  20. package/dist/components/dm-query/index.js +3 -0
  21. package/dist/components/dm-search/index.js +3 -0
  22. package/dist/components/dm-table/index.js +3 -0
  23. package/dist/components/dm-toolbar/index.js +3 -0
  24. package/dist/components/dropdown/index.js +3 -0
  25. package/dist/components/markdown/Markdown.d.ts +3 -0
  26. package/dist/components/markdown/Markdown.types.d.ts +14 -0
  27. package/dist/components/markdown/index.d.ts +2 -0
  28. package/dist/components/markdown/index.js +171 -0
  29. package/dist/components/popconfirm/index.js +3 -0
  30. package/dist/components/progress/Progress.types.d.ts +1 -1
  31. package/dist/components/progress/index.js +6 -3
  32. package/dist/components/radio/Radio.types.d.ts +1 -1
  33. package/dist/components/radio/index.js +8 -1
  34. package/dist/components/rate/Rate.types.d.ts +1 -1
  35. package/dist/components/rate/index.js +8 -2
  36. package/dist/components/slider/Slider.types.d.ts +1 -1
  37. package/dist/components/slider/index.js +9 -2
  38. package/dist/components/switch/Switch.types.d.ts +1 -1
  39. package/dist/components/switch/index.js +8 -1
  40. package/dist/components/tag/Tag.types.d.ts +1 -1
  41. package/dist/components/tag/index.js +5 -2
  42. package/dist/components/timeline/Timeline.types.d.ts +1 -1
  43. package/dist/components/timeline/index.js +6 -1
  44. package/dist/components/tour/index.js +3 -0
  45. package/dist/generated/version.d.ts +1 -1
  46. package/dist/index.d.ts +1 -0
  47. package/dist/index.js +252 -43
  48. package/dist/infrastructure.js +1 -1
  49. package/dist/styles.css +545 -0
  50. package/package.json +9 -2
@@ -0,0 +1,171 @@
1
+ "use client";
2
+
3
+ // src/components/markdown/Markdown.tsx
4
+ import { forwardRef } from "react";
5
+ import ReactMarkdown from "react-markdown";
6
+ import remarkBreaks from "remark-breaks";
7
+ import remarkGfm from "remark-gfm";
8
+
9
+ // ../../node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.mjs
10
+ function r(e) {
11
+ var t, f, n = "";
12
+ if (typeof e == "string" || typeof e == "number")
13
+ n += e;
14
+ else if (typeof e == "object")
15
+ if (Array.isArray(e)) {
16
+ var o = e.length;
17
+ for (t = 0;t < o; t++)
18
+ e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
19
+ } else
20
+ for (f in e)
21
+ e[f] && (n && (n += " "), n += f);
22
+ return n;
23
+ }
24
+ function clsx() {
25
+ for (var e, t, f = 0, n = "", o = arguments.length;f < o; f++)
26
+ (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
27
+ return n;
28
+ }
29
+
30
+ // src/utils/cn.ts
31
+ function cn(...inputs) {
32
+ return clsx(inputs);
33
+ }
34
+ // src/classes/markdown.ts
35
+ var markdownBaseClass = "markdown-body";
36
+ var markdownFrontMatterClass = "dm-front-matter";
37
+ var markdownColorCodeClass = "dm-color-code";
38
+ var markdownColorChipClass = "dm-color-chip";
39
+ var markdownColorChipSwatchClass = "dm-color-chip-swatch";
40
+ function getMarkdownClasses({
41
+ variant,
42
+ className
43
+ }) {
44
+ return cn(markdownBaseClass, variant && `${markdownBaseClass}-${variant}`, className);
45
+ }
46
+
47
+ // src/components/markdown/Markdown.tsx
48
+ import { jsx, jsxs } from "react/jsx-runtime";
49
+ function splitFrontMatter(markdown) {
50
+ const source = markdown.startsWith("\uFEFF") ? markdown.slice(1) : markdown;
51
+ const lines = source.split(/\r?\n/);
52
+ if (lines.length < 2 || lines[0] !== "---")
53
+ return;
54
+ for (let index = 1;index < lines.length; index += 1) {
55
+ if (lines[index] === "---" || lines[index] === "...") {
56
+ return {
57
+ source: lines.slice(1, index).join(`
58
+ `),
59
+ body: lines.slice(index + 1).join(`
60
+ `)
61
+ };
62
+ }
63
+ }
64
+ return;
65
+ }
66
+ function numberInRange(value, minimum, maximum) {
67
+ if (!/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)$/.test(value))
68
+ return false;
69
+ const number = Number(value);
70
+ return Number.isFinite(number) && number >= minimum && number <= maximum;
71
+ }
72
+ function percentage(value) {
73
+ return value.endsWith("%") && numberInRange(value.slice(0, -1), 0, 100);
74
+ }
75
+ function alpha(value) {
76
+ return percentage(value) || numberInRange(value, 0, 1);
77
+ }
78
+ function isCssColor(value) {
79
+ if (!value || Array.from(value).some((character) => character.charCodeAt(0) > 127) || value.trim() !== value) {
80
+ return false;
81
+ }
82
+ if (/^#[\da-f]{3,4}(?:[\da-f]{2}){0,2}$/i.test(value))
83
+ return true;
84
+ const match = /^(rgba?|hsla?)\((.*)\)$/i.exec(value);
85
+ if (!match || match[2].includes("(") || match[2].includes(")"))
86
+ return false;
87
+ const name = match[1].toLowerCase();
88
+ const parts = match[2].split(",").map((part) => part.trim());
89
+ const hasAlpha = name.endsWith("a");
90
+ if (parts.length !== (hasAlpha ? 4 : 3))
91
+ return false;
92
+ if (name.startsWith("rgb")) {
93
+ const channels = parts.slice(0, 3);
94
+ const allPercentages = channels.every(percentage);
95
+ const allNumbers = channels.every((part) => numberInRange(part, 0, 255));
96
+ return (allPercentages || allNumbers) && (!hasAlpha || alpha(parts[3]));
97
+ }
98
+ const hue = parts[0].replace(/deg$/i, "");
99
+ return numberInRange(hue, 0, 360) && percentage(parts[1]) && percentage(parts[2]) && (!hasAlpha || alpha(parts[3]));
100
+ }
101
+ function markdownSource(markdown, mode) {
102
+ if (mode === "disabled")
103
+ return { body: markdown, source: undefined };
104
+ const frontMatter = splitFrontMatter(markdown);
105
+ return frontMatter ?? { body: markdown, source: undefined };
106
+ }
107
+ var Markdown = forwardRef(function Markdown2({
108
+ markdown = "",
109
+ breaks = true,
110
+ colorChips = true,
111
+ frontMatter = "render",
112
+ variant,
113
+ className,
114
+ ...props
115
+ }, ref) {
116
+ const source = markdownSource(markdown, frontMatter);
117
+ const components = colorChips ? {
118
+ code({ children, className: codeClassName, node, ...codeProps }) {
119
+ const value = String(children).replace(/\n$/, "");
120
+ const isInline = node?.position?.start.line === node?.position?.end.line;
121
+ if (!isInline || !isCssColor(value)) {
122
+ return /* @__PURE__ */ jsx("code", {
123
+ className: codeClassName,
124
+ ...codeProps,
125
+ children
126
+ });
127
+ }
128
+ return /* @__PURE__ */ jsxs("code", {
129
+ className: markdownColorCodeClass,
130
+ ...codeProps,
131
+ children: [
132
+ children,
133
+ /* @__PURE__ */ jsx("span", {
134
+ className: markdownColorChipClass,
135
+ role: "img",
136
+ "aria-label": `Color ${value}`,
137
+ children: /* @__PURE__ */ jsx("span", {
138
+ className: markdownColorChipSwatchClass,
139
+ style: { backgroundColor: value },
140
+ "aria-hidden": "true"
141
+ })
142
+ })
143
+ ]
144
+ });
145
+ }
146
+ } : undefined;
147
+ return /* @__PURE__ */ jsxs("div", {
148
+ ref,
149
+ className: getMarkdownClasses({ variant, className }),
150
+ ...props,
151
+ children: [
152
+ frontMatter === "render" && source.source !== undefined ? /* @__PURE__ */ jsx("div", {
153
+ className: markdownFrontMatterClass,
154
+ children: /* @__PURE__ */ jsx("pre", {
155
+ children: /* @__PURE__ */ jsx("code", {
156
+ className: "language-yaml",
157
+ children: source.source
158
+ })
159
+ })
160
+ }) : null,
161
+ /* @__PURE__ */ jsx(ReactMarkdown, {
162
+ remarkPlugins: breaks ? [remarkGfm, remarkBreaks] : [remarkGfm],
163
+ components,
164
+ children: source.body
165
+ })
166
+ ]
167
+ });
168
+ });
169
+ export {
170
+ Markdown
171
+ };
@@ -31,6 +31,9 @@ var buttonColorClasses = {
31
31
  primary: "btn-primary",
32
32
  secondary: "btn-secondary",
33
33
  tertiary: "btn-tertiary",
34
+ accent: "btn-accent",
35
+ neutral: "btn-neutral",
36
+ base: "btn-base",
34
37
  info: "btn-info",
35
38
  success: "btn-success",
36
39
  warning: "btn-warning",
@@ -1,5 +1,5 @@
1
1
  import type { ComponentProps } from "react";
2
- export type ProgressColor = "primary" | "secondary" | "tertiary" | "success" | "error" | "warning" | "info";
2
+ export type ProgressColor = "primary" | "secondary" | "tertiary" | "accent" | "neutral" | "base" | "info" | "success" | "warning" | "error";
3
3
  export type ProgressSize = "sm" | "md" | "lg" | "xl";
4
4
  export interface ProgressProps extends ComponentProps<"div"> {
5
5
  color?: ProgressColor;
@@ -31,13 +31,16 @@ function cn(...inputs) {
31
31
  // src/classes/progress.ts
32
32
  var progressBaseClass = "progress";
33
33
  var progressColorClasses = {
34
- primary: "",
34
+ primary: "progress-primary",
35
35
  secondary: "progress-secondary",
36
36
  tertiary: "progress-tertiary",
37
+ accent: "progress-accent",
38
+ neutral: "progress-neutral",
39
+ base: "progress-base",
40
+ info: "progress-info",
37
41
  success: "progress-success",
38
- error: "progress-error",
39
42
  warning: "progress-warning",
40
- info: "progress-info"
43
+ error: "progress-error"
41
44
  };
42
45
  var progressSizeClasses = {
43
46
  sm: "progress-sm",
@@ -1,5 +1,5 @@
1
1
  import type { ChangeEvent, ComponentProps, ReactNode } from "react";
2
- export type RadioColor = "primary" | "secondary" | "tertiary";
2
+ export type RadioColor = "primary" | "secondary" | "tertiary" | "accent" | "neutral" | "base" | "info" | "success" | "warning" | "error";
3
3
  export type RadioSize = "sm" | "md" | "lg";
4
4
  export type RadioLabelPosition = "left" | "right";
5
5
  export interface RadioProps extends Omit<ComponentProps<"input">, "children" | "className" | "size" | "type"> {
@@ -37,7 +37,14 @@ var radioLabelBaseClass = "radio-label";
37
37
  var radioColorClasses = {
38
38
  primary: "radio-primary",
39
39
  secondary: "radio-secondary",
40
- tertiary: "radio-tertiary"
40
+ tertiary: "radio-tertiary",
41
+ accent: "radio-accent",
42
+ neutral: "radio-neutral",
43
+ base: "radio-base",
44
+ info: "radio-info",
45
+ success: "radio-success",
46
+ warning: "radio-warning",
47
+ error: "radio-error"
41
48
  };
42
49
  var radioSizeClasses = {
43
50
  sm: "radio-sm",
@@ -1,6 +1,6 @@
1
1
  import type { ComponentProps, ReactNode } from "react";
2
2
  export type RateSize = "sm" | "md" | "lg" | "xl";
3
- export type RateColor = "primary" | "secondary" | "tertiary" | "warning";
3
+ export type RateColor = "primary" | "secondary" | "tertiary" | "accent" | "neutral" | "base" | "info" | "success" | "warning" | "error";
4
4
  export interface RateCharacterRenderInfo {
5
5
  index: number;
6
6
  value: number;
@@ -46,10 +46,16 @@ var rateSizeClasses = {
46
46
  xl: "rating-xl"
47
47
  };
48
48
  var rateColorClasses = {
49
- primary: "",
49
+ primary: "rating-primary",
50
50
  secondary: "rating-secondary",
51
51
  tertiary: "rating-tertiary",
52
- warning: "rating-warning"
52
+ accent: "rating-accent",
53
+ neutral: "rating-neutral",
54
+ base: "rating-base",
55
+ info: "rating-info",
56
+ success: "rating-success",
57
+ warning: "rating-warning",
58
+ error: "rating-error"
53
59
  };
54
60
  function getRateClasses({
55
61
  size = "md",
@@ -1,7 +1,7 @@
1
1
  import type { ComponentProps, CSSProperties, KeyboardEvent, ReactNode } from "react";
2
2
  export type SliderValue = number | [number, number];
3
3
  export type SliderSize = "sm" | "md" | "lg";
4
- export type SliderColor = "primary" | "secondary" | "tertiary";
4
+ export type SliderColor = "primary" | "secondary" | "tertiary" | "accent" | "neutral" | "base" | "info" | "success" | "warning" | "error";
5
5
  export interface SliderMarkConfig {
6
6
  label?: ReactNode;
7
7
  style?: CSSProperties;
@@ -55,9 +55,16 @@ var sliderSizeClasses = {
55
55
  lg: "slider-lg"
56
56
  };
57
57
  var sliderColorClasses = {
58
- primary: "",
58
+ primary: "slider-primary",
59
59
  secondary: "slider-secondary",
60
- tertiary: "slider-tertiary"
60
+ tertiary: "slider-tertiary",
61
+ accent: "slider-accent",
62
+ neutral: "slider-neutral",
63
+ base: "slider-base",
64
+ info: "slider-info",
65
+ success: "slider-success",
66
+ warning: "slider-warning",
67
+ error: "slider-error"
61
68
  };
62
69
  function getSliderClasses({
63
70
  size = "md",
@@ -1,6 +1,6 @@
1
1
  import type { ChangeEvent, ComponentProps, ReactNode } from "react";
2
2
  export type SwitchSize = "sm" | "md" | "lg";
3
- export type SwitchColor = "primary" | "secondary" | "tertiary";
3
+ export type SwitchColor = "primary" | "secondary" | "tertiary" | "accent" | "neutral" | "base" | "info" | "success" | "warning" | "error";
4
4
  export type SwitchChangeEvent = ChangeEvent<HTMLInputElement>;
5
5
  export interface SwitchProps extends Omit<ComponentProps<"input">, "checked" | "children" | "className" | "color" | "defaultChecked" | "onChange" | "size" | "type"> {
6
6
  checked?: boolean;
@@ -42,7 +42,14 @@ var switchSizeClasses = {
42
42
  var switchColorClasses = {
43
43
  primary: "switch-primary",
44
44
  secondary: "switch-secondary",
45
- tertiary: "switch-tertiary"
45
+ tertiary: "switch-tertiary",
46
+ accent: "switch-accent",
47
+ neutral: "switch-neutral",
48
+ base: "switch-base",
49
+ info: "switch-info",
50
+ success: "switch-success",
51
+ warning: "switch-warning",
52
+ error: "switch-error"
46
53
  };
47
54
  function getSwitchClasses({
48
55
  size = "md",
@@ -1,5 +1,5 @@
1
1
  import type { ComponentProps, ForwardRefExoticComponent, MouseEvent, ReactNode, RefAttributes } from "react";
2
- export type TagColor = "primary" | "secondary" | "tertiary" | "success" | "error" | "warning" | "info";
2
+ export type TagColor = "primary" | "secondary" | "tertiary" | "accent" | "neutral" | "base" | "info" | "success" | "warning" | "error";
3
3
  export type TagType = TagColor | (string & {});
4
4
  export interface TagProps extends Omit<ComponentProps<"span">, "color"> {
5
5
  color?: TagType;
@@ -41,10 +41,13 @@ var tagColorClasses = {
41
41
  primary: "chip-primary",
42
42
  secondary: "chip-secondary",
43
43
  tertiary: "chip-tertiary",
44
+ accent: "chip-accent",
45
+ neutral: "chip-neutral",
46
+ base: "chip-base",
47
+ info: "chip-info",
44
48
  success: "chip-success",
45
- error: "chip-error",
46
49
  warning: "chip-warning",
47
- info: "chip-info"
50
+ error: "chip-error"
48
51
  };
49
52
  function getTagClasses({
50
53
  color,
@@ -1,6 +1,6 @@
1
1
  import type { ComponentProps, ReactNode } from "react";
2
2
  export type TimelineMode = "left" | "right" | "alternate";
3
- export type TimelineColor = "primary" | "secondary" | "tertiary" | "success" | "error";
3
+ export type TimelineColor = "primary" | "secondary" | "tertiary" | "accent" | "neutral" | "base" | "info" | "success" | "warning" | "error";
4
4
  export type TimelineSize = "sm" | "md" | "lg";
5
5
  export interface TimelineItem {
6
6
  children?: ReactNode;
@@ -47,10 +47,15 @@ var timelineSizeClasses = {
47
47
  lg: "timeline-lg"
48
48
  };
49
49
  var timelineMarkerColorClasses = {
50
- primary: "",
50
+ primary: "timeline-marker-primary",
51
51
  secondary: "timeline-marker-secondary",
52
52
  tertiary: "timeline-marker-tertiary",
53
+ accent: "timeline-marker-accent",
54
+ neutral: "timeline-marker-neutral",
55
+ base: "timeline-marker-base",
56
+ info: "timeline-marker-info",
53
57
  success: "timeline-marker-success",
58
+ warning: "timeline-marker-warning",
54
59
  error: "timeline-marker-error"
55
60
  };
56
61
  function getTimelineClasses({
@@ -31,6 +31,9 @@ var buttonColorClasses = {
31
31
  primary: "btn-primary",
32
32
  secondary: "btn-secondary",
33
33
  tertiary: "btn-tertiary",
34
+ accent: "btn-accent",
35
+ neutral: "btn-neutral",
36
+ base: "btn-base",
34
37
  info: "btn-info",
35
38
  success: "btn-success",
36
39
  warning: "btn-warning",
@@ -1 +1 @@
1
- export declare const version = "0.2.1";
1
+ export declare const version = "0.3.1";
package/dist/index.d.ts CHANGED
@@ -95,5 +95,6 @@ export * from "./components/transfer";
95
95
  export * from "./components/tree";
96
96
  export * from "./components/tree-select";
97
97
  export * from "./components/typography";
98
+ export * from "./components/markdown";
98
99
  export * from "./components/upload";
99
100
  export * from "./components/watermark";