vueless 0.0.152 → 0.0.153

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vueless",
3
- "version": "0.0.152",
3
+ "version": "0.0.153",
4
4
  "license": "MIT",
5
5
  "description": "Vue Styleless Component Framework.",
6
6
  "homepage": "https://vueless.com",
@@ -1,12 +1,27 @@
1
1
  import useUI from "../../composable.ui";
2
+ import { cva } from "../../service.ui";
2
3
 
3
4
  import defaultConfig from "../configs/default.config";
4
5
  import { computed, watchEffect } from "vue";
5
6
 
6
7
  export default function useAttrs(props, { isShownCalendar }) {
7
8
  const { config, getAttrs } = useUI(defaultConfig, () => props.config);
9
+ const { calendar } = config.value;
8
10
 
9
- const calendarAttrs = getAttrs("calendar");
11
+ const cvaCalendarWrapper = cva({
12
+ base: calendar.wrapper.base,
13
+ variants: calendar.wrapper.variants,
14
+ compoundVariants: calendar.wrapper.compoundVariants,
15
+ });
16
+
17
+ const calendarWrapperClasses = computed(() =>
18
+ cvaCalendarWrapper({ openDirection: props.openDirection }),
19
+ );
20
+
21
+ const calendarAttrs = getAttrs("calendar", {
22
+ isComponent: true,
23
+ classes: calendarWrapperClasses,
24
+ });
10
25
  const inputBlurAttrs = getAttrs("input");
11
26
  const inputActiveAttrs = getAttrs("inputActive");
12
27
  const wrapperAttrs = getAttrs("wrapper");
@@ -6,7 +6,17 @@ export default /*tw*/ {
6
6
  base: "ring-4 ring-brand-600/[.15] border-brand-500 hover:border-brand-500",
7
7
  },
8
8
  },
