Prechádzať zdrojové kódy

[stdf]Update TimePicker compoent, demo and documents.

dufu1991 1 rok pred
rodič
commit
abd8662f79

+ 67 - 83
demo/src/routes/en_US/timePicker/+page.svelte

@@ -2,46 +2,33 @@
 <script>
 	import { Cell, TimePicker } from '../../../../../packages/stdf/components';
 
-	let visible1 = false;
-	let visible2 = false;
-	let visible3 = false;
-	let visible4 = false;
-	let visible5 = false;
-	let visible6 = false;
-	let visible7 = false;
-	let visible8 = false;
-	let visible9 = false;
-	let visible10 = false;
-	let visible11 = false;
-	let visible12 = false;
-	let visible13 = false;
-	let visible14 = false;
-	let visible15 = false;
-	let visible16 = false;
-	let visible17 = false;
-	let visible18 = false;
-	let visible19 = false;
-	let visible20 = false;
-	let visible21 = false;
-	let visible22 = false;
-
-	let defaultTimeStr = '';
-	const getDefaultFunc = e => {
-		defaultTimeStr = e.detail.times;
-	};
-	let customFormatStr = '';
-	const customFormatFunc = e => {
-		customFormatStr = e.detail.times;
-	};
-	let monthFirstStr = '';
-	const monthFirstFunc = e => {
-		monthFirstStr = e.detail.times;
-	};
-	let timeObj = {};
-	$: timeObjStr = JSON.stringify(timeObj);
-	const getTimeObjFunc = e => {
-		timeObj = e.detail.times;
-	};
+	let visible1 = $state(false);
+	let visible2 = $state(false);
+	let visible3 = $state(false);
+	let visible4 = $state(false);
+	let visible5 = $state(false);
+	let visible6 = $state(false);
+	let visible8 = $state(false);
+	let visible9 = $state(false);
+	let visible10 = $state(false);
+	let visible11 = $state(false);
+	let visible12 = $state(false);
+	let visible13 = $state(false);
+	let visible14 = $state(false);
+	let visible15 = $state(false);
+	let visible16 = $state(false);
+	let visible17 = $state(false);
+	let visible18 = $state(false);
+	let visible19 = $state(false);
+	let visible20 = $state(false);
+	let visible21 = $state(false);
+	let visible22 = $state(false);
+
+	let defaultTimeStr = $state('');
+	let customFormatStr = $state('');
+	let monthFirstStr = $state('');
+	let timeObj = $state({});
+	let timeObjStr = $derived(JSON.stringify(timeObj));
 </script>
 
 <div class="py-4">
@@ -50,32 +37,25 @@
 			Currently selected:
 			<span class="mr-2 text-primary dark:text-dark">{defaultTimeStr}</span>
 		{:else}
-			<div>Please select the time</div>
+			<div>Please select a time</div>
 		{/if}
 	</div>
-	<Cell title="Basic usage" subTitle="By default, the current time is selected. 10 years is optional" on:click={() => (visible1 = true)} />
-	<TimePicker bind:visible={visible1} on:confirm={getDefaultFunc} />
+	<Cell title="Basic Usage" subTitle="Default to current time, can select 10 years before and after" onclick={() => (visible1 = true)} />
+	<TimePicker bind:visible={visible1} onconfirm={time => (defaultTimeStr = time)} />
 
-	<Cell title="Just the year, the month and the day" on:click={() => (visible2 = true)} />
-	<TimePicker bind:visible={visible2} type="YMD" />
+	<Cell title="Year Month Day only" onclick={() => (visible2 = true)} />
+	<TimePicker bind:visible={visible2} type="YYYYMMDD" />
 
-	<Cell
-		title="Misrepresentation unsupported type"
-		subTitle="Use the default year, month, day, hour and second"
-		on:click={() => (visible7 = true)}
-	/>
-	<TimePicker bind:visible={visible7} type="MD" />
-
-	<Cell title="Just use the minutes and seconds" on:click={() => (visible3 = true)} />
-	<TimePicker bind:visible={visible3} type="hms" />
+	<Cell title="Hour Minute Second only" onclick={() => (visible3 = true)} />
+	<TimePicker bind:visible={visible3} type="hhmmss" />
 
-	<Cell title="Just the year, the month, the day" on:click={() => (visible4 = true)} />
-	<TimePicker bind:visible={visible4} type="YMDh" />
+	<Cell title="Year Month Day Hour only" onclick={() => (visible4 = true)} />
+	<TimePicker bind:visible={visible4} type="YYYYMMDDhh" />
 
-	<Cell title="Do not display prompt" on:click={() => (visible5 = true)} />
+	<Cell title="Hide Tips" onclick={() => (visible5 = true)} />
 	<TimePicker bind:visible={visible5} showTips={false} />
 
-	<Cell title="Different columns have different visible rows" on:click={() => (visible6 = true)} />
+	<Cell title="Different visible rows for each column" onclick={() => (visible6 = true)} />
 	<TimePicker
 		bind:visible={visible6}
 		yearProps={{ showRow: 3 }}
@@ -84,25 +64,25 @@
 		secondProps={{ showRow: 7 }}
 	/>
 
-	<Cell title="Different columns have different widths" on:click={() => (visible8 = true)} />
+	<Cell title="Different widths for each column" onclick={() => (visible8 = true)} />
 	<TimePicker bind:visible={visible8} yearProps={{ flex: 3 }} dayProps={{ flex: 2 }} />
 
-	<Cell title="Align annual data to the right and daily data to the left" on:click={() => (visible22 = true)} />
-	<TimePicker bind:visible={visible22} type="YMD" yearProps={{ align: 'right' }} dayProps={{ align: 'left' }} />
+	<Cell title="Year data right-aligned, day data left-aligned" onclick={() => (visible22 = true)} />
+	<TimePicker bind:visible={visible22} type="YYYYMMDD" yearProps={{ align: 'right' }} dayProps={{ align: 'left' }} />
 
-	<Cell title="Limited year interval" on:click={() => (visible9 = true)} />
+	<Cell title="Limit year range" onclick={() => (visible9 = true)} />
 	<TimePicker bind:visible={visible9} yearRange={[2022, 2025]} />
 
-	<Cell title="Limited month range" on:click={() => (visible10 = true)} />
+	<Cell title="Limit month range" onclick={() => (visible10 = true)} />
 	<TimePicker bind:visible={visible10} monthRange={[2, 5]} />
 
-	<Cell title="Limited time interval" on:click={() => (visible11 = true)} />
+	<Cell title="Limit hour, minute, second range" onclick={() => (visible11 = true)} />
 	<TimePicker bind:visible={visible11} hourRange={[2, 5]} minuteRange={[25, 45]} secondRange={[5, 10]} />
 
-	<Cell title="The minute step length is 5" on:click={() => (visible12 = true)} />
+	<Cell title="Minute step of 5" onclick={() => (visible12 = true)} />
 	<TimePicker bind:visible={visible12} minuteStep={5} />
 
-	<Cell title="The second step is 10" on:click={() => (visible13 = true)} />
+	<Cell title="Second step of 10" onclick={() => (visible13 = true)} />
 	<TimePicker bind:visible={visible13} secondStep={10} />
 
 	<div class="px-4">
@@ -110,46 +90,50 @@
 			Currently selected:
 			<span class="mr-2 text-primary dark:text-dark">{customFormatStr}</span>
 		{:else}
-			<div>Please select the time</div>
+			<div>Please select a time</div>
 		{/if}
 	</div>
 	<Cell
