@kilnonedre/foundation 0.0.1-alpha.1 → 0.0.1-alpha.2

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 CHANGED
@@ -1,3 +1,5 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ReactNode } from 'react';
1
3
  import { z } from 'zod';
2
4
  import { ClassValue } from 'clsx';
3
5
 
@@ -98,6 +100,20 @@ declare const EnumVariant: {
98
100
  type EnumVariant = (typeof EnumVariant)[keyof typeof EnumVariant];
99
101
  declare const EnumVariantLabel: Record<EnumVariant, string>;
100
102
 
103
+ interface ConfigProp {
104
+ semanticColor?: EnumSemanticColor;
105
+ variant?: EnumVariant;
106
+ children?: ReactNode;
107
+ className?: string;
108
+ onClick?: () => void;
109
+ disabled?: boolean;
110
+ loading?: boolean;
111
+ size?: "default" | "sm" | "lg" | "icon" | null;
112
+ type?: "button" | "submit" | "reset";
113
+ }
114
+
115
+ declare const Button: ({ semanticColor, variant, children, className, onClick, disabled, type, size, loading, }: ConfigProp) => react_jsx_runtime.JSX.Element;
116
+
101
117
  declare const boolToText: (bool: boolean) => "是" | "否";
102
118
 
103
119
  declare const formatDecimal: (value: number | string | null | undefined, digits?: number) => string;
@@ -147,4 +163,4 @@ declare const formatDateTime: (value: string | Date | number | null | undefined,
147
163
 
148
164
  declare function cn(...inputs: ClassValue[]): string;
149
165
 
150
- export { type CommonOption, EnumApprovalStatus, EnumApprovalStatusLabel, EnumApprovalView, EnumApprovalViewLabel, EnumEntityStatus, EnumEntityStatusLabel, EnumFormMode, EnumFormModeLabel, EnumGenderType, EnumGenderTypeLabel, EnumMapProvider, EnumMapProviderLabel, EnumOrderStatus, EnumOrderStatusLabel, EnumPublishMethod, EnumPublishMethodLabel, EnumSemanticColor, EnumSemanticColorLabel, EnumStorageMethod, EnumStorageMethodLabel, EnumVariant, EnumVariantLabel, boolToText, cn, emptyToUndefined, enumToOptions, enumValues, formatDateTime, formatDecimal, isValidEmail, isValidURL, zBool, zCoerceNumber, zCoerceNumberOptional, zDate, zDateOptional, zDecimal, zDecimalOptional, zEmail, zEnumNullable, zEnumNullableOptional, zEnumNullableRequired, zEnumOptional, zEnumRequired, zId, zIdCard, zIdCardOptional, zIds, zImageId, zImageIdRequired, zImageIds, zImageIdsOptional, zNumber, zNumberOptional, zPhone, zTextOptional, zTextRequired, zTexts };
166
+ export { Button, type CommonOption, EnumApprovalStatus, EnumApprovalStatusLabel, EnumApprovalView, EnumApprovalViewLabel, EnumEntityStatus, EnumEntityStatusLabel, EnumFormMode, EnumFormModeLabel, EnumGenderType, EnumGenderTypeLabel, EnumMapProvider, EnumMapProviderLabel, EnumOrderStatus, EnumOrderStatusLabel, EnumPublishMethod, EnumPublishMethodLabel, EnumSemanticColor, EnumSemanticColorLabel, EnumStorageMethod, EnumStorageMethodLabel, EnumVariant, EnumVariantLabel, boolToText, cn, emptyToUndefined, enumToOptions, enumValues, formatDateTime, formatDecimal, isValidEmail, isValidURL, zBool, zCoerceNumber, zCoerceNumberOptional, zDate, zDateOptional, zDecimal, zDecimalOptional, zEmail, zEnumNullable, zEnumNullableOptional, zEnumNullableRequired, zEnumOptional, zEnumRequired, zId, zIdCard, zIdCardOptional, zIds, zImageId, zImageIdRequired, zImageIds, zImageIdsOptional, zNumber, zNumberOptional, zPhone, zTextOptional, zTextRequired, zTexts };
package/dist/index.js CHANGED
@@ -168,6 +168,9 @@ import { Slot } from "radix-ui";
168
168
  // src/shadcn/lib/utils.ts
169
169
  import { clsx } from "clsx";
170
170
  import { twMerge } from "tailwind-merge";
171
+ function cn(...inputs) {
172
+ return twMerge(clsx(inputs));
173
+ }
171
174
 
172
175
  // src/shadcn/components/button.tsx
173
176
  import { jsx } from "react/jsx-runtime";
@@ -200,6 +203,25 @@ var buttonVariants = cva(
200
203
  }
201
204
  }
202
205
  );
