@3birds/midori-ui 0.0.48 → 0.0.50

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.
@@ -1,13 +1,24 @@
1
1
  <script lang="ts">
2
- import { Img, type ContentGeo } from '..';
2
+ import { Btn, closeSvg, Img, type ContentGeo } from '..';
3
3
 
4
- let { content, searchParams = '' }: { content: ContentGeo; searchParams?: string } = $props();
4
+ let {
5
+ content,
6
+ searchParams = '',
7
+ onClickClose
8
+ }: {
9
+ content: ContentGeo;
10
+ searchParams?: string;
11
+ onClickClose: (e: MouseEvent) => void;
12
+ } = $props();
5
13
  </script>
6
14
 
7
15
  <a
8
16
  class="card fixed right-22 bottom-4 left-4 z-20 mx-auto card-side h-32 max-w-sm rounded-3xl bg-base-100 shadow-sm card-sm sm:right-4"
9
17
  href="/contents/{content.id}{searchParams}"
10
18
  >
19
+ <Btn class="absolute top-2 right-2 btn-circle btn-sm" onclick={onClickClose}>
20
+ <Img src={closeSvg} alt="削除" class="size-4" />
21
+ </Btn>
11
22
  <figure class="aspect-1">
12
23
  <Img src={content.thumbnail} alt={content.name} class="h-full w-full object-cover" />
13
24
  </figure>
@@ -2,6 +2,7 @@ import { type ContentGeo } from '..';
2
2
  type $$ComponentProps = {
3
3
  content: ContentGeo;
4
4
  searchParams?: string;
5
+ onClickClose: (e: MouseEvent) => void;
5
6
  };
6
7
  declare const CardSide: import("svelte").Component<$$ComponentProps, {}, "">;
7
8
  type CardSide = ReturnType<typeof CardSide>;
