@almadar/ui 5.36.0 → 5.38.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.
@@ -4,9 +4,6 @@ var React8 = require('react');
4
4
  var logger = require('@almadar/logger');
5
5
  var jsxRuntime = require('react/jsx-runtime');
6
6
  var LucideIcons2 = require('lucide-react');
7
- var PhosphorIcons = require('@phosphor-icons/react');
8
- var TablerIcons = require('@tabler/icons-react');
9
- var FaIcons = require('react-icons/fa');
10
7
  var SyntaxHighlighter = require('react-syntax-highlighter/dist/esm/prism-light.js');
11
8
  var dark = require('react-syntax-highlighter/dist/esm/styles/prism/vsc-dark-plus.js');
12
9
  var syntax = require('@almadar/syntax');
@@ -49,9 +46,6 @@ function _interopNamespace(e) {
49
46
 
50
47
  var React8__default = /*#__PURE__*/_interopDefault(React8);
51
48
  var LucideIcons2__namespace = /*#__PURE__*/_interopNamespace(LucideIcons2);
52
- var PhosphorIcons__namespace = /*#__PURE__*/_interopNamespace(PhosphorIcons);
53
- var TablerIcons__namespace = /*#__PURE__*/_interopNamespace(TablerIcons);
54
- var FaIcons__namespace = /*#__PURE__*/_interopNamespace(FaIcons);
55
49
  var SyntaxHighlighter__default = /*#__PURE__*/_interopDefault(SyntaxHighlighter);
56
50
  var dark__default = /*#__PURE__*/_interopDefault(dark);
57
51
  var langJson__default = /*#__PURE__*/_interopDefault(langJson);
@@ -3151,6 +3145,41 @@ function kebabToPascal(name) {
3151
3145
  return part.charAt(0).toUpperCase() + part.slice(1);
3152
3146
  }).join("");
3153
3147
  }
