cclkit4svelte 3.1.0 → 4.0.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/README.md CHANGED
@@ -10,6 +10,11 @@ CANDY CHUPS Labのサイトで使うコンポーネントのキットです。
10
10
 
11
11
  このライブラリの開発を行うにはSvelteの導入が必要です。
12
12
 
13
+ ## Svelte互換性
14
+
15
+ `cclkit4svelte` 4.x はSvelte 5専用です。Svelte 4はサポート対象外です。
16
+ 実装方針と段階的な移行ルールは[docs/SVELTE_5_MIGRATION.md](docs/SVELTE_5_MIGRATION.md)を参照してください。
17
+
13
18
  ## Figma
14
19
 
15
20
  [Figma](https://www.figma.com/file/RWLq3IaUeF0soEH666sXQC/Common-Component?type=design&node-id=0%3A1&mode=design&t=ESVNyUtQevAFIe3o-1)
@@ -1,5 +1,7 @@
1
1
  <script lang="ts">
2
2
  import Button from './Button.svelte';
3
+ import { CCLVividColor } from './const/config';
4
+ import type { ColorVar } from './const/config';
3
5
 
4
6
  /**
5
7
  * 書籍のタイトル
@@ -43,7 +45,10 @@
43
45
  * @default --strawberry-pink
44
46
  * @type string
45
47
  */
46
- export let borderColor: string = '--strawberry-pink';
48
+ export let borderColor: string = CCLVividColor.STRAWBERRY_PINK;
49
+ let buttonColor: ColorVar;
50
+ // Preserve support for consumer-defined CSS custom properties at the public boundary.
51
+ $: buttonColor = borderColor as ColorVar;
47
52
 
48
53
  function handleLinkClick() {
49
54
  if (linkUrl) {
@@ -63,7 +68,7 @@
63
68
  </div>
64
69
  {#if linkUrl}
65
70
  <div class="BookCardLinkWrapper">
66
- <Button label={linkText} bgColor={borderColor} onClick={handleLinkClick} />
71
+ <Button label={linkText} bgColor={buttonColor} onClick={handleLinkClick} />
67
72
  </div>
68
73
  {/if}
69
74
  </div>
@@ -44,12 +44,12 @@
44
44
  >
45
45
  <div class="slides">
46
46
  {#each src as item, index}
47
- <img class="slide" src={item.src} alt={item.alt} />
47
+ <img class="slide" src={item.src} alt={item.alt} aria-hidden={index !== currentIndex} />
48
48
  {/each}
49
49
  </div>
50
50
  <div class="buttons">
51
- <button on:click={prevSlide}>❮</button>
52
- <button on:click={nextSlide}>❯</button>
51
+ <button type="button" aria-label="前のスライドへ" on:click={prevSlide}>❮</button>
52
+ <button type="button" aria-label="次のスライドへ" on:click={nextSlide}>❯</button>
53
53
  </div>
54
54
  </div>
55
55
 
@@ -1,3 +1,17 @@
1
+ <script context="module" lang="ts">
2
+ /**
3
+ * 更新履歴の表示項目
4
+ */
5
+ export interface HistoryItem {
6
+ date: string;
7
+ title: string;
8
+ tag?: string;
9
+ color?: string;
10
+ version?: string;
11
+ details?: string[];
12
+ }
13
+ </script>
14
+
1
15
  <script lang="ts">
2
16
  import { CCLVividColor, CCLPastelColor } from './const/config';
3
17
 
@@ -10,15 +24,6 @@
10
24
  * @property {string} [version] - バージョン番号 (例: "v1.1.0")。省略可能
11
25
  * @property {string[]} [details] - 更新内容の詳細なリスト。省略可能
12
26
  */
13
- export interface HistoryItem {
14
- date: string;
15
- title: string;
16
- tag?: string;
17
- color?: string;
18
- version?: string;
19
- details?: string[];
20
- }
21
-
22
27
  /**
23
28
  * 表示する更新履歴の配列
24
29
  * @type {HistoryItem[]}
@@ -1,3 +1,14 @@
1
+ /**
2
+ * 更新履歴の表示項目
3
+ */
4
+ export interface HistoryItem {
5
+ date: string;
6
+ title: string;
7
+ tag?: string;
8
+ color?: string;
9
+ version?: string;
10
+ details?: string[];
11
+ }
1
12
  interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
2
13
  new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
3
14
  $$bindings?: Bindings;
@@ -1,5 +1,6 @@
1
1
  <script lang="ts">
2
2
  import { createEventDispatcher } from 'svelte';
3
+ import type { Action } from 'svelte/action';
3
4
  import { DateTime } from 'luxon';
4
5
 
5
6
  const dispatch = createEventDispatcher();
@@ -89,7 +90,11 @@
89
90
  * Svelte Action to detect clicks outside an element.
90
91
  * @param {HTMLElement} node
91
92
  */
92
- function clickOutside(node: HTMLElement) {
93
+ const clickOutside: Action<
94
+ HTMLElement,
95
+ undefined,
96
+ { 'on:click_outside': (event: CustomEvent<void>) => void }
97
+ > = (node) => {
93
98
  const handleClick = (event: MouseEvent) => {
94
99
  if (node && !node.contains(event.target as Node) && !event.defaultPrevented) {
95
100
  // 'click_outside' というカスタムイベントを発行
@@ -104,7 +109,7 @@
104
109
  document.removeEventListener('click', handleClick, true);
105
110
  }
106
111
  };
107
- }
112
+ };
108
113
 
109
114
  $: daysInMonth = getDaysInMonth(currentMonth);
110
115
  </script>
@@ -31,7 +31,7 @@ declare const Dialog: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_PropsWit
31
31
  */ closeOnOutside?: boolean;
32
32
  /**
33
33
  * アクセント色(境界線やタイトルに使用)
34
- */ borderColor?: any;
34
+ */ borderColor?: "--strawberry-pink" | "--pineapple-yellow" | "--soda-blue" | "--melon-green" | "--grape-purple" | "--wrap-grey";
35
35
  }, {
36
36
  title: {};
37
37
  default: {};
@@ -1,10 +1,12 @@
1
- <script lang="ts">
2
- import { CCLVividColor } from './const/config';
3
-
1
+ <script context="module" lang="ts">
4
2
  /**
5
3
  * オプションの型定義
6
4
  */
7
5
  export type SelectOption = { value: string; label: string };
6
+ </script>
7
+
8
+ <script lang="ts">
9
+ import { CCLVividColor } from './const/config';
8
10
 
9
11
  /**
10
12
  * ラベルのテキスト
@@ -1,3 +1,10 @@
1
+ /**
2
+ * オプションの型定義
3
+ */
4
+ export type SelectOption = {
5
+ value: string;
6
+ label: string;
7
+ };
1
8
  interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
2
9
  new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
3
10
  $$bindings?: Bindings;
@@ -20,10 +27,7 @@ declare const Select: $$__sveltets_2_IsomorphicComponent<{
20
27
  /**
21
28
  * 選択肢のリスト
22
29
  * @type SelectOption[]
23
- */ options?: {
24
- value: string;
25
- label: string;
26
- }[];
30
+ */ options?: SelectOption[];
27
31
  /**
28
32
  * 選択された値
29
33
  * @default ''
@@ -22,7 +22,8 @@
22
22
  export let disabled: boolean = false;
23
23
 
24
24
  import { TABS_CONTEXT_KEY } from './scripts/tabsContext';
25
- const { addTab, activeTabLabel } = getContext(TABS_CONTEXT_KEY);
25
+ import type { TabsContext } from './scripts/tabsContext';
26
+ const { addTab, activeTabLabel } = getContext<TabsContext>(TABS_CONTEXT_KEY);
26
27
 
27
28
  onMount(() => {
28
29
  addTab({ label, color, disabled });
package/dist/Tabs.svelte CHANGED
@@ -3,11 +3,12 @@
3
3
  import { writable } from 'svelte/store';
4
4
 
5
5
  import { TABS_CONTEXT_KEY } from './scripts/tabsContext';
6
+ import type { TabData, TabsContext } from './scripts/tabsContext';
6
7
 
7
- const tabData = writable([]);
8
+ const tabData = writable<TabData[]>([]);
8
9
  const activeTabLabel = writable('');
9
10
 
10
- setContext(TABS_CONTEXT_KEY, {
11
+ setContext<TabsContext>(TABS_CONTEXT_KEY, {
11
12
  addTab: (tab) => {
12
13
  tabData.update((currentTabs) => {
13
14
  const newTabs = [...currentTabs, tab];
@@ -1,14 +1,13 @@
1
- var _a;
2
1
  import { CCLPastelColor, CCLVividColor } from './config';
3
2
  // Pastel -> Vivid CSS variable mapping
4
- export var pastelToVividMap = (_a = {},
5
- _a[CCLPastelColor.PEACH_PINK] = CCLVividColor.STRAWBERRY_PINK,
6
- _a[CCLPastelColor.LEMON_YELLOW] = CCLVividColor.PINEAPPLE_YELLOW,
7
- _a[CCLPastelColor.SUGAR_BLUE] = CCLVividColor.SODA_BLUE,
8
- _a[CCLPastelColor.MATCHA_GREEN] = CCLVividColor.MELON_GREEN,
9
- _a[CCLPastelColor.AKEBI_PURPLE] = CCLVividColor.GRAPE_PURPLE,
10
- _a[CCLPastelColor.CLOUD_GREY] = CCLVividColor.WRAP_GREY,
11
- _a);
3
+ export const pastelToVividMap = {
4
+ [CCLPastelColor.PEACH_PINK]: CCLVividColor.STRAWBERRY_PINK,
5
+ [CCLPastelColor.LEMON_YELLOW]: CCLVividColor.PINEAPPLE_YELLOW,
6
+ [CCLPastelColor.SUGAR_BLUE]: CCLVividColor.SODA_BLUE,
7
+ [CCLPastelColor.MATCHA_GREEN]: CCLVividColor.MELON_GREEN,
8
+ [CCLPastelColor.AKEBI_PURPLE]: CCLVividColor.GRAPE_PURPLE,
9
+ [CCLPastelColor.CLOUD_GREY]: CCLVividColor.WRAP_GREY
10
+ };
12
11
  /** Returns the vivid counterpart for a given color var if it's pastel; otherwise undefined. */
13
12
  export function vividFor(colorVar) {
14
13
  if (!colorVar)
@@ -1,15 +1,4 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- var CCLVividColor = {
1
+ const CCLVividColor = {
13
2
  STRAWBERRY_PINK: '--strawberry-pink',
14
3
  PINEAPPLE_YELLOW: '--pineapple-yellow',
15
4
  SODA_BLUE: '--soda-blue',
@@ -17,7 +6,7 @@ var CCLVividColor = {
17
6
  GRAPE_PURPLE: '--grape-purple',
18
7
  WRAP_GREY: '--wrap-grey'
19
8
  };
20
- var CCLPastelColorBase = {
9
+ const CCLPastelColorBase = {
21
10
  PEACH_PINK: '--peach-pink',
22
11
  LEMON_YELLOW: '--lemon-yellow',
23
12
  SUGAR_BLUE: '--sugar-blue',
@@ -25,8 +14,10 @@ var CCLPastelColorBase = {
25
14
  AKEBI_PURPLE: '--akebi-purple',
26
15
  CLOUD_GREY: '--cloud-grey'
27
16
  };
28
- var CCLPastelColor = __assign({}, CCLPastelColorBase);
29
- var CCLPaletteColor = {
17
+ const CCLPastelColor = {
18
+ ...CCLPastelColorBase
19
+ };
20
+ const CCLPaletteColor = {
30
21
  STRAWBERRY_50: '--palette-strawberry-50',
31
22
  STRAWBERRY_100: '--palette-strawberry-100',
32
23
  STRAWBERRY_200: '--palette-strawberry-200',
@@ -148,7 +139,7 @@ var CCLPaletteColor = {
148
139
  CLOUD_800: '--palette-cloud-800',
149
140
  CLOUD_900: '--palette-cloud-900'
150
141
  };
151
- var CCLSemanticColor = {
142
+ const CCLSemanticColor = {
152
143
  SURFACE_GLASS: '--color-surface-glass',
153
144
  ACTION_PRIMARY_DEFAULT: '--color-action-primary-default',
154
145
  ACTION_PRIMARY_HOVER: '--color-action-primary-hover',
@@ -171,7 +162,7 @@ export var ProgressBarHeight;
171
162
  ProgressBarHeight["DEFAULT"] = "10px";
172
163
  ProgressBarHeight["WIDE"] = "20px";
173
164
  })(ProgressBarHeight || (ProgressBarHeight = {}));
174
- var HeaderHeight = {
165
+ const HeaderHeight = {
175
166
  WIDE: '--hd-wide',
176
167
  NORMAL: '--hd-normal',
177
168
  NALLOW: '--hd-nallow'
@@ -1 +1 @@
1
- export declare const ACCORDION_CONTEXT_KEY: any;
1
+ export declare const ACCORDION_CONTEXT_KEY: unique symbol;
@@ -1 +1 @@
1
- export var ACCORDION_CONTEXT_KEY = Symbol('accordion-context');
1
+ export const ACCORDION_CONTEXT_KEY = Symbol('accordion-context');
@@ -1,4 +1,4 @@
1
- var getYear = function () {
1
+ const getYear = () => {
2
2
  return new Date().getFullYear();
3
3
  };
4
4
  export { getYear };
@@ -1 +1,11 @@
1
- export declare const TABS_CONTEXT_KEY: any;
1
+ import type { Writable } from 'svelte/store';
2
+ export type TabData = {
3
+ label: string;
4
+ color: string;
5
+ disabled: boolean;
6
+ };
7
+ export type TabsContext = {
8
+ addTab: (tab: TabData) => void;
9
+ activeTabLabel: Writable<string>;
10
+ };
11
+ export declare const TABS_CONTEXT_KEY: unique symbol;
@@ -1 +1 @@
1
- export var TABS_CONTEXT_KEY = Symbol('tabs-context');
1
+ export const TABS_CONTEXT_KEY = Symbol('tabs-context');
package/dist/toast.js CHANGED
@@ -1,64 +1,50 @@
1
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
2
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
3
- if (ar || !(i in from)) {
4
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
5
- ar[i] = from[i];
6
- }
7
- }
8
- return to.concat(ar || Array.prototype.slice.call(from));
9
- };
10
1
  import { writable } from 'svelte/store';
11
2
  import { CCLVividColor } from './const/config';
12
- export var toasts = writable([]);
3
+ export const toasts = writable([]);
13
4
  function genId() {
14
5
  return Math.random().toString(36).slice(2) + Date.now().toString(36);
15
6
  }
16
7
  // Default auto-dismiss duration held internally
17
- var DEFAULT_DURATION = 3000;
8
+ const DEFAULT_DURATION = 3000;
18
9
  export function show(opts) {
19
- var _a, _b;
20
- var id = genId();
21
- var item = {
22
- id: id,
10
+ const id = genId();
11
+ const item = {
12
+ id,
23
13
  title: opts.title,
24
14
  message: opts.message,
25
- variant: (_a = opts.variant) !== null && _a !== void 0 ? _a : 'info',
26
- duration: (_b = opts.duration) !== null && _b !== void 0 ? _b : DEFAULT_DURATION
15
+ variant: opts.variant ?? 'info',
16
+ duration: opts.duration ?? DEFAULT_DURATION
27
17
  };
28
- toasts.update(function (list) { return __spreadArray([item], list, true).slice(0, 50); });
18
+ toasts.update((list) => [item, ...list].slice(0, 50));
29
19
  if (typeof window !== 'undefined' && item.duration > 0) {
30
- window.setTimeout(function () { return dismiss(id); }, item.duration);
20
+ window.setTimeout(() => dismiss(id), item.duration);
31
21
  }
32
22
  return id;
33
23
  }
34
24
  export function dismiss(id) {
35
- toasts.update(function (list) { return list.filter(function (t) { return t.id !== id; }); });
25
+ toasts.update((list) => list.filter((t) => t.id !== id));
36
26
  }
37
27
  export function clear() {
38
28
  toasts.set([]);
39
29
  }
40
- export var toast = {
41
- show: show,
42
- success: function (message, title, duration) {
43
- if (title === void 0) { title = 'Success'; }
44
- return show({ message: message, title: title, variant: 'success', duration: duration });
30
+ export const toast = {
31
+ show,
32
+ success(message, title = 'Success', duration) {
33
+ return show({ message, title, variant: 'success', duration });
45
34
  },
46
- error: function (message, title, duration) {
47
- if (title === void 0) { title = 'Error'; }
48
- return show({ message: message, title: title, variant: 'error', duration: duration });
35
+ error(message, title = 'Error', duration) {
36
+ return show({ message, title, variant: 'error', duration });
49
37
  },
50
- warning: function (message, title, duration) {
51
- if (title === void 0) { title = 'Warning'; }
52
- return show({ message: message, title: title, variant: 'warning', duration: duration });
38
+ warning(message, title = 'Warning', duration) {
39
+ return show({ message, title, variant: 'warning', duration });
53
40
  },
54
- info: function (message, title, duration) {
55
- if (title === void 0) { title = 'Info'; }
56
- return show({ message: message, title: title, variant: 'info', duration: duration });
41
+ info(message, title = 'Info', duration) {
42
+ return show({ message, title, variant: 'info', duration });
57
43
  },
58
- dismiss: dismiss,
59
- clear: clear
44
+ dismiss,
45
+ clear
60
46
  };
61
- export var variantColor = {
47
+ export const variantColor = {
62
48
  success: CCLVividColor.MELON_GREEN,
63
49
  error: CCLVividColor.STRAWBERRY_PINK,
64
50
  warning: CCLVividColor.PINEAPPLE_YELLOW,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cclkit4svelte",
3
- "version": "3.1.0",
3
+ "version": "4.0.0",
4
4
  "author": "reiji1020 <sk@reiji1020.info>",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -21,6 +21,7 @@
21
21
  },
22
22
  "scripts": {
23
23
  "preinstall": "node -e \"if (!/pnpm/.test(process.env.npm_execpath || '')) { console.error('Use pnpm to install dependencies.'); process.exit(1); }\"",
24
+ "prepare": "svelte-kit sync",
24
25
  "dev": "vite dev",
25
26
  "build": "vite build",
26
27
  "preview": "vite preview",
@@ -85,7 +86,7 @@
85
86
  "vite": "^5.4.20"
86
87
  },
87
88
  "peerDependencies": {
88
- "svelte": "^4.0.0"
89
+ "svelte": "^5.0.0"
89
90
  },
90
91
  "volta": {
91
92
  "node": "20.11.1",