@jnrs/vue-core 1.2.39 → 1.2.41

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/AGENTS.md CHANGED
@@ -751,26 +751,30 @@ const dialogVisible = ref(false)
751
751
 
752
752
  #### JnDateQuery
753
753
 
754
- 通用时间查询组件,支持日/周/月/年/日期时间/任意区间/时间区间七种类型切换,配合快捷按钮实现前后时间段快速导航。组件初始化时若未设置值,自动根据 `type` 配置设置当前时间为默认值。推荐使用 `showTypeSwitcher` 模式(时间查询),可覆盖所有时间类型的查询需求。开启 `range` 后,单选日/月/年会展开为日期范围数组(date→`[d,d]`、month→`[月初,月末]`、year→`[年初,年末]`)。
754
+ 通用时间查询组件,通过 `range` prop 控制范围模式或单值模式,类型选项由组件内部根据 `range` 自动配置(不可由用户自定义)。配合快捷按钮实现前后时间段快速导航。`showDefault=true` 时组件初始化自动设置当天为默认值。
755
+
756
+ - `range=true`(默认):typeOptions 为 `['daterange','week','month','year']`,modelValue 始终为 `[string, string]`。默认类型为 `daterange`。month/year 选择器为单选,组件自动展开为 `[月初,月末]`/`[年初,年末]`。
757
+ - `range=false`:typeOptions 为 `['date','month','year']`,modelValue 为 `string`。默认类型为 `date`。
758
+ - `valueFormat` 仅对 `range=true` 的所有类型最终 modelValue,或 `range=false` 的 `date` 类型有效。`range=false` 的 month/year 使用各自默认格式(`YYYY-MM`/`YYYY`)。
755
759
 
756
760
  **Props:**
757
761
 
