@micromag/data 0.3.832 → 0.4.6

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 (3) hide show
  1. package/es/index.d.ts +178 -0
  2. package/es/index.js +14 -33
  3. package/package.json +12 -11
package/es/index.d.ts ADDED
@@ -0,0 +1,178 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+
3
+ declare const useContributionCreate: ({ screenId, visitorId: providedVisitorId, storyId: providedStoryId, onSuccess, }?: {
4
+ visitorId?: any;
5
+ storyId?: any;
6
+ onSuccess?: any;
7
+ }) => {
8
+ create: (data: any) => any;
9
+ creating: boolean;
10
+ };
11
+
12
+ declare const useContributions: ({ screenId, storyId: providedStoryId, opts }?: {
13
+ storyId?: any;
14
+ opts?: {};
15
+ }) => {
16
+ load?: (...args: any[]) => any;
17
+ loading?: boolean;
18
+ error?: boolean;
19
+ contributions: any;
20
+ };
21
+
22
+ declare const useData: (loadData: any, { initialData, autoload }?: {
23
+ initialData?: any;
24
+ autoload?: boolean;
25
+ }) => {
26
+ data: any;
27
+ load: (...args: any[]) => any;
28
+ loading: boolean;
29
+ error: boolean;
30
+ };
31
+
32
+ declare const useItems: ({ getPage, getItems, page, count, items: providedItems, pages: initialPages, getPageFromResponse, getItemsFromResponse, onItemsLoaded, onPageLoaded, onLoaded, onError, }: {
33
+ getPage?: any;
34
+ getItems?: any;
35
+ page?: any;
36
+ count?: number;
37
+ items?: any;
38
+ pages?: any;
39
+ getPageFromResponse?: ({ meta: { current_page: currentPage, last_page: lastPage, total }, data: items, }: {
40
+ meta: {
41
+ current_page: any;
42
+ last_page: any;
43
+ total: any;
44
+ };
45
+ data: any;
46
+ }) => {
47
+ page: number;
48
+ lastPage: number;
49
+ total: number;
50
+ items: any;
51
+ };
52
+ getItemsFromResponse?: (data: any) => any;
53
+ onItemsLoaded?: any;
54
+ onPageLoaded?: any;
55
+ onLoaded?: any;
56
+ onError?: any;
57
+ }) => {
58
+ items: any;
59
+ pages: any;
60
+ pageItems: any;
61
+ total: any;
62
+ lastPage: any;
63
+ loaded: boolean;
64
+ allLoaded: boolean;
65
+ loading: boolean;
66
+ loadNextPage: () => any;
67
+ loadPage: (pageToLoad: any) => any;
68
+ };
69
+
70
+ declare const useMedia: (id: any, opts: any) => {
71
+ load: (...args: any[]) => any;
72
+ loading: boolean;
73
+ error: boolean;
74
+ story: any;
75
+ };
76
+
77
+ declare const useMediaAuthors: (query: any, count: number, opts: any) => {
78
+ authors: any[];
79
+ };
80
+
81
+ declare const useMediaCreate: () => {
82
+ create: (data: any) => any;
83
+ creating: boolean;
84
+ };
85
+
86
+ declare const useMedias: (query?: any, page?: number, count?: number, opts?: any) => {
87
+ items: any;
88
+ total: any;
89
+ page: any;
90
+ count: any;
91
+ lastPage: any;
92
+ loading: boolean;
93
+ loaded: boolean;
94
+ allLoaded: boolean;
95
+ disabled: boolean;
96
+ loadNextPage: () => void;
97
+ reset: () => void;
98
+ };
99
+
100
+ declare const useMediasRecent: (opts: any, key?: string) => {
101
+ createSearch: (value: any) => boolean;
102
+ getSearches: (count?: number) => any;
103
+ };
104
+
105
+ declare const useMediaTags: (query?: any, count?: number, opts?: any) => {
106
+ pages: any;
107
+ total: any;
108
+ lastPage: any;
109
+ loaded: boolean;
110
+ allLoaded: boolean;
111
+ loading: boolean;
112
+ loadNextPage: () => any;
113
+ loadPage: (pageToLoad: any) => any;
114
+ tags: any;
115
+ };
116
+
117
+ declare const useMediaUpdate: () => {
118
+ update: (id: any, data: any) => any;
119
+ updating: boolean;
120
+ };
121
+
122
+ declare const useMediaRequestDelete: () => {
123
+ requestDeleteMedia: (id: any) => any;
124
+ requesting: boolean;
125
+ };
126
+
127
+ declare const useMediaDelete: () => {
128
+ deleteMedia: (id: any) => any;
129
+ deleting: boolean;
130
+ };
131
+
132
+ declare const useQuiz: ({ screenId, storyId: providedStoryId, opts }?: {
133
+ storyId?: any;
134
+ opts?: {};
135
+ }) => {
136
+ load?: (...args: any[]) => any;
137
+ loading?: boolean;
138
+ error?: boolean;
139
+ quiz: any;
140
+ };
141
+
142
+ declare const useQuizCreate: ({ screenId, visitorId: providedVisitorId, storyId: providedStoryId, onSuccess, }?: {
143
+ visitorId?: any;
144
+ storyId?: any;
145
+ onSuccess?: any;
146
+ }) => {
147
+ create: (data: any) => any;
148
+ creating: boolean;
149
+ };
150
+
151
+ declare const useApi: () => unknown;
152
+ declare function ApiProvider({ api: initialApi, baseUrl, children }: {
153
+ api?: any;
154
+ baseUrl?: any;
155
+ children: any;
156
+ }): react_jsx_runtime.JSX.Element;
157
+
158
+ declare class Base {
159
+ constructor(opts?: {});
160
+ requestGet(path: any, query?: any): any;
161
+ requestPost(path: any, data: any): any;
162
+ requestPut(path: any, data: any): any;
163
+ requestDelete(path: any): any;
164
+ route(route: any, params: any): string;
165
+ getFullUrl(path: any): string;
166
+ }
167
+
168
+ declare class Api extends Base {
169
+ constructor(opts?: {});
170
+ }
171
+
172
+ declare function DataProvider({ api, apiBaseUrl, children }: {
173
+ api?: any;
174
+ apiBaseUrl?: any;
175
+ children?: any;
176
+ }): react_jsx_runtime.JSX.Element;
177
+
178
+ export { Api, ApiProvider, Base as BaseApi, DataProvider, useApi, useContributionCreate, useContributions, useData, useItems, useMedia, useMediaAuthors, useMediaCreate, useMediaDelete, useMediaRequestDelete, useMediaTags, useMediaUpdate, useMedias, useMediasRecent as useMediasRecentSearches, useQuiz, useQuizCreate };
package/es/index.js CHANGED
@@ -1,4 +1,3 @@
1
- import PropTypes from 'prop-types';
2
1
  import React, { useMemo, useContext, useState, useCallback, useEffect, useRef } from 'react';
