runeforge 0.0.8 → 0.0.9

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/README.md CHANGED
@@ -23,6 +23,7 @@ A SvelteKit toolkit that forges forms, tables, actions, and CRUD workflows from
23
23
  - [Theming](#theming)
24
24
  - [Tailwind source scanning](#tailwind-source-scanning)
25
25
  - [CSS variables](#css-variables)
26
+ - [Configuration](#configuration)
26
27
  - [Basic Usage](#basic-usage)
27
28
  - [1. Define your interface and metadata](#1-define-your-interface-and-metadata)
28
29
  - [2. Create the model](#2-create-the-model)
@@ -136,6 +137,25 @@ Responsive overrides work too:
136
137
 
137
138
  ---
138
139
 
140
+ ## Configuration
141
+
142
+ Global settings are applied once in your root layout via `setConfig`. This avoids passing the same prop to every CRUD component.
143
+
144
+ ```svelte
145
+ <!-- +layout.svelte -->
146
+ <script>
147
+ import { setConfig } from 'runeforge';
148
+
149
+ setConfig({ homeHref: '/admin' });
150
+ </script>
151
+ ```
152
+
153
+ | Option | Default | Description |
154
+ | --- | --- | --- |
155
+ | `homeHref` | `'/'` | URL for the home crumb in every breadcrumb trail |
156
+
157
+ ---
158
+
139
159
  ## Basic Usage
140
160
 
141
161
  ### 1. Define your interface and metadata
@@ -7,19 +7,17 @@
7
7
  title,
8
8
  breadcrumbs = [],
9
9
  buttons,
10
- admin = false,
11
10
  }: {
12
11
  title: string;
13
12
  breadcrumbs?: BreadcrumbItem[];
14
13
  buttons?: Snippet;
15
- admin?: boolean;
16
14
  } = $props();
17
15
  </script>
18
16
 
19
17
  <div class="header-root flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between">
20
18
  <div class="flex flex-col gap-1 flex-1">
21
19
  <h1>{title}</h1>
22
- <Breadcrumbs items={breadcrumbs} {admin} />
20
+ <Breadcrumbs items={breadcrumbs} />
23
21
  </div>
24
22
 
25
23
  {#if buttons}
@@ -4,7 +4,6 @@ type $$ComponentProps = {
4
4
  title: string;
5
5
  breadcrumbs?: BreadcrumbItem[];
6
6
  buttons?: Snippet;
7
- admin?: boolean;
8
7
  };
9
8
  declare const Header: import("svelte").Component<$$ComponentProps, {}, "">;
10
9
  type Header = ReturnType<typeof Header>;
@@ -75,7 +75,6 @@
75
75
  <div class="flex flex-col gap-6">
76
76
 
77
77
  <Header
78
- admin
79
78
  title={labelMany}
80
79
  breadcrumbs={[
81
80
  { label: labelMany, icon: entityIcon, link: { href: '#', onclick: (e) => { e.preventDefault(); onCancel?.(); } }, prominent: true },
@@ -126,7 +126,6 @@
126
126
  <div class="flex flex-col gap-6">
127
127
 
128
128
  <Header
129
- admin
130
129
  title={labelMany}
131
130
  breadcrumbs={[
132
131
  { label: labelMany, icon: entityIcon, link: { href: '#' }, prominent: true },
@@ -65,7 +65,6 @@
65
65
  <div class="flex flex-col gap-6">
66
66
 
67
67
  <Header
68
- admin
69
68
  title={labelMany}
70
69
  breadcrumbs={[
71
70
  { label: labelMany, icon: entityIcon, link: { href: '#', onclick: (e) => { e.preventDefault(); onCancel?.(); } }, prominent: true },
@@ -85,7 +85,6 @@
85
85
  <div class="flex flex-col gap-6">
86
86
 
87
87
  <Header
88
- admin
89
88
  title={labelMany}
90
89
  breadcrumbs={[
91
90
  { label: labelMany, icon: entityIcon, link: { href: '#', onclick: (e) => { e.preventDefault(); onCancel?.(); } }, prominent: true },
@@ -1,15 +1,14 @@
1
1
  <script lang="ts">
2
2
  import { getIconSet } from '../../icons/context.js';
3
3
  import { defaultIconSet } from '../../icons/sets/default.js';
4
+ import { getConfig } from '../../config/context.js';
4
5
  import type { BreadcrumbItem } from '../../types/breadcrumb.js';
5
6
 
6
7
  let {
7
8
  items = [],
8
- admin = false,
9
9
  homeHref,
10
10
  }: {
11
11
  items?: BreadcrumbItem[];
12
- admin?: boolean;
13
12
  homeHref?: string;
14
13
  } = $props();
15
14
 
@@ -18,7 +17,7 @@
18
17
  const home: BreadcrumbItem = $derived({
19
18
  label: 'Inicio',
20
19
  icon: icons.home,
21
- link: { href: homeHref ?? (admin ? '/admin' : '/') },
20
+ link: { href: homeHref ?? getConfig().homeHref ?? '/' },
22
21
  });
23
22
 
24
23
  const allItems = $derived([home, ...items]);
@@ -1,7 +1,6 @@
1
1
  import type { BreadcrumbItem } from '../../types/breadcrumb.js';
2
2
  type $$ComponentProps = {
3
3
  items?: BreadcrumbItem[];
4
- admin?: boolean;
5
4
  homeHref?: string;
6
5
  };
7
6
  declare const Breadcrumbs: import("svelte").Component<$$ComponentProps, {}, "">;
@@ -0,0 +1,5 @@
1
+ export interface RuneforgeConfig {
2
+ homeHref?: string;
3
+ }
4
+ export declare function setConfig(config: RuneforgeConfig): void;
5
+ export declare function getConfig(): RuneforgeConfig;
@@ -0,0 +1,9 @@
1
+ import { getContext, setContext } from 'svelte';
2
+ const KEY = Symbol('runeforge-config');
3
+ export function setConfig(config) {
4
+ const existing = getContext(KEY) ?? {};
5
+ setContext(KEY, { ...existing, ...config });
6
+ }
7
+ export function getConfig() {
8
+ return getContext(KEY) ?? {};
9
+ }
package/dist/index.d.ts CHANGED
@@ -3,6 +3,8 @@ export { AttributeType } from './types/attribute.js';
3
3
  export type { AttributeMetadata, InterfaceMetadata, SelectOption, OptionsResolver, FormatterResolver } from './types/attribute.js';
4
4
  export type { CellProps, CellComponent, CellFormatter, SortDirection, IndexedRow, DistinctEntry } from './types/table.js';
5
5
  export type { ColumnDefinition, FieldDefinition, ActionConfiguration, CustomAction, RowAction } from './types/crud.js';
6
+ export type { RuneforgeConfig } from './config/context.js';
7
+ export { setConfig, getConfig } from './config/context.js';
6
8
  export type { CRUDIconSet, IconComponent } from './icons/types.js';
7
9
  export { setIconSet, getIconSet } from './icons/context.js';
8
10
  export { defaultIconSet } from './icons/sets/default.js';
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export { AttributeType } from './types/attribute.js';
2
+ export { setConfig, getConfig } from './config/context.js';
2
3
  export { setIconSet, getIconSet } from './icons/context.js';
3
4
  export { defaultIconSet } from './icons/sets/default.js';
4
5
  export { bootstrapIconSet } from './icons/sets/bootstrap.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "runeforge",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "description": "SvelteKit toolkit for building metadata-driven CRUD interfaces with tables, forms, and actions",
5
5
  "license": "MIT",
6
6
  "author": "Ezequiel Puerta",