9
- calendar: "absolute z-40 mt-2",
9
+ calendar: {
10
+ wrapper: {
11
+ base: "absolute z-40 mt-2",
12
+ variants: {
13
+ openDirection: {
14
+ left: "left-0",
15
+ right: "right-0",
16
+ },
17
+ },
18
+ },
19
+ },
10
20
  calendarTransition: {
11
21
  enterFromClass: "opacity-0 scale-95",
12
22
  enterActiveClass: "transition transform ease-out duration-100",
@@ -99,6 +109,7 @@ export default /*tw*/ {
99
109
  dateFormat: "Y-m-d",
100
110
  userFormat: "F j, Y",
101
111
  size: "md",
112
+ openDirection: "left",
102
113
  timepicker: false,
103
114
  disabled: false,
104
115
  maxDate: undefined,
@@ -64,6 +64,28 @@ const SizesTemplate = (args, { argTypes } = {}) => ({
64
64
  `,
65
65
  });
66
66
 
67
+ const OpenDirectionTemplate = (args, { argTypes } = {}) => ({
68
+ components: { UDatePicker, URow },
69
+ setup() {
70
+ return {
71
+ args,
72
+ directions: argTypes.openDirection.options,
73
+ };
74
+ },
75
+ template: `
76
+ <URow class="!flex-col">
77
+ <UDatePicker
78
+ class="w-full"
79
+ v-for="(direction, index) in directions"
80
+ :open-direction="direction"
81
+ v-bind="args"
82
+ v-model="args.value"
83
+ :key="index"
84
+ />
85
+ </URow>
86
+ `,
87
+ });
88
+
67
89
  const SlotTemplate = (args) => ({
68
90
  components: { UDatePicker, UIcon },
69
91
  setup() {
@@ -82,6 +104,9 @@ Default.args = { date: 1645653600 };
82
104
  export const sizes = SizesTemplate.bind({});
83
105
  sizes.args = { label: "" };
84
106
 
107
+ export const openDirection = OpenDirectionTemplate.bind({});
108
+ openDirection.args = {};
109
+
85
110
  export const description = DefaultTemplate.bind({});
86
111
  description.args = { description: "some description" };
87
112
 
@@ -101,6 +101,15 @@ const props = defineProps({
101
101
  default: null,
102
102
  },
103
103
 
104
+ /**
105
+ * Datepicker open direction.
106
+ * @values left, right
107
+ */
108
+ openDirection: {
109
+ type: String,
110
+ default: UIService.get(defaultConfig, UDatePicker).default.openDirection,
111
+ },
112
+
104
113
  /**
105
114
  * Min date in format date string or Date.
106
115
  */
@@ -1,5 +1,5 @@
1
1
  import useUI from "../../composable.ui";
2
- import { cx } from "../../service.ui";
2
+ import { cx, cva } from "../../service.ui";
3
3
 
4
4
  import { computed, watchEffect } from "vue";
5
5
 
@@ -7,6 +7,15 @@ import defaultConfig from "../configs/default.config";
7
7
 
8
8
  export default function useAttrs(props, { isShownMenu }) {
9
9
  const { config, getAttrs } = useUI(defaultConfig, () => props.config);
10
+ const { menu } = config.value;
11
+
12
+ const cvaMenu = cva({
13
+ base: menu.base,
14
+ variants: menu.variants,
15
+ compoundVariants: menu.compoundVariants,
16
+ });
17
+
18
+ const menuClasses = computed(() => cvaMenu({ openDirection: props.openDirection }));
10
19
 
11
20
  const wrapperAttrs = getAttrs("wrapper");
12
21
  const buttonWrapperAttrsRaw = getAttrs("buttonWrapper");
@@ -57,7 +66,7 @@ export default function useAttrs(props, { isShownMenu }) {
57
66
  return isShownMenu.value ? inputActiveAttrs.value : inputBlurAttrs.value;
58
67
  });
59
68
 
60
- const menuAttrs = getAttrs("menu");
69
+ const menuAttrs = getAttrs("menu", { classes: menuClasses });
61
70
  const periodsRowAttrs = getAttrs("periodsRow");
62
71
  const rangeSwitchWrapperAttrs = getAttrs("rangeSwitchWrapper");
63
72
  const nextIconAttrs = getAttrs("nextIcon");
@@ -19,7 +19,15 @@ export default /*tw*/ {
19
19
  hover:bg-zinc-200 hover:ring-brand-600/[.15] focus:border-0 focus:ring-0 focus:ring-brand-600/[.15] active:bg-zinc-200
20
20
  disabled:cursor-not-allowed last:rounded-l-none last:rounded-r-lg first:rounded-l-lg first:rounded-r-none
21
21
  `,
22
- menu: "absolute z-40 mt-2 w-80 overflow-hidden rounded-lg border border-brand-300 bg-white p-2 shadow focus:outline-none",
22
+ menu: {
23
+ base: "absolute z-40 mt-2 w-80 overflow-hidden rounded-lg border border-brand-300 bg-white p-2 shadow focus:outline-none",
24
+ variants: {
25
+ openDirection: {
26
+ left: "left-0",
27
+ right: "right-0",
28
+ },
29
+ },
30
+ },
23
31
  menuTransition: {
24
32
  enterFromClass: "opacity-0 scale-95",
25
33
  enterActiveClass: "transition transform ease-out duration-100",
@@ -185,6 +193,7 @@ export default /*tw*/ {
185
193
  defaultVariants: {
186
194
  size: "md",
187
195
  variant: "button",
196
+ openDirection: "left",
188
197
  timepicker: false,
189
198
  disabled: false,
190
199
  dateFormat: "d.m.Y",
@@ -18,5 +18,5 @@ export const PERIOD = {
18
18
  quarter: "quarter",
19
19
  year: "year",
20
20
  ownRange: "ownRange",
21
- lastThirtyDays: "lastThirtyDays",
21
+ custom: "custom",
22
22
  };
@@ -79,12 +79,37 @@ const VariantsTemplate = (args, { argTypes } = {}) => ({
79
79
  `,
80
80
  });
81
81
 
82
+ const OpenDirectionTemplate = (args, { argTypes } = {}) => ({
83
+ components: { UDatePickerRange, URow },
84
+ setup() {
85
+ return {
86
+ args,
87
+ directions: argTypes.openDirection.options,
88
+ };
89
+ },
90
+ template: `
91
+ <URow class="!flex-col">
92
+ <UDatePickerRange
93
+ class="w-full"
94
+ v-for="(direction, index) in directions"
95
+ :open-direction="direction"
96
+ v-bind="args"
97
+ v-model="args.value"
98
+ :key="index"
99
+ />
100
+ </URow>
101
+ `,
102
+ });
103
+
82
104
  export const Default = DefaultTemplate.bind({});
83
105
  Default.args = {};
84
106
 
85
107
  export const variants = VariantsTemplate.bind({});
86
108
  variants.args = {};
87
109
 
110
+ export const openDirection = OpenDirectionTemplate.bind({});
111
+ openDirection.args = {};
112
+
88
113
  export const disabled = VariantsTemplate.bind({});
89
114
  disabled.args = { disabled: true };
90
115
 
@@ -272,6 +272,15 @@ const props = defineProps({
272
272
  }),
273
273
  },
274
274
 
275
+ /**
276
+ * Datepicker open direction.
277
+ * @values left, right
278
+ */
279
+ openDirection: {
280
+ type: String,
281
+ default: UIService.get(defaultConfig, UDatePickerRange).default.openDirection,
282
+ },
283
+
275
284
  /**
276
285
  * The variant of the date picker.
277
286
  * @values button, input
@@ -860,8 +869,11 @@ function onInputRangeInput(value, type) {
860
869
  setDefaultPeriodForButton();
861
870
 
862
871
  function setDefaultPeriodForButton() {
863
- const from = utcToGMT(getDateFromUnixTimestamp(props.modelValue.to || new Date()));
864
- const to = utcToGMT(getDateFromUnixTimestamp(props.modelValue.from || new Date()));
872
+ const from = utcToGMT(getDateFromUnixTimestamp(props.modelValue.from || new Date()));
873
+ const to = utcToGMT(getDateFromUnixTimestamp(props.modelValue.to || new Date()));
874
+
875
+ const customFrom = utcToGMT(getDateFromUnixTimestamp(props.customRangeButton.range.from));
876
+ const customTo = utcToGMT(getDateFromUnixTimestamp(props.customRangeButton.range.to));
865
877
 
866
878
  const isWeekPeriod =
867
879
  String(from) === String(getStartOfWeek(from, { weekStartsOn: 1 })) &&
@@ -874,6 +886,7 @@ function setDefaultPeriodForButton() {
874
886
  String(from) === String(getStartOfQuarter(from)) && String(to) === String(getEndOfQuarter(to));
875
887
  const isYearPeriod =
876
888
  String(from) === String(getStartOfYear(from)) && String(to) === String(getEndOfYear(to));
889
+ const isCustomPeriod = String(from) === String(customFrom) && String(to) === String(customTo);
877
890
 
878
891
  if (!props.modelValue.from && !props.modelValue.to) {
879
892
  period.value = PERIOD.ownRange;
@@ -885,6 +898,8 @@ function setDefaultPeriodForButton() {
885
898
  period.value = PERIOD.quarter;
886
899
  } else if (isWeekPeriod) {
887
900
  period.value = PERIOD.week;
901
+ } else if (isCustomPeriod) {
902
+ period.value = PERIOD.custom;
888
903
  } else {
889
904
  period.value = PERIOD.ownRange;
890
905
  }
@@ -93,12 +93,10 @@ export function getWeekDateList(date, monthShortLocales = {}) {
93
93
  const isLastWeek = week + day === weeksInMonth;
94
94
 
95
95
  let monthFirstDayOfWeek = "";
96
- let monthLastDayOfWeek = endOfWeekDate.toLocaleString("en-us", { month: "long" }).toLowerCase();
96
+ let monthLastDayOfWeek = endOfWeekDate.getMonth();
97
97
 
98
98
  if (isDayInPreviousMonth || isLastWeek) {
99
- monthFirstDayOfWeek = startOfWeekDate
100
- .toLocaleString("en-us", { month: "long" })
101
- .toLowerCase();
99
+ monthFirstDayOfWeek = startOfWeekDate.getMonth();
102
100
  }
103
101
 
104
102
  const title = `${firstDayOfWeek} ${
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "framework": "vue",
3
3
  "name": "vueless",
4
- "version": "0.0.152",
4
+ "version": "0.0.153",
5
5
  "contributions": {
6
6
  "html": {
7
7
  "description-markup": "markdown",
@@ -1530,6 +1530,15 @@
1530
1530
  },
1531
1531
  "default": "null"
1532
1532
  },
1533
+ {
1534
+ "name": "openDirection",
1535
+ "description": "Datepicker open direction.",
1536
+ "value": {
1537
+ "kind": "expression",
1538
+ "type": "'left' | 'right'"
1539
+ },
1540
+ "default": "left"
1541
+ },
1533
1542
  {
1534
1543
  "name": "minDate",
1535
1544
  "description": "Min date in format date string or Date.",
@@ -1683,6 +1692,15 @@
1683
1692
  },
1684
1693
  "default": "{\n range: { from: 0, to: 0 },\n label: \"\",\n description: \"\"\n}"
1685
1694
  },
1695
+ {
1696
+ "name": "openDirection",
1697
+ "description": "Datepicker open direction.",
1698
+ "value": {
1699
+ "kind": "expression",
1700
+ "type": "'left' | 'right'"
1701
+ },
1702
+ "default": "left"
1703
+ },
1686
1704
  {
1687
1705
  "name": "variant",
1688
1706
  "description": "The variant of the date picker.",