nish-ui 1.7.0 → 1.8.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.
package/dist/files.json CHANGED
@@ -6,6 +6,9 @@
6
6
  "theme.js",
7
7
  "theme.global.js",
8
8
  "elements.js",
9
+ "elements-forms.js",
10
+ "elements-data.js",
11
+ "elements-charts.js",
9
12
  "fonts/inter-latin-wght-normal.3100e775.woff2",
10
13
  "fonts/inter-latin-ext-wght-normal.34b9c504.woff2"
11
14
  ]
package/dist/index.js CHANGED
@@ -587,6 +587,13 @@ function mountThemeToggle(button, opts = {}) {
587
587
  off();
588
588
  };
589
589
  }
590
+ var TOAST_ICON_PATHS = {
591
+ neutral: '<circle cx="12" cy="12" r="10"/><path d="M12 16v-4M12 8h.01"/>',
592
+ info: '<circle cx="12" cy="12" r="10"/><path d="M12 16v-4M12 8h.01"/>',
593
+ ok: '<circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/>',
594
+ warn: '<path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"/><path d="M12 9v4M12 17h.01"/>',
595
+ loss: '<path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"/><path d="M12 9v4M12 17h.01"/>'
596
+ };
590
597
  var TOAST_MS = 6e3;
591
598
  var toastRegion = null;
592
599
  var hideCurrent = null;