-		title="User-defined return time format"
-		subTitle="The output format is Y year M month D day h hour m minute s second"
-		on:click={() => (visible15 = true)}
+		title="Custom return time format"
+		subTitle="Output format: X year X month X day X hour X minute X second"
+		onclick={() => (visible15 = true)}
+	/>
+	<TimePicker
+		bind:visible={visible15}
+		outFormat="YYYY year MM month DD day hh hour mm minute ss second"
+		onconfirm={timeStr => (customFormatStr = timeStr)}
 	/>
-	<TimePicker bind:visible={visible15} outFormat="Y year, M month, D day, h hour, m minutes, s seconds" on:confirm={customFormatFunc} />
 
 	<div class="px-4">
 		{#if monthFirstStr !== ''}
 			Currently selected:
 			<span class="mr-2 text-primary dark:text-dark">{monthFirstStr}</span>
 		{:else}
-			<div>Please select the time</div>
+			<div>Please select a time</div>
 		{/if}
 	</div>
-	<Cell title="Return time month before" on:click={() => (visible16 = true)} />
-	<TimePicker bind:visible={visible16} type="YMD" outFormat="M/D/Y" on:confirm={monthFirstFunc} />
+	<Cell title="Return time with month first" onclick={() => (visible16 = true)} />
+	<TimePicker bind:visible={visible16} type="YYYYMMDD" outFormat="MM/DD/YYYY" onconfirm={timeStr => (monthFirstStr = timeStr)} />
 
 	<div class="px-4 text-xs">
 		Currently selected:<br />
-		<span class="mr-2 text-primary dark:text-dark break-words">{timeObjStr}</span>
+		<span class="mr-2 break-words text-primary dark:text-dark">{timeObjStr}</span>
 	</div>
-	<Cell title="Return time object" on:click={() => (visible17 = true)} />
-	<TimePicker bind:visible={visible17} outFormat="object" on:confirm={getTimeObjFunc} />
+	<Cell title="Return time object" onclick={() => (visible17 = true)} />
+	<TimePicker bind:visible={visible17} onconfirm={(_, obj) => (timeObj = obj)} />
 
-	<Cell title="I want some rounded corners on the top" on:click={() => (visible14 = true)} />
+	<Cell title="Rounded corners at the top" onclick={() => (visible14 = true)} />
 	<TimePicker bind:visible={visible14} popup={{ radius: 'xl' }} />
 
-	<Cell title="Custom title" on:click={() => (visible18 = true)} />
-	<TimePicker bind:visible={visible18} title="Please select the time" />
+	<Cell title="Custom title" onclick={() => (visible18 = true)} />
+	<TimePicker bind:visible={visible18} title="Please select a time" />
 
-	<Cell title="Specifies the initial selection year" on:click={() => (visible19 = true)} />
+	<Cell title="Specify initial selected year" onclick={() => (visible19 = true)} />
 	<TimePicker bind:visible={visible19} initYear="2020" />
 
-	<Cell title="Specifies the initial selected month" on:click={() => (visible20 = true)} />
+	<Cell title="Specify initial selected month" onclick={() => (visible20 = true)} />
 	<TimePicker bind:visible={visible20} initMonth="05" />
 
-	<Cell title="Specifies the initial selection time" on:click={() => (visible21 = true)} />
+	<Cell title="Specify initial selected hour, minute, second" onclick={() => (visible21 = true)} />
 	<TimePicker bind:visible={visible21} initHour="05" initMinute="05" initSecond="05" />
 </div>

+ 67 - 83
doc/components/timePicker/api.md

@@ -1,94 +1,78 @@
 ## TimePicker Props
 
-| 属性        | 类型    | 默认值                               | 可选值                                   | 必传 | 说明               |
-| ----------- | ------- | ------------------------------------ | ---------------------------------------- | ---- | ------------------ |
-| visible     | Boolean | false                                | true/false                               | N    | 是否显示。         |
-| type        | String  | 'YMDhms'                             | 由 Y M D h m s 组合,共 13 种。          | N    | 时间类型。         |
-| yearProps   | Object  | {}                                   | 参考 yearProps                           | N    | 年份列参数。       |
-| monthProps  | Object  | {}                                   | 参考 monthProps                          | N    | 月份列参数。       |
-| dayProps    | Object  | {}                                   | 参考 dayProps                            | N    | 日期列参数。       |
-| hourProps   | Object  | {}                                   | 参考 hourProps                           | N    | 小时列参数。       |
-| minuteProps | Object  | {}                                   | 参考 minuteProps                         | N    | 分钟列参数。       |
-| secondProps | Object  | {}                                   | 参考 secondProps                         | N    | 秒钟列参数。       |
-| initYear    | String  | ''                                   | -                                        | N    | 初始选定的年份。   |
-| initMonth   | String  | ''                                   | -                                        | N    | 初始选定的月份。   |
-| initDay     | String  | ''                                   | -                                        | N    | 初始选定的日期。   |
-| initHour    | String  | ''                                   | -                                        | N    | 初始选定的小时。   |
-| initMinute  | String  | ''                                   | -                                        | N    | 初始选定的分钟。   |
-| initSecond  | String  | ''                                   | -                                        | N    | 初始选定的秒钟。   |
-| minuteStep  | Number  | 1                                    | -                                        | N    | 分钟步长。         |
-| secondStep  | Number  | 1                                    | -                                        | N    | 秒钟步长。         |
-| yearRange   | Array   | []                                   | -                                        | N    | 年份范围。         |
-| monthRange  | Array   | [1, 12]                              | -                                        | N    | 月份范围。         |
-| hourRange   | Array   | [0, 23]                              | -                                        | N    | 小时范围。         |
-| minuteRange | Array   | [0, 59]                              | -                                        | N    | 分钟范围。         |
-| secondRange | Array   | [0, 59]                              | -                                        | N    | 秒钟范围。         |
-| showTips    | Boolean | true                                 | true/false                               | N    | 是否显示提示信息。 |
-| cancelText  | String  | 当前语言的 timePicker.defaultCancel  | -                                        | N    | 取消选项文本。     |
-| confirmText | String  | 当前语言的 timePicker.defaultConfirm | -                                        | N    | 确定选项文本。     |
-| title       | String  | 当前语言的 timePicker.defaultTitle   | -                                        | N    | 中间标题文本。     |
-| yearText    | String  | 当前语言的 timePicker.defaultYear    | -                                        | N    | 年份列提示文本。   |
-| monthText   | String  | 当前语言的 timePicker.defaultMonth   | -                                        | N    | 月份列提示文本。   |
-| dayText     | String  | 当前语言的 timePicker.defaultDay     | -                                        | N    | 日期列提示文本。   |
-| hourText    | String  | 当前语言的 timePicker.defaultHour    | -                                        | N    | 小时列提示文本。   |
-| minuteText  | String  | 当前语言的 timePicker.defaultMinute  | -                                        | N    | 分钟列提示文本。   |
-| secondText  | String  | 当前语言的 timePicker.defaultSecond  | -                                        | N    | 秒钟列提示文本。   |
-| outFormat   | String  | ''                                   | 'object' 或包含 Y M D h m s 组合的字符。 | N    | 返回数据格式。     |
-| popup       | Object  | {}                                   | 参考 Popup Props                         | N    | 弹出层参数。       |
+| 名称        | 类型                                                        | 默认值                               | 必传 | 说明               |
+| ----------- | ----------------------------------------------------------- | ------------------------------------ | ---- | ------------------ |
+| visible     | `boolean`                                                   | `false`                              | N    | 是否显示。         |
+| type        | `TimePickerType`                                            | `'YYYYMMDDhhmmss'`                   | N    | 时间类型。         |
+| yearProps   | `TimePickerItem`                                            | `{}`                                 | N    | 年份列参数。       |
+| monthProps  | `TimePickerItem`                                            | `{}`                                 | N    | 月份列参数。       |
+| dayProps    | `TimePickerItem`                                            | `{}`                                 | N    | 日期列参数。       |
+| hourProps   | `TimePickerItem`                                            | `{}`                                 | N    | 小时列参数。       |
+| minuteProps | `TimePickerItem`                                            | `{}`                                 | N    | 分钟列参数。       |
+| secondProps | `TimePickerItem`                                            | `{}`                                 | N    | 秒钟列参数。       |
+| initYear    | `string`                                                    | `''`                                 | N    | 初始选定的年份。   |
+| initMonth   | `string`                                                    | `''`                                 | N    | 初始选定的月份。   |
+| initDay     | `string`                                                    | `''`                                 | N    | 初始选定的日期。   |
+| initHour    | `string`                                                    | `''`                                 | N    | 初始选定的小时。   |
+| initMinute  | `string`                                                    | `''`                                 | N    | 初始选定的分钟。   |
+| initSecond  | `string`                                                    | `''`                                 | N    | 初始选定的秒钟。   |
+| minuteStep  | `number`                                                    | `1`                                  | N    | 分钟步长。         |
+| secondStep  | `number`                                                    | `1`                                  | N    | 秒钟步长。         |
+| yearRange   | `[number,number]\|[]`                                       | `[]`                                 | N    | 年份范围。         |
+| monthRange  | `[number,number]`                                           | `[1, 12]`                            | N    | 月份范围。         |
+| hourRange   | `[number,number]`                                           | `[0, 23]`                            | N    | 小时范围。         |
+| minuteRange | `[number,number]`                                           | `[0, 59]`                            | N    | 分钟范围。         |
+| secondRange | `[number,number]`                                           | `[0, 59]`                            | N    | 秒钟范围。         |
+| showTips    | `boolean`                                                   | `true`                               | N    | 是否显示提示信息。 |
+| cancelText  | `string`                                                    | 当前语言的 timePicker.defaultCancel  | N    | 取消选项文本。     |
+| confirmText | `string`                                                    | 当前语言的 timePicker.defaultConfirm | N    | 确定选项文本。     |
+| title       | `string`                                                    | 当前语言的 timePicker.defaultTitle   | N    | 中间标题文本。     |
+| yearText    | `string`                                                    | 当前语言的 timePicker.defaultYear    | N    | 年份列提示文本。   |
+| monthText   | `string`                                                    | 当前语言的 timePicker.defaultMonth   | N    | 月份列提示文本。   |
+| dayText     | `string`                                                    | 当前语言的 timePicker.defaultDay     | N    | 日期列提示文本。   |
+| hourText    | `string`                                                    | 当前语言的 timePicker.defaultHour    | N    | 小时列提示文本。   |
+| minuteText  | `string`                                                    | 当前语言的 timePicker.defaultMinute  | N    | 分钟列提示文本。   |
+| secondText  | `string`                                                    | 当前语言的 timePicker.defaultSecond  | N    | 秒钟列提示文本。   |
+| outFormat   | `string`                                                    | `''`                                 | N    | 返回数据格式。     |
+| popup       | [`Popup`](https://stdf.design/#/components?nav=popup&tab=1) | `{}`                                 | N    | 弹出层参数。       |
 
 ## TimePicker Events
 
-| 名称    | 参数                                                                                            | 描述                 |
-| ------- | ----------------------------------------------------------------------------------------------- | -------------------- |
-| open    | -                                                                                               | 打开时触发。         |
-| close   | -                                                                                               | 关闭时触发。         |
-| cancel  | -                                                                                               | 点击左侧取消时触发。 |
-| confirm | event:事件对象,其中 detail 内有一个参数 times:选定时间之后返回的格式化时间字符串或时间对象。 | 点击右侧确定时触发。 |
+| 名称      | 类型                                                | 参数                                                   | 描述                 |
+| --------- | --------------------------------------------------- | ------------------------------------------------------ | -------------------- |
+| onclose   | `() => void`                                        | -                                                      | 关闭时触发。         |
+| oncancel  | `() => void`                                        | -                                                      | 点击左侧取消时触发。 |
+| onconfirm | `(timeStr: string, timeObj: TimePickerObj) => void` | timeStr - 格式化后的时间字符串<br />timeObj - 时间对象 | 点击右侧确定时触发。 |
 
-## yearProps
+## TimePickerItem Props
 
-| 属性    | 类型   | 默认值   | 可选值                  | 必传 | 说明                     |
-| ------- | ------ | -------- | ----------------------- | ---- | ------------------------ |
-| flex    | Number | 1        | -                       | N    | 年数据列所占的宽度比例。 |
-| showRow | Number | 5        | 3/5/7                   | N    | 年数据列可见行数。       |
-| align   | String | 'center' | 'left'/'center'/'right' | N    | 年数据列对齐方式。       |
+| 名称    | 类型                        | 默认值     | 必传 | 说明                                         |
+| ------- | --------------------------- | ---------- | ---- | -------------------------------------------- |
+| flex    | `number`                    | `1`        | N    | 年、月、日、时、分、秒数据列所占的宽度比例。 |
+| showRow | `3\|5\|7`                   | `5`        | N    | 年、月、日、时、分、秒数据列可见行数。       |
+| align   | `'left'\|'center'\|'right'` | `'center'` | N    | 年、月、日、时、分、秒数据列对齐方式。       |
 
-## monthProps
+## TimePickerType
 
-| 属性    | 类型   | 默认值   | 可选值                  | 必传 | 说明                     |
-| ------- | ------ | -------- | ----------------------- | ---- | ------------------------ |
-| flex    | Number | 1        | -                       | N    | 月数据列所占的宽度比例。 |
-| showRow | Number | 5        | 3/5/7                   | N    | 月数据列可见行数。       |
-| align   | String | 'center' | 'left'/'center'/'right' | N    | 月数据列对齐方式。       |
+```javascript
+type TimePickerType =
+	| 'YYYY'
+	| 'MM'
+	| 'hh'
+	| 'mm'
+	| 'ss'
+	| 'YYYYMM'
+	| 'hhmm'
+	| 'mmss'
+	| 'YYYYMMDD'
+	| 'hhmmss'
+	| 'YYYYMMDDhh'
+	| 'YYYYMMDDhhmm'
+	| 'YYYYMMDDhhmmss';
+```
 
-## dayProps
+## TimePickerObj
 
-| 属性    | 类型   | 默认值   | 可选值                  | 必传 | 说明                     |
-| ------- | ------ | -------- | ----------------------- | ---- | ------------------------ |
-| flex    | Number | 1        | -                       | N    | 日数据列所占的宽度比例。 |
-| showRow | Number | 5        | 3/5/7                   | N    | 日数据列可见行数。       |
-| align   | String | 'center' | 'left'/'center'/'right' | N    | 日数据列对齐方式。       |
-
-## hourProps
-
-| 属性    | 类型   | 默认值   | 可选值                  | 必传 | 说明                     |
-| ------- | ------ | -------- | ----------------------- | ---- | ------------------------ |
-| flex    | Number | 1        | -                       | N    | 时数据列所占的宽度比例。 |
-| showRow | Number | 5        | 3/5/7                   | N    | 时数据列可见行数。       |
-| align   | String | 'center' | 'left'/'center'/'right' | N    | 时数据列对齐方式。       |
-
-## minuteProps
-
-| 属性    | 类型   | 默认值   | 可选值                  | 必传 | 说明                     |
-| ------- | ------ | -------- | ----------------------- | ---- | ------------------------ |
-| flex    | Number | 1        | -                       | N    | 分数据列所占的宽度比例。 |
-| showRow | Number | 5        | 3/5/7                   | N    | 分数据列可见行数。       |
-| align   | String | 'center' | 'left'/'center'/'right' | N    | 分数据列对齐方式。       |
-
-## secondProps
-
-| 属性    | 类型   | 默认值   | 可选值                  | 必传 | 说明                     |
-| ------- | ------ | -------- | ----------------------- | ---- | ------------------------ |
-| flex    | Number | 1        | -                       | N    | 秒数据列所占的宽度比例。 |
-| showRow | Number | 5        | 3/5/7                   | N    | 秒数据列可见行数。       |
-| align   | String | 'center' | 'left'/'center'/'right' | N    | 秒数据列对齐方式。       |
+```javascript
+type TimePickerObj = { YYYY: string; MM: string; DD: string; hh: string; mm: string; ss: string };
+```

+ 67 - 83
doc/components/timePicker/api_en.md

@@ -1,94 +1,78 @@
 ## TimePicker Props
 
-| Property    | Type    | Default Value                                       | Optional Values                           | Required | Description                         |
-| ----------- | ------- | --------------------------------------------------- | ----------------------------------------- | -------- | ----------------------------------- |
-| visible     | Boolean | false                                               | true/false                                | No       | Whether to show.                    |
-| type        | String  | 'YMDhms'                                            | Combination of Y M D h m s, totalling 13  | No       | Type of time.                       |
-| yearProps   | Object  | {}                                                  | Refer to yearProps                        | No       | Year column params.                 |
-| monthProps  | Object  | {}                                                  | Refer to monthProps                       | No       | Month column params.                |
-| dayProps    | Object  | {}                                                  | Refer to dayProps                         | No       | Day column params.                  |
-| hourProps   | Object  | {}                                                  | Refer to hourProps                        | No       | Hour column params.                 |
-| minuteProps | Object  | {}                                                  | Refer to minuteProps                      | No       | Minute column params.               |
-| secondProps | Object  | {}                                                  | Refer to secondProps                      | No       | Second column params.               |
-| initYear    | String  | ''                                                  | -                                         | No       | Initial selected year.              |
-| initMonth   | String  | ''                                                  | -                                         | No       | Initial selected month.             |
-| initDay     | String  | ''                                                  | -                                         | No       | Initial selected date.              |
-| initHour    | String  | ''                                                  | -                                         | No       | Initial selected hour.              |
-| initMinute  | String  | ''                                                  | -                                         | No       | Initial selected minute.            |
-| initSecond  | String  | ''                                                  | -                                         | No       | Initial selected second.            |
-| minuteStep  | Number  | 1                                                   | -                                         | N        | The step size for minutes.          |
-| secondStep  | Number  | 1                                                   | -                                         | N        | The step size for seconds.          |
-| yearRange   | Array   | []                                                  | -                                         | N        | The range of years.                 |
-| monthRange  | Array   | [1, 12]                                             | -                                         | N        | The range of months.                |
-| hourRange   | Array   | [0, 23]                                             | -                                         | N        | The range of hours.                 |
-| minuteRange | Array   | [0, 59]                                             | -                                         | N        | The range of minutes.               |
-| secondRange | Array   | [0, 59]                                             | -                                         | N        | The range of seconds.               |
-| showTips    | Boolean | true                                                | true/false                                | N        | Whether to show the tips.           |
-| cancelText  | String  | The default cancel text in the current language     | -                                         | N        | The text for cancel option.         |
-| confirmText | String  | `timePicker.defaultConfirm` in the current language | -                                         | N        | The text for the confirm option.    |
-| title       | String  | `timePicker.defaultTitle` in the current language   | -                                         | N        | The text for the middle title.      |
-| yearText    | String  | `timePicker.defaultYear` in the current language    | -                                         | N        | The text for the year column tip.   |
-| monthText   | String  | `timePicker.defaultMonth` in the current language   | -                                         | N        | The text for the month column tip.  |
-| dayText     | String  | `timePicker.defaultDay` in the current language     | -                                         | N        | The text for the day column tip.    |
-| hourText    | String  | `timePicker.defaultHour` in the current language    | -                                         | N        | The text for the hour column tip.   |
-| minuteText  | String  | `timePicker.defaultMinute` in the current language  | -                                         | N        | The text for the minute column tip. |
-| secondText  | String  | `timePicker.defaultSecond` in the current language  | -                                         | N        | The text for the second column tip. |
-| outFormat   | String  | ''                                                  | 'object' or a combination of Y M D h m s. | N        | The data output format.             |
-| popup       | Object  | {}                                                  | Refer to Popup Props                      | N        | The parameters for the popup layer. |
+| Name        | Type                                                        | Default                                    | Required | Description                 |
+| ----------- | ----------------------------------------------------------- | ------------------------------------------ | -------- | --------------------------- |
+| visible     | `boolean`                                                   | `false`                                    | N        | Whether to show the picker. |
+| type        | `TimePickerType`                                            | `'YYYYMMDDhhmmss'`                         | N        | Time type.                  |
+| yearProps   | `TimePickerItem`                                            | `{}`                                       | N        | Year column parameters.     |
+| monthProps  | `TimePickerItem`                                            | `{}`                                       | N        | Month column parameters.    |
+| dayProps    | `TimePickerItem`                                            | `{}`                                       | N        | Day column parameters.      |
+| hourProps   | `TimePickerItem`                                            | `{}`                                       | N        | Hour column parameters.     |
+| minuteProps | `TimePickerItem`                                            | `{}`                                       | N        | Minute column parameters.   |
+| secondProps | `TimePickerItem`                                            | `{}`                                       | N        | Second column parameters.   |
+| initYear    | `string`                                                    | `''`                                       | N        | Initial selected year.      |
+| initMonth   | `string`                                                    | `''`                                       | N        | Initial selected month.     |
+| initDay     | `string`                                                    | `''`                                       | N        | Initial selected day.       |
+| initHour    | `string`                                                    | `''`                                       | N        | Initial selected hour.      |
+| initMinute  | `string`                                                    | `''`                                       | N        | Initial selected minute.    |
+| initSecond  | `string`                                                    | `''`                                       | N        | Initial selected second.    |
+| minuteStep  | `number`                                                    | `1`                                        | N        | Minute step.                |
+| secondStep  | `number`                                                    | `1`                                        | N        | Second step.                |
+| yearRange   | `[number,number]\|[]`                                       | `[]`                                       | N        | Year range.                 |
+| monthRange  | `[number,number]`                                           | `[1, 12]`                                  | N        | Month range.                |
+| hourRange   | `[number,number]`                                           | `[0, 23]`                                  | N        | Hour range.                 |
+| minuteRange | `[number,number]`                                           | `[0, 59]`                                  | N        | Minute range.               |
+| secondRange | `[number,number]`                                           | `[0, 59]`                                  | N        | Second range.               |
+| showTips    | `boolean`                                                   | `true`                                     | N        | Whether to show tips.       |
+| cancelText  | `string`                                                    | Current language timePicker.defaultCancel  | N        | Cancel button text.         |
+| confirmText | `string`                                                    | Current language timePicker.defaultConfirm | N        | Confirm button text.        |
+| title       | `string`                                                    | Current language timePicker.defaultTitle   | N        | Title text.                 |
+| yearText    | `string`                                                    | Current language timePicker.defaultYear    | N        | Year column tip text.       |
+| monthText   | `string`                                                    | Current language timePicker.defaultMonth   | N        | Month column tip text.      |
+| dayText     | `string`                                                    | Current language timePicker.defaultDay     | N        | Day column tip text.        |
+| hourText    | `string`                                                    | Current language timePicker.defaultHour    | N        | Hour column tip text.       |
+| minuteText  | `string`                                                    | Current language timePicker.defaultMinute  | N        | Minute column tip text.     |
+| secondText  | `string`                                                    | Current language timePicker.defaultSecond  | N        | Second column tip text.     |
+| outFormat   | `string`                                                    | `''`                                       | N        | Output data format.         |
+| popup       | [`Popup`](https://stdf.design/#/components?nav=popup&tab=1) | `{}`                                       | N        | Popup parameters.           |
 
 ## TimePicker Events
 
-| Name    | Parameters                                                                                                                         | Description                                                       |
-| ------- | ---------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- |
-| open    | -                                                                                                                                  | Triggered when the time picker opens.                             |
-| close   | -                                                                                                                                  | Triggered when the time picker closes.                            |
-| cancel  | -                                                                                                                                  | Triggered when the "cancel" option on the left side is clicked.   |
-| confirm | event: Event Object, which contains a parameter times: the formatted time string or time object returned after selecting the time. | Triggered when the "confirm" option on the right side is clicked. |
+| Name      | Type                                                | Parameters                                                 | Description                             |
+| --------- | --------------------------------------------------- | ---------------------------------------------------------- | --------------------------------------- |
+| onclose   | `() => void`                                        | -                                                          | Triggered when closing.                 |
+| oncancel  | `() => void`                                        | -                                                          | Triggered when clicking cancel button.  |
+| onconfirm | `(timeStr: string, timeObj: TimePickerObj) => void` | timeStr - Formatted time string<br />timeObj - Time object | Triggered when clicking confirm button. |
 
-## yearProps
+## TimePickerItem Props
 
-| Property | Type   | Default Value | Optional Values         | Required | Description                                         |
-| -------- | ------ | ------------- | ----------------------- | -------- | --------------------------------------------------- |
-| flex     | Number | 1             | -                       | N        | The width proportion of the year data column.       |
-| showRow  | Number | 5             | 3/5/7                   | N        | The number of visible rows in the year data column. |
-| align    | String | 'center'      | 'left'/'center'/'right' | N        | The alignment of the year data column.              |
+| Name    | Type                        | Default    | Required | Description                                                     |
+| ------- | --------------------------- | ---------- | -------- | --------------------------------------------------------------- |
+| flex    | `number`                    | `1`        | N        | Width ratio of year, month, day, hour, minute, second columns.  |
+| showRow | `3\|5\|7`                   | `5`        | N        | Visible rows of year, month, day, hour, minute, second columns. |
+| align   | `'left'\|'center'\|'right'` | `'center'` | N        | Alignment of year, month, day, hour, minute, second columns.    |
 
-## monthProps
+## TimePickerType
 
-| Property | Type   | Default Value | Optional Values         | Required | Description                                          |
-| -------- | ------ | ------------- | ----------------------- | -------- | ---------------------------------------------------- |
-| flex     | Number | 1             | -                       | N        | The width proportion of the month data column.       |
-| showRow  | Number | 5             | 3/5/7                   | N        | The number of visible rows in the month data column. |
-| align    | String | 'center'      | 'left'/'center'/'right' | N        | The alignment of the month data column.              |
+```javascript
+type TimePickerType =
+	| 'YYYY'
+	| 'MM'
+	| 'hh'
+	| 'mm'
+	| 'ss'
+	| 'YYYYMM'
+	| 'hhmm'
+	| 'mmss'
+	| 'YYYYMMDD'
+	| 'hhmmss'
+	| 'YYYYMMDDhh'
+	| 'YYYYMMDDhhmm'
+	| 'YYYYMMDDhhmmss';
+```
 
-## dayProps
+## TimePickerObj
 
-| Property | Type   | Default Value | Optional Values         | Required | Description                                        |
-| -------- | ------ | ------------- | ----------------------- | -------- | -------------------------------------------------- |
-| flex     | Number | 1             | -                       | N        | The width proportion of the day data column.       |
-| showRow  | Number | 5             | 3/5/7                   | N        | The number of visible rows in the day data column. |
-| align    | String | 'center'      | 'left'/'center'/'right' | N        | The alignment of the day data column.              |
-
-## hourProps
-
-| Property | Type   | Default Value | Optional Values         | Required | Description                                         |
-| -------- | ------ | ------------- | ----------------------- | -------- | --------------------------------------------------- |
-| flex     | Number | 1             | -                       | N        | The width proportion of the hour data column.       |
-| showRow  | Number | 5             | 3/5/7                   | N        | The number of visible rows in the hour data column. |
-| align    | String | 'center'      | 'left'/'center'/'right' | N        | The alignment of the hour data column.              |
-
-## minuteProps
-
-| Property | Type   | Default Value | Optional Values         | Required | Description                                           |
-| -------- | ------ | ------------- | ----------------------- | -------- | ----------------------------------------------------- |
-| flex     | Number | 1             | -                       | N        | The width proportion of the minute data column.       |
-| showRow  | Number | 5             | 3/5/7                   | N        | The number of visible rows in the minute data column. |
-| align    | String | 'center'      | 'left'/'center'/'right' | N        | The alignment of the minute data column.              |
-
-## secondProps
-
-| Property | Type   | Default Value | Optional Values         | Required | Description                                           |
-| -------- | ------ | ------------- | ----------------------- | -------- | ----------------------------------------------------- |
-| flex     | Number | 1             | -                       | N        | The width proportion of the second data column.       |
-| showRow  | Number | 5             | 3/5/7                   | N        | The number of visible rows in the second data column. |
-| align    | String | 'center'      | 'left'/'center'/'right' | N        | The alignment of the second data column.              |
+```javascript
+type TimePickerObj = { YYYY: string; MM: string; DD: string; hh: string; mm: string; ss: string };
+```

+ 18 - 17
doc/components/timePicker/guide.md

@@ -4,21 +4,22 @@ TimePicker 组件用于选择时间,支持单列选择和多列选择。默认
 
 ## 时间类型
 
-TimePicker 组件通过传入的 type 参数来决定选择的时间类型,由 Y M D h m s 组合而来,目前共支持以下 13 种,不在此列出的类型将使用默认的 'YMDhms' 类型。
-
-- Y:年
-- M:月
-- h:时
-- m:分
-- s:秒
-- YM:年月
-- hm:时分
-- ms:分秒
-- YMD:年月日
-- hms:时分秒
-- YMDh:年月日时
-- YMDhm:年月日时分
-- YMDhms:年月日时分秒
+TimePicker 组件通过传入的 type 参数来决定选择的时间类型,由 YYYY MM DD hh mm ss 组合而来,目前共支持以下 13 种,不在此列出的类型将使用默认的 'YYYYMMDDhhmmss' 类型。
+
+- YYYY:年
+- MM:月
+- DD:日
+- hh:时
+- mm:分
+- ss:秒
+- YYYYMM:年月
+- hhmm:时分
+- mmss:分秒
+- YYYYMMDD:年月日
+- hhmmss:时分秒
+- YYYYMMDDhh:年月日时
+- YYYYMMDDhhmm:年月日时分
+- YYYYMMDDhhmmss:年月日时分秒
 
 ## 单列样式
 
@@ -38,9 +39,9 @@ TimePicker 组件通过传入的 type 参数来决定选择的时间类型,由
 
 ## outFormat
 
-默认情况下,TimePicker 组件的 outFormat 由传入的 type 按照『年月日之间用 - 连接,时分秒之间用 : 连接,两者之间用空格连接』的规则生成,比如转入 YMD 对应 Y-M-D,YMDh 对应 Y-M-D h, hms 对应 h:m:s 等。当然也可以自定义输出格式。具体使用请参考示例。
+默认情况下,TimePicker 组件的 outFormat 由传入的 type 按照 【年月日之间用 - 连接,时分秒之间用 : 连接,两者之间用空格连接】的规则生成,比如转入 `'YYYYMMDD'` 对应 `YYYY-MM-DD`,`'YYYYMMDDhh'` 对应 `YYYY-MM-DD hh`,`'hhmmss'` 对应 `hh:mm:ss` 等。当然也可以自定义输出格式。具体使用请参考示例。
 
-需要注意的是,如果传入的 outFormat 是空字符串,则不会对选择的时间进行格式化,而是直接返回选择的时间对象,也方便开发者自行处理。
+需要注意的是,onconfirm 返回的第二个参数是选择的时间对象,方便开发者自行处理。
 
 ## 说明
 

+ 28 - 27
doc/components/timePicker/guide_en.md

@@ -1,47 +1,48 @@
-## Usage Scenario
+## Usage Scenarios
 
-The TimePicker component is used to select time and supports single and multiple column selection. The default parameter selects the time ten years before and after, and the current time is selected by default.
+The TimePicker component is used for time selection, supporting both single-column and multi-column selection. By default, it allows selection of time within 10 years before and after the current year, and initially selects the current time.
 
 ## Time Types
 
-The TimePicker component determines the selected time type based on the type parameter passed in, which is composed of Y, M, D, h, m, and s. Currently, a total of 13 types are supported, and types not listed here will use the default 'YMDhms' type.
-
-- Y: Year
-- M: Month
-- h: Hour
-- m: Minute
-- s: Second
-- YM: Year and month
-- hm: Hour and minute
-- ms: Minute and second
-- YMD: Year, month, and day
-- hms: Hour, minute, and second
-- YMDh: Year, month, day, and hour
-- YMDhm: Year, month, day, hour, and minute
-- YMDhms: Year, month, day, hour, minute, and second
+The TimePicker component determines the time type through the type parameter, which is composed of YYYY MM DD hh mm ss. Currently, it supports the following 13 types. Any type not listed here will use the default 'YYYYMMDDhhmmss' type.
+
+- YYYY: Year
+- MM: Month
+- DD: Day
+- hh: Hour
+- mm: Minute
+- ss: Second
+- YYYYMM: Year and Month
+- hhmm: Hour and Minute
+- mmss: Minute and Second
+- YYYYMMDD: Year, Month and Day
+- hhmmss: Hour, Minute and Second
+- YYYYMMDDhh: Year, Month, Day and Hour
+- YYYYMMDDhhmm: Year, Month, Day, Hour and Minute
+- YYYYMMDDhhmmss: Year, Month, Day, Hour, Minute and Second
 
 ## Single Column Style
 
-The columns for year, month, day, hour, minute, and second data can all be customized with three styles by passing in the corresponding props, which are flex, showRow, and align. Please refer to the example for specific usage.
+For all column data (year, month, day, hour, minute, second), you can customize three styles by passing corresponding Props: flex, showRow, and align. Please refer to the examples for specific usage.
 
-## Limiting the Selection Range
+## Selection Range Limitation
 
-Because the number of days per month will dynamically update based on the current year and month, except for the column for day data, all other column data can be limited to a selection range by passing in the corresponding range, which is an array consisting of the corresponding data. However, please ensure that the range array passed in has two items, **each of which is a number**, and the first item is less than the second item, otherwise the default range will be used. Please refer to the example for specific usage.
+Since the number of days in each month updates dynamically based on the current year and month, all column data except days can have their selection range limited by passing in the corresponding Range, which is an array of corresponding data. However, please ensure that the range array has two items, **each item being of Number type**, and the first item is less than the second item, otherwise the default range will be used. Please refer to the examples for specific usage.
 
-## Initial Value
+## Initial Selected Value
 
-By default, each column of data is initialized to the current time. It also supports passing in the corresponding initial value to customize the initial selection. However, it should be noted that the type of the initial value passed in is a character type, and **ensure that the initial values for months, days, hours, minutes, and seconds are padded to two digits if less than two digits**. Please refer to the example for specific usage.
+By default, each column data initially selects the current time, but you can also pass in corresponding initial values to customize the initially selected value. Note that the initial value type should be string type, and **ensure that month, day, hour, minute, and second initial values are padded to two digits if less than two digits**. Please refer to the examples for specific usage.
 
 ## Minute and Second Step
 
-Considering the actual usage, support for setting the step size for minute and second data is added. The step size is 1 by default, so each selection will increase by 1 minute or 1 second. Please refer to the example for specific usage.
+Considering practical use, the component supports step settings for minute and second data. The default step is 1, meaning each selection increases by 1 minute or 1 second. Please refer to the examples for specific usage.
 
 ## outFormat
 
-By default, the outFormat of the TimePicker component is generated based on the type passed in, following the rule of "connecting with - between year, month, and day, connecting with : between hour, minute, and second, and connecting with a space between them", for example, YMD corresponds to Y-M-D, YMDh corresponds to Y-M-D h, and hms corresponds to h:m:s, etc. Of course, you can also customize the output format. Please refer to the example for specific usage.
+By default, the TimePicker component's outFormat is generated from the input type following the rule [years, months, and days are connected by -, hours, minutes, and seconds are connected by :, and the two parts are connected by space]. For example, `'YYYYMMDD'` corresponds to `YYYY-MM-DD`, `'YYYYMMDDhh'` corresponds to `YYYY-MM-DD hh`, `'hhmmss'` corresponds to `hh:mm:ss`, etc. Of course, you can also customize the output format. Please refer to the examples for specific usage.
 
-Please note that if the outFormat passed in is an empty string, the selected time will not be formatted, but the time object will be returned directly, which is also convenient for developers to handle themselves.
+Note that the second parameter returned by onconfirm is the selected time object, making it convenient for developers to handle themselves.
 
-## Description
+## Note
 
-The TimePicker is encapsulated based on the Popup, and is implemented by predefining some of the Popup Props. Therefore, different effects can be achieved by passing in the Popup attributes. For example, in the example, the radius of the popup is changed to change the rounded style.
+TimePicker is encapsulated based on Popup by pre-defining some Popup Props, so different effects can be achieved by passing in Popup properties. For example, in the example, the radius style is changed by setting the popup's radius.

+ 82 - 132
packages/stdf/components/timePicker/TimePicker.svelte

@@ -14,7 +14,7 @@
 	/** @type {TimePickerProps} */
 	let {
 		visible = $bindable(false),
-		type = 'YMDhms',
+		type = 'YYYYMMDDhhmmss',
 		yearProps = {},
 		monthProps = {},
 		dayProps = {},
@@ -46,7 +46,6 @@
 		secondText = timePickerLang.defaultSecond,
 		outFormat = '',
 		popup = {},
-		onopen,
 		onclose,
 		onconfirm,
 		oncancel,
@@ -65,24 +64,24 @@
 	// 总共可以传入 13 种 type,做一个映射,方便后面使用
 	// A total of 13 types can be passed in, do a mapping, and it is convenient to use later
 	const typeMap = {
-		Y: 'Y',
-		M: 'M',
-		h: 'h',
-		m: 'm',
-		s: 's',
-		YM: 'YM',
-		hm: 'hm',
-		ms: 'ms',
-		YMD: 'YMD',
-		hms: 'hms',
-		YMDh: 'YMDh',
-		YMDhm: 'YMDhm',
-		YMDhms: 'YMDhms',
+		YYYY: 'YYYY',
+		MM: 'MM',
+		hh: 'hh',
+		mm: 'mm',
+		ss: 'ss',
+		YYYYMM: 'YYYYMM',
+		hhmm: 'hhmm',
+		mmss: 'mmss',
+		YYYYMMDD: 'YYYYMMDD',
+		hhmmss: 'hhmmss',
+		YYYYMMDDhh: 'YYYYMMDDhh',
+		YYYYMMDDhhmm: 'YYYYMMDDhhmm',
+		YYYYMMDDhhmmss: 'YYYYMMDDhhmmss',
 	};
 
 	// 定义 typeInner,对不在 typeMap 的 type 做一个过滤,不在 typeMap 的 type 设置为默认值 YMDhms
 	// Define typeInner, filter out types that are not in typeMap, and set types that are not in typeMap to the default value YMDhms
-	let typeInner = typeMap[type] || 'YMDhms';
+	let typeInner = typeMap[type] || 'YYYYMMDDhhmmss';
 
 	// 如果 yearRange 长度为2且后一项大于前一项,表示限定区间,否则取当前年的的前后 10 年
 	// If the length of yearRange is 2 and the second item is greater than the first item, it means that the range is limited, otherwise the previous and next 10 years of the current year are taken
@@ -239,8 +238,7 @@
 
 	// 年数据滚动结束时的回调函数
 	// Callback function when the year data scrolling ends
-	const scrollEndYearFunc = e => {
-		const { index, isTouch } = e.detail;
+	const scrollEndYearFunc = (index, isTouch) => {
 		yearIndex = index;
 		// 如果月份是 2 月,需要重新计算天数
 		// If the month is February, the number of days needs to be recalculated
@@ -255,8 +253,7 @@
 
 	// 月数据滚动结束时的回调函数
 	// Callback function when the month data scrolling ends
-	const scrollEndMonthFunc = e => {
-		const { index, isTouch } = e.detail;
+	const scrollEndMonthFunc = (index, isTouch) => {
 		monthIndex = index;
 		// 根据年份和月份获取对应的天数
 		// Get the number of days corresponding to the year and month according to the year and month
@@ -269,46 +266,19 @@
 		}
 	};
 
-	// 日数据滚动结束时的回调函数
-	// Callback function when the day data scrolling ends
-	const scrollEndDayFunc = e => {
-		const { index } = e.detail;
-		dayIndex = index;
-	};
-
-	// 时数据滚动结束时的回调函数
-	// Callback function when the hour data scrolling ends
-	const scrollEndHourFunc = e => {
-		const { index } = e.detail;
-		hourIndex = index;
-	};
-
-	// 分数据滚动结束时的回调函数
-	// Callback function when the minute data scrolling ends
-	const scrollEndMinuteFunc = e => {
-		const { index } = e.detail;
-		minuteIndex = index;
-	};
-
-	// 秒数据滚动结束时的回调函数
-	// Callback function when the second data scrolling ends
-	const scrollEndSecondFunc = e => {
-		const { index } = e.detail;
-		secondIndex = index;
-	};
-
 	// 点击取消按钮的回调函数
 	// Callback function when clicking the cancel button
 	const clickCancelFunc = () => {
 		visible = false;
 		oncancel && oncancel();
+		onclose && onclose();
 	};
 
 	// 传入时间格式与时间对象,返回时间字符串
 	// Pass in the time format and time object, return the time string
 	const getTimeStr = (format, timeObj) => {
-		const { Y, M, D, h, m, s } = timeObj;
-		const timeStr = format.replace('Y', Y).replace('M', M).replace('D', D).replace('h', h).replace('m', m).replace('s', s);
+		const { YYYY, MM, DD, hh, mm, ss } = timeObj;
+		const timeStr = format.replace('YYYY', YYYY).replace('MM', MM).replace('DD', DD).replace('hh', hh).replace('mm', mm).replace('ss', ss);
 		return timeStr;
 	};
 
@@ -316,86 +286,60 @@
 	// Callback function when clicking the confirm button
 	const clickConfirmFunc = () => {
 		visible = false;
+		onclose && onclose();
 		const outData = {};
-		if (typeInner.includes('Y')) {
-			outData.Y = yearData[yearIndex].label;
+		if (typeInner.includes('YYYY')) {
+			outData.YYYY = yearData[yearIndex].label;
 		}
-		if (typeInner.includes('M')) {
-			outData.M = baseMonthData[monthIndex].label;
+		if (typeInner.includes('MM')) {
+			outData.MM = baseMonthData[monthIndex].label;
 		}
-		if (typeInner.includes('D')) {
-			outData.D = baseDayData[dayIndex].label;
+		if (typeInner.includes('DD')) {
+			outData.DD = baseDayData[dayIndex].label;
 		}
-		if (typeInner.includes('h')) {
-			outData.h = baseHourData[hourIndex].label;
+		if (typeInner.includes('hh')) {
+			outData.hh = baseHourData[hourIndex].label;
 		}
-		if (typeInner.includes('m')) {
-			outData.m = baseMinuteData[minuteIndex].label;
+		if (typeInner.includes('mm')) {
+			outData.mm = baseMinuteData[minuteIndex].label;
 		}
-		if (typeInner.includes('s')) {
-			outData.s = baseSecondData[secondIndex].label;
+		if (typeInner.includes('ss')) {
+			outData.ss = baseSecondData[secondIndex].label;
 		}
 
-		// 如果传入的 outFormat 为空,则根据 type 格式,否则去除里面的 YMDhms 以外的字符,再按照 YMDhms 的顺序拼接,再与 typeInner 比对,如果不一致,则给出警告
-		// If the outFormat passed in is empty, it is formatted according to the type, otherwise the characters other than YMDhms are removed, and then they are spliced in the order of YMDhms, and then compared with typeInner. If they are inconsistent, a warning will be given
-		if (outFormat === 'object') {
-			// 如果 outFormat 为 object,则返回时间对象
-			// If outFormat is empty, return the time object
-			onconfirm && onconfirm(outData);
-		} else {
-			// 如果 outFormat 为空,则根据 type 格式
-			// If outFormat is empty, format according to type
-			if (outFormat === '') {
-				// 预先根据 typeInner 生成一份 defaultOutFormat 字符,年月日之间用 - 连接,时分秒之间用 : 连接,年月日和时分秒之间用空格连接
-				// Generate a copy of defaultOutFormat characters according to typeInner in advance, and connect the year, month and day with -, and connect the hour, minute and second with :, and connect the year, month, day and hour, minute and second with spaces
-				let defaultOutFormat = typeInner
-					.replace(/Y/g, 'Y-')
-					.replace(/M/g, 'M-')
-					.replace(/D/g, 'D ')
-					.replace(/h/g, 'h:')
-					.replace(/m/g, 'm:')
-					.replace(/s/g, 's');
-				// 如果 defaultOutFormat 以 - 或 : 或空格 结尾,则去掉最后一个字符
-				// If defaultOutFormat ends with - or : or space, remove the last character
-				if (defaultOutFormat.endsWith('-') || defaultOutFormat.endsWith(':') || defaultOutFormat.endsWith(' ')) {
-					defaultOutFormat = defaultOutFormat.slice(0, -1);
-				}
-				onconfirm && onconfirm(getTimeStr(defaultOutFormat, outData));
-			} else {
-				// 删除掉 outFormat 里面 YMDhms 以外的所有字符
-				// Delete all characters other than YMDhms in outFormat
-				const outFormatInner = outFormat.replace(/[^YMDhms]/g, '');
-				// 对 outFormatInner 字符按照 YMDhms 的顺序进行排序
-				// Sort the outFormatInner character in the order of YMDhms
-				const outFormatInnerArr = outFormatInner.split('');
-				outFormatInnerArr.sort((a, b) => {
-					const aIndex = typeInner.indexOf(a);
-					const bIndex = typeInner.indexOf(b);
-					return aIndex - bIndex;
-				});
-				const outFormatInnerSort = outFormatInnerArr.join('');
-
-				//  如果 outFormatInnerSort 与 typeInner 不一致,则给出警告
-				// If outFormatInnerSort is inconsistent with typeInner, a warning will be given
-				if (outFormatInnerSort !== typeInner) {
-					console.warn('The outFormat passed in is not consistent with the typeInner');
-				} else {
-					// 如果 outFormat 为空,则返回时间对象,否则返回时间字符串
-					// If outFormat is empty, return the time object, otherwise return the time string
-					onconfirm && onconfirm(getTimeStr(outFormat, outData));
-				}
+		// 如果 outFormat 为空,则根据 type 格式
+		// If outFormat is empty, format according to type
+		if (outFormat === '') {
+			// 预先根据 typeInner 生成一份 defaultOutFormat 字符,年月日之间用 - 连接,时分秒之间用 : 连接,年月日和时分秒之间用空格连接
+			// Generate a copy of defaultOutFormat characters according to typeInner in advance, and connect the year, month and day with -, and connect the hour, minute and second with :, and connect the year, month, day and hour, minute and second with spaces
+			let defaultOutFormat = typeInner
+				.replace(/YYYY/g, 'YYYY-')
+				.replace(/MM/g, 'MM-')
+				.replace(/DD/g, 'DD ')
+				.replace(/hh/g, 'hh:')
+				.replace(/mm/g, 'mm:')
+				.replace(/ss/g, 'ss');
+			// 如果 defaultOutFormat 以 - 或 : 或空格 结尾,则去掉最后一个字符
+			// If defaultOutFormat ends with - or : or space, remove the last character
+			if (defaultOutFormat.endsWith('-') || defaultOutFormat.endsWith(':') || defaultOutFormat.endsWith(' ')) {
+				defaultOutFormat = defaultOutFormat.slice(0, -1);
 			}
-		}
-	};
-	// 监听 visible 的变化,派发事件
-	// Listen to the change of visible, dispatch events
-	$effect(() => {
-		if (visible) {
-			onopen && onopen();
+			onconfirm && onconfirm(getTimeStr(defaultOutFormat, outData), outData);
 		} else {
-			onclose && onclose();
+			// 将 outFormat 里面 YYYY MM DD hh mm ss 替换为对应的 outData 中的值
+			// Replace YYYY MM DD hh mm ss in outFormat with the corresponding value in outData
+			const outFormatInner = outFormat
+				.replace(/YYYY/g, outData.YYYY)
+				.replace(/MM/g, outData.MM)
+				.replace(/DD/g, outData.DD)
+				.replace(/hh/g, outData.hh)
+				.replace(/mm/g, outData.mm)
+				.replace(/ss/g, outData.ss);
+			// 如果 outFormat 为空,则返回时间对象,否则返回时间字符串
+			// If outFormat is empty, return the time object, otherwise return the time string
+			onconfirm && onconfirm(getTimeStr(outFormatInner, outData), outData);
 		}
-	});
+	};
 </script>
 
 <Popup
@@ -405,18 +349,14 @@
 	transitionDistance={(maxShowRows === 3 ? 64 : maxShowRows === 5 ? 48 : 32) * maxShowRows + 41 + (showTips ? 32 : 0)}
 	{...popup}
 >
-	<div class="flex justify-between items-center bg-white dark:bg-black border-b border-black/10 dark:border-white/20">
-		<!-- svelte-ignore a11y_click_events_have_key_events -->
-		<!-- svelte-ignore a11y_no_static_element_interactions -->
-		<div class="text-black/60 dark:text-white/60 h-10 leading-10 px-4 cursor-pointer" onclick={clickCancelFunc}>{cancelText}</div>
+	<div class="flex justify-between items-center bg-white border-b dark:bg-black border-black/10 dark:border-white/20">
+		<button class="px-4 h-10 leading-10 cursor-pointer text-black/60 dark:text-white/60" onclick={clickCancelFunc}>{cancelText}</button>
 		<div>{title}</div>
-		<!-- svelte-ignore a11y_click_events_have_key_events -->
-		<!-- svelte-ignore a11y_no_static_element_interactions -->
-		<div class="text-primary dark:text-dark h-10 leading-10 px-4 cursor-pointer" onclick={clickConfirmFunc}>{confirmText}</div>
+		<button class="px-4 h-10 leading-10 cursor-pointer text-primary dark:text-dark" onclick={clickConfirmFunc}>{confirmText}</button>
 	</div>
 	{#if showTips}
 		<div
-			class="flex justify-around items-center text-center gap-1 bg-white dark:bg-black text-black/60 dark:text-white/60 h-8 leading-8 text-sm"
+			class="flex gap-1 justify-around items-center h-8 text-sm leading-8 text-center bg-white dark:bg-black text-black/60 dark:text-white/60"
 		>
 			{#if typeInner.includes('Y')}
 				<div class="px-2" style="flex:{yearProps.flex || '1'};text-align:{yearProps.align}">{yearText}</div>{/if}
@@ -432,7 +372,7 @@
 				<div class="px-2" style="flex:{secondProps.flex || '1'};text-align:{secondProps.align}">{secondText}</div>{/if}
 		</div>
 	{/if}
-	<div class="flex justify-around items-center gap-1 bg-white dark:bg-black">
+	<div class="flex gap-1 justify-around items-center bg-white dark:bg-black">
 		{#if typeInner.includes('Y')}
 			<div class="truncate" style="flex:{yearProps.flex || '1'}">
 				<ScrollRadio data={yearData} initIndex={initYearIndex} autoScrollToLast={false} {...yearProps} onscrollEnd={scrollEndYearFunc} />
@@ -445,22 +385,32 @@
 		{/if}
 		{#if baseDayData.length > 0 && typeInner.includes('D')}
 			<div class="truncate" style="flex:{dayProps.flex || '1'}">
-				<ScrollRadio data={baseDayData} lastSelectedIndex={initDayIndex} {...dayProps} onscrollEnd={scrollEndDayFunc} />
+				<ScrollRadio data={baseDayData} lastSelectedIndex={initDayIndex} {...dayProps} onscrollEnd={index => (dayIndex = index)} />
 			</div>
 		{/if}
 		{#if typeInner.includes('h')}
 			<div class="truncate" style="flex:{hourProps.flex || '1'}">
-				<ScrollRadio data={baseHourData} lastSelectedIndex={initHourIndex} {...hourProps} onscrollEnd={scrollEndHourFunc} />
+				<ScrollRadio data={baseHourData} lastSelectedIndex={initHourIndex} {...hourProps} onscrollEnd={index => (hourIndex = index)} />
 			</div>
 		{/if}
 		{#if typeInner.includes('m')}
 			<div class="truncate" style="flex:{minuteProps.flex || '1'}">
-				<ScrollRadio data={baseMinuteData} lastSelectedIndex={initMinuteIndex} {...minuteProps} onscrollEnd={scrollEndMinuteFunc} />
+				<ScrollRadio
+					data={baseMinuteData}
+					lastSelectedIndex={initMinuteIndex}
+					{...minuteProps}
+					onscrollEnd={index => (minuteIndex = index)}
+				/>
 			</div>
 		{/if}
 		{#if typeInner.includes('s')}
 			<div class="truncate" style="flex:{secondProps.flex || '1'}">
-				<ScrollRadio data={baseSecondData} lastSelectedIndex={initSecondIndex} {...secondProps} onscrollEnd={scrollEndSecondFunc} />
+				<ScrollRadio
+					data={baseSecondData}
+					lastSelectedIndex={initSecondIndex}
+					{...secondProps}
+					onscrollEnd={index => (secondIndex = index)}
+				/>
 			</div>
 		{/if}
 	</div>