3
2
  import _createClass from '@babel/runtime/helpers/createClass';
4
3
  import _classCallCheck from '@babel/runtime/helpers/classCallCheck';
@@ -263,18 +262,11 @@ var ApiContext = /*#__PURE__*/React.createContext(null);
263
262
  var useApi = function useApi() {
264
263
  return useContext(ApiContext);
265
264
  };
266
- var propTypes$1 = {
267
- api: PropTypes.instanceOf(Api),
268
- baseUrl: PropTypes.string,
269
- children: PropTypes.node.isRequired
270
- };
271
- var defaultProps$1 = {
272
- api: null,
273
- baseUrl: undefined
274
- };
275
- var ApiProvider = function ApiProvider(_ref) {
276
- var initialApi = _ref.api,
277
- baseUrl = _ref.baseUrl,
265
+ function ApiProvider(_ref) {
266
+ var _ref$api = _ref.api,
267
+ initialApi = _ref$api === void 0 ? null : _ref$api,
268
+ _ref$baseUrl = _ref.baseUrl,
269
+ baseUrl = _ref$baseUrl === void 0 ? undefined : _ref$baseUrl,
278
270
  children = _ref.children;
279
271
  var previousApi = useApi();
280
272
  var api = useMemo(function () {
@@ -286,9 +278,7 @@ var ApiProvider = function ApiProvider(_ref) {
286
278
  return /*#__PURE__*/React.createElement(ApiContext.Provider, {
287
279
  value: api
288
280
  }, children);
289
- };
290
- ApiProvider.propTypes = propTypes$1;
291
- ApiProvider.defaultProps = defaultProps$1;
281
+ }
292
282
 
293
283
  var useContributionCreate = function useContributionCreate() {
294
284
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
@@ -1064,26 +1054,17 @@ var useQuizCreate = function useQuizCreate() {
1064
1054
  };
1065
1055
 
1066
1056
  /* eslint-disable react/jsx-props-no-spreading */
1067
- var propTypes = {
1068
- api: PropTypes.instanceOf(Api),
1069
- apiBaseUrl: PropTypes.string,
1070
- children: PropTypes.node
1071
- };
1072
- var defaultProps = {
1073
- api: null,
1074
- apiBaseUrl: undefined,
1075
- children: null
1076
- };
1077
- var DataProvider = function DataProvider(_ref) {
1078
- var api = _ref.api,
1079
- apiBaseUrl = _ref.apiBaseUrl,
1080
- children = _ref.children;
1057
+ function DataProvider(_ref) {
1058
+ var _ref$api = _ref.api,
1059
+ api = _ref$api === void 0 ? null : _ref$api,
1060
+ _ref$apiBaseUrl = _ref.apiBaseUrl,
1061
+ apiBaseUrl = _ref$apiBaseUrl === void 0 ? undefined : _ref$apiBaseUrl,
1062
+ _ref$children = _ref.children,
1063
+ children = _ref$children === void 0 ? null : _ref$children;
1081
1064
  return /*#__PURE__*/React.createElement(ApiProvider, {
1082
1065
  api: api,
1083
1066
  baseUrl: apiBaseUrl
1084
1067
  }, children);
1085
- };
1086
- DataProvider.propTypes = propTypes;
1087
- DataProvider.defaultProps = defaultProps;
1068
+ }
1088
1069
 
1089
1070
  export { Api, ApiProvider, Base as BaseApi, DataProvider, useApi, useContributionCreate, useContributions, useData, useItems$1 as useItems, useMedia, useMediaAuthors, useMediaCreate, useMediaDelete, useMediaRequestDelete, useMediaTags, useMediaUpdate, useMedias, useMediasRecent as useMediasRecentSearches, useQuiz, useQuizCreate };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromag/data",
3
- "version": "0.3.832",
3
+ "version": "0.4.6",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [
@@ -34,6 +34,7 @@
34
34
  "module": "es/index.js",
35
35
  "exports": {
36
36
  ".": {
37
+ "types": "./es/index.d.ts",
37
38
  "import": "./es/index.js"
38
39
  }
39
40
  },
@@ -45,28 +46,28 @@
45
46
  "scripts": {
46
47
  "clean": "rm -rf es && rm -rf lib && rm -rf assets",
47
48
  "prepublishOnly": "npm run build",
48
- "build": "../../scripts/prepare-package.sh"
49
+ "build": "../../scripts/prepare-package.sh --types"
49
50
  },
50
51
  "devDependencies": {
51
- "react": "^16.8.0 || ^17.0.0 || ^18.0.0",
52
- "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
52
+ "react": "^19.2.0",
53
+ "react-dom": "^18.3.0 || ^19.0.0"
53
54
  },
54
55
  "peerDependencies": {
55
- "react": "^16.8.0 || ^17.0.0 || ^18.0.0",
56
- "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
56
+ "react": "^19.2.0",
57
+ "react-dom": "^18.3.0 || ^19.0.0"
57
58
  },
58
59
  "dependencies": {
59
- "@babel/runtime": "^7.13.10",
60
+ "@babel/runtime": "^7.28.6",
60
61
  "@folklore/fetch": "^0.1.17",
61
62
  "@folklore/routes": "^0.2.36",
62
- "@micromag/core": "^0.3.832",
63
- "lodash": "^4.17.21",
64
- "prop-types": "^15.7.2",
63
+ "@micromag/core": "^0.4.6",
64
+ "lodash": "^4.17.23",
65
65
  "query-string": "^9.0.0"
66
66
  },
67
67
  "publishConfig": {
68
68
  "access": "public",
69
69
  "registry": "https://registry.npmjs.org/"
70
70
  },
71
- "gitHead": "4969d64e304334cfd47321e624e5914e0694c55f"
71
+ "gitHead": "cf8440c2851b864167a1f545aa56551d55473263",
72
+ "types": "es/index.d.ts"
72
73
  }