@@ -602,6 +609,11 @@ function showToast(content, opts = {}) {
602
609
  const region = toastRegion;
603
610
  const box = document.createElement("div");
604
611
  box.className = "nish-toast" + (opts.tone && opts.tone !== "neutral" ? ` nish-toast--${opts.tone}` : "");
612
+ const icon = document.createElement("span");
613
+ icon.className = "nish-toast-icon";
614
+ icon.setAttribute("aria-hidden", "true");
615
+ icon.innerHTML = `<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" focusable="false">${TOAST_ICON_PATHS[opts.tone ?? "neutral"]}</svg>`;
616
+ box.append(icon);
605
617
  const body = document.createElement("p");
606
618
  body.className = "nish-toast-body";
607
619
  body.append(typeof content === "string" ? document.createTextNode(content) : content);
@@ -4784,6 +4796,31 @@ import {
4784
4796
  useRef as useRef9,
4785
4797
  useState as useState8
4786
4798
  } from "react";
4799
+
4800
+ // src/sparkline-path.ts
4801
+ function sparklineGeometry(values, width, height, min, max) {
4802
+ const nums = values.filter((v) => v != null && Number.isFinite(v));
4803
+ const empty = nums.length === 0;
4804
+ const lo = min ?? (empty ? 0 : Math.min(...nums));
4805
+ const hi = max ?? (empty ? 1 : Math.max(...nums));
4806
+ const pad = 2;
4807
+ const x = (i) => values.length <= 1 ? width / 2 : i / (values.length - 1) * width;
4808
+ const y = (v) => hi === lo ? height / 2 : pad + (1 - (v - lo) / (hi - lo)) * (height - 2 * pad);
4809
+ const runs = [];
4810
+ let run = [];
4811
+ values.forEach((v, i) => {
4812
+ if (v == null || !Number.isFinite(v)) {
4813
+ if (run.length) runs.push(run);
4814
+ run = [];
4815
+ } else run.push({ x: x(i), y: y(v) });
4816
+ });
4817
+ if (run.length) runs.push(run);
4818
+ const line = (r) => r.length === 1 ? `M${r[0].x},${r[0].y}h0` : r.map((p, i) => `${i ? "L" : "M"}${p.x},${p.y}`).join("");
4819
+ const area = (r) => r.length < 2 ? "" : `${line(r)}L${r[r.length - 1].x},${height}L${r[0].x},${height}Z`;
4820
+ return { empty, lines: runs.map(line), areas: runs.map(area), baseline: `M0,${height / 2}H${width}` };
4821
+ }
4822
+
4823
+ // src/components/display.tsx
4787
4824
  import { Fragment as Fragment6, jsx as jsx12, jsxs as jsxs12 } from "react/jsx-runtime";
4788
4825
  function Svg3({ size = 16, children, ...rest }) {
4789
4826
  return /* @__PURE__ */ jsx12(
@@ -5099,24 +5136,7 @@ function Sparkline({
5099
5136
  max,
5100
5137
  className
5101
5138
  }) {
5102
- const nums = values.filter((v) => v != null && Number.isFinite(v));
5103
- const empty = nums.length === 0;
5104
- const lo = min ?? (empty ? 0 : Math.min(...nums));
5105
- const hi = max ?? (empty ? 1 : Math.max(...nums));
5106
- const pad = 2;
5107
- const x = (i) => values.length <= 1 ? width / 2 : i / (values.length - 1) * width;
5108
- const y = (v) => hi === lo ? height / 2 : pad + (1 - (v - lo) / (hi - lo)) * (height - 2 * pad);
5109
- const runs = [];
5110
- let run = [];
5111
- values.forEach((v, i) => {
5112
- if (v == null || !Number.isFinite(v)) {
5113
- if (run.length) runs.push(run);
5114
- run = [];
5115
- } else run.push({ x: x(i), y: y(v) });
5116
- });
5117
- if (run.length) runs.push(run);
5118
- const line = (r) => r.length === 1 ? `M${r[0].x},${r[0].y}h0` : r.map((p, i) => `${i ? "L" : "M"}${p.x},${p.y}`).join("");
5119
- const area = (r) => r.length < 2 ? "" : `${line(r)}L${r[r.length - 1].x},${height}L${r[0].x},${height}Z`;
5139
+ const { empty, lines, areas, baseline } = sparklineGeometry(values, width, height, min, max);
5120
5140
  return /* @__PURE__ */ jsx12(
5121
5141
  "svg",
5122
5142
  {
@@ -5130,18 +5150,18 @@ function Sparkline({
5130
5150
  children: empty ? /* @__PURE__ */ jsx12(
5131
5151
  "path",
5132
5152
  {
5133
- d: `M0,${height / 2}H${width}`,
5153
+ d: baseline,
5134
5154
  stroke: "currentColor",
5135
5155
  strokeWidth: 1.5,
5136
5156
  strokeDasharray: "3 3",
5137
5157
  vectorEffect: "non-scaling-stroke"
5138
5158
  }
5139
5159
  ) : /* @__PURE__ */ jsxs12(Fragment6, { children: [
5140
- fill ? runs.map((r, i) => /* @__PURE__ */ jsx12("path", { d: area(r), fill: "currentColor", fillOpacity: 0.15 }, `a${i}`)) : null,
5141
- runs.map((r, i) => /* @__PURE__ */ jsx12(
5160
+ fill ? areas.map((d, i) => /* @__PURE__ */ jsx12("path", { d, fill: "currentColor", fillOpacity: 0.15 }, `a${i}`)) : null,
5161
+ lines.map((d, i) => /* @__PURE__ */ jsx12(
5142
5162
  "path",
5143
5163
  {
5144
- d: line(r),
5164
+ d,
5145
5165
  fill: "none",
5146
5166
  stroke: "currentColor",
5147
5167
  strokeWidth: 1.5,
@@ -8878,14 +8898,21 @@ function ServiceTokensSection({
8878
8898
 
8879
8899
  // src/components/combobox.tsx
8880
8900
  import { useCallback as useCallback10, useEffect as useEffect23, useId as useId11, useMemo as useMemo7, useRef as useRef21, useState as useState21 } from "react";
8881
- import { jsx as jsx25, jsxs as jsxs24 } from "react/jsx-runtime";
8882
- var MAX_SHOWN = 50;
8883
- var DEBOUNCE_MS = 200;
8884
- var defaultFilter = (o, q) => {
8901
+
8902
+ // src/combobox-filter.ts
8903
+ var COMBOBOX_MAX_SHOWN = 50;
8904
+ var COMBOBOX_DEBOUNCE_MS = 200;
8905
+ var defaultComboboxFilter = (o, q) => {
8885
8906
  const needle = q.trim().toLowerCase();
8886
8907
  if (!needle) return true;
8887
8908
  return o.label.toLowerCase().includes(needle) || (o.hint?.toLowerCase().includes(needle) ?? false);
8888
8909
  };
8910
+
8911
+ // src/components/combobox.tsx
8912
+ import { jsx as jsx25, jsxs as jsxs24 } from "react/jsx-runtime";
8913
+ var MAX_SHOWN = COMBOBOX_MAX_SHOWN;
8914
+ var DEBOUNCE_MS = COMBOBOX_DEBOUNCE_MS;
8915
+ var defaultFilter = defaultComboboxFilter;
8889
8916
  function Combobox({
8890
8917
  options,
8891
8918
  value,