@adecore/ui 0.50.6 → 0.50.7

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/FileIcon.js CHANGED
@@ -1,14 +1,14 @@
1
1
  import { c as _c } from "react/compiler-runtime";
2
2
  import { useInsertionEffect } from 'react';
3
3
  import clsx from 'clsx';
4
- import { fileIconFor, mountFileIconSprite } from './file-icon.js';
4
+ import { fileIconFor, fileIconOverrideFor, mountFileIconSprite } from './file-icon.js';
5
5
  /*
6
6
  * The one place the library steps outside Lucide. The glyphs are Seti's, and so are their colors: a
7
7
  * TypeScript blue is the mark of the file type, not a theme choice. Decorative like every other icon here.
8
8
  */
9
9
  import { jsx as _jsx } from "react/jsx-runtime";
10
10
  export function FileIcon(t0) {
11
- const $ = _c(12);
11
+ const $ = _c(20);
12
12
  const {
13
13
  path,
14
14
  size: t1,
@@ -25,50 +25,86 @@ export function FileIcon(t0) {
25
25
  }
26
26
  useInsertionEffect(mountFileIconSprite, t2);
27
27
  let t3;
28
- if ($[1] !== className) {
29
- t3 = clsx("file-icon", className);
30
- $[1] = className;
28
+ if ($[1] !== path) {
29
+ t3 = fileIconOverrideFor(path);
30
+ $[1] = path;
31
31
  $[2] = t3;
32
32
  } else {
33
33
  t3 = $[2];
34
34
  }
35
+ const own = t3;
36
+ if (own !== null) {
37
+ let t4;
38
+ if ($[3] !== className) {
39
+ t4 = clsx("file-icon", className);
40
+ $[3] = className;
41
+ $[4] = t4;
42
+ } else {
43
+ t4 = $[4];
44
+ }
45
+ let t5;
46
+ if ($[5] !== own || $[6] !== size || $[7] !== t4) {
47
+ t5 = /*#__PURE__*/_jsx("img", {
48
+ src: own,
49
+ alt: "",
50
+ width: size,
51
+ height: size,
52
+ className: t4
53
+ });
54
+ $[5] = own;
55
+ $[6] = size;
56
+ $[7] = t4;
57
+ $[8] = t5;
58
+ } else {
59
+ t5 = $[8];
60
+ }
61
+ return t5;
62
+ }
35
63
  let t4;
36
- if ($[3] !== path) {
37
- t4 = fileIconFor(path);
38
- $[3] = path;
39
- $[4] = t4;
64
+ if ($[9] !== className) {
65
+ t4 = clsx("file-icon", className);
66
+ $[9] = className;
67
+ $[10] = t4;
40
68
  } else {
41
- t4 = $[4];
69
+ t4 = $[10];
42
70
  }
43
- const t5 = `#${t4}`;
44
- let t6;
45
- if ($[5] !== t5) {
46
- t6 = /*#__PURE__*/_jsx("use", {
47
- href: t5
48
- });
49
- $[5] = t5;
50
- $[6] = t6;
71
+ let t5;
72
+ if ($[11] !== path) {
73
+ t5 = fileIconFor(path);
74
+ $[11] = path;
75
+ $[12] = t5;
51
76
  } else {
52
- t6 = $[6];
77
+ t5 = $[12];
53
78
  }
79
+ const t6 = `#${t5}`;
54
80
  let t7;
55
- if ($[7] !== ref || $[8] !== size || $[9] !== t3 || $[10] !== t6) {
56
- t7 = /*#__PURE__*/_jsx("svg", {
81
+ if ($[13] !== t6) {
82
+ t7 = /*#__PURE__*/_jsx("use", {
83
+ href: t6
84
+ });
85
+ $[13] = t6;
86
+ $[14] = t7;
87
+ } else {
88
+ t7 = $[14];
89
+ }
90
+ let t8;
91
+ if ($[15] !== ref || $[16] !== size || $[17] !== t4 || $[18] !== t7) {
92
+ t8 = /*#__PURE__*/_jsx("svg", {
57
93
  ref: ref,
58
- className: t3,
94
+ className: t4,
59
95
  width: size,
60
96
  height: size,
61
97
  viewBox: "0 0 16 16",
62
98
  "aria-hidden": true,
63
- children: t6
99
+ children: t7
64
100
  });
65
- $[7] = ref;
66
- $[8] = size;
67
- $[9] = t3;
68
- $[10] = t6;
69
- $[11] = t7;
101
+ $[15] = ref;
102
+ $[16] = size;
103
+ $[17] = t4;
104
+ $[18] = t7;
105
+ $[19] = t8;
70
106
  } else {
71
- t7 = $[11];
107
+ t8 = $[19];
72
108
  }
73
- return t7;
109
+ return t8;
74
110
  }
@@ -1,4 +1,6 @@
1
1
  import { type FileTreeIconConfig } from '@pierre/trees';
2
2
  export declare const FILE_TREE_ICONS: FileTreeIconConfig;
3
3
  export declare const fileIconFor: (path: string) => string;
4
+ export declare function setFileIconOverride(next: ((path: string) => string | null) | null): void;
5
+ export declare function fileIconOverrideFor(path: string): string | null;
4
6
  export declare const mountFileIconSprite: () => void;
package/dist/file-icon.js CHANGED
@@ -24,6 +24,14 @@ const resolveIcon = (...args) => {
24
24
  * generic file icon: the tree marks a folder with its chevron, not a glyph.
25
25
  */
26
26
  export const fileIconFor = path => resolveIcon('file-tree-icon-file', path).name;
27
+ let override = null;
28
+ /* What an app knows better about a file's icon: the address of an svg, or null for the icon this set has. */
29
+ export function setFileIconOverride(next) {
30
+ override = next;
31
+ }
32
+ export function fileIconOverrideFor(path) {
33
+ return override?.(path) ?? null;
34
+ }
27
35
  /* The tree carries the sprite into its own shadow root, out of reach of anything that draws an
28
36
  icon next to it, so the document gets a copy of the same sheet to point `<use>` at. */
29
37
  export const mountFileIconSprite = () => {
package/dist/index.d.ts CHANGED
@@ -73,7 +73,7 @@ export { ZoomControls, type ZoomControlsProps, type ZoomLabels, type ZoomSelecti
73
73
  export { copyText, readClipboardText } from './clipboard.ts';
74
74
  export { messageOf } from './error-message.ts';
75
75
  export type { ResetKeys } from './error-boundary.ts';
76
- export { FILE_TREE_ICONS } from './file-icon.ts';
76
+ export { FILE_TREE_ICONS, setFileIconOverride } from './file-icon.ts';
77
77
  export { cameThroughPortal, isInFloatingLayer } from './floating.ts';
78
78
  export { LoadedComponent, lazyDialog, lazyNamed, onLazyOpenError } from './lazy.tsx';
79
79
  export type { LazyComponent } from './lazy.tsx';
package/dist/index.js CHANGED
@@ -69,7 +69,7 @@ export { Wipe } from "./Wipe.js";
69
69
  export { ZoomControls } from "./ZoomControls.js";
70
70
  export { copyText, readClipboardText } from './clipboard.js';
71
71
  export { messageOf } from './error-message.js';
72
- export { FILE_TREE_ICONS } from './file-icon.js';
72
+ export { FILE_TREE_ICONS, setFileIconOverride } from './file-icon.js';
73
73
  export { cameThroughPortal, isInFloatingLayer } from './floating.js';
74
74
  export { LoadedComponent, lazyDialog, lazyNamed, onLazyOpenError } from "./lazy.js";
75
75
  export { LazyBoundary } from "./LazyBoundary.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adecore/ui",
3
- "version": "0.50.6",
3
+ "version": "0.50.7",
4
4
  "description": "React components, a theme, formatters and a settings dialog for desktop-grade apps on React 19, Base UI and Tailwind 4.",
5
5
  "license": "FSL-1.1-MIT",
6
6
  "author": "Bas Milius",
package/src/FileIcon.tsx CHANGED
@@ -1,6 +1,6 @@
1
1
  import { useInsertionEffect, type Ref } from 'react';
2
2
  import clsx from 'clsx';
3
- import { fileIconFor, mountFileIconSprite } from './file-icon.ts';
3
+ import { fileIconFor, fileIconOverrideFor, mountFileIconSprite } from './file-icon.ts';
4
4
 
5
5
  export interface FileIconProps {
6
6
  /* Absolute or relative; only the last segment decides which icon this is. */
@@ -19,6 +19,12 @@ export function FileIcon({ path, size = 16, className, ref }: FileIconProps) {
19
19
  // Before the browser paints, so a `<use>` never points at a symbol that is not in the document yet.
20
20
  useInsertionEffect(mountFileIconSprite, []);
21
21
 
22
+ const own = fileIconOverrideFor(path);
23
+
24
+ if (own !== null) {
25
+ return <img src={own} alt="" width={size} height={size} className={clsx('file-icon', className)} />;
26
+ }
27
+
22
28
  return (
23
29
  <svg ref={ref} className={clsx('file-icon', className)} width={size} height={size} viewBox="0 0 16 16" aria-hidden>
24
30
  <use href={`#${fileIconFor(path)}`} />
package/src/file-icon.ts CHANGED
@@ -29,6 +29,17 @@ const resolveIcon: ReturnType<typeof createFileTreeIconResolver>['resolveIcon']
29
29
  */
30
30
  export const fileIconFor = (path: string): string => resolveIcon('file-tree-icon-file', path).name;
31
31
 
32
+ let override: ((path: string) => string | null) | null = null;
33
+
34
+ /* What an app knows better about a file's icon: the address of an svg, or null for the icon this set has. */
35
+ export function setFileIconOverride(next: ((path: string) => string | null) | null): void {
36
+ override = next;
37
+ }
38
+
39
+ export function fileIconOverrideFor(path: string): string | null {
40
+ return override?.(path) ?? null;
41
+ }
42
+
32
43
  /* The tree carries the sprite into its own shadow root, out of reach of anything that draws an
33
44
  icon next to it, so the document gets a copy of the same sheet to point `<use>` at. */
34
45
  export const mountFileIconSprite = (): void => {
package/src/index.ts CHANGED
@@ -92,7 +92,7 @@ export { ZoomControls, type ZoomControlsProps, type ZoomLabels, type ZoomSelecti
92
92
  export { copyText, readClipboardText } from './clipboard.ts';
93
93
  export { messageOf } from './error-message.ts';
94
94
  export type { ResetKeys } from './error-boundary.ts';
95
- export { FILE_TREE_ICONS } from './file-icon.ts';
95
+ export { FILE_TREE_ICONS, setFileIconOverride } from './file-icon.ts';
96
96
  export { cameThroughPortal, isInFloatingLayer } from './floating.ts';
97
97
  export { LoadedComponent, lazyDialog, lazyNamed, onLazyOpenError } from './lazy.tsx';
98
98
  export type { LazyComponent } from './lazy.tsx';