@@ -0,0 +1,63 @@
1
+ <script lang="ts">
2
+ import 'leaflet/dist/leaflet.css';
3
+
4
+ let {
5
+ container = $bindable(),
6
+ class: className
7
+ }: {
8
+ container: HTMLDivElement | undefined;
9
+ class?: string;
10
+ } = $props();
11
+ </script>
12
+
13
+ <div bind:this={container} class={className}></div>
14
+
15
+ <style>
16
+ :global(.midori-marker) {
17
+ background: transparent;
18
+ border: none;
19
+ }
20
+
21
+ :global(.marker-wrapper) {
22
+ width: 20px;
23
+ display: flex;
24
+ align-items: center;
25
+ gap: 3px;
26
+ }
27
+
28
+ :global(.marker-icon) {
29
+ min-width: 20px;
30
+ width: 20px;
31
+ height: 20px;
32
+ border-radius: 6px;
33
+ display: flex;
34
+ align-items: center;
35
+ justify-content: center;
36
+ box-sizing: border-box;
37
+ }
38
+
39
+ :global(.marker-icon img) {
40
+ width: 14px;
41
+ height: 14px;
42
+ display: block;
43
+ }
44
+
45
+ :global(.marker-label) {
46
+ font-size: 10px;
47
+ line-height: 1.2;
48
+ color: #747476;
49
+ white-space: nowrap;
50
+ max-width: 100px;
51
+ text-shadow:
52
+ -1px -1px 0 #f8f8f8,
53
+ 1px -1px 0 #f8f8f8,
54
+ -1px 1px 0 #f8f8f8,
55
+ 1px 1px 0 #f8f8f8;
56
+ }
57
+
58
+ :global(.marker-label span) {
59
+ overflow-x: hidden;
60
+ text-overflow: ellipsis;
61
+ display: block;
62
+ }
63
+ </style>
@@ -0,0 +1,8 @@
1
+ import 'leaflet/dist/leaflet.css';
2
+ type $$ComponentProps = {
3
+ container: HTMLDivElement | undefined;
4
+ class?: string;
5
+ };
6
+ declare const Map: import("svelte").Component<$$ComponentProps, {}, "container">;
7
+ type Map = ReturnType<typeof Map>;
8
+ export default Map;
@@ -0,0 +1,54 @@
1
+ <script lang="ts">
2
+ import { Img } from '@3birds/midori-ui';
3
+
4
+ let {
5
+ label,
6
+ icon,
7
+ option,
8
+ value = $bindable()
9
+ }: {
10
+ label?: string;
11
+ icon?: string;
12
+ option?: string;
13
+ value: any;
14
+ oninput?: (e: Event & { currentTarget: EventTarget & HTMLInputElement }) => void;
15
+ onchange?: (e: Event & { currentTarget: EventTarget & HTMLInputElement }) => void;
16
+ } = $props();
17
+ </script>
18
+
19
+ <fieldset class="fieldset w-full">
20
+ {#if label}
21
+ <legend class="fieldset-legend whitespace-nowrap">{label}</legend>
22
+ {/if}
23
+ <label class="flex w-full items-center gap-4 rounded-full {icon ? '' : 'px-5'}">
24
+ {#if icon}
25
+ <Img src={icon} class="size-8" alt="アイコン" />
26
+ {/if}
27
+ <div class="flex-1">
28
+ <input
29
+ type="range"
30
+ min="0"
31
+ max="5.0"
32
+ bind:value
33
+ class="range w-full range-warning"
34
+ step="0.5"
35
+ />
36
+ <div class="mt-2 flex justify-between px-2.5 text-xs">
37
+ <span>0</span>
38
+ <span> </span>
39
+ <span>1</span>
40
+ <span> </span>
41
+ <span>2</span>
42
+ <span> </span>
43
+ <span>3</span>
44
+ <span> </span>
45
+ <span>4</span>
46
+ <span> </span>
47
+ <span>5</span>
48
+ </div>
49
+ </div>
50
+ </label>
51
+ {#if option}
52
+ <p class="label ml-auto whitespace-pre-wrap">{option}</p>
53
+ {/if}
54
+ </fieldset>
@@ -0,0 +1,15 @@
1
+ type $$ComponentProps = {
2
+ label?: string;
3
+ icon?: string;
4
+ option?: string;
5
+ value: any;
6
+ oninput?: (e: Event & {
7
+ currentTarget: EventTarget & HTMLInputElement;
8
+ }) => void;
9
+ onchange?: (e: Event & {
10
+ currentTarget: EventTarget & HTMLInputElement;
11
+ }) => void;
12
+ };
13
+ declare const Range: import("svelte").Component<$$ComponentProps, {}, "value">;
14
+ type Range = ReturnType<typeof Range>;
15
+ export default Range;
@@ -0,0 +1,43 @@
1
+ <script lang="ts">
2
+ let {
3
+ required,
4
+ readonly,
5
+ disabled,
6
+ label,
7
+ placeholder,
8
+ option,
9
+ value = $bindable(),
10
+ class: className,
11
+ oninput,
12
+ onchange
13
+ }: {
14
+ required?: boolean;
15
+ readonly?: boolean;
16
+ disabled?: boolean;
17
+ label?: string;
18
+ placeholder?: string;
19
+ option?: string;
20
+ value: string;
21
+ class?: string;
22
+ oninput?: (e: Event & { currentTarget: EventTarget & HTMLTextAreaElement }) => void;
23
+ onchange?: (e: Event & { currentTarget: EventTarget & HTMLTextAreaElement }) => void;
24
+ } = $props();
25
+ </script>
26
+
27
+ <fieldset class="fieldset w-full">
28
+ {#if label}
29
+ <legend class="fieldset-legend whitespace-nowrap">{label}</legend>
30
+ {/if}
31
+ <textarea
32
+ class="textarea w-full rounded-3xl p-4 {className}"
33
+ {required}
34
+ {readonly}
35
+ {disabled}
36
+ {placeholder}
37
+ bind:value
38
+ {oninput}
39
+ {onchange}></textarea>
40
+ {#if option}
41
+ <p class="label ml-auto whitespace-pre-wrap">{option}</p>
42
+ {/if}
43
+ </fieldset>
@@ -0,0 +1,19 @@
1
+ type $$ComponentProps = {
2
+ required?: boolean;
3
+ readonly?: boolean;
4
+ disabled?: boolean;
5
+ label?: string;
6
+ placeholder?: string;
7
+ option?: string;
8
+ value: string;
9
+ class?: string;
10
+ oninput?: (e: Event & {
11
+ currentTarget: EventTarget & HTMLTextAreaElement;
12
+ }) => void;
13
+ onchange?: (e: Event & {
14
+ currentTarget: EventTarget & HTMLTextAreaElement;
15
+ }) => void;
16
+ };
17
+ declare const Textarea: import("svelte").Component<$$ComponentProps, {}, "value">;
18
+ type Textarea = ReturnType<typeof Textarea>;
19
+ export default Textarea;
@@ -8,5 +8,9 @@ export declare const MAP_DEFAULT_LATITUDE: number;
8
8
  export declare const MAP_DEFAULT_LONGITUDE: number;
9
9
  export declare const PRIORITIES: PriorityChoice[];
10
10
  export declare const PRIORITIES_WITHOUT_LOG: PriorityChoice[];
11
+ export declare const RATING_OPTIONS: {
12
+ value: number;
13
+ label: string;
14
+ }[];
11
15
  export declare const PREFECTURE_SVG: Record<string, string>;
12
16
  export declare const POI_ICON: Record<string, string>;
@@ -17,6 +17,19 @@ export const PRIORITIES_WITHOUT_LOG = [
17
17
  { label: 'コンテンツ', value: '20' },
18
18
  { label: 'アメニティ', value: '10' }
19
19
  ];
20
+ export const RATING_OPTIONS = [
21
+ { value: 0, label: '0' },
22
+ { value: 0.5, label: '0.5' },
23
+ { value: 1.0, label: '1.0' },
24
+ { value: 1.5, label: '1.5' },
25
+ { value: 2.0, label: '2.0' },
26
+ { value: 2.5, label: '2.5' },
27
+ { value: 3.0, label: '3.0' },
28
+ { value: 3.5, label: '3.5' },
29
+ { value: 4.0, label: '4.0' },
30
+ { value: 4.5, label: '4.5' },
31
+ { value: 5.0, label: '5.0' }
32
+ ];
20
33
  import { 北海道, 青森県, 岩手県, 宮城県, 秋田県, 山形県, 福島県, 茨城県, 栃木県, 群馬県, 埼玉県, 千葉県, 東京都, 神奈川県, 新潟県, 富山県, 石川県, 福井県, 山梨県, 長野県, 岐阜県, 静岡県, 愛知県, 三重県, 滋賀県, 京都府, 大阪府, 兵庫県, 奈良県, 和歌山県, 鳥取県, 島根県, 岡山県, 広島県, 山口県, 徳島県, 香川県, 愛媛県, 高知県, 福岡県, 佐賀県, 長崎県, 熊本県, 大分県, 宮崎県, 鹿児島県, 沖縄県 } from '..';
21
34
  export const PREFECTURE_SVG = {
22
35
  北海道: 北海道,
@@ -0,0 +1,3 @@
1
+ export declare const image: {
2
+ optimize: (file: File | Blob, callback: Function) => Promise<void>;
3
+ };
package/dist/image.js ADDED
@@ -0,0 +1,41 @@
1
+ import { browser } from '$app/environment';
2
+ // 元ファイルがこのサイズ以下なら圧縮処理自体をスキップする(劣化防止)
3
+ const SKIP_COMPRESSION_THRESHOLD_MB = 1;
4
+ let heic2any = null;
5
+ let imageCompression = null;
6
+ const loadLibs = async () => {
7
+ if (!heic2any) {
8
+ heic2any = (await import('heic2any')).default;
9
+ imageCompression = (await import('browser-image-compression')).default;
10
+ }
11
+ };
12
+ const convert = async (file) => {
13
+ await loadLibs();
14
+ return await imageCompression(new File([file], '', { type: file.type }), {
15
+ maxSizeMB: 3,
16
+ maxWidthOrHeight: 2048,
17
+ useWebWorker: true,
18
+ fileType: 'image/webp',
19
+ initialQuality: 1
20
+ });
21
+ };
22
+ export const image = {
23
+ optimize: async (file, callback) => {
24
+ if (!browser)
25
+ return;
26
+ await loadLibs();
27
+ if (file.type === 'image/heic' || file.name.endsWith('.HEIC')) {
28
+ file = (await heic2any({
29
+ blob: file,
30
+ toType: 'image/jpeg',
31
+ quality: 1
32
+ }));
33
+ }
34
+ // 元々十分小さいファイルは再エンコードせずそのまま使う
35
+ const fileSizeMB = file.size / 1024 / 1024;
36
+ const convertedImage = fileSizeMB <= SKIP_COMPRESSION_THRESHOLD_MB ? file : await convert(file);
37
+ const reader = new FileReader();
38
+ reader.onload = () => callback(reader.result);
39
+ reader.readAsDataURL(convertedImage);
40
+ }
41
+ };
package/dist/index.d.ts CHANGED
@@ -11,6 +11,9 @@ export { default as CardSide } from './components/CardSide.svelte';
11
11
  export { default as Header } from './components/Header.svelte';
12
12
  export { default as Pagination } from './components/Pagination.svelte';
13
13
  export { default as Img } from './components/Img.svelte';
14
+ export { default as Map } from './components/Map.svelte';
15
+ export { default as Range } from './components/Range.svelte';
16
+ export { default as Textarea } from './components/Textarea.svelte';
14
17
  export { default as accountSvg } from './assets/account.svg';
15
18
  export { default as alertSvg } from './assets/alert.svg';
16
19
  export { default as calendarMonthSvg } from './assets/calendar-month.svg';
@@ -250,5 +253,6 @@ export * as firebase from './auth';
250
253
  export { auth } from './firebase';
251
254
  export * as modal from './modals-context.ts';
252
255
  export * from './utils/index.ts';
253
- export { MAP_ATTRIBUTION, MAP_DEFAULT_ICON_SIZE, PRIORITIES, MAP_DEFAULT_ICON_ANCHOR, MAP_MAX_ZOOM, MAP_DEFAULT_LATITUDE, MAP_DEFAULT_LONGITUDE, PRIORITIES_WITHOUT_LOG, PREFECTURE_SVG, POI_ICON } from './constants/index.ts';
254
- export type { BtnType, InputType, AlertType, AlertState, BreadcrumbsItem, FilterItem, Priority, PriorityChoice, ModalsContext, Data, ContentAdditionalInfo, ContentAdmin, ContentImage, ContentReview, ContentMinimal, ContentCasual, ContentFormal, ContentGeo, ContentChildren, ContentReviews, Account, Dashboard, DashboardPref } from './types/index.ts';
256
+ export { image } from './image.ts';
257
+ export { MAP_ATTRIBUTION, MAP_DEFAULT_ICON_SIZE, PRIORITIES, RATING_OPTIONS, MAP_DEFAULT_ICON_ANCHOR, MAP_MAX_ZOOM, MAP_DEFAULT_LATITUDE, MAP_DEFAULT_LONGITUDE, PRIORITIES_WITHOUT_LOG, PREFECTURE_SVG, POI_ICON } from './constants/index.ts';
258
+ export type { BtnType, InputType, AlertType, ImageType, AlertState, BreadcrumbsItem, FilterItem, Priority, PriorityChoice, ModalsContext, Data, ContentAdditionalInfo, ContentAdmin, ContentImage, ContentReview, ContentMinimal, ContentCasual, ContentFormal, ContentGeo, ContentChildren, ContentReviews, Account, Dashboard, DashboardPref } from './types/index.ts';
package/dist/index.js CHANGED
@@ -12,6 +12,9 @@ export { default as CardSide } from './components/CardSide.svelte';
12
12
  export { default as Header } from './components/Header.svelte';
13
13
  export { default as Pagination } from './components/Pagination.svelte';
14
14
  export { default as Img } from './components/Img.svelte';
15
+ export { default as Map } from './components/Map.svelte';
16
+ export { default as Range } from './components/Range.svelte';
17
+ export { default as Textarea } from './components/Textarea.svelte';
15
18
  export { default as accountSvg } from './assets/account.svg';
16
19
  export { default as alertSvg } from './assets/alert.svg';
17
20
  export { default as calendarMonthSvg } from './assets/calendar-month.svg';
@@ -251,4 +254,5 @@ export * as firebase from './auth';
251
254
  export { auth } from './firebase';
252
255
  export * as modal from "./modals-context.js";
253
256
  export * from "./utils/index.js";
254
- export { MAP_ATTRIBUTION, MAP_DEFAULT_ICON_SIZE, PRIORITIES, MAP_DEFAULT_ICON_ANCHOR, MAP_MAX_ZOOM, MAP_DEFAULT_LATITUDE, MAP_DEFAULT_LONGITUDE, PRIORITIES_WITHOUT_LOG, PREFECTURE_SVG, POI_ICON } from "./constants/index.js";
257
+ export { image } from "./image.js";
258
+ export { MAP_ATTRIBUTION, MAP_DEFAULT_ICON_SIZE, PRIORITIES, RATING_OPTIONS, MAP_DEFAULT_ICON_ANCHOR, MAP_MAX_ZOOM, MAP_DEFAULT_LATITUDE, MAP_DEFAULT_LONGITUDE, PRIORITIES_WITHOUT_LOG, PREFECTURE_SVG, POI_ICON } from "./constants/index.js";
@@ -1,6 +1,7 @@
1
1
  export type BtnType = 'button' | 'submit' | 'reset';
2
2
  export type InputType = 'text' | 'email' | 'search' | 'tel' | 'url' | 'none' | 'numeric' | 'decimal' | 'password' | 'datetime-local' | 'date';
3
3
  export type AlertType = 'info' | 'success' | 'error' | 'warning';
4
+ export type ImageType = 'contents' | 'general_user' | 'admin';
4
5
  export interface AlertState {
5
6
  show: boolean;
6
7
  message: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@3birds/midori-ui",
3
- "version": "0.0.48",
3
+ "version": "0.0.50",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite dev",
@@ -57,6 +57,8 @@
57
57
  "vite": "^8.0.16"
58
58
  },
59
59
  "dependencies": {
60
- "firebase": "^12.0.0"
60
+ "browser-image-compression": "^2.0.2",
61
+ "firebase": "^12.0.0",
62
+ "heic2any": "^0.0.4"
61
63
  }
62
64
  }