@freegridjs/svelte 0.0.0-stage → 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.
package/LICENSE ADDED
@@ -0,0 +1,72 @@
1
+ FreeGrid License
2
+ Version 1.0, 2026-10-15
3
+
4
+ Copyright (c) 2026 2nd Korea (세컨드코리아). All rights reserved.
5
+ Contact: help@2nd-korea.com · https://freegrid.app/pricing/
6
+
7
+ This license covers the FreeGrid software, including the packages @freegridjs/core,
8
+ @freegridjs/react and @freegridjs/vue, their source code and the files built from them
9
+ (the "Software").
10
+
11
+ 1. Personal use is free
12
+
13
+ An individual may use, copy and modify the Software free of charge for personal,
14
+ educational, research or other non-commercial purposes, including personal websites,
15
+ open-source projects that are not run by a company, and learning or evaluation.
16
+
17
+ 2. Company use needs a domain license
18
+
19
+ Any use by or for a company, organization, public body or other business ("Company"),
20
+ whether the product is sold, used internally or offered to customers, requires a paid
21
+ Company License. A Company may evaluate the Software for up to 30 days without a license.
22
+
23
+ - A Company License is issued for one domain (for example example.com) and covers that
24
+ domain and its subdomains. Applications without a domain (desktop apps, intranets
25
+ reached by address) count as one domain per installation site.
26
+ - The fee is KRW 200,000 per domain per year. The license is valid for one year from the
27
+ date it is issued and may be renewed.
28
+ - A license key is provided with each Company License. Setting the key removes the
29
+ console notice described in section 5.
30
+
31
+ 3. Conditions for all users
32
+
33
+ - Keep this license and the copyright notice in copies of the Software.
34
+ - Do not sell, rent or sublicense the Software itself, or offer it as a standalone grid
35
+ component or library, with or without changes.
36
+ - Do not remove or work around the license check, or share license keys outside the
37
+ licensed domain.
38
+
39
+ 4. No warranty
40
+
41
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
42
+ INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
43
+ PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
44
+ FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY ARISING FROM THE SOFTWARE OR ITS USE.
45
+
46
+ 5. Usage report
47
+
48
+ When the Software runs on a public domain (not localhost or a private network address),
49
+ it sends the domain name, the page address without query string, the Software version
50
+ and whether a license key is set to freegrid.app once a day. No data shown in the grid
51
+ and no information about end users is sent. Without a license key on such a domain it
52
+ also prints a notice in the browser developer console.
53
+
54
+ ---------------------------------------------------------------------------------------
55
+
56
+ FreeGrid 라이선스 (요약, 한국어)
57
+
58
+ - 개인: 개인적·교육·연구 등 비상업적 용도로 무료로 사용, 복제, 수정할 수 있습니다.
59
+ - 회사: 회사, 단체, 공공기관 등 업무용으로 쓰려면 판매용·내부용·고객 제공용 모두 유료
60
+ 회사 라이선스가 필요합니다. 30일 동안은 평가 목적으로 라이선스 없이 써 볼 수 있습니다.
61
+ - 도메인 1개(하위 도메인 포함) 기준 연 200,000원이며, 발급일로부터 1년간 유효하고
62
+ 갱신할 수 있습니다.
63
+ - 라이선스마다 키를 발급하며, 키를 설정하면 콘솔 안내가 사라집니다.
64
+ - 모든 사용자: 저작권과 이 라이선스 문구를 유지해야 하며, 소프트웨어 자체를 판매하거나
65
+ 별도 그리드 라이브러리로 재배포할 수 없고, 라이선스 확인을 제거하거나 키를 다른
66
+ 도메인에 공유할 수 없습니다.
67
+ - 보증 없음: 소프트웨어는 있는 그대로 제공됩니다.
68
+ - 사용 보고: 공개 도메인에서 실행되면 하루 한 번 도메인 이름, 쿼리 문자열을 뺀 페이지
69
+ 주소, 버전, 라이선스 키 설정 여부를 freegrid.app으로 보냅니다. 그리드의 데이터나 최종
70
+ 사용자 정보는 보내지 않습니다.
71
+
72
+ 문의: help@2nd-korea.com · 대표번호 070-7768-1326
package/README.md CHANGED
@@ -1,3 +1,42 @@
1
- # Temporary Holding Version
1
+ # @freegridjs/svelte
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Svelte 5 component and action for [FreeGrid](https://freegrid.app).
4
+
5
+ ```bash
6
+ npm i @freegridjs/core @freegridjs/svelte
7
+ ```
8
+
9
+ ```svelte
10
+ <script>
11
+ import { FreeGrid } from '@freegridjs/svelte';
12
+ import '@freegridjs/core/styles.css';
13
+
14
+ let api;
15
+ const columns = [{ field: 'name' }, { field: 'qty', type: 'number' }];
16
+ let rows = $state([{ name: 'Pen', qty: 3 }]);
17
+ </script>
18
+
19
+ <FreeGrid {columns} data={rows} rowSelection="multiple" height={480}
20
+ onReady={a => (api = a)} onCellClick={e => console.log(e.row)} />
21
+ ```
22
+
23
+ Every grid option is a prop; events are `on` + the event name (`onSortChange`, `onCellValueChanged`, …).
24
+ `columns`, `data`, `theme`, `locale`, `summary`, `groupBy`, `pivot`, `fontSize` and `fontFamily` update the grid
25
+ when they change. Without a component, use the action:
26
+
27
+ ```svelte
28
+ <script>
29
+ import { freegrid } from '@freegridjs/svelte';
30
+ </script>
31
+
32
+ <div use:freegrid={{ columns, data: rows }} style="height: 400px"></div>
33
+ ```
34
+
35
+ Docs: https://freegrid.app/docs/#svelte
36
+
37
+ ## License
38
+
39
+ Free for personal use. Company use needs a domain license: KRW 200,000 per domain per year
40
+ (subdomains included). See https://freegrid.app/pricing/ and the LICENSE file.
41
+
42
+ 개인은 무료, 회사는 도메인당 연 20만 원입니다. 자세한 내용은 https://freegrid.app/pricing/
@@ -0,0 +1,57 @@
1
+ <script lang="ts">
2
+ import { createGrid, type GridApi } from '@freegridjs/core';
3
+ import { onMount } from 'svelte';
4
+ import { EVENT_TYPES, handlerName, splitProps, type FreeGridProps } from './events.js';
5
+
6
+ interface Props extends FreeGridProps {
7
+ /** Host height; number = px. */
8
+ height?: number | string;
9
+ class?: string;
10
+ }
11
+
12
+ let { height = 400, class: className = '', ...props }: Props = $props();
13
+ let host: HTMLDivElement;
14
+ let api = $state<GridApi | null>(null);
15
+
16
+ onMount(() => {
17
+ const grid = createGrid(host, splitProps(props as Record<string, unknown>).options);
18
+ for (const type of EVENT_TYPES) {
19
+ // read the prop at call time so a replaced callback is used
20
+ grid.on(type, payload => {
21
+ const fn = (props as Record<string, unknown>)[handlerName(type)];
22
+ if (typeof fn === 'function') fn(payload);
23
+ });
24
+ }
25
+ api = grid;
26
+ props.onReady?.(grid);
27
+ return () => {
28
+ grid.destroy();
29
+ api = null;
30
+ };
31
+ });
32
+
33
+ // props that can change after creation; the first run only records the starting value
34
+ const watch = <T,>(read: () => T, apply: (grid: GridApi, value: T) => void) => {
35
+ let first = true;
36
+ $effect(() => {
37
+ const value = read();
38
+ const grid = api;
39
+ if (!grid) return;
40
+ if (first) {
41
+ first = false;
42
+ return;
43
+ }
44
+ apply(grid, value);
45
+ });
46
+ };
47
+ watch(() => props.columns, (g, c) => g.setColumns(c));
48
+ watch(() => props.data, (g, d) => { if (d) g.setData(d); });
49
+ watch(() => props.theme, (g, t) => { if (t) g.setTheme(t); });
50
+ watch(() => props.locale, (g, l) => { if (l !== undefined) g.setLocale(l); });
51
+ watch(() => props.summary, (g, s) => g.setSummary(s ?? null));
52
+ watch(() => props.groupBy, (g, v) => g.setGroupBy(v ?? []));
53
+ watch(() => props.pivot, (g, p) => g.setPivot(p ?? null));
54
+ watch(() => [props.fontSize, props.fontFamily] as const, (g, [size, family]) => g.setFont({ size, family: family ?? null }));
55
+ </script>
56
+
57
+ <div bind:this={host} class={className} style:height={typeof height === 'number' ? `${height}px` : height}></div>
@@ -0,0 +1,9 @@
1
+ import { type FreeGridProps } from './events.js';
2
+ interface Props extends FreeGridProps {
3
+ /** Host height; number = px. */
4
+ height?: number | string;
5
+ class?: string;
6
+ }
7
+ declare const FreeGrid: import("svelte").Component<Props, {}, "">;
8
+ type FreeGrid = ReturnType<typeof FreeGrid>;
9
+ export default FreeGrid;
@@ -0,0 +1,9 @@
1
+ import { type FreeGridProps } from './events.js';
2
+ /**
3
+ * `<div use:freegrid={{ columns, data }} style="height: 400px"></div>`: a grid on any element.
4
+ * Changes to `columns`, `data`, `theme` and `locale` are applied; other options apply at creation.
5
+ */
6
+ export declare function freegrid(node: HTMLElement, props: FreeGridProps): {
7
+ update(next: FreeGridProps): void;
8
+ destroy(): void;
9
+ };
package/dist/action.js ADDED
@@ -0,0 +1,35 @@
1
+ import { createGrid } from '@freegridjs/core';
2
+ import { EVENT_TYPES, handlerName, splitProps } from './events.js';
3
+ /**
4
+ * `<div use:freegrid={{ columns, data }} style="height: 400px"></div>`: a grid on any element.
5
+ * Changes to `columns`, `data`, `theme` and `locale` are applied; other options apply at creation.
6
+ */
7
+ export function freegrid(node, props) {
8
+ let current = props;
9
+ const { options } = splitProps(props);
10
+ const api = createGrid(node, options);
11
+ for (const type of EVENT_TYPES) {
12
+ api.on(type, payload => {
13
+ const fn = current[handlerName(type)];
14
+ if (typeof fn === 'function')
15
+ fn(payload);
16
+ });
17
+ }
18
+ props.onReady?.(api);
19
+ return {
20
+ update(next) {
21
+ if (next.columns !== current.columns)
22
+ api.setColumns(next.columns);
23
+ if (next.data !== current.data && next.data)
24
+ api.setData(next.data);
25
+ if (next.theme && next.theme !== current.theme)
26
+ api.setTheme(next.theme);
27
+ if (next.locale !== undefined && next.locale !== current.locale)
28
+ api.setLocale(next.locale);
29
+ current = next;
30
+ },
31
+ destroy() {
32
+ api.destroy();
33
+ },
34
+ };
35
+ }
@@ -0,0 +1,17 @@
1
+ import type { GridApi, GridEvents, GridOptions } from '@freegridjs/core';
2
+ export declare const EVENT_TYPES: (keyof GridEvents)[];
3
+ /** 'sortChange' → 'onSortChange' */
4
+ export declare const handlerName: (type: string) => string;
5
+ /** `onSortChange`, `onCellClick`, … one optional callback per grid event. */
6
+ export type GridHandlers = {
7
+ [K in keyof GridEvents as `on${Capitalize<K & string>}`]?: (payload: GridEvents[K]) => void;
8
+ };
9
+ export interface FreeGridProps extends GridOptions, GridHandlers {
10
+ /** Called once with the grid API after the grid is created. */
11
+ onReady?: (api: GridApi) => void;
12
+ }
13
+ /** Split props into grid options and event callbacks. */
14
+ export declare function splitProps(props: Record<string, unknown>): {
15
+ options: GridOptions;
16
+ handlers: Record<string, unknown>;
17
+ };
package/dist/events.js ADDED
@@ -0,0 +1,22 @@
1
+ /** Every grid event; the record type makes the compiler flag a missing one. */
2
+ const ALL = {
3
+ cellClick: true, cellDoubleClick: true, selectionChange: true, sortChange: true, filterChange: true,
4
+ columnResize: true, columnMove: true, focusChange: true, columnVisible: true, rangeChange: true,
5
+ cellValueChanged: true, paste: true, editStart: true, editStop: true, validationFailed: true,
6
+ rowsAdded: true, rowsRemoved: true, groupChange: true, groupToggle: true, detailToggle: true,
7
+ rowDragEnd: true, pageChange: true, rowsLoaded: true, rowsLoadFailed: true, pivotChange: true,
8
+ rowDrop: true, scroll: true, childrenLoaded: true, childrenLoadFailed: true, beforeSort: true, beforeFilter: true, beforePageChange: true,
9
+ beforeEdit: true, beforeCellChange: true,
10
+ };
11
+ export const EVENT_TYPES = Object.keys(ALL);
12
+ /** 'sortChange' → 'onSortChange' */
13
+ export const handlerName = (type) => `on${type[0].toUpperCase()}${type.slice(1)}`;
14
+ /** Split props into grid options and event callbacks. */
15
+ export function splitProps(props) {
16
+ const options = {};
17
+ const handlers = {};
18
+ const names = new Set(EVENT_TYPES.map(handlerName).concat('onReady'));
19
+ for (const [k, v] of Object.entries(props))
20
+ (names.has(k) ? handlers : options)[k] = v;
21
+ return { options: options, handlers };
22
+ }
@@ -0,0 +1,3 @@
1
+ export { default as FreeGrid } from './FreeGrid.svelte';
2
+ export { freegrid } from './action.js';
3
+ export type { FreeGridProps, GridHandlers } from './events.js';
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { default as FreeGrid } from './FreeGrid.svelte';
2
+ export { freegrid } from './action.js';
package/package.json CHANGED
@@ -1,6 +1,52 @@
1
1
  {
2
2
  "name": "@freegridjs/svelte",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.8.0",
4
+ "description": "Svelte component and action for FreeGrid, the fast data grid (free for personal use).",
5
+ "license": "SEE LICENSE IN LICENSE",
6
+ "type": "module",
7
+ "svelte": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "svelte": "./dist/index.js",
13
+ "default": "./dist/index.js"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist",
18
+ "README.md",
19
+ "LICENSE"
20
+ ],
21
+ "peerDependencies": {
22
+ "@freegridjs/core": "^0.8.0",
23
+ "svelte": "^5.0.0"
24
+ },
25
+ "keywords": [
26
+ "data-grid",
27
+ "svelte",
28
+ "grid",
29
+ "table",
30
+ "@freegridjs/core"
31
+ ],
32
+ "homepage": "https://freegrid.app",
33
+ "author": "secondkorea",
34
+ "publishConfig": {
35
+ "access": "public"
36
+ },
37
+ "devDependencies": {
38
+ "@freegridjs/core": "^0.8.0",
39
+ "@sveltejs/package": "^3.0.0",
40
+ "@sveltejs/vite-plugin-svelte": "^7.3.1",
41
+ "jsdom": "^30.1.2",
42
+ "svelte": "^5.0.0",
43
+ "svelte-check": "^4.7.6",
44
+ "typescript": "~5.9.3",
45
+ "vitest": "^5.0.4"
46
+ },
47
+ "scripts": {
48
+ "build": "svelte-package -i src -o dist",
49
+ "test": "vitest run",
50
+ "typecheck": "svelte-check --tsconfig ./tsconfig.json --threshold error"
51
+ }
6
52
  }