3148
+ function loadLib(key, importer) {
3149
+ let p = libPromises.get(key);
3150
+ if (!p) {
3151
+ p = importer().then((m) => m);
3152
+ libPromises.set(key, p);
3153
+ }
3154
+ return p;
3155
+ }
3156
+ function lazyFamilyIcon(libKey, importer, pick, fallbackName, family) {
3157
+ const Lazy = React8__default.default.lazy(async () => {
3158
+ const lib = await loadLib(libKey, importer);
3159
+ const Comp = pick(lib);
3160
+ if (!Comp) {
3161
+ warnFallback(fallbackName, family);
3162
+ return { default: makeLucideAdapter(fallbackName, true) };
3163
+ }
3164
+ return { default: Comp };
3165
+ });
3166
+ const Wrapped = (props) => /* @__PURE__ */ jsxRuntime.jsx(
3167
+ React8__default.default.Suspense,
3168
+ {
3169
+ fallback: /* @__PURE__ */ jsxRuntime.jsx(
3170
+ "span",
3171
+ {
3172
+ "aria-hidden": true,
3173
+ className: props.className,
3174
+ style: { display: "inline-block", ...props.style }
3175
+ }
3176
+ ),
3177
+ children: /* @__PURE__ */ jsxRuntime.jsx(Lazy, { ...props })
3178
+ }
3179
+ );
3180
+ Wrapped.displayName = `Lazy.${libKey}.${fallbackName}`;
3181
+ return Wrapped;
3182
+ }
3154
3183
  function resolveLucide(name) {
3155
3184
  if (lucideAliases[name]) return lucideAliases[name];
3156
3185
  const pascal = kebabToPascal(name);
@@ -3161,60 +3190,81 @@ function resolveLucide(name) {
3161
3190
  if (asIs && typeof asIs === "object") return asIs;
3162
3191
  return LucideIcons2__namespace.HelpCircle;
3163
3192
  }
3164
- function resolvePhosphor(name, weight) {
3193
+ function resolvePhosphor(name, weight, family) {
3165
3194
  const target = phosphorAliases[name] ?? kebabToPascal(name);
3166
- const map = PhosphorIcons__namespace;
3167
- const PhosphorComp = map[target];
3168
- if (!PhosphorComp || typeof PhosphorComp !== "object") return null;
3169
- const Component = PhosphorComp;
3170
- const Adapter = (props) => /* @__PURE__ */ jsxRuntime.jsx(
3171
- Component,
3172
- {
3173
- weight,
3174
- className: props.className,
3175
- style: props.style,
3176
- size: props.size ?? "1em"
3177
- }
3195
+ return lazyFamilyIcon(
3196
+ "phosphor",
3197
+ () => import('@phosphor-icons/react'),
3198
+ (lib) => {
3199
+ const PhosphorComp = lib[target];
3200
+ if (!PhosphorComp || typeof PhosphorComp !== "object") return null;
3201
+ const Component = PhosphorComp;
3202
+ const Adapter = (props) => /* @__PURE__ */ jsxRuntime.jsx(
3203
+ Component,
3204
+ {
3205
+ weight,
3206
+ className: props.className,
3207
+ style: props.style,
3208
+ size: props.size ?? "1em"
3209
+ }
3210
+ );
3211
+ Adapter.displayName = `Phosphor.${target}.${weight}`;
3212
+ return Adapter;
3213
+ },
3214
+ name,
3215
+ family
3178
3216
  );
3179
- Adapter.displayName = `Phosphor.${target}.${weight}`;
3180
- return Adapter;
3181
3217
  }
3182
- function resolveTabler(name) {
3218
+ function resolveTabler(name, family) {
3183
3219
  const suffix = tablerAliases[name] ?? kebabToPascal(name);
3184
3220
  const target = `Icon${suffix}`;
3185
- const map = TablerIcons__namespace;
3186
- const TablerComp = map[target];
3187
- if (!TablerComp || typeof TablerComp !== "object") return null;
3188
- const Component = TablerComp;
3189
- const Adapter = (props) => /* @__PURE__ */ jsxRuntime.jsx(
3190
- Component,
3191
- {
3192
- stroke: props.strokeWidth ?? 1.5,
3193
- className: props.className,
3194
- style: props.style,
3195
- size: props.size ?? 24
3196
- }
3221
+ return lazyFamilyIcon(
3222
+ "tabler",
3223
+ () => import('@tabler/icons-react'),
3224
+ (lib) => {
3225
+ const TablerComp = lib[target];
3226
+ if (!TablerComp || typeof TablerComp !== "object") return null;
3227
+ const Component = TablerComp;
3228
+ const Adapter = (props) => /* @__PURE__ */ jsxRuntime.jsx(
3229
+ Component,
3230
+ {
3231
+ stroke: props.strokeWidth ?? 1.5,
3232
+ className: props.className,
3233
+ style: props.style,
3234
+ size: props.size ?? 24
3235
+ }
3236
+ );
3237
+ Adapter.displayName = `Tabler.${target}`;
3238
+ return Adapter;
3239
+ },
3240
+ name,
3241
+ family
3197
3242
  );
3198
- Adapter.displayName = `Tabler.${target}`;
3199
- return Adapter;
3200
3243
  }
3201
- function resolveFa(name) {
3244
+ function resolveFa(name, family) {
3202
3245
  const suffix = faAliases[name] ?? kebabToPascal(name);
3203
3246
  const target = `Fa${suffix}`;
3204
- const map = FaIcons__namespace;
3205
- const FaComp = map[target];
3206
- if (!FaComp || typeof FaComp !== "function") return null;
3207
- const Component = FaComp;
3208
- const Adapter = (props) => /* @__PURE__ */ jsxRuntime.jsx(
3209
- Component,
3210
- {
3211
- className: props.className,
3212
- style: props.style,
3213
- size: props.size ?? "1em"
3214
- }
3247
+ return lazyFamilyIcon(
3248
+ "fa",
3249
+ () => import('react-icons/fa'),
3250
+ (lib) => {
3251
+ const FaComp = lib[target];
3252
+ if (!FaComp || typeof FaComp !== "function") return null;
3253
+ const Component = FaComp;
3254
+ const Adapter = (props) => /* @__PURE__ */ jsxRuntime.jsx(
3255
+ Component,
3256
+ {
3257
+ className: props.className,
3258
+ style: props.style,
3259
+ size: props.size ?? "1em"
3260
+ }
3261
+ );
3262
+ Adapter.displayName = `Fa.${target}`;
3263
+ return Adapter;
3264
+ },
3265
+ name,
3266
+ family
3215
3267
  );
3216
- Adapter.displayName = `Fa.${target}`;
3217
- return Adapter;
3218
3268
  }
3219
3269
  function warnFallback(name, family) {
3220
3270
  const key = `${family}::${name}`;
@@ -3248,39 +3298,22 @@ function resolveIconForFamily(name, family) {
3248
3298
  switch (family) {
3249
3299
  case "lucide":
3250
3300
  return makeLucideAdapter(name, false);
3251
- case "phosphor-outline": {
3252
- const p = resolvePhosphor(name, "regular");
3253
- if (p) return p;
3254
- warnFallback(name, family);
3255
- return makeLucideAdapter(name, true);
3256
- }
3257
- case "phosphor-fill": {
3258
- const p = resolvePhosphor(name, "fill");
3259
- if (p) return p;
3260
- warnFallback(name, family);
3261
- return makeLucideAdapter(name, true);
3262
- }
3263
- case "phosphor-duotone": {
3264
- const p = resolvePhosphor(name, "duotone");
3265
- if (p) return p;
3266
- warnFallback(name, family);
3267
- return makeLucideAdapter(name, true);
3268
- }
3269
- case "tabler": {
3270
- const t = resolveTabler(name);
3271
- if (t) return t;
3272
- warnFallback(name, family);
3273
- return makeLucideAdapter(name, true);
3274
- }
3275
- case "fa-solid": {
3276
- const f = resolveFa(name);
3277
- if (f) return f;
3278
- warnFallback(name, family);
3279
- return makeLucideAdapter(name, true);
3280
- }
3301
+ // Non-lucide families resolve to a lazy, Suspense-wrapped component that
3302
+ // dynamic-imports the library on first render and falls back to lucide
3303
+ // internally when the family lacks the icon (see lazyFamilyIcon).
3304
+ case "phosphor-outline":
3305
+ return resolvePhosphor(name, "regular", family);
3306
+ case "phosphor-fill":
3307
+ return resolvePhosphor(name, "fill", family);
3308
+ case "phosphor-duotone":
3309
+ return resolvePhosphor(name, "duotone", family);
3310
+ case "tabler":
3311
+ return resolveTabler(name, family);
3312
+ case "fa-solid":
3313
+ return resolveFa(name, family);
3281
3314
  }
3282
3315
  }
3283
- var DEFAULT_FAMILY, VALID_FAMILIES, cachedFamily, listeners, observer, lucideAliases, phosphorAliases, tablerAliases, faAliases, warned;
3316
+ var DEFAULT_FAMILY, VALID_FAMILIES, cachedFamily, listeners, observer, libPromises, lucideAliases, phosphorAliases, tablerAliases, faAliases, warned;
3284
3317
  var init_iconFamily = __esm({
3285
3318
  "lib/iconFamily.tsx"() {
3286
3319
  "use client";
@@ -3296,6 +3329,7 @@ var init_iconFamily = __esm({
3296
3329
  cachedFamily = null;
3297
3330
  listeners = /* @__PURE__ */ new Set();
3298
3331
  observer = null;
3332
+ libPromises = /* @__PURE__ */ new Map();
3299
3333
  lucideAliases = {
3300
3334
  close: LucideIcons2__namespace.X,
3301
3335
  trash: LucideIcons2__namespace.Trash2,
@@ -3,9 +3,6 @@ import { createLogger } from '@almadar/logger';
3
3
  import { jsx, jsxs } from 'react/jsx-runtime';
4
4
  import * as LucideIcons2 from 'lucide-react';
5
5
  import { Loader2, Code, FileText, WrapText, Check, Copy, X } from 'lucide-react';
6
- import * as PhosphorIcons from '@phosphor-icons/react';
7
- import * as TablerIcons from '@tabler/icons-react';
8
- import * as FaIcons from 'react-icons/fa';
9
6
  import SyntaxHighlighter from 'react-syntax-highlighter/dist/esm/prism-light.js';
10
7
  import dark from 'react-syntax-highlighter/dist/esm/styles/prism/vsc-dark-plus.js';
11
8
  import { orbLanguage, loloLanguage, ORB_COLORS } from '@almadar/syntax';
@@ -3106,6 +3103,41 @@ function kebabToPascal(name) {
3106
3103
  return part.charAt(0).toUpperCase() + part.slice(1);
3107
3104
  }).join("");
3108
3105
  }
3106
+ function loadLib(key, importer) {
3107
+ let p = libPromises.get(key);
3108
+ if (!p) {
3109
+ p = importer().then((m) => m);
3110
+ libPromises.set(key, p);
3111
+ }
3112
+ return p;
3113
+ }
3114
+ function lazyFamilyIcon(libKey, importer, pick, fallbackName, family) {
3115
+ const Lazy = React8.lazy(async () => {
3116
+ const lib = await loadLib(libKey, importer);
3117
+ const Comp = pick(lib);
3118
+ if (!Comp) {
3119
+ warnFallback(fallbackName, family);
3120
+ return { default: makeLucideAdapter(fallbackName, true) };
3121
+ }
3122
+ return { default: Comp };
3123
+ });
3124
+ const Wrapped = (props) => /* @__PURE__ */ jsx(
3125
+ React8.Suspense,
3126
+ {
3127
+ fallback: /* @__PURE__ */ jsx(
3128
+ "span",
3129
+ {
3130
+ "aria-hidden": true,
3131
+ className: props.className,
3132
+ style: { display: "inline-block", ...props.style }
3133
+ }
3134
+ ),
3135
+ children: /* @__PURE__ */ jsx(Lazy, { ...props })
3136
+ }
3137
+ );
3138
+ Wrapped.displayName = `Lazy.${libKey}.${fallbackName}`;
3139
+ return Wrapped;
3140
+ }
3109
3141
  function resolveLucide(name) {
3110
3142
  if (lucideAliases[name]) return lucideAliases[name];
3111
3143
  const pascal = kebabToPascal(name);
@@ -3116,60 +3148,81 @@ function resolveLucide(name) {
3116
3148
  if (asIs && typeof asIs === "object") return asIs;
3117
3149
  return LucideIcons2.HelpCircle;
3118
3150
  }
3119
- function resolvePhosphor(name, weight) {
3151
+ function resolvePhosphor(name, weight, family) {
3120
3152
  const target = phosphorAliases[name] ?? kebabToPascal(name);
3121
- const map = PhosphorIcons;
3122
- const PhosphorComp = map[target];
3123
- if (!PhosphorComp || typeof PhosphorComp !== "object") return null;
3124
- const Component = PhosphorComp;
3125
- const Adapter = (props) => /* @__PURE__ */ jsx(
3126
- Component,
3127
- {
3128
- weight,
3129
- className: props.className,
3130
- style: props.style,
3131
- size: props.size ?? "1em"
3132
- }
3153
+ return lazyFamilyIcon(
3154
+ "phosphor",
3155
+ () => import('@phosphor-icons/react'),
3156
+ (lib) => {
3157
+ const PhosphorComp = lib[target];
3158
+ if (!PhosphorComp || typeof PhosphorComp !== "object") return null;
3159
+ const Component = PhosphorComp;
3160
+ const Adapter = (props) => /* @__PURE__ */ jsx(
3161
+ Component,
3162
+ {
3163
+ weight,
3164
+ className: props.className,
3165
+ style: props.style,
3166
+ size: props.size ?? "1em"
3167
+ }
3168
+ );
3169
+ Adapter.displayName = `Phosphor.${target}.${weight}`;
3170
+ return Adapter;
3171
+ },
3172
+ name,
3173
+ family
3133
3174
  );
3134
- Adapter.displayName = `Phosphor.${target}.${weight}`;
3135
- return Adapter;
3136
3175
  }
3137
- function resolveTabler(name) {
3176
+ function resolveTabler(name, family) {
3138
3177
  const suffix = tablerAliases[name] ?? kebabToPascal(name);
3139
3178
  const target = `Icon${suffix}`;
3140
- const map = TablerIcons;
3141
- const TablerComp = map[target];
3142
- if (!TablerComp || typeof TablerComp !== "object") return null;
3143
- const Component = TablerComp;
3144
- const Adapter = (props) => /* @__PURE__ */ jsx(
3145
- Component,
3146
- {
3147
- stroke: props.strokeWidth ?? 1.5,
3148
- className: props.className,
3149
- style: props.style,
3150
- size: props.size ?? 24
3151
- }
3179
+ return lazyFamilyIcon(
3180
+ "tabler",
3181
+ () => import('@tabler/icons-react'),
3182
+ (lib) => {
3183
+ const TablerComp = lib[target];
3184
+ if (!TablerComp || typeof TablerComp !== "object") return null;
3185
+ const Component = TablerComp;
3186
+ const Adapter = (props) => /* @__PURE__ */ jsx(
3187
+ Component,
3188
+ {
3189
+ stroke: props.strokeWidth ?? 1.5,
3190
+ className: props.className,
3191
+ style: props.style,
3192
+ size: props.size ?? 24
3193
+ }
3194
+ );
3195
+ Adapter.displayName = `Tabler.${target}`;
3196
+ return Adapter;
3197
+ },
3198
+ name,
3199
+ family
3152
3200
  );
3153
- Adapter.displayName = `Tabler.${target}`;
3154
- return Adapter;
3155
3201
  }
3156
- function resolveFa(name) {
3202
+ function resolveFa(name, family) {
3157
3203
  const suffix = faAliases[name] ?? kebabToPascal(name);
3158
3204
  const target = `Fa${suffix}`;
3159
- const map = FaIcons;
3160
- const FaComp = map[target];
3161
- if (!FaComp || typeof FaComp !== "function") return null;
3162
- const Component = FaComp;
3163
- const Adapter = (props) => /* @__PURE__ */ jsx(
3164
- Component,
3165
- {
3166
- className: props.className,
3167
- style: props.style,
3168
- size: props.size ?? "1em"
3169
- }
3205
+ return lazyFamilyIcon(
3206
+ "fa",
3207
+ () => import('react-icons/fa'),
3208
+ (lib) => {
3209
+ const FaComp = lib[target];
3210
+ if (!FaComp || typeof FaComp !== "function") return null;
3211
+ const Component = FaComp;
3212
+ const Adapter = (props) => /* @__PURE__ */ jsx(
3213
+ Component,
3214
+ {
3215
+ className: props.className,
3216
+ style: props.style,
3217
+ size: props.size ?? "1em"
3218
+ }
3219
+ );
3220
+ Adapter.displayName = `Fa.${target}`;
3221
+ return Adapter;
3222
+ },
3223
+ name,
3224
+ family
3170
3225
  );
3171
- Adapter.displayName = `Fa.${target}`;
3172
- return Adapter;
3173
3226
  }
3174
3227
  function warnFallback(name, family) {
3175
3228
  const key = `${family}::${name}`;
@@ -3203,39 +3256,22 @@ function resolveIconForFamily(name, family) {
3203
3256
  switch (family) {
3204
3257
  case "lucide":
3205
3258
  return makeLucideAdapter(name, false);
3206
- case "phosphor-outline": {
3207
- const p = resolvePhosphor(name, "regular");
3208
- if (p) return p;
3209
- warnFallback(name, family);
3210
- return makeLucideAdapter(name, true);
3211
- }
3212
- case "phosphor-fill": {
3213
- const p = resolvePhosphor(name, "fill");
3214
- if (p) return p;
3215
- warnFallback(name, family);
3216
- return makeLucideAdapter(name, true);
3217
- }
3218
- case "phosphor-duotone": {
3219
- const p = resolvePhosphor(name, "duotone");
3220
- if (p) return p;
3221
- warnFallback(name, family);
3222
- return makeLucideAdapter(name, true);
3223
- }
3224
- case "tabler": {
3225
- const t = resolveTabler(name);
3226
- if (t) return t;
3227
- warnFallback(name, family);
3228
- return makeLucideAdapter(name, true);
3229
- }
3230
- case "fa-solid": {
3231
- const f = resolveFa(name);
3232
- if (f) return f;
3233
- warnFallback(name, family);
3234
- return makeLucideAdapter(name, true);
3235
- }
3259
+ // Non-lucide families resolve to a lazy, Suspense-wrapped component that
3260
+ // dynamic-imports the library on first render and falls back to lucide
3261
+ // internally when the family lacks the icon (see lazyFamilyIcon).
3262
+ case "phosphor-outline":
3263
+ return resolvePhosphor(name, "regular", family);
3264
+ case "phosphor-fill":
3265
+ return resolvePhosphor(name, "fill", family);
3266
+ case "phosphor-duotone":
3267
+ return resolvePhosphor(name, "duotone", family);
3268
+ case "tabler":
3269
+ return resolveTabler(name, family);
3270
+ case "fa-solid":
3271
+ return resolveFa(name, family);
3236
3272
  }
3237
3273
  }
3238
- var DEFAULT_FAMILY, VALID_FAMILIES, cachedFamily, listeners, observer, lucideAliases, phosphorAliases, tablerAliases, faAliases, warned;
3274
+ var DEFAULT_FAMILY, VALID_FAMILIES, cachedFamily, listeners, observer, libPromises, lucideAliases, phosphorAliases, tablerAliases, faAliases, warned;
3239
3275
  var init_iconFamily = __esm({
3240
3276
  "lib/iconFamily.tsx"() {
3241
3277
  "use client";
@@ -3251,6 +3287,7 @@ var init_iconFamily = __esm({
3251
3287
  cachedFamily = null;
3252
3288
  listeners = /* @__PURE__ */ new Set();
3253
3289
  observer = null;
3290
+ libPromises = /* @__PURE__ */ new Map();
3254
3291
  lucideAliases = {
3255
3292
  close: LucideIcons2.X,
3256
3293
  trash: LucideIcons2.Trash2,