758
- | 属性名 | 类型 | 默认值 | 说明 |
759
- | ---------------- | --------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
760
- | modelValue | `string \| [string, string]` | — | v-model 绑定值(`type='date'/'month'/'year'/'datetime'` 为 string,`type='week'/'daterange'/'datetimerange'` 为 [string, string]);`range=true` 时单选日/月/年也展开为 [string, string] |
761
- | type | `'date' \| 'week' \| 'month' \| 'year' \| 'datetime' \| 'daterange' \| 'datetimerange'` | `'date'` | 日期类型;`showTypeSwitcher=true` 时作为初始类型;组件会根据 type 自动设置当前时间为默认值 |
762
- | showTypeSwitcher | `boolean` | `false` | 是否显示类型切换器(推荐开启,可覆盖所有时间类型) |
763
- | switcherStyle | `'select' \| 'button-group'` | `'select'` | 切换器风格(下拉选择 or 按钮组) |
764
- | typeOptions | `DateType[]` | `['date','week','month','year','datetime','daterange','datetimerange']` | 可切换的类型选项 |
765
- | quickButtons | `'none' \| 'arrows' \| 'group'` | `'none'` | 快捷按钮风格(无 / 左右箭头 / 按钮组);`arrows` 模式支持 date/datetime/week/month/year(不含 daterange/datetimerange) |
766
- | valueFormat | `string` | `'YYYY-MM-DD'` | 日期格式 |
767
- | clearable | `boolean` | `false` | 是否可清除 |
768
- | size | `'' \| 'small' \| 'default' \| 'large'` | `'default'` | 尺寸 |
769
- | placeholder | `string` | `''`(i18n 提供) | 单值 placeholder |
770
- | startPlaceholder | `string` | `''`(i18n 提供) | 范围开始 placeholder |
771
- | endPlaceholder | `string` | `''`(i18n 提供) | 范围结束 placeholder |
772
- | rangeSeparator | `string` | `''`(i18n 提供) | 范围分隔符 |
773
- | range | `boolean` | `false` | 是否将单选日/月/年展开为范围数组(date→`[d,d]`、month→`[月初,月末]`、year→`[年初,年末]`;对 week/daterange/datetimerange 无效) |
762
+ | 属性名 | 类型 | 默认值 | 说明 |
763
+ | ---------------- | ----------------------------------------------------------------------- | -------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
764
+ | modelValue | `string \| [string, string]` | — | v-model 绑定值(`range=true` 为 [string, string];`range=false` string|
765
+ | type | `'date' \| 'week' \| 'month' \| 'year' \| 'daterange'` | — | 日期类型;`showTypeSwitcher=true` 时作为初始类型。未指定时:`range=true` 默认 `'daterange'`,`range=false` 默认 `'date'` |
766
+ | showTypeSwitcher | `boolean` | `false` | 是否显示类型切换器 |
767
+ | switcherStyle | `'select' \| 'button-group'` | `'select'` | 切换器风格(下拉选择 or 按钮组) |
768
+ | quickButtons | `'none' \| 'arrows' \| 'group'` | `'none'` | 快捷按钮风格(无 / 左右箭头 / 按钮组);`arrows` 模式不支持 daterange |
769
+ | valueFormat | `string` | `'YYYY-MM-DD'` | 日期格式(仅对 `range=true` 所有类型最终 modelValue,或 `range=false` date 有效) |
770
+ | clearable | `boolean` | `false` | 是否可清除 |
771
+ | size | `'' \| 'small' \| 'default' \| 'large'` | `'default'` | 尺寸 |
772
+ | placeholder | `string` | `''`(i18n 提供) | 单值 placeholder |
773
+ | startPlaceholder | `string` | `''`(i18n 提供) | 范围开始 placeholder |
774
+ | endPlaceholder | `string` | `''`(i18n 提供) | 范围结束 placeholder |
775
+ | rangeSeparator | `string` | `''`(i18n 提供) | 范围分隔符 |
776
+ | range | `boolean` | `true` | 是否启用范围模式。`true`:typeOptions 为 `['daterange','week','month','year']`;`false`:typeOptions `['date','month','year']` |
777
+ | showDefault | `boolean` | `true` | 是否在 modelValue 为空时自动设置默认值为当天 |
774
778
 
775
779
  **Events:**
776
780
 
@@ -778,21 +782,20 @@ const dialogVisible = ref(false)
778
782
  - `change` - 值变化时触发,参数为 `(value, type)`
779
783
  - `type-change` - 类型切换时触发,参数为 `(type)`
780
784
 
781
- **使用示例:时间查询(推荐,覆盖所有时间类型)**
785
+ **使用示例:时间查询(range 模式,推荐)**
782
786
 
783
787
  ```vue
784
788
  <template>
785
789
  <JnDateQuery
786
790
  v-model="dateValue"
787
- type="date"
788
791
  show-type-switcher
789
792
  switcher-style="button-group"
790
- :type-options="['date', 'week', 'month', 'year', 'datetime', 'daterange', 'datetimerange']"
791
793
  quick-buttons="arrows"
792
- value-format="YYYY-MM-DD HH:mm:ss"
793
- placeholder="选择日期时间"
794
- start-placeholder="开始时间"
795
- end-placeholder="结束时间"
794
+ value-format="YYYY-MM-DD"
795
+ placeholder="选择日期"
796
+ start-placeholder="开始日期"
797
+ end-placeholder="结束日期"
798
+ @change="handleDateQueryChange"
796
799
  />
797
800
  </template>
798
801
 
@@ -800,7 +803,10 @@ const dialogVisible = ref(false)
800
803
  import { ref } from 'vue'
801
804
  import { JnDateQuery } from '@jnrs/vue-core/components'
802
805
 
803
- const dateValue = (ref < string) | ([string, string] > '')
806
+ const dateValue = ref<string | [string, string]>('')
807
+ const handleDateQueryChange = (val: string | [string, string]) => {
808
+ console.log(val)
809
+ }
804
810
  </script>
805
811
  ```
806
812
 
package/CHANGELOG.md CHANGED
@@ -1,6 +1,31 @@
1
1
  # 发版日志
2
2
 
3
- ## [1.2.39] - 2026-07-29 【latest】
3
+ ## [1.2.41] - 2026-07-30 【latest】
4
+
5
+ ### Fixed
6
+
7
+ - `JnDateQuery`:切换类型时 modelValue 未更新的问题,现始终基于当前日期重新计算(如本周范围、本月范围、本年范围)
8
+
9
+ ## [1.2.40] - 2026-07-30
10
+
11
+ ### ⚠️ Breaking Changes
12
+
13
+ - `JnDateQuery`:`range` 默认值改为 `true`(原 `false`)
14
+ - `JnDateQuery`:移除 `typeOptions` prop,改为组件内部根据 `range` 自动配置
15
+ - `JnDateQuery`:移除 `datetime` 和 `datetimerange` 类型及相关逻辑
16
+
17
+ ### Features
18
+
19
+ - `JnDateQuery`:新增 `showDefault` prop(默认 `true`),控制 modelValue 为空时是否自动设置当天为默认值
20
+ - `JnDateQuery`:`typeOptions` 内部化——range=true 为 `['daterange','week','month','year']`,range=false 为 `['date','month','year']`
21
+ - `JnDateQuery`:`valueFormat` 仅对 range=true 所有类型最终 modelValue 或 range=false 的 date 有效;range=false 的 month/year 使用默认格式(YYYY-MM / YYYY)
22
+
23
+ ### Refactor
24
+
25
+ - `JnDateQuery`:移除 `formatDate`/`formatDateTime`,统一使用 `formatByPattern` 按模式格式化
26
+ - `JnDateQuery`:`parseDate` 增强,支持 YYYY-MM 和 YYYY 格式解析
27
+
28
+ ## [1.2.39] - 2026-07-29
4
29
 
5
30
  ### Features
6
31
 
@@ -1,20 +1,18 @@
1
- type DateType = 'date' | 'week' | 'month' | 'year' | 'datetime' | 'daterange' | 'datetimerange';
1
+ type DateType = 'date' | 'week' | 'month' | 'year' | 'daterange';
2
2
  type QuickButtonStyle = 'none' | 'arrows' | 'group';
3
3
  type SwitcherStyle = 'select' | 'button-group';
4
4
  interface Props {
5
5
  /** v-model 绑定值(单值为 string,范围为 [string, string]) */
6
6
  modelValue: string | [string, string];
7
- /** 日期类型(固定模式),showTypeSwitcher=true 时作为初始类型 */
7
+ /** 日期类型(固定模式),showTypeSwitcher=true 时作为初始类型。未指定时:range=true 默认 'daterange',range=false 默认 'date' */
8
8
  type?: DateType;
9
9
  /** 是否显示类型切换器 */
10
10
  showTypeSwitcher?: boolean;
11
11
  /** 切换器风格 */
12
12
  switcherStyle?: SwitcherStyle;
13
- /** 可切换的类型选项 */
14
- typeOptions?: DateType[];
15
13
  /** 快捷按钮风格 */
16
14
  quickButtons?: QuickButtonStyle;
17
- /** 日期格式 */
15
+ /** 日期格式(仅对 range=true 的所有类型最终 modelValue,或 range=false 的 date 有效) */
18
16
  valueFormat?: string;
19
17
  /** 是否可清除 */
20
18
  clearable?: boolean;
@@ -29,14 +27,17 @@ interface Props {
29
27
  /** 范围分隔符 */
30
28
  rangeSeparator?: string;
31
29
  /**
32
- * 是否将单选日/月/年展开为日期范围数组([string, string])
33
- * - range=true type=date [day, day]
34
- * - range=true type=month [月初, 月末]
35
- * - range=true 且 type=year → [年初, 年末]
36
- * - 对 week/daterange/datetimerange 无效(这些类型本身即返回数组)
37
- * @default false
30
+ * 是否启用范围模式
31
+ * - true(默认):typeOptions ['daterange', 'week', 'month', 'year'],单选月/年展开为 [string, string]
32
+ * - false:typeOptions ['date', 'month', 'year'],modelValue string
33
+ * @default true
38
34
  */
39
35
  range?: boolean;
36
+ /**
37
+ * 是否在 modelValue 为空时自动设置默认值为当天
38
+ * @default true
39
+ */
40
+ showDefault?: boolean;
40
41
  }
41
42
  declare const _default: import('vue').DefineComponent<Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
42
43
  "update:modelValue": (value: string | [string, string]) => any;
@@ -53,12 +54,12 @@ declare const _default: import('vue').DefineComponent<Props, {}, {}, {}, {}, imp
53
54
  clearable: boolean;
54
55
  showTypeSwitcher: boolean;
55
56
  switcherStyle: SwitcherStyle;
56
- typeOptions: DateType[];
57
57
  quickButtons: QuickButtonStyle;
58
58
  valueFormat: string;
59
59
  startPlaceholder: string;
60
60
  endPlaceholder: string;
61
61
  rangeSeparator: string;
62
62
  range: boolean;
63
+ showDefault: boolean;
63
64
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
64
65
  export default _default;