206
+ function Button({
207
+ className,
208
+ variant = "default",
209
+ size = "default",
210
+ asChild = false,
211
+ ...props
212
+ }) {
213
+ const Comp = asChild ? Slot.Root : "button";
214
+ return /* @__PURE__ */ jsx(
215
+ Comp,
216
+ {
217
+ "data-slot": "button",
218
+ "data-variant": variant,
219
+ "data-size": size,
220
+ className: cn(buttonVariants({ variant, size, className })),
221
+ ...props
222
+ }
223
+ );
224
+ }
203
225
 
204
226
  // src/util/bool-to-text.ts
205
227
  var boolToText = (bool) => {
@@ -368,6 +390,17 @@ function cn2(...inputs) {
368
390
  // src/shadcn/components/spinner.tsx
369
391
  import { Loader2Icon } from "lucide-react";
370
392
  import { jsx as jsx2 } from "react/jsx-runtime";
393
+ function Spinner({ className, ...props }) {
394
+ return /* @__PURE__ */ jsx2(
395
+ Loader2Icon,
396
+ {
397
+ role: "status",
398
+ "aria-label": "Loading",
399
+ className: cn("size-4 animate-spin", className),
400
+ ...props
401
+ }
402
+ );
403
+ }
371
404
 
372
405
  // src/components/button/index.tsx
373
406
  import { jsx as jsx3, jsxs } from "react/jsx-runtime";
@@ -408,7 +441,39 @@ var colorMap = {
408
441
  [EnumVariant.OUTLINE]: "border border-black text-black bg-transparent hover:bg-black/10"
409
442
  }
410
443
  };
444
+ var Button2 = ({
445
+ semanticColor = EnumSemanticColor.PRIMARY,
446
+ variant = EnumVariant.SOLID,
447
+ children,
448
+ className,
449
+ onClick,
450
+ disabled,
451
+ type = "button",
452
+ size,
453
+ loading
454
+ }) => {
455
+ return /* @__PURE__ */ jsxs(
456
+ Button,
457
+ {
458
+ type,
459
+ onClick,
460
+ size,
461
+ disabled: disabled || loading,
462
+ className: cn2(
463
+ "whitespace-nowrap",
464
+ colorMap[semanticColor][variant],
465
+ disabled && "opacity-50 pointer-events-none",
466
+ className
467
+ ),
468
+ children: [
469
+ loading && /* @__PURE__ */ jsx3(Spinner, { "data-icon": "inline-start" }),
470
+ children
471
+ ]
472
+ }
473
+ );
474
+ };
411
475
  export {
476
+ Button2 as Button,
412
477
  EnumApprovalStatus,
413
478
  EnumApprovalStatusLabel,
414
479
  EnumApprovalView,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kilnonedre/foundation",
3
- "version": "0.0.1-alpha.1",
3
+ "version": "0.0.1-alpha.2",
4
4
  "private": false,
5
5
  "description": "Kilnonedre frontend foundation package",
6
6
  "type": "module",
@@ -10,6 +10,12 @@
10
10
  "files": [
11
11
  "dist"
12
12
  ],
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.js"
17
+ }
18
+ },
13
19
  "scripts": {
14
20
  "build": "tsup src/index.ts --format esm --dts --clean",
15
21
  "dev": "tsup src/index.ts --format esm --dts --watch",