@storecraft/dashboard 1.0.37 → 1.0.38

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,9 +1,11 @@
1
+ import { DiscountMetaEnum } from '@storecraft/core/api/types.api.enums.js';
1
2
  import { BulkDiscountExtra, BundleDiscountExtra, BuyXGetYDiscountExtra, DiscountDetails, DiscountType, OrderDiscountExtra, RegularDiscountExtra } from '@storecraft/core/api';
2
3
  import { FieldContextData, FieldLeafViewParams } from './fields-view';
3
4
  export declare const discount_details_validator: (v: any) => (string | boolean)[];
5
+ type DiscountMeta = typeof DiscountMetaEnum[keyof typeof DiscountMetaEnum];
4
6
  export type DiscountTypesParams = {
5
- selectedType: DiscountDetails["meta"];
6
- onChange: (meta: DiscountDetails["meta"]) => void;
7
+ selectedMeta: DiscountMeta;
8
+ onChange: (meta: DiscountMeta) => void;
7
9
  };
8
10
  export type BulkDiscountParams = {
9
11
  type: "bulk";
@@ -11,7 +13,6 @@ export type BulkDiscountParams = {
11
13
  onChange: (extra: BulkDiscountExtra) => void;
12
14
  };
13
15
  export type BundleDiscountParams = {
14
- meta: "bundle";
15
16
  value: BundleDiscountExtra;
16
17
  context: FieldContextData;
17
18
  onChange: (extra: BundleDiscountExtra) => void;
@@ -38,17 +39,37 @@ export type OrderDiscountParams = {
38
39
  onChange: (extra: OrderDiscountExtra) => void;
39
40
  };
40
41
  export type Type2CompParams = {
41
- meta: DiscountDetails["meta"];
42
+ meta: DiscountMeta;
42
43
  context: FieldContextData<DiscountType>;
43
44
  onChange: (extra: DiscountDetails["extra"]) => void;
44
45
  value: DiscountDetails["extra"];
45
46
  };
46
47
  export type DiscountDetailsViewParams = FieldLeafViewParams<DiscountDetails, import('../pages/discount.js').Context, DiscountType>;
47
- export declare const discount_types: {
48
- id: number;
49
- type: string;
50
- name: string;
48
+ export declare const discount_types: ({
51
49
  desc: string;
52
- }[];
50
+ id: 0;
51
+ type: "regular";
52
+ name?: string;
53
+ } | {
54
+ desc: string;
55
+ id: 1;
56
+ type: "bulk";
57
+ name?: string;
58
+ } | {
59
+ desc: string;
60
+ id: 2;
61
+ type: "buy_x_get_y";
62
+ name?: string;
63
+ } | {
64
+ desc: string;
65
+ id: 3;
66
+ type: "order";
67
+ name?: string;
68
+ } | {
69
+ desc: string;
70
+ id: 4;
71
+ type: "bundle";
72
+ name?: string;
73
+ })[];
53
74
  declare const DiscountDetailsView: ({ field, value, context, onChange, ...rest }: DiscountDetailsViewParams) => import("react/jsx-runtime").JSX.Element;
54
75
  export default DiscountDetailsView;
@@ -1,36 +1,37 @@
1
1
  import { default as React } from 'react';
2
- import { CustomerType, DiscountType, Filter, FilterValue_o_date_in_range, FilterValue_o_items_count_in_range, FilterValue_o_subtotal_in_range, FilterValue_p_in_collections, FilterValue_p_in_price_range, FilterValue_p_in_products, FilterValue_p_in_tags } from '@storecraft/core/api';
2
+ import { FilterMetaEnum } from '@storecraft/core/api/types.api.enums.js';
3
+ import { CustomerType, DiscountType, Filter, Filter_o_date_in_range, Filter_o_items_count_in_range, Filter_o_subtotal_in_range, Filter_p_in_collections, Filter_p_in_price_range, Filter_p_in_products, Filter_p_in_tags } from '@storecraft/core/api';
3
4
  import { FieldLeafViewParams } from './fields-view.js';
4
5
  export type Filter_ProductInCollectionsParams = {
5
- value: FilterValue_p_in_collections;
6
- onChange: (filter_value: FilterValue_p_in_collections) => void;
6
+ value: Filter_p_in_collections["value"];
7
+ onChange: (filter_value: Filter_p_in_collections["value"]) => void;
7
8
  context: import('../pages/discount.js').Context;
8
9
  };
9
10
  export type Filter_ProductHasTagsParams = {
10
- value: FilterValue_p_in_tags;
11
- onChange: (filter_value: FilterValue_p_in_tags) => void;
11
+ value: Filter_p_in_tags["value"];
12
+ onChange: (filter_value: Filter_p_in_tags["value"]) => void;
12
13
  context: import('../pages/discount.js').Context;
13
14
  };
14
15
  export type Filter_ProductHasHandleParams = {
15
- value: FilterValue_p_in_products;
16
- onChange: (filter_value: FilterValue_p_in_products) => void;
16
+ value: Filter_p_in_products["value"];
17
+ onChange: (filter_value: Filter_p_in_products["value"]) => void;
17
18
  context: import('../pages/discount.js').Context;
18
19
  };
19
20
  export type Filter_ProductPriceInRangeParams = {
20
- value: FilterValue_p_in_price_range;
21
- onChange: (filter_value: FilterValue_p_in_price_range) => void;
21
+ value: Filter_p_in_price_range["value"];
22
+ onChange: (filter_value: Filter_p_in_price_range["value"]) => void;
22
23
  };
23
24
  export type Filter_OrderSubTotalParams = {
24
- value: FilterValue_o_subtotal_in_range;
25
- onChange: (filter_value: FilterValue_o_subtotal_in_range) => void;
25
+ value: Filter_o_subtotal_in_range["value"];
26
+ onChange: (filter_value: Filter_o_subtotal_in_range["value"]) => void;
26
27
  };
27
28
  export type Filter_OrderItemCountParams = {
28
- value?: FilterValue_o_items_count_in_range;
29
- onChange: (filter_value: FilterValue_o_items_count_in_range) => void;
29
+ value?: Filter_o_items_count_in_range["value"];
30
+ onChange: (filter_value: Filter_o_items_count_in_range["value"]) => void;
30
31
  };
31
32
  export type Filter_OrderDateParams = {
32
- onChange: (value: FilterValue_o_date_in_range) => void;
33
- value?: FilterValue_o_date_in_range;
33
+ onChange: (value: Filter_o_date_in_range["value"]) => void;
34
+ value?: Filter_o_date_in_range["value"];
34
35
  };
35
36
  export type Filter_OrderHasCustomersParams = {
36
37
  onChange: (value: CustomerType[]) => void;
@@ -42,7 +43,7 @@ export type ProductFilterContainerParams = {
42
43
  value: Filter["value"];
43
44
  Comp: any;
44
45
  CompParams: any;
45
- type: Filter["meta"]["type"];
46
+ type: typeof FilterMetaEnum[Exclude<keyof typeof FilterMetaEnum, 'any'>]["type"];
46
47
  onChange: (value: Filter["value"]) => void;
47
48
  onRemove: () => void;
48
49
  ix: number;
@@ -55,6 +56,5 @@ export type AddFilterParams = {
55
56
  export type DiscountFiltersParams = FieldLeafViewParams<Filter[], import('../pages/discount.js').Context, DiscountType> & React.ComponentProps<'div'> & {
56
57
  types: ("product" | "order")[];
57
58
  };
58
- export declare const discount_filters_validator: (v: Filter["meta"][]) => (string | boolean)[];
59
59
  declare const DiscountFilters: ({ value, onChange, types, context, ...rest }: DiscountFiltersParams) => import("react/jsx-runtime").JSX.Element;
60
60
  export default DiscountFilters;
@@ -1,6 +1,6 @@
1
1
  import { DiscountDetails } from '@storecraft/core/api';
2
2
  import { TableSchemaViewComponentParams } from './table-schema-view';
3
3
  export declare const discount_types_to_color: (type: DiscountDetails["meta"]["type"]) => "bg-kf-400 dark:bg-kf-400/40" | "bg-red-400 dark:bg-red-400/40" | "bg-teal-600 dark:bg-teal-600/40" | "bg-cyan-500 dark:bg-cyan-500/40" | "bg-sky-500 dark:bg-sky-400/40" | "bg-slate-400 dark:bg-slate-400/20";
4
- export type DiscountTypeParams = TableSchemaViewComponentParams<DiscountDetails["meta"]>;
4
+ export type DiscountTypeParams = TableSchemaViewComponentParams<DiscountDetails>;
5
5
  declare const DiscountType: ({ value, ...rest }: DiscountTypeParams) => import("react/jsx-runtime").JSX.Element;
6
6
  export default DiscountType;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * error message view from document pages
2
+ * @description error message view from document pages
3
3
  */
4
4
  export type EditMessageParams = {
5
5
  error?: import('@storecraft/core/api').error;
@@ -7,12 +7,11 @@ export type EditMessageParams = {
7
7
  className?: string;
8
8
  } & React.ComponentProps<'div'>;
9
9
  /**
10
- * Easily `format` errors coming from the `storecraft` backend
11
- *
10
+ * @description Easily `format` errors coming from the `storecraft` backend
12
11
  */
13
12
  export declare const format_storecraft_errors: (error: import('@storecraft/core/api').error) => string[];
14
13
  /**
15
- * error message view from document pages
14
+ * @description error message view from document pages
16
15
  */
17
16
  declare const ErrorMessage: ({ error, positive, className, ...rest }: EditMessageParams) => import("react/jsx-runtime").JSX.Element;
18
17
  export default ErrorMessage;
@@ -1,13 +1,20 @@
1
1
  import { InferQueryableType, queryable_resources } from '@storecraft/sdk-react-hooks';
2
2
  import { ApiQuery } from '@storecraft/core/api';
3
3
  /**
4
- * `useCollectionsActions` is a hook designed for the collections pages,
5
- * for performing:
4
+ * @description `useCollectionsActions` is a hook designed for
5
+ * the collections pages, for performing:
6
6
  * - Viewing of collections
7
7
  * - Pagination through querying or navigation
8
8
  * - Querying
9
+ * It's main use case is for performing url navigation with query params
10
+ * although can be used without.
9
11
  *
10
- * This hook wraps `useCollection` hook
12
+ * TODO: Rewrite the cursors to be used by `vql` in later versions.
13
+ * currently, i dont do that because it is a breaking change for dashboards
14
+ * that dont have the backend to support it.
15
+ * Also, `limit` always resets the query.
16
+ *
17
+ * This hook wraps {@link useCollection} hook
11
18
  *
12
19
  * @param resource the collection id in backend
13
20
  * @param slug front end slug
@@ -36,7 +43,7 @@ declare const useCollectionsActions: <RESOURCE extends (string | queryable_resou
36
43
  limit: number;
37
44
  vql: string;
38
45
  expand?: import('@storecraft/core/api').ExpandQuery<T>;
39
- vqlParsed?: import("@storecraft/core/vql").VQL.AST;
46
+ __vql_as_string?: string;
40
47
  sortBy?: import('@storecraft/core/api').SortCursor<T>;
41
48
  order?: import('@storecraft/core/api').SortOrder;
42
49
  equals?: import('@storecraft/core/api').Cursor<T>;
@@ -1,2 +1,2 @@
1
- declare function _default({}: {}): import("react/jsx-runtime").JSX.Element;
1
+ declare const _default: ({}: {}) => import("react/jsx-runtime").JSX.Element;
2
2
  export default _default;