@immich/ui 0.6.0 → 0.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.
Files changed (64) hide show
  1. package/README.md +39 -45
  2. package/dist/assets/appstore-badge.svg +46 -0
  3. package/dist/assets/fdroid-badge.svg +124 -0
  4. package/dist/assets/playstore-badge.png +0 -0
  5. package/dist/components/Alert/Alert.svelte +13 -7
  6. package/dist/components/Alert/Alert.svelte.d.ts +3 -2
  7. package/dist/components/AppShell/AppShell.svelte +34 -0
  8. package/dist/components/AppShell/AppShell.svelte.d.ts +6 -0
  9. package/dist/components/AppShell/AppShellHeader.svelte +15 -0
  10. package/dist/components/AppShell/AppShellHeader.svelte.d.ts +5 -0
  11. package/dist/components/AppShell/AppShellSidebar.svelte +23 -0
  12. package/dist/components/AppShell/AppShellSidebar.svelte.d.ts +7 -0
  13. package/dist/components/AppShell/PageLayout.svelte +44 -0
  14. package/dist/components/AppShell/PageLayout.svelte.d.ts +9 -0
  15. package/dist/components/Avatar/Avatar.svelte +66 -0
  16. package/dist/components/Avatar/Avatar.svelte.d.ts +7 -0
  17. package/dist/components/Card/Card.svelte +7 -9
  18. package/dist/components/Card/CardBody.svelte +1 -1
  19. package/dist/components/Card/CardFooter.svelte +6 -2
  20. package/dist/components/Card/CardFooter.svelte.d.ts +1 -0
  21. package/dist/components/Code/Code.svelte +62 -0
  22. package/dist/components/Code/Code.svelte.d.ts +9 -0
  23. package/dist/components/Form/Checkbox.svelte +67 -27
  24. package/dist/components/Form/Checkbox.svelte.d.ts +2 -2
  25. package/dist/components/Form/Input.svelte +43 -35
  26. package/dist/components/Form/Input.svelte.d.ts +2 -9
  27. package/dist/components/Form/PasswordInput.svelte +31 -0
  28. package/dist/components/Form/PasswordInput.svelte.d.ts +3 -0
  29. package/dist/components/FormatBytes/FormatBytes.svelte +16 -0
  30. package/dist/components/FormatBytes/FormatBytes.svelte.d.ts +6 -0
  31. package/dist/components/Heading/Heading.svelte +2 -1
  32. package/dist/components/Heading/Heading.svelte.d.ts +1 -1
  33. package/dist/components/LoadingSpinner/LoadingSpinner.svelte +54 -0
  34. package/dist/components/LoadingSpinner/LoadingSpinner.svelte.d.ts +7 -0
  35. package/dist/components/Logo/Logo.svelte +8 -8
  36. package/dist/components/Logo/Logo.svelte.d.ts +1 -2
  37. package/dist/components/MultiSelect/MultiSelect.svelte +15 -0
  38. package/dist/components/MultiSelect/MultiSelect.svelte.d.ts +3 -0
  39. package/dist/components/Navbar/NavbarGroup.svelte +12 -0
  40. package/dist/components/Navbar/NavbarGroup.svelte.d.ts +4 -0
  41. package/dist/components/Navbar/NavbarItem.svelte +30 -0
  42. package/dist/components/Navbar/NavbarItem.svelte.d.ts +7 -0
  43. package/dist/components/Scrollable/Scrollable.svelte +41 -0
  44. package/dist/components/Scrollable/Scrollable.svelte.d.ts +6 -0
  45. package/dist/components/Select/Select.svelte +15 -0
  46. package/dist/components/Select/Select.svelte.d.ts +3 -0
  47. package/dist/components/Switch/Switch.svelte +99 -0
  48. package/dist/components/Switch/Switch.svelte.d.ts +10 -0
  49. package/dist/components/Text/Text.svelte +15 -3
  50. package/dist/components/Text/Text.svelte.d.ts +1 -1
  51. package/dist/constants.d.ts +3 -0
  52. package/dist/constants.js +3 -0
  53. package/dist/index.d.ts +25 -0
  54. package/dist/index.js +28 -0
  55. package/dist/internal/Button.svelte +28 -16
  56. package/dist/internal/Select.svelte +174 -0
  57. package/dist/internal/Select.svelte.d.ts +9 -0
  58. package/dist/services/theme.svelte.d.ts +5 -0
  59. package/dist/services/theme.svelte.js +13 -0
  60. package/dist/types.d.ts +45 -2
  61. package/dist/types.js +5 -1
  62. package/dist/utilities/byte-units.d.ts +52 -0
  63. package/dist/utilities/byte-units.js +75 -0
  64. package/package.json +7 -5
package/dist/types.d.ts CHANGED
@@ -1,11 +1,15 @@
1
1
  import type { Snippet } from 'svelte';
2
- import type { HTMLAnchorAttributes, HTMLButtonAttributes } from 'svelte/elements';
2
+ import type { HTMLAnchorAttributes, HTMLButtonAttributes, HTMLInputAttributes } from 'svelte/elements';
3
3
  export type Color = 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info';
