najm-kit 0.0.8 → 0.0.10

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/json.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import * as React3 from 'react';
2
- import React3__default, { createContext, useContext, useMemo, useRef, useCallback } from 'react';
1
+ import * as React2 from 'react';
2
+ import React2__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';
@@ -173,6 +173,44 @@ function JsonViewer({ value, colors = defaultJsonViewColors, className, maxHeigh
173
173
  }
174
174
  );
175
175
  }
176
+ React2.createContext(0);
177
+ React2.createContext(null);
178
+ var DEFAULT_APPEARANCE = {
179
+ borderDegree: "default"
180
+ };
181
+ var NajmAppearanceContext = React2.createContext(DEFAULT_APPEARANCE);
182
+ function useNajmAppearance() {
183
+ return React2.useContext(NajmAppearanceContext);
184
+ }
185
+
186
+ // src/theme/borders.ts
187
+ function resolveBorderDegree(borderDegree, bordered, globalBorderDegree, fallback = "default") {
188
+ if (borderDegree) return borderDegree;
189
+ if (bordered === true) return "strong";
190
+ if (bordered === false) return fallback;
191
+ return globalBorderDegree ?? fallback;
192
+ }
193
+ function borderColorClassForDegree(degree) {
194
+ switch (degree) {
195
+ case "none":
196
+ return "border-transparent";
197
+ case "subtle":
198
+ return "border-border-subtle";
199
+ case "strong":
200
+ return "border-border-strong";
201
+ default:
202
+ return "border-border";
203
+ }
204
+ }
205
+ function useResolvedBorderDegree(options = {}) {
206
+ const appearance = useNajmAppearance();
207
+ return resolveBorderDegree(
208
+ options.borderDegree,
209
+ options.bordered,
210
+ appearance.borderDegree,
211
+ options.fallback
212
+ );
213
+ }
176
214
  function toPascalCase(value) {
177
215
  return value.replace(/([a-z0-9])([A-Z])/g, "$1 $2").split(/[\s_-]+/).filter(Boolean).map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join("");
178
216
  }
