@antify/ui 2.5.7 → 3.0.0

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.
Files changed (37) hide show
  1. package/dist/components/AntAccordion.vue +5 -6
  2. package/dist/components/AntAccordionItem.vue +5 -7
  3. package/dist/components/AntAlert.vue +53 -54
  4. package/dist/components/AntButton.vue +60 -62
  5. package/dist/components/AntCard.vue +10 -11
  6. package/dist/components/AntIcon.vue +8 -8
  7. package/dist/components/AntKeycap.vue +15 -15
  8. package/dist/components/AntListGroup.vue +10 -10
  9. package/dist/components/AntModal.vue +5 -5
  10. package/dist/components/AntPagination.vue +38 -40
  11. package/dist/components/AntSkeleton.vue +5 -25
  12. package/dist/components/__stories/AntListGroup.stories.js +6 -9
  13. package/dist/components/__stories/AntListGroup.stories.mjs +6 -9
  14. package/dist/components/__stories/AntListGroupItem.stories.js +1 -1
  15. package/dist/components/__stories/AntListGroupItem.stories.mjs +1 -1
  16. package/dist/components/inputs/AntCheckbox.vue +8 -9
  17. package/dist/components/inputs/AntColorInput/AntColorInput.vue +5 -10
  18. package/dist/components/inputs/AntImageInput.vue +34 -36
  19. package/dist/components/inputs/AntRadio.vue +8 -9
  20. package/dist/components/inputs/AntSelect.vue +64 -63
  21. package/dist/components/inputs/AntSwitch.vue +26 -27
  22. package/dist/components/inputs/AntSwitcher.vue +12 -11
  23. package/dist/components/inputs/AntTagInput.vue +6 -10
  24. package/dist/components/inputs/AntTextarea.vue +5 -9
  25. package/dist/components/inputs/Elements/AntBaseInput.vue +60 -60
  26. package/dist/components/inputs/__stories/AntCheckbox.stories.js +41 -14
  27. package/dist/components/inputs/__stories/AntCheckbox.stories.mjs +41 -14
  28. package/dist/components/table/AntTable.vue +11 -7
  29. package/dist/components/table/AntTableSkeleton.vue +5 -1
  30. package/dist/components/tabs/AntTabItem.vue +5 -7
  31. package/dist/composables/index.d.ts +1 -0
  32. package/dist/composables/index.js +11 -0
  33. package/dist/composables/index.mjs +1 -0
  34. package/dist/composables/useFlickerProtection.d.ts +22 -0
  35. package/dist/composables/useFlickerProtection.js +48 -0
  36. package/dist/composables/useFlickerProtection.mjs +48 -0
  37. package/package.json +1 -1
@@ -0,0 +1,22 @@
1
+ import { type Ref, type ComputedRef } from 'vue';
2
+ /**
3
+ * Add flicker protection to a ref or computed ref to ensure
4
+ * the value change is not too fast and does not cause flicker.
5
+ *
6
+ * [refToWatch = true]
7
+ * [visible = false] [if refToWatch = false -> Finish] [visible = true] [freeze now, ignore any change] [visible = refToWatch] [unlock]
8
+ * [------------------ flickerThreshold ------------------][------------------ minShowTime ------------------]
9
+ *
10
+ * This logic is separated into 4 phases:
11
+ * - null: The initial phase where the value is hidden.
12
+ * - threshold: The initial phase where the value is hidden and waits for flicker threshold time.
13
+ * If in this phase, refToWatch changes to false, the process get canceled.
14
+ * - minShowTime: The phase where the value is shown for a minimum time.
15
+ * - over: The final phase where the value is shown or hidden based on the refToWatch.
16
+ *
17
+ * @param refToWatch - The ref or computed ref to watch for changes.
18
+ * @param minShowTime - The minimum time (in ms) the value should remain visible.
19
+ * @param flickerThreshold - The threshold (in ms) to ignore rapid changes.
20
+ * @returns A ref that manages the visibility state with flicker protection.
21
+ */
22
+ export declare const useFlickerProtection: (refToWatch: Ref<boolean> | ComputedRef<boolean>, minShowTime?: number, flickerThreshold?: number) => Ref<boolean>;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useFlickerProtection = void 0;
7
+ var _vue = require("vue");
8
+ const useFlickerProtection = (refToWatch, minShowTime = 300, flickerThreshold = 50) => {
9
+ const visible = (0, _vue.ref)(refToWatch.value);
10
+ const phase = (0, _vue.ref)(null);
11
+ function startThresholdPhase() {
12
+ phase.value = "threshold";
13
+ visible.value = false;
14
+ setTimeout(() => {
15
+ if (refToWatch.value) {
16
+ startMinShowTimePhase();
17
+ }
18
+ }, flickerThreshold);
19
+ }
20
+ function startMinShowTimePhase() {
21
+ phase.value = "minShowTime";
22
+ visible.value = true;
23
+ setTimeout(() => {
24
+ visible.value = refToWatch.value;
25
+ phase.value = refToWatch.value ? "over" : null;
26
+ }, minShowTime);
27
+ }
28
+ (0, _vue.watch)(refToWatch, newValue => {
29
+ if (phase.value === "minShowTime") {
30
+ return;
31
+ }
32
+ if (phase.value === null && newValue) {
33
+ return startThresholdPhase();
34
+ }
35
+ if (phase.value === "threshold" && !newValue) {
36
+ phase.value = null;
37
+ return visible.value = false;
38
+ }
39
+ if (phase.value === "over" && !newValue) {
40
+ phase.value = null;
41
+ visible.value = false;
42
+ }
43
+ }, {
44
+ immediate: true
45
+ });
46
+ return visible;
47
+ };
48
+ exports.useFlickerProtection = useFlickerProtection;
@@ -0,0 +1,48 @@
1
+ import {
2
+ ref,
3
+ watch
4
+ } from "vue";
5
+ export const useFlickerProtection = (refToWatch, minShowTime = 300, flickerThreshold = 50) => {
6
+ const visible = ref(refToWatch.value);
7
+ const phase = ref(null);
8
+ function startThresholdPhase() {
9
+ phase.value = "threshold";
10
+ visible.value = false;
11
+ setTimeout(() => {
12
+ if (refToWatch.value) {
13
+ startMinShowTimePhase();
14
+ }
15
+ }, flickerThreshold);
16
+ }
17
+ function startMinShowTimePhase() {
18
+ phase.value = "minShowTime";
19
+ visible.value = true;
20
+ setTimeout(() => {
21
+ visible.value = refToWatch.value;
22
+ phase.value = refToWatch.value ? "over" : null;
23
+ }, minShowTime);
24
+ }
25
+ watch(
26
+ refToWatch,
27
+ (newValue) => {
28
+ if (phase.value === "minShowTime") {
29
+ return;
30
+ }
31
+ if (phase.value === null && newValue) {
32
+ return startThresholdPhase();
33
+ }
34
+ if (phase.value === "threshold" && !newValue) {
35
+ phase.value = null;
36
+ return visible.value = false;
37
+ }
38
+ if (phase.value === "over" && !newValue) {
39
+ phase.value = null;
40
+ visible.value = false;
41
+ }
42
+ },
43
+ {
44
+ immediate: true
45
+ }
46
+ );
47
+ return visible;
48
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antify/ui",
3
- "version": "2.5.7",
3
+ "version": "3.0.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "exports": {