@sheinx/hooks 3.9.3-beta.13 → 3.9.3-beta.14

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 +1 @@
1
- {"version":3,"file":"use-date.d.ts","sourceRoot":"","sources":["use-date.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAW/C,QAAA,MAAM,OAAO,UAAW,YAAY;;;;;;;;;;wBAoBX,IAAI;2BAkDD,IAAI;yBAkBN,IAAI;0BAgEH,IAAI;+BAtFC,IAAI;+BAiDJ,IAAI,YAAY,OAAO;0BAnB5B,IAAI;2BAIH,IAAI;;gCAIC,IAAI;;CA+FpC,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"use-date.d.ts","sourceRoot":"","sources":["use-date.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAW/C,QAAA,MAAM,OAAO,UAAW,YAAY;;;;;;;;;;wBAoBX,IAAI;2BAkDD,IAAI;yBAkBN,IAAI;0BA2EH,IAAI;+BAjGC,IAAI;+BAiDJ,IAAI,YAAY,OAAO;0BAnB5B,IAAI;2BAIH,IAAI;;gCAIC,IAAI;;CA0GpC,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -125,15 +125,24 @@ var useDate = function useDate(props) {
125
125
  var getTimeStr = function getTimeStr() {
126
126
  var format = props.format,
127
127
  type = props.type;
128
- if (!props.value) return '';
129
128
  if (type !== 'datetime' || !format) return '';
130
- if (/^[X|x]$/.test(format)) {
129
+ if (/^[X|x]$/.test(_util.default.compatibleFmt(format))) {
131
130
  format = 'HH:mm:ss';
132
131
  } else {
133
132
  var match = format.match(/[H|h].*/);
134
133
  // eslint-disable-next-line
135
134
  if (match) format = match[0];
136
135
  }
136
+
137
+ // 当不存在 props.value 时,根据 format 格式返回默认时间字符串
138
+ if (!props.value) {
139
+ return format.replace(/[Hh]+/g, '00') // HH/hh -> 00
140
+ .replace(/m+/g, '00') // mm -> 00
141
+ .replace(/s+/g, '00') // ss -> 00
142
+ .replace(/S+/g, '0') // SSS -> 0
143
+ .replace(/A/g, 'AM') // A -> AM
144
+ .replace(/a/g, 'am'); // a -> am
145
+ }
137
146
  return _util.default.format(props.value, format, options);
138
147
  };
139
148
  var isInRange = function isInRange(date) {
@@ -1 +1 @@
1
- {"version":3,"file":"use-date.d.ts","sourceRoot":"","sources":["use-date.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAW/C,QAAA,MAAM,OAAO,UAAW,YAAY;;;;;;;;;;wBAoBX,IAAI;2BAkDD,IAAI;yBAkBN,IAAI;0BAgEH,IAAI;+BAtFC,IAAI;+BAiDJ,IAAI,YAAY,OAAO;0BAnB5B,IAAI;2BAIH,IAAI;;gCAIC,IAAI;;CA+FpC,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"use-date.d.ts","sourceRoot":"","sources":["use-date.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAW/C,QAAA,MAAM,OAAO,UAAW,YAAY;;;;;;;;;;wBAoBX,IAAI;2BAkDD,IAAI;yBAkBN,IAAI;0BA2EH,IAAI;+BAjGC,IAAI;+BAiDJ,IAAI,YAAY,OAAO;0BAnB5B,IAAI;2BAIH,IAAI;;gCAIC,IAAI;;CA0GpC,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -119,15 +119,24 @@ var useDate = function useDate(props) {
119
119
  var getTimeStr = function getTimeStr() {
120
120
  var format = props.format,
121
121
  type = props.type;
122
- if (!props.value) return '';
123
122
  if (type !== 'datetime' || !format) return '';
124
- if (/^[X|x]$/.test(format)) {
123
+ if (/^[X|x]$/.test(utils.compatibleFmt(format))) {
125
124
  format = 'HH:mm:ss';
126
125
  } else {
127
126
  var match = format.match(/[H|h].*/);
128
127
  // eslint-disable-next-line
129
128
  if (match) format = match[0];
130
129
  }
130
+
131
+ // 当不存在 props.value 时,根据 format 格式返回默认时间字符串
132
+ if (!props.value) {
133
+ return format.replace(/[Hh]+/g, '00') // HH/hh -> 00
134
+ .replace(/m+/g, '00') // mm -> 00
135
+ .replace(/s+/g, '00') // ss -> 00
136
+ .replace(/S+/g, '0') // SSS -> 0
137
+ .replace(/A/g, 'AM') // A -> AM
138
+ .replace(/a/g, 'am'); // a -> am
139
+ }
131
140
  return dateUtil.format(props.value, format, options);
132
141
  };
133
142
  var isInRange = function isInRange(date) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sheinx/hooks",
3
- "version": "3.9.3-beta.13",
3
+ "version": "3.9.3-beta.14",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "MIT",