@@ -196,8 +234,8 @@ var NIcon = ({
196
234
  height: size,
197
235
  ...style
198
236
  };
199
- if (React3__default.isValidElement(icon)) {
200
- return React3__default.cloneElement(icon, {
237
+ if (React2__default.isValidElement(icon)) {
238
+ return React2__default.cloneElement(icon, {
201
239
  className: cn(className, icon.props.className),
202
240
  onClick,
203
241
  ...rest
@@ -315,7 +353,7 @@ function renderIcon(icon) {
315
353
  if (!icon) return null;
316
354
  return /* @__PURE__ */ jsx(NIcon, { "aria-hidden": "true", icon, className: "shrink-0" });
317
355
  }
318
- var Button = React3.forwardRef(
356
+ var Button = React2.forwardRef(
319
357
  ({
320
358
  className,
321
359
  variant,
@@ -331,17 +369,23 @@ var Button = React3.forwardRef(
331
369
  loaderPosition = "left",
332
370
  leftIcon,
333
371
  rightIcon,
334
- bordered = false,
372
+ bordered,
373
+ borderDegree,
335
374
  disabled,
336
375
  children,
337
376
  onClick,
338
377
  ...props
339
378
  }, ref) => {
340
- const [pending, setPending] = React3.useState(false);
379
+ const [pending, setPending] = React2.useState(false);
341
380
  const isLoading = loading || pending;
342
381
  const isDisabled = disabled || disabledWhileLoading && isLoading;
343
382
  const Comp = asChild ? Slot : "button";
344
- const handleClick = React3.useCallback(
383
+ const resolvedBorderDegree = useResolvedBorderDegree({
384
+ borderDegree,
385
+ bordered,
386
+ fallback: "default"
387
+ });
388
+ const handleClick = React2.useCallback(
345
389
  (event) => {
346
390
  if (isDisabled) {
347
391
  event.preventDefault();
@@ -370,12 +414,22 @@ var Button = React3.forwardRef(
370
414
  "data-slot": "button",
371
415
  "data-loading": isLoading || void 0,
372
416
  "data-disabled": isDisabled || void 0,
417
+ "data-border-degree": variant === "outline" || bordered || borderDegree ? resolvedBorderDegree : void 0,
373
418
  "aria-busy": isLoading || void 0,
374
419
  "aria-disabled": asChild && isDisabled ? true : void 0,
375
420
  disabled: !asChild ? isDisabled : void 0,
376
421
  className: cn(
377
422
  buttonVariants({ variant, size, rounded, fullWidth }),
378
- bordered && "border border-muted-foreground",
423
+ // Outline buttons always have a border; let the resolved degree drive its color.
424
+ variant === "outline" && borderColorClassForDegree(resolvedBorderDegree),
425
+ // Filled/ghost/plain/link/success/warning/info/soft/subtle buttons only get a
426
+ // border when the consumer explicitly opts in via `bordered` or `borderDegree`.
427
+ // We do NOT honor the global strong mode for these, because it would make every
428
+ // filled button look outlined.
429
+ variant !== "outline" && (bordered || borderDegree) && cn(
430
+ "border",
431
+ borderDegree ? borderColorClassForDegree(resolvedBorderDegree) : "border-muted-foreground"
432
+ ),
379
433
  className
380
434
  ),
381
435
  onClick: handleClick,
package/dist/styles.css CHANGED
@@ -1190,6 +1190,8 @@ video {
1190
1190
  --najm-destructive: 0 84.2% 60.2%;
1191
1191
  --najm-destructive-foreground: 0 0% 98%;
1192
1192
  --najm-border: 0 0% 89.8%;
1193
+ --najm-border-subtle: 0 0% 95%;
1194
+ --najm-border-strong: 0 0% 30%;
1193
1195
  --najm-input: 0 0% 89.8%;
1194
1196
  --najm-ring: 240 4% 11%;
1195
1197
  --najm-radius: 0.5rem;
@@ -1215,6 +1217,8 @@ video {
1215
1217
  --najm-destructive: 0 84% 60%;
1216
1218
  --najm-destructive-foreground: 0 0% 100%;
1217
1219
  --najm-border: 240 6% 15%;
1220
+ --najm-border-subtle: 240 6% 11%;
1221
+ --najm-border-strong: 0 0% 78%;
1218
1222
  --najm-input: 240 6% 15%;
1219
1223
  --najm-ring: 240 4% 11%;
1220
1224
  }
@@ -1304,6 +1308,9 @@ video {
1304
1308
  .invisible {
1305
1309
  visibility: hidden;
1306
1310
  }
1311
+ .collapse {
1312
+ visibility: collapse;
1313
+ }
1307
1314
  .static {
1308
1315
  position: static;
1309
1316
  }
@@ -1402,6 +1409,9 @@ video {
1402
1409
  .top-4 {
1403
1410
  top: 1rem;
1404
1411
  }
1412
+ .top-7 {
1413
+ top: 1.75rem;
1414
+ }
1405
1415
  .top-\[50\%\] {
1406
1416
  top: 50%;
1407
1417
  }
@@ -1420,6 +1430,9 @@ video {
1420
1430
  .z-50 {
1421
1431
  z-index: 50;
1422
1432
  }
1433
+ .z-\[10000\] {
1434
+ z-index: 10000;
1435
+ }
1423
1436
  .col-start-2 {
1424
1437
  grid-column-start: 2;
1425
1438
  }
@@ -2364,6 +2377,12 @@ video {
2364
2377
  .border-border {
2365
2378
  border-color: hsl(var(--najm-border));
2366
2379
  }
2380
+ .border-border-strong {
2381
+ border-color: hsl(var(--najm-border-strong));
2382
+ }
2383
+ .border-border-subtle {
2384
+ border-color: hsl(var(--najm-border-subtle));
2385
+ }
2367
2386
  .border-border\/30 {
2368
2387
  border-color: hsl(var(--najm-border) / 0.3);
2369
2388
  }
@@ -2907,6 +2926,9 @@ video {
2907
2926
  .pl-9 {
2908
2927
  padding-left: 2.25rem;
2909
2928
  }
2929
+ .pl-\[calc\(var\(--rail\2c 4rem\)\/2_-_1\.5rem\)\] {
2930
+ padding-left: calc(var(--rail,4rem) / 2 - 1.5rem);
2931
+ }
2910
2932
  .pr-1\.5 {
2911
2933
  padding-right: 0.375rem;
2912
2934
  }
@@ -3448,6 +3470,9 @@ video {
3448
3470
  .ease-out {
3449
3471
  animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
3450
3472
  }
3473
+ .border-border-strong {
3474
+ border-color: hsl(var(--najm-border-strong)) !important;
3475
+ }
3451
3476
  /* Scrollable, but the scrollbar reserves no layout space (hidden in all
3452
3477
  browsers). `overflow: overlay` was removed from Chrome (~v121) and now
3453
3478
  behaves like `auto`, so hiding the bar is the only pure-CSS way to avoid
@@ -3557,6 +3582,9 @@ video {
3557
3582
  .focus-within\:border-primary:focus-within {
3558
3583
  border-color: hsl(var(--najm-primary));
3559
3584
  }
3585
+ .focus-within\:border-primary\/70:focus-within {
3586
+ border-color: hsl(var(--najm-primary) / 0.7);
3587
+ }
3560
3588
  .focus-within\:opacity-100:focus-within {
3561
3589
  opacity: 1;
3562
3590
  }
@@ -3573,6 +3601,9 @@ video {
3573
3601
  .hover\:border-border\/60:hover {
3574
3602
  border-color: hsl(var(--najm-border) / 0.6);
3575
3603
  }
3604
+ .hover\:border-input:hover {
3605
+ border-color: hsl(var(--najm-input));
3606
+ }
3576
3607
  .hover\:border-muted-foreground\/30:hover {
3577
3608
  border-color: hsl(var(--najm-muted-foreground) / 0.3);
3578
3609
  }
@@ -5003,12 +5034,12 @@ video {
5003
5034
  .\[\&_tr\]\:border-b tr {
5004
5035
  border-bottom-width: 1px;
5005
5036
  }
5037
+ .\[\&_tr\]\:border-border tr {
5038
+ border-color: hsl(var(--najm-border));
5039
+ }
5006
5040
  .\[\&_tr\]\:border-border\/40 tr {
5007
5041
  border-color: hsl(var(--najm-border) / 0.4);
5008
5042
  }
5009
- .\[\&_tr\]\:border-muted-foreground tr {
5010
- border-color: hsl(var(--najm-muted-foreground));
5011
- }
5012
5043
  a.\[a\&\]\:hover\:bg-accent\/50:hover {
5013
5044
  background-color: hsl(var(--najm-accent) / 0.5);
5014
5045
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "najm-kit",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "type": "module",
5
5
  "description": "Reusable React UI component package for Najm framework",
6
6
  "main": "./dist/index.mjs",