@jnrs/vue-core 1.2.38 → 1.2.40

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
@@ -451,7 +451,7 @@ const tableRowClassName = ({ row }) => {
451
451
 
452
452
  #### JnSelectTemplate
453
453
 
454
- 选择组件通用模板,支持下拉选择、弹窗多选等功能。
454
+ 选择组件通用模板,支持下拉选择、弹窗多选等功能。默认懒加载:`onMounted` 不请求列表数据,仅在下拉框展开或弹窗显示时请求;如需在挂载时立即加载,传 `immediate`。
455
455
 
456
456
  **Props:**
457
457
 
@@ -484,6 +484,8 @@ const tableRowClassName = ({ row }) => {
484
484
  | remoteFilterKey | `string` | `'name'` | 下拉框查询参数远程过滤参数的 key 值 |
485
485
  | collapseTags | `boolean` | `true` | 是否折叠标签 |
486
486
  | maxCollapseTags | `number` | `1` | 折叠时显示的最大标签数 |
487
+ | immediate | `boolean` | `false` | 是否在 onMounted 期间立即请求列表(默认懒加载:下拉展开/弹窗显示时才请求) |
488
+ | pageSize | `number` | `100` | 每页条数 |
487
489
 
488
490
  **使用示例:**
489
491
 
@@ -749,25 +751,30 @@ const dialogVisible = ref(false)
749
751
 
750
752
  #### JnDateQuery
751
753
 
752
- 通用时间查询组件,支持日/周/月/年/日期时间/任意区间/时间区间七种类型切换,配合快捷按钮实现前后时间段快速导航。组件初始化时若未设置值,自动根据 `type` 配置设置当前时间为默认值。推荐使用 `showTypeSwitcher` 模式(时间查询),可覆盖所有时间类型的查询需求。
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`)。
753
759
 
754
760
  **Props:**
755
761
 
756
- | 属性名 | 类型 | 默认值 | 说明 |
757
- | ---------------- | --------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
758
- | modelValue | `string \| [string, string]` | — | v-model 绑定值(`type='date'/'month'/'year'/'datetime'` 为 string,`type='week'/'daterange'/'datetimerange'` 为 [string, string] |
759
- | type | `'date' \| 'week' \| 'month' \| 'year' \| 'datetime' \| 'daterange' \| 'datetimerange'` | `'date'` | 日期类型;`showTypeSwitcher=true` 时作为初始类型;组件会根据 type 自动设置当前时间为默认值 |
760
- | showTypeSwitcher | `boolean` | `false` | 是否显示类型切换器(推荐开启,可覆盖所有时间类型) |
761
- | switcherStyle | `'select' \| 'button-group'` | `'select'` | 切换器风格(下拉选择 or 按钮组) |
762
- | typeOptions | `DateType[]` | `['date','week','month','year','datetime','daterange','datetimerange']` | 可切换的类型选项 |
763
- | quickButtons | `'none' \| 'arrows' \| 'group'` | `'none'` | 快捷按钮风格(无 / 左右箭头 / 按钮组);`arrows` 模式支持 date/datetime/week/month/year(不含 daterange/datetimerange) |
764
- | valueFormat | `string` | `'YYYY-MM-DD'` | 日期格式 |
765
- | clearable | `boolean` | `false` | 是否可清除 |
766
- | size | `'' \| 'small' \| 'default' \| 'large'` | `'default'` | 尺寸 |
767
- | placeholder | `string` | `''`(i18n 提供) | 单值 placeholder |
768
- | startPlaceholder | `string` | `''`(i18n 提供) | 范围开始 placeholder |
769
- | endPlaceholder | `string` | `''`(i18n 提供) | 范围结束 placeholder |
770
- | rangeSeparator | `string` | `''`(i18n 提供) | 范围分隔符 |
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 为空时自动设置默认值为当天 |
771
778
 
772
779
  **Events:**
773
780
 
@@ -775,21 +782,20 @@ const dialogVisible = ref(false)
775
782
  - `change` - 值变化时触发,参数为 `(value, type)`
776
783
  - `type-change` - 类型切换时触发,参数为 `(type)`
777
784
 
778
- **使用示例:时间查询(推荐,覆盖所有时间类型)**
785
+ **使用示例:时间查询(range 模式,推荐)**
779
786
 
780
787
  ```vue
781
788
  <template>
782
789
  <JnDateQuery
783
790
  v-model="dateValue"
784
- type="date"
785
791
  show-type-switcher
786
792
  switcher-style="button-group"
787
- :type-options="['date', 'week', 'month', 'year', 'datetime', 'daterange', 'datetimerange']"
788
793
  quick-buttons="arrows"
789
- value-format="YYYY-MM-DD HH:mm:ss"
790
- placeholder="选择日期时间"
791
- start-placeholder="开始时间"
792
- end-placeholder="结束时间"
794
+ value-format="YYYY-MM-DD"
795
+ placeholder="选择日期"
796
+ start-placeholder="开始日期"
797
+ end-placeholder="结束日期"
798
+ @change="handleDateQueryChange"
793
799
  />
794
800
  </template>
795
801
 
@@ -797,7 +803,10 @@ const dialogVisible = ref(false)
797
803
  import { ref } from 'vue'
798
804
  import { JnDateQuery } from '@jnrs/vue-core/components'
799
805
 
800
- 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
+ }
801
810
  </script>
802
811
  ```
803
812
 
package/CHANGELOG.md CHANGED
@@ -1,6 +1,32 @@
1
1
  # 发版日志
2
2
 
3
- ## [1.2.38] - 2026-07-29 【latest】
3
+ ## [1.2.40] - 2026-07-30 【latest】
4
+
5
+ ### ⚠️ Breaking Changes
6
+
7
+ - `JnDateQuery`:`range` 默认值改为 `true`(原 `false`)
8
+ - `JnDateQuery`:移除 `typeOptions` prop,改为组件内部根据 `range` 自动配置
9
+ - `JnDateQuery`:移除 `datetime` 和 `datetimerange` 类型及相关逻辑
10
+
11
+ ### Features
12
+
13
+ - `JnDateQuery`:新增 `showDefault` prop(默认 `true`),控制 modelValue 为空时是否自动设置当天为默认值
14
+ - `JnDateQuery`:`typeOptions` 内部化——range=true 为 `['daterange','week','month','year']`,range=false 为 `['date','month','year']`
15
+ - `JnDateQuery`:`valueFormat` 仅对 range=true 所有类型最终 modelValue 或 range=false 的 date 有效;range=false 的 month/year 使用默认格式(YYYY-MM / YYYY)
16
+
17
+ ### Refactor
18
+
19
+ - `JnDateQuery`:移除 `formatDate`/`formatDateTime`,统一使用 `formatByPattern` 按模式格式化
20
+ - `JnDateQuery`:`parseDate` 增强,支持 YYYY-MM 和 YYYY 格式解析
21
+
22
+ ## [1.2.39] - 2026-07-29
23
+
24
+ ### Features
25
+
26
+ - `JnDateQuery`:新增 `range` prop,开启后单选日/月/年自动展开为日期范围数组(date→`[d,d]`、month→`[月初,月末]`、year→`[年初,年末]`),默认 `false` 完全向后兼容
27
+ - `JnSelectTemplate`:新增 `immediate`(默认 `false`)与 `pageSize`(默认 `100`)props;默认懒加载,仅在下拉框展开或弹窗显示时请求列表数据,`immediate=true` 时 onMounted 期间加载
28
+
29
+ ## [1.2.38] - 2026-07-29
4
30
 
5
31
  ### Refactor
6
32
 
@@ -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;
@@ -28,6 +26,18 @@ interface Props {
28
26
  endPlaceholder?: string;
29
27
  /** 范围分隔符 */
30
28
  rangeSeparator?: string;
29
+ /**
30
+ * 是否启用范围模式
31
+ * - true(默认):typeOptions 为 ['daterange', 'week', 'month', 'year'],单选月/年展开为 [string, string]
32
+ * - false:typeOptions 为 ['date', 'month', 'year'],modelValue 为 string
33
+ * @default true
34
+ */
35
+ range?: boolean;
36
+ /**
37
+ * 是否在 modelValue 为空时自动设置默认值为当天
38
+ * @default true
39
+ */
40
+ showDefault?: boolean;
31
41
  }
32
42
  declare const _default: import('vue').DefineComponent<Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
33
43
  "update:modelValue": (value: string | [string, string]) => any;
@@ -44,11 +54,12 @@ declare const _default: import('vue').DefineComponent<Props, {}, {}, {}, {}, imp
44
54
  clearable: boolean;
45
55
  showTypeSwitcher: boolean;
46
56
  switcherStyle: SwitcherStyle;
47
- typeOptions: DateType[];
48
57
  quickButtons: QuickButtonStyle;
49
58
  valueFormat: string;
50
59
  startPlaceholder: string;
51
60
  endPlaceholder: string;
52
61
  rangeSeparator: string;
62
+ range: boolean;
63
+ showDefault: boolean;
53
64
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
54
65
  export default _default;
@@ -140,6 +140,18 @@ export interface Props {
140
140
  * @default 1
141
141
  */
142
142
  maxCollapseTags?: number;
143
+ /**
144
+ * 是否在 onMounted 期间立即请求列表数据
145
+ * - false(默认):懒加载,仅在下拉框展开或弹窗显示时请求
146
+ * - true:onMounted 期间即加载列表
147
+ * @default false
148
+ */
149
+ immediate?: boolean;
150
+ /**
151
+ * 每页条数
152
+ * @default 100
153
+ */
154
+ pageSize?: number;
143
155
  }
144
156
  declare function __VLS_template(): {
145
157
  attrs: Partial<{}>;