najm-kit 2.1.28 → 2.1.29
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 +8 -1
- package/dist/index.mjs +17 -13
- package/dist/json.mjs +29 -25
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2285,6 +2285,13 @@ interface BaseFormInputProps {
|
|
|
2285
2285
|
onChange?: (value: any) => void;
|
|
2286
2286
|
}
|
|
2287
2287
|
type FormInputSpecificProps<T> = Omit<T, "value" | "onChange" | keyof BaseFormInputProps>;
|
|
2288
|
+
type FormImageInputProps = FormInputSpecificProps<ImageInputProps> & {
|
|
2289
|
+
/**
|
|
2290
|
+
* Optional controlled preview value.
|
|
2291
|
+
* React Hook Form owns the value when omitted.
|
|
2292
|
+
*/
|
|
2293
|
+
value?: ImageInputProps["value"];
|
|
2294
|
+
};
|
|
2288
2295
|
type InputTypeMap = {
|
|
2289
2296
|
text: FormInputSpecificProps<TextInputProps>;
|
|
2290
2297
|
number: FormInputSpecificProps<NumberInputProps>;
|
|
@@ -2298,7 +2305,7 @@ type InputTypeMap = {
|
|
|
2298
2305
|
checkbox: FormInputSpecificProps<CheckboxInputProps>;
|
|
2299
2306
|
checkboxGroup: FormInputSpecificProps<CheckboxGroupInputProps>;
|
|
2300
2307
|
file: FormInputSpecificProps<FileInputProps>;
|
|
2301
|
-
image:
|
|
2308
|
+
image: FormImageInputProps;
|
|
2302
2309
|
date: FormInputSpecificProps<DateInputProps>;
|
|
2303
2310
|
starRating: FormInputSpecificProps<StarRatingInputProps>;
|
|
2304
2311
|
colorArray: FormInputSpecificProps<ColorArrayInputProps>;
|
package/dist/index.mjs
CHANGED
|
@@ -1234,11 +1234,26 @@ var Button = React.forwardRef(
|
|
|
1234
1234
|
},
|
|
1235
1235
|
[autoLoading, isDisabled, onClick]
|
|
1236
1236
|
);
|
|
1237
|
-
const
|
|
1237
|
+
const child = asChild ? React.Children.only(children) : null;
|
|
1238
|
+
const childContent = asChild && React.isValidElement(child) ? child.props.children : children;
|
|
1239
|
+
const content = loadingText && isLoading ? loadingText : childContent;
|
|
1238
1240
|
const loaderNode = isLoading ? loader : null;
|
|
1239
1241
|
const leftIconNode = renderIcon(leftIcon);
|
|
1240
1242
|
const rightIconNode = renderIcon(rightIcon);
|
|
1241
1243
|
const showCenteredLoader = Boolean(loaderNode && loaderPosition === "center");
|
|
1244
|
+
const renderedContent = showCenteredLoader ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1245
|
+
/* @__PURE__ */ jsxs("span", { className: "invisible inline-flex items-center gap-2", children: [
|
|
1246
|
+
leftIconNode,
|
|
1247
|
+
content,
|
|
1248
|
+
rightIconNode
|
|
1249
|
+
] }),
|
|
1250
|
+
/* @__PURE__ */ jsx("span", { className: "absolute inset-0 inline-flex items-center justify-center", children: loaderNode })
|
|
1251
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1252
|
+
loaderNode && loaderPosition === "left" ? loaderNode : leftIconNode,
|
|
1253
|
+
content,
|
|
1254
|
+
loaderNode && loaderPosition === "right" ? loaderNode : rightIconNode
|
|
1255
|
+
] });
|
|
1256
|
+
const renderedChild = asChild && React.isValidElement(child) ? React.cloneElement(child, void 0, renderedContent) : renderedContent;
|
|
1242
1257
|
return /* @__PURE__ */ jsx(
|
|
1243
1258
|
Comp,
|
|
1244
1259
|
{
|
|
@@ -1267,18 +1282,7 @@ var Button = React.forwardRef(
|
|
|
1267
1282
|
),
|
|
1268
1283
|
onClick: handleClick,
|
|
1269
1284
|
...props,
|
|
1270
|
-
children:
|
|
1271
|
-
/* @__PURE__ */ jsxs("span", { className: "invisible inline-flex items-center gap-2", children: [
|
|
1272
|
-
leftIconNode,
|
|
1273
|
-
content,
|
|
1274
|
-
rightIconNode
|
|
1275
|
-
] }),
|
|
1276
|
-
/* @__PURE__ */ jsx("span", { className: "absolute inset-0 inline-flex items-center justify-center", children: loaderNode })
|
|
1277
|
-
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1278
|
-
loaderNode && loaderPosition === "left" ? loaderNode : leftIconNode,
|
|
1279
|
-
content,
|
|
1280
|
-
loaderNode && loaderPosition === "right" ? loaderNode : rightIconNode
|
|
1281
|
-
] })
|
|
1285
|
+
children: renderedChild
|
|
1282
1286
|
}
|
|
1283
1287
|
);
|
|
1284
1288
|
}
|
package/dist/json.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import
|
|
1
|
+
import * as React5 from 'react';
|
|
2
|
+
import React5__default, { createContext, useContext, useMemo, useRef, useCallback } from 'react';
|
|
3
3
|
import CodeMirror from '@uiw/react-codemirror';
|
|
4
4
|
import { json } from '@codemirror/lang-json';
|
|
5
5
|
import { keymap, EditorView, Decoration, ViewPlugin } from '@codemirror/view';
|
|
@@ -201,8 +201,8 @@ var NIcon = ({
|
|
|
201
201
|
height: size,
|
|
202
202
|
...style
|
|
203
203
|
};
|
|
204
|
-
if (
|
|
205
|
-
return
|
|
204
|
+
if (React5__default.isValidElement(icon)) {
|
|
205
|
+
return React5__default.cloneElement(icon, {
|
|
206
206
|
className: cn(className, icon.props.className),
|
|
207
207
|
onClick,
|
|
208
208
|
...rest
|
|
@@ -249,15 +249,15 @@ var NIcon = ({
|
|
|
249
249
|
return null;
|
|
250
250
|
};
|
|
251
251
|
NIcon.displayName = "NIcon";
|
|
252
|
-
|
|
253
|
-
|
|
252
|
+
React5.createContext(0);
|
|
253
|
+
React5.createContext(null);
|
|
254
254
|
var DEFAULT_APPEARANCE = {};
|
|
255
|
-
|
|
256
|
-
var NajmDesignContext =
|
|
255
|
+
React5.createContext(DEFAULT_APPEARANCE);
|
|
256
|
+
var NajmDesignContext = React5.createContext({
|
|
257
257
|
components: {}
|
|
258
258
|
});
|
|
259
259
|
function useNajmDesign() {
|
|
260
|
-
return
|
|
260
|
+
return React5.useContext(NajmDesignContext);
|
|
261
261
|
}
|
|
262
262
|
function useNajmComponentStyle(name) {
|
|
263
263
|
const { components } = useNajmDesign();
|
|
@@ -427,7 +427,7 @@ function renderIcon(icon) {
|
|
|
427
427
|
if (!icon) return null;
|
|
428
428
|
return /* @__PURE__ */ jsx(NIcon, { "aria-hidden": "true", icon, className: "shrink-0" });
|
|
429
429
|
}
|
|
430
|
-
var Button =
|
|
430
|
+
var Button = React5.forwardRef(
|
|
431
431
|
({
|
|
432
432
|
className,
|
|
433
433
|
variant,
|
|
@@ -459,11 +459,11 @@ var Button = React3.forwardRef(
|
|
|
459
459
|
const effSize = size ?? recipe?.defaultSize;
|
|
460
460
|
const recipeRadius = rounded === void 0 ? resolveRadiusValue(recipe?.radius) : void 0;
|
|
461
461
|
const recipeStyle = recipeRadius ? { borderRadius: recipeRadius } : void 0;
|
|
462
|
-
const [pending, setPending] =
|
|
462
|
+
const [pending, setPending] = React5.useState(false);
|
|
463
463
|
const isLoading = loading || pending;
|
|
464
464
|
const isDisabled = disabled || disabledWhileLoading && isLoading;
|
|
465
465
|
const Comp = asChild ? Slot : "button";
|
|
466
|
-
const handleClick =
|
|
466
|
+
const handleClick = React5.useCallback(
|
|
467
467
|
(event) => {
|
|
468
468
|
if (isDisabled) {
|
|
469
469
|
event.preventDefault();
|
|
@@ -480,11 +480,26 @@ var Button = React3.forwardRef(
|
|
|
480
480
|
},
|
|
481
481
|
[autoLoading, isDisabled, onClick]
|
|
482
482
|
);
|
|
483
|
-
const
|
|
483
|
+
const child = asChild ? React5.Children.only(children) : null;
|
|
484
|
+
const childContent = asChild && React5.isValidElement(child) ? child.props.children : children;
|
|
485
|
+
const content = loadingText && isLoading ? loadingText : childContent;
|
|
484
486
|
const loaderNode = isLoading ? loader : null;
|
|
485
487
|
const leftIconNode = renderIcon(leftIcon);
|
|
486
488
|
const rightIconNode = renderIcon(rightIcon);
|
|
487
489
|
const showCenteredLoader = Boolean(loaderNode && loaderPosition === "center");
|
|
490
|
+
const renderedContent = showCenteredLoader ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
491
|
+
/* @__PURE__ */ jsxs("span", { className: "invisible inline-flex items-center gap-2", children: [
|
|
492
|
+
leftIconNode,
|
|
493
|
+
content,
|
|
494
|
+
rightIconNode
|
|
495
|
+
] }),
|
|
496
|
+
/* @__PURE__ */ jsx("span", { className: "absolute inset-0 inline-flex items-center justify-center", children: loaderNode })
|
|
497
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
498
|
+
loaderNode && loaderPosition === "left" ? loaderNode : leftIconNode,
|
|
499
|
+
content,
|
|
500
|
+
loaderNode && loaderPosition === "right" ? loaderNode : rightIconNode
|
|
501
|
+
] });
|
|
502
|
+
const renderedChild = asChild && React5.isValidElement(child) ? React5.cloneElement(child, void 0, renderedContent) : renderedContent;
|
|
488
503
|
return /* @__PURE__ */ jsx(
|
|
489
504
|
Comp,
|
|
490
505
|
{
|
|
@@ -513,18 +528,7 @@ var Button = React3.forwardRef(
|
|
|
513
528
|
),
|
|
514
529
|
onClick: handleClick,
|
|
515
530
|
...props,
|
|
516
|
-
children:
|
|
517
|
-
/* @__PURE__ */ jsxs("span", { className: "invisible inline-flex items-center gap-2", children: [
|
|
518
|
-
leftIconNode,
|
|
519
|
-
content,
|
|
520
|
-
rightIconNode
|
|
521
|
-
] }),
|
|
522
|
-
/* @__PURE__ */ jsx("span", { className: "absolute inset-0 inline-flex items-center justify-center", children: loaderNode })
|
|
523
|
-
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
524
|
-
loaderNode && loaderPosition === "left" ? loaderNode : leftIconNode,
|
|
525
|
-
content,
|
|
526
|
-
loaderNode && loaderPosition === "right" ? loaderNode : rightIconNode
|
|
527
|
-
] })
|
|
531
|
+
children: renderedChild
|
|
528
532
|
}
|
|
529
533
|
);
|
|
530
534
|
}
|