@yogiswara/honcho-editor-ui 3.2.1 → 3.2.2

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.
@@ -123,6 +123,7 @@ export default function HSliderColorMobile(props) {
123
123
  right: 0,
124
124
  zIndex: 1,
125
125
  touchAction: 'manipulation', // ✅ 1. Add this to make double-tap reliable on mobile
126
+ userSelect: 'none',
126
127
  } }), _jsx(Slider, { sx: {
127
128
  width: "100%",
128
129
  color: colors.surface,
@@ -161,6 +162,7 @@ export default function HSliderColorMobile(props) {
161
162
  right: 0,
162
163
  zIndex: 1,
163
164
  touchAction: 'manipulation', // ✅ 1. Add this to make double-tap reliable on mobile
165
+ userSelect: 'none',
164
166
  } }), _jsx(Slider, { sx: {
165
167
  width: "100%",
166
168
  color: colors.surface,
@@ -199,6 +201,7 @@ export default function HSliderColorMobile(props) {
199
201
  right: 0,
200
202
  zIndex: 1,
201
203
  touchAction: 'manipulation', // ✅ 1. Add this to make double-tap reliable on mobile
204
+ userSelect: 'none',
202
205
  } }), _jsx(Slider, { sx: {
203
206
  width: "100%",
204
207
  color: colors.surface,
@@ -237,6 +240,7 @@ export default function HSliderColorMobile(props) {
237
240
  right: 0,
238
241
  zIndex: 1,
239
242
  touchAction: 'manipulation', // ✅ 1. Add this to make double-tap reliable on mobile
243
+ userSelect: 'none',
240
244
  } }), _jsx(Slider, { sx: {
241
245
  width: "100%",
242
246
  color: colors.surface,
@@ -105,6 +105,7 @@ export default function HSliderLightMobile(props) {
105
105
  right: 0,
106
106
  zIndex: 1,
107
107
  touchAction: 'manipulation', // ✅ 1. Add this to make double-tap reliable on mobile
108
+ userSelect: 'none',
108
109
  } }), _jsx(Slider, { sx: {
109
110
  width: "100%",
110
111
  color: colors.onSurfaceVariant,
@@ -144,6 +145,7 @@ export default function HSliderLightMobile(props) {
144
145
  right: 0,
145
146
  zIndex: 1,
146
147
  touchAction: 'manipulation', // ✅ 1. Add this to make double-tap reliable on mobile
148
+ userSelect: 'none',
147
149
  } }), _jsx(Slider, { sx: {
148
150
  width: "100%",
149
151
  color: colors.onSurfaceVariant,
@@ -183,6 +185,7 @@ export default function HSliderLightMobile(props) {
183
185
  right: 0,
184
186
  zIndex: 1,
185
187
  touchAction: 'manipulation', // ✅ 1. Add this to make double-tap reliable on mobile
188
+ userSelect: 'none',
186
189
  } }), _jsx(Slider, { sx: {
187
190
  width: "100%",
188
191
  color: colors.onSurfaceVariant,
@@ -222,6 +225,7 @@ export default function HSliderLightMobile(props) {
222
225
  right: 0,
223
226
  zIndex: 1,
224
227
  touchAction: 'manipulation', // ✅ 1. Add this to make double-tap reliable on mobile
228
+ userSelect: 'none',
225
229
  } }), _jsx(Slider, { sx: {
226
230
  width: "100%",
227
231
  color: colors.onSurfaceVariant,
@@ -261,6 +265,7 @@ export default function HSliderLightMobile(props) {
261
265
  right: 0,
262
266
  zIndex: 1,
263
267
  touchAction: 'manipulation', // ✅ 1. Add this to make double-tap reliable on mobile
268
+ userSelect: 'none',
264
269
  } }), _jsx(Slider, { sx: {
265
270
  width: "100%",
266
271
  color: colors.onSurfaceVariant,
@@ -300,6 +305,7 @@ export default function HSliderLightMobile(props) {
300
305
  right: 0,
301
306
  zIndex: 1,
302
307
  touchAction: 'manipulation', // ✅ 1. Add this to make double-tap reliable on mobile
308
+ userSelect: 'none',
303
309
  } }), _jsx(Slider, { sx: {
304
310
  width: "100%",
305
311
  color: colors.onSurfaceVariant,
@@ -0,0 +1,57 @@
1
+ import { AxiosInstance, AxiosRequestConfig, AxiosResponse } from "axios";
2
+ import { Observable } from "rxjs/internal/Observable";
3
+ export declare const api: any;
4
+ export interface ResponseData<T> {
5
+ code?: number;
6
+ message?: string;
7
+ data?: T;
8
+ error_message?: string;
9
+ }
10
+ export declare class ResponseError extends Error {
11
+ code: number;
12
+ error_message: string;
13
+ isEmptyData: boolean;
14
+ constructor(code: number, error_message: string, originalError?: Error, isEmptyData?: boolean);
15
+ }
16
+ export declare class EmptyDataError extends Error {
17
+ constructor();
18
+ }
19
+ export declare function handleResponse<T>(res: AxiosResponse<ResponseData<T>>): T;
20
+ export declare function handleError(error: any): Observable<any>;
21
+ export declare function isResponseError(error: any): Boolean;
22
+ /**
23
+ * @deprecated use axiosGetObservable, axiosPostObservable, axiosPutObservable, axiosDeleteObservable instead
24
+ * @param promise
25
+ */
26
+ export declare function fromAxiosToObservable<T>(promise: Promise<AxiosResponse<ResponseData<T>>>): Observable<T>;
27
+ export declare const apiV3: any;
28
+ export declare class BaseServices {
29
+ protected axios: AxiosInstance;
30
+ protected constructor(axios: AxiosInstance);
31
+ protected axiosGetObservable<T>(url: string, params?: AxiosRequestConfig<any> | undefined): Observable<T>;
32
+ protected axiosPostObservable<T>(url: string, data: any, params?: AxiosRequestConfig<any> | undefined): Observable<T>;
33
+ protected axiosPutObservable<T>(url: string, data: any, params?: AxiosRequestConfig<any> | undefined): Observable<T>;
34
+ protected axiosDeleteObservable<T>(url: string, params?: AxiosRequestConfig<any> | undefined): Observable<T>;
35
+ }
36
+ export interface Result<T> {
37
+ getStatus(): "loading" | "success" | "error" | "not-found" | "idle";
38
+ getData(): T;
39
+ getDataOrNull(): T | null | undefined;
40
+ getError(): any;
41
+ }
42
+ export declare class ResultImpl<T> implements Result<T> {
43
+ private readonly status;
44
+ private readonly data;
45
+ private readonly error;
46
+ getStatus(): "loading" | "success" | "error" | "not-found" | "idle";
47
+ getData(): T;
48
+ getError(): any;
49
+ getDataOrNull(): T | null | undefined;
50
+ private constructor();
51
+ static success<T>(data: T): Result<T>;
52
+ static loading<T>(): Result<T>;
53
+ static error<T>(err: any): Result<T>;
54
+ static notFound<T>(): Result<T>;
55
+ static idle<T>(): Result<T>;
56
+ }
57
+ export declare function fromPromise<T>(promise: Promise<T>): Observable<T>;
@@ -0,0 +1,243 @@
1
+ import axios from "axios";
2
+ import axiosRetry from 'axios-retry';
3
+ import { Observable } from "rxjs/internal/Observable";
4
+ import { catchError, from, map } from "rxjs";
5
+ const BASE_URL = process.env.NEXT_PUBLIC_BASE_URL || "http://localhost:8080";
6
+ const apiConfig = (version) => {
7
+ return axios.create({
8
+ baseURL: `${BASE_URL}/${version}/`,
9
+ timeout: 60000 * 2,
10
+ });
11
+ };
12
+ export const api = axios.create({
13
+ baseURL: `${BASE_URL}`,
14
+ timeout: 60000 * 2,
15
+ });
16
+ axiosRetry(api, { retries: 3, retryDelay: axiosRetry.linearDelay() });
17
+ export class ResponseError extends Error {
18
+ constructor(code, error_message, originalError, isEmptyData = false) {
19
+ super(`${code}: ${error_message}`);
20
+ this.isEmptyData = false;
21
+ this.code = code;
22
+ this.error_message = error_message;
23
+ this.isEmptyData = isEmptyData;
24
+ if (originalError && originalError.stack) {
25
+ this.stack += `\nCaused by: ${originalError.stack}`;
26
+ }
27
+ // we need to set prototype to make this object can check by
28
+ // instanceof ResponseError
29
+ Object.setPrototypeOf(this, ResponseError.prototype);
30
+ }
31
+ }
32
+ export class EmptyDataError extends Error {
33
+ constructor() {
34
+ super("Data Empty, server not send any data in response");
35
+ // we need to set prototype to make this object can check by
36
+ // instanceof EmptyDataError
37
+ Object.setPrototypeOf(this, EmptyDataError.prototype);
38
+ }
39
+ }
40
+ // get data from response
41
+ export function handleResponse(res) {
42
+ if (!res.data.data) {
43
+ throw new EmptyDataError();
44
+ }
45
+ return res.data.data;
46
+ }
47
+ function mapError(error) {
48
+ if (error.isAxiosError) {
49
+ if (error.response) {
50
+ if (typeof error.response.data === "string") {
51
+ return {
52
+ code: error.response.status,
53
+ message: `${error.response.status}: ${error.response.statusText}`,
54
+ data: undefined,
55
+ error_message: error.response.data,
56
+ };
57
+ }
58
+ else {
59
+ return error.response?.data;
60
+ }
61
+ }
62
+ else if (error.request) {
63
+ return {
64
+ code: 400,
65
+ message: "`${error.name}: failed connect to server check your connection`",
66
+ data: undefined,
67
+ error_message: "failed connect to server",
68
+ };
69
+ }
70
+ else {
71
+ return {
72
+ code: 400,
73
+ message: error.message,
74
+ data: undefined,
75
+ error_message: error.message,
76
+ };
77
+ }
78
+ }
79
+ else {
80
+ return {
81
+ code: 500,
82
+ message: String(error),
83
+ data: undefined,
84
+ error_message: String(error),
85
+ };
86
+ }
87
+ }
88
+ // handle error from response convert it and throw it as ResponseError
89
+ export function handleError(error) {
90
+ if (error instanceof EmptyDataError) {
91
+ // if data is empty just throw error
92
+ throw new ResponseError(204, "Data Empty, server not send any data in response", error, true);
93
+ }
94
+ let response = mapError(error);
95
+ throw new ResponseError(response.code || 500, response.error_message || "Unknown error", error);
96
+ }
97
+ export function isResponseError(error) {
98
+ return !!((error.code) && (error.error_message));
99
+ }
100
+ /**
101
+ * @deprecated use axiosGetObservable, axiosPostObservable, axiosPutObservable, axiosDeleteObservable instead
102
+ * @param promise
103
+ */
104
+ export function fromAxiosToObservable(promise) {
105
+ return from(promise).pipe(map(handleResponse), catchError(handleError));
106
+ }
107
+ export const apiV3 = apiConfig('v3');
108
+ export class BaseServices {
109
+ constructor(axios) {
110
+ this.axios = axios;
111
+ }
112
+ axiosGetObservable(url, params) {
113
+ return new Observable(subscriber => {
114
+ const controller = new AbortController();
115
+ const paramsData = { signal: controller.signal, ...params };
116
+ this.axios.get(url, paramsData)
117
+ .then(res => {
118
+ console.debug({ res, url, params }, "success GET request");
119
+ subscriber.next(res);
120
+ subscriber.complete();
121
+ })
122
+ .catch((error) => {
123
+ console.error({ error, url, params }, "Failed GET request");
124
+ subscriber.error(error);
125
+ });
126
+ return () => {
127
+ console.debug({ url, params, method: "GET" }, "Abort request");
128
+ controller.abort();
129
+ };
130
+ }).pipe(map(handleResponse), catchError(handleError));
131
+ }
132
+ axiosPostObservable(url, data, params) {
133
+ return new Observable(subscriber => {
134
+ const controller = new AbortController();
135
+ const paramsData = { signal: controller.signal, ...params };
136
+ this.axios.post(url, data, paramsData)
137
+ .then(res => {
138
+ console.debug({ res, url, params }, "success POST request");
139
+ subscriber.next(res);
140
+ subscriber.complete();
141
+ })
142
+ .catch((error) => {
143
+ console.error({ error, url, params }, "Failed POST request");
144
+ subscriber.error(error);
145
+ });
146
+ return () => {
147
+ console.debug({ url, params, method: "POST" }, "Abort request");
148
+ controller.abort();
149
+ };
150
+ }).pipe(map(handleResponse), catchError(handleError));
151
+ }
152
+ axiosPutObservable(url, data, params) {
153
+ return new Observable(subscriber => {
154
+ const controller = new AbortController();
155
+ const paramsData = { signal: controller.signal, ...params };
156
+ this.axios.put(url, data, paramsData)
157
+ .then(res => {
158
+ console.debug({ res, url, params }, "success PUT request");
159
+ subscriber.next(res);
160
+ subscriber.complete();
161
+ })
162
+ .catch((error) => {
163
+ console.error({ error, url, params }, "Failed PUT request");
164
+ subscriber.error(error);
165
+ });
166
+ return () => {
167
+ console.debug({ url, params, method: "PUT" }, "Abort request");
168
+ controller.abort();
169
+ };
170
+ }).pipe(map(handleResponse), catchError(handleError));
171
+ }
172
+ axiosDeleteObservable(url, params) {
173
+ return new Observable(subscriber => {
174
+ const controller = new AbortController();
175
+ const paramsData = { signal: controller.signal, ...params };
176
+ this.axios.delete(url, paramsData)
177
+ .then(res => {
178
+ console.debug({ res, url, params }, "success DELETE request");
179
+ subscriber.next(res);
180
+ subscriber.complete();
181
+ })
182
+ .catch((error) => {
183
+ console.error({ error, url, params }, "Failed DELETE request");
184
+ subscriber.error(error);
185
+ });
186
+ return () => {
187
+ console.debug({ url, params, method: "DELETE" }, "Abort request");
188
+ controller.abort();
189
+ };
190
+ }).pipe(map(handleResponse), catchError(handleError));
191
+ }
192
+ }
193
+ export class ResultImpl {
194
+ getStatus() {
195
+ return this.status;
196
+ }
197
+ getData() {
198
+ if (this.data)
199
+ return this.data;
200
+ throw new Error("Data is not available");
201
+ }
202
+ getError() {
203
+ if (this.error)
204
+ return this.error;
205
+ throw new Error("Error is not available");
206
+ }
207
+ getDataOrNull() {
208
+ return this.data;
209
+ }
210
+ constructor(status, data, error) {
211
+ this.status = "idle";
212
+ this.status = status;
213
+ this.data = data;
214
+ this.error = error;
215
+ }
216
+ static success(data) {
217
+ return new ResultImpl("success", data, null);
218
+ }
219
+ static loading() {
220
+ return new ResultImpl("loading");
221
+ }
222
+ static error(err) {
223
+ return new ResultImpl("error", null, err);
224
+ }
225
+ static notFound() {
226
+ return new ResultImpl("not-found");
227
+ }
228
+ static idle() {
229
+ return new ResultImpl("idle");
230
+ }
231
+ }
232
+ export function fromPromise(promise) {
233
+ return new Observable(subscriber => {
234
+ promise.then(value => {
235
+ console.debug({ value }, "Promise success");
236
+ subscriber.next(value);
237
+ subscriber.complete();
238
+ }).catch(err => {
239
+ console.error({ err }, "Promise error");
240
+ subscriber.error(err);
241
+ });
242
+ });
243
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yogiswara/honcho-editor-ui",
3
- "version": "3.2.1",
3
+ "version": "3.2.2",
4
4
  "description": "A complete UI component library for the Honcho photo editor.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",