4
4
  export type Size = 'tiny' | 'small' | 'medium' | 'large' | 'giant';
5
5
  export type HeadingSize = Size | 'title';
6
6
  export type Shape = 'rectangle' | 'semi-round' | 'round';
7
- export type Variants = 'filled' | 'outline' | 'ghost' | 'hero';
7
+ export type Variants = 'filled' | 'outline' | 'ghost';
8
8
  export type Gap = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;
9
+ export declare enum Theme {
10
+ Light = "light",
11
+ Dark = "dark"
12
+ }
9
13
  type ButtonOrAnchor = ({
10
14
  href?: never;
11
15
  } & HTMLButtonAttributes) | ({
@@ -37,6 +41,7 @@ export type IconProps = {
37
41
  export type IconButtonProps = ButtonBaseProps & IconProps;
38
42
  export type ButtonProps = ButtonBaseProps & {
39
43
  fullWidth?: boolean;
44
+ loading?: boolean;
40
45
  };
41
46
  type StackBaseProps = {
42
47
  class?: string;
@@ -59,4 +64,42 @@ export type FieldContext = {
59
64
  required?: boolean;
60
65
  readOnly?: boolean;
61
66
  };
67
+ type BaseInputProps = {
68
+ class?: string;
69
+ value?: string;
70
+ size?: Size;
71
+ shape?: Shape;
72
+ inputSize?: HTMLInputAttributes['size'];
73
+ } & Omit<HTMLInputAttributes, 'size' | 'type'>;
74
+ export type InputProps = BaseInputProps & {
75
+ containerRef?: HTMLElement | null;
76
+ type?: HTMLInputAttributes['type'];
77
+ trailingIcon?: Snippet;
78
+ };
79
+ export type PasswordInputProps = BaseInputProps & {
80
+ showLabel?: string;
81
+ hideLabel?: string;
82
+ isVisible?: boolean;
83
+ };
84
+ export type SelectItem = {
85
+ label?: string;
86
+ value: string;
87
+ disabled?: boolean;
88
+ };
89
+ export type SelectCommonProps<T extends SelectItem> = {
90
+ data: string[] | T[];
91
+ size?: Size;
92
+ color?: Color;
93
+ shape?: Shape;
94
+ placeholder?: string;
95
+ class?: string;
96
+ };
97
+ export type SelectProps<T extends SelectItem> = SelectCommonProps<T> & {
98
+ value?: T;
99
+ onChange?: (value: T) => void;
100
+ };
101
+ export type MultiSelectProps<T extends SelectItem> = SelectCommonProps<T> & {
102
+ value?: T[];
103
+ onChange?: (values: T[]) => void;
104
+ };
62
105
  export {};
package/dist/types.js CHANGED
@@ -1 +1,5 @@
1
- export {};
1
+ export var Theme;
2
+ (function (Theme) {
3
+ Theme["Light"] = "light";
4
+ Theme["Dark"] = "dark";
5
+ })(Theme || (Theme = {}));
@@ -0,0 +1,52 @@
1
+ export declare const enum ByteUnit {
2
+ 'B' = "B",
3
+ 'KiB' = "KiB",
4
+ 'MiB' = "MiB",
5
+ 'GiB' = "GiB",
6
+ 'TiB' = "TiB",
7
+ 'PiB' = "PiB",
8
+ 'EiB' = "EiB"
9
+ }
10
+ /**
11
+ * Convert bytes to best human readable unit and number of that unit.
12
+ *
13
+ * * For `1024` bytes, returns `1` and `KiB`.
14
+ * * For `1536` bytes, returns `1.5` and `KiB`.
15
+ *
16
+ * @param bytes number of bytes
17
+ * @param maxPrecision maximum number of decimal places, default is `1`
18
+ * @returns size (number) and unit (string)
19
+ */
20
+ export declare function getBytesWithUnit(bytes: number, maxPrecision?: number): [number, ByteUnit];
21
+ /**
22
+ * Localized number of bytes with a unit.
23
+ *
24
+ * For `1536` bytes:
25
+ * * en: `1.5 KiB`
26
+ * * de: `1,5 KiB`
27
+ *
28
+ * @param bytes number of bytes
29
+ * @param maxPrecision maximum number of decimal places, default is `1`
30
+ * @returns localized bytes with unit as string
31
+ */
32
+ export declare function getByteUnitString(bytes: number, locale?: string, maxPrecision?: number): string;
33
+ /**
34
+ * Convert to bytes from on a specified unit.
35
+ *
36
+ * * `1, 'GiB'`, returns `1073741824` bytes
37
+ *
38
+ * @param size value to be converted
39
+ * @param unit unit to convert from
40
+ * @returns bytes (number)
41
+ */
42
+ export declare function convertToBytes(size: number, unit: ByteUnit): number;
43
+ /**
44
+ * Convert from bytes to a specified unit.
45
+ *
46
+ * * `11073741824, 'GiB'`, returns `1` GiB
47
+ *
48
+ * @param bytes value to be converted
49
+ * @param unit unit to convert to
50
+ * @returns bytes (number)
51
+ */
52
+ export declare function convertFromBytes(bytes: number, unit: ByteUnit): number;
@@ -0,0 +1,75 @@
1
+ export var ByteUnit;
2
+ (function (ByteUnit) {
3
+ ByteUnit["B"] = "B";
4
+ ByteUnit["KiB"] = "KiB";
5
+ ByteUnit["MiB"] = "MiB";
6
+ ByteUnit["GiB"] = "GiB";
7
+ ByteUnit["TiB"] = "TiB";
8
+ ByteUnit["PiB"] = "PiB";
9
+ ByteUnit["EiB"] = "EiB";
10
+ })(ByteUnit || (ByteUnit = {}));
11
+ const byteUnits = [
12
+ ByteUnit.B,
13
+ ByteUnit.KiB,
14
+ ByteUnit.MiB,
15
+ ByteUnit.GiB,
16
+ ByteUnit.TiB,
17
+ ByteUnit.PiB,
18
+ ByteUnit.EiB,
19
+ ];
20
+ /**
21
+ * Convert bytes to best human readable unit and number of that unit.
22
+ *
23
+ * * For `1024` bytes, returns `1` and `KiB`.
24
+ * * For `1536` bytes, returns `1.5` and `KiB`.
25
+ *
26
+ * @param bytes number of bytes
27
+ * @param maxPrecision maximum number of decimal places, default is `1`
28
+ * @returns size (number) and unit (string)
29
+ */
30
+ export function getBytesWithUnit(bytes, maxPrecision = 1) {
31
+ const magnitude = Math.floor(Math.log(bytes === 0 ? 1 : bytes) / Math.log(1024));
32
+ return [
33
+ Number.parseFloat((bytes / 1024 ** magnitude).toFixed(maxPrecision)),
34
+ byteUnits[magnitude],
35
+ ];
36
+ }
37
+ /**
38
+ * Localized number of bytes with a unit.
39
+ *
40
+ * For `1536` bytes:
41
+ * * en: `1.5 KiB`
42
+ * * de: `1,5 KiB`
43
+ *
44
+ * @param bytes number of bytes
45
+ * @param maxPrecision maximum number of decimal places, default is `1`
46
+ * @returns localized bytes with unit as string
47
+ */
48
+ export function getByteUnitString(bytes, locale, maxPrecision = 1) {
49
+ const [size, unit] = getBytesWithUnit(bytes, maxPrecision);
50
+ return `${size.toLocaleString(locale)} ${unit}`;
51
+ }
52
+ /**
53
+ * Convert to bytes from on a specified unit.
54
+ *
55
+ * * `1, 'GiB'`, returns `1073741824` bytes
56
+ *
57
+ * @param size value to be converted
58
+ * @param unit unit to convert from
59
+ * @returns bytes (number)
60
+ */
61
+ export function convertToBytes(size, unit) {
62
+ return size * 1024 ** byteUnits.indexOf(unit);
63
+ }
64
+ /**
65
+ * Convert from bytes to a specified unit.
66
+ *
67
+ * * `11073741824, 'GiB'`, returns `1` GiB
68
+ *
69
+ * @param bytes value to be converted
70
+ * @param unit unit to convert to
71
+ * @returns bytes (number)
72
+ */
73
+ export function convertFromBytes(bytes, unit) {
74
+ return bytes / 1024 ** byteUnits.indexOf(unit);
75
+ }
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@immich/ui",
3
- "version": "0.6.0",
3
+ "version": "0.8.0",
4
4
  "license": "GNU Affero General Public License version 3",
5
5
  "scripts": {
6
+ "create": "node scripts/create.js",
6
7
  "start": "npm run start:dev",
7
8
  "start:dev": "vite dev",
8
9
  "watch": "vite build --watch",
@@ -40,9 +41,9 @@
40
41
  },
41
42
  "devDependencies": {
42
43
  "@sveltejs/adapter-static": "^3.0.6",
43
- "@sveltejs/kit": "^2.0.0",
44
+ "@sveltejs/kit": "^2.13.0",
44
45
  "@sveltejs/package": "^2.0.0",
45
- "@sveltejs/vite-plugin-svelte": "^4.0.0",
46
+ "@sveltejs/vite-plugin-svelte": "^5.0.2",
46
47
  "@types/eslint": "^9.6.0",
47
48
  "autoprefixer": "^10.4.20",
48
49
  "eslint": "^9.7.0",
@@ -55,10 +56,11 @@
55
56
  "publint": "^0.2.0",
56
57
  "svelte": "^5.0.0",
57
58
  "svelte-check": "^4.0.0",
59
+ "svelte-highlight": "^7.8.0",
58
60
  "tailwindcss": "^3.4.9",
59
61
  "typescript": "^5.0.0",
60
- "typescript-eslint": "^8.0.0",
61
- "vite": "^5.0.11",
62
+ "typescript-eslint": "^8.15.0",
63
+ "vite": "^6.0.3",
62
64
  "vitest": "^2.0.4"
63
65
  },
64
66
  "dependencies": {