@chekinapp/ui 0.0.99 → 0.0.100

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/dist/index.cjs CHANGED
@@ -9234,21 +9234,37 @@ var sign_finger_default = SvgSignFinger;
9234
9234
 
9235
9235
  // src/signature-canvas/SignatureCanvas.tsx
9236
9236
  var import_jsx_runtime109 = require("react/jsx-runtime");
9237
- var CANVAS_PROPS = {
9238
- width: "250px",
9239
- height: "174px"
9240
- };
9241
9237
  var SIGNATURE_PROPS = {
9242
9238
  penColor: "#161643",
9243
9239
  minWidth: 1.5,
9244
9240
  maxWidth: 1.5,
9245
9241
  dotSize: 1
9246
9242
  };
9243
+ var ASPECT_RATIO = 330 / 190;
9247
9244
  var SignatureCanvas = (0, import_react74.forwardRef)(
9248
9245
  ({ onClear, hasSignature, onEnd, onEnable, className, enabled }, ref) => {
9249
9246
  const { t } = (0, import_react_i18next17.useTranslation)();
9250
9247
  const internalRef = (0, import_react74.useRef)(null);
9248
+ const containerRef = (0, import_react74.useRef)(null);
9251
9249
  const combinedRef = useCombinedRef(ref, internalRef);
9250
+ const [size, setSize] = (0, import_react74.useState)({ width: 330, height: 190 });
9251
+ const calculateSize = (0, import_react74.useCallback)((containerWidth) => {
9252
+ const width = Math.min(containerWidth, 646);
9253
+ const height = Math.round(width / ASPECT_RATIO);
9254
+ setSize({ width, height });
9255
+ }, []);
9256
+ (0, import_react74.useEffect)(() => {
9257
+ const container = containerRef.current;
9258
+ if (!container) return;
9259
+ const observer = new ResizeObserver((entries) => {
9260
+ const entry = entries[0];
9261
+ if (entry) {
9262
+ calculateSize(entry.contentRect.width);
9263
+ }
9264
+ });
9265
+ observer.observe(container);
9266
+ return () => observer.disconnect();
9267
+ }, [calculateSize]);
9252
9268
  (0, import_react74.useEffect)(() => {
9253
9269
  if (!onEnd) return;
9254
9270
  const signPad = internalRef.current?.instance;
@@ -9257,73 +9273,85 @@ var SignatureCanvas = (0, import_react74.forwardRef)(
9257
9273
  signPad?.removeEventListener("endStroke", onEnd);
9258
9274
  };
9259
9275
  }, [onEnd]);
9260
- return /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("div", { className: cn("relative inline-flex flex-col", className), children: [
9261
- !enabled && /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(
9262
- "button",
9263
- {
9264
- type: "button",
9265
- className: cn(
9266
- "absolute left-0 top-0 z-10 flex h-[174px] w-[250px] flex-col items-center",
9267
- "justify-between rounded border-0 bg-[var(--signature-canvas-placeholder-bg)] px-0 pb-7 pt-10",
9268
- "cursor-pointer select-none"
9269
- ),
9270
- onClick: onEnable,
9271
- "data-testid": "signature-placeholder",
9272
- children: [
9273
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(SvgIcon, { as: sign_finger_default, size: 41, className: "w-[37px] opacity-[0.55]" }),
9274
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
9275
- "span",
9276
- {
9277
- className: cn(
9278
- "mx-auto mt-2 max-w-[154px] break-words text-center text-sm font-medium uppercase",
9279
- "text-[var(--signature-canvas-placeholder-text)] opacity-[0.55]"
9280
- ),
9281
- children: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(import_react_i18next17.Trans, { i18nKey: "signature_placeholder_text" })
9282
- }
9283
- )
9284
- ]
9285
- }
9286
- ),
9287
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
9288
- "div",
9289
- {
9290
- className: cn(
9291
- "inline-flex h-[174px] w-[250px] cursor-pointer justify-center rounded border",
9292
- "border-[var(--signature-canvas-border)] shadow-[var(--signature-canvas-shadow)]",
9293
- "box-border max-[320px]:overflow-hidden"
9294
- ),
9295
- children: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
9296
- import_react_signature_pad_wrapper.default,
9276
+ return /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(
9277
+ "div",
9278
+ {
9279
+ ref: containerRef,
9280
+ className: cn("relative flex w-full flex-col items-center", className),
9281
+ children: [
9282
+ !enabled && /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(
9283
+ "button",
9297
9284
  {
9298
- ref: combinedRef,
9299
- "data-testid": "canvas",
9300
- ...SIGNATURE_PROPS,
9301
- canvasProps: CANVAS_PROPS
9285
+ type: "button",
9286
+ className: cn(
9287
+ "absolute left-1/2 top-0 z-10 flex -translate-x-1/2 flex-col items-center",
9288
+ "justify-center rounded-xl border-2 border-[var(--signature-canvas-border)] bg-transparent",
9289
+ "cursor-pointer select-none"
9290
+ ),
9291
+ style: { width: size.width, height: size.height },
9292
+ onClick: onEnable,
9293
+ "data-testid": "signature-placeholder",
9294
+ children: [
9295
+ /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(SvgIcon, { as: sign_finger_default, size: 41, className: "w-[37px] opacity-55" }),
9296
+ /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
9297
+ "span",
9298
+ {
9299
+ className: cn(
9300
+ "mx-auto mt-4 max-w-[200px] break-words text-center text-base font-medium",
9301
+ "text-[var(--signature-canvas-placeholder-text)] opacity-55"
9302
+ ),
9303
+ children: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(import_react_i18next17.Trans, { i18nKey: "tap_here_to_sign" })
9304
+ }
9305
+ )
9306
+ ]
9302
9307
  }
9303
- )
9304
- }
9305
- ),
9306
- /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
9307
- "div",
9308
- {
9309
- className: cn("text-right", {
9310
- invisible: !enabled || !hasSignature
9311
- }),
9312
- children: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
9313
- Button,
9308
+ ),
9309
+ /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
9310
+ "div",
9314
9311
  {
9315
- variant: "link",
9316
9312
  className: cn(
9317
- "ml-auto mt-2 h-[30px] min-w-[70px] select-none rounded-sm px-2 py-0.5 text-right",
9318
- "text-xs uppercase hover:opacity-[0.88] active:opacity-100"
9313
+ "inline-flex cursor-pointer justify-center rounded-xl border-2",
9314
+ "border-[var(--signature-canvas-border)] bg-[var(--signature-canvas-bg)]",
9315
+ { hidden: !enabled }
9319
9316
  ),
9320
- onClick: onClear,
9321
- children: t("clear")
9317
+ style: { width: size.width, height: size.height },
9318
+ children: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
9319
+ import_react_signature_pad_wrapper.default,
9320
+ {
9321
+ ref: combinedRef,
9322
+ "data-testid": "canvas",
9323
+ options: SIGNATURE_PROPS,
9324
+ canvasProps: {
9325
+ style: { width: `${size.width}px`, height: `${size.height}px` }
9326
+ }
9327
+ }
9328
+ )
9329
+ }
9330
+ ),
9331
+ /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
9332
+ "div",
9333
+ {
9334
+ className: cn("w-full text-right", {
9335
+ invisible: !enabled || !hasSignature
9336
+ }),
9337
+ style: { maxWidth: size.width },
9338
+ children: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
9339
+ Button,
9340
+ {
9341
+ variant: "link",
9342
+ className: cn(
9343
+ "ml-auto mt-2 h-[30px] min-w-[70px] select-none rounded-sm px-2 py-0.5 text-right",
9344
+ "text-xs uppercase hover:opacity-[0.88] active:opacity-100"
9345
+ ),
9346
+ onClick: onClear,
9347
+ children: t("clear")
9348
+ }
9349
+ )
9322
9350
  }
9323
9351
  )
9324
- }
9325
- )
9326
- ] });
9352
+ ]
9353
+ }
9354
+ );
9327
9355
  }
9328
9356
  );
9329
9357
  SignatureCanvas.displayName = "SignatureCanvas";
@@ -11682,7 +11710,7 @@ function DeviceCamera({ onChange, facingMode, className }) {
11682
11710
  ),
11683
11711
  children: [
11684
11712
  /* @__PURE__ */ (0, import_jsx_runtime139.jsx)("div", { children: t("camera_errors.experiencing_camera_issues") }),
11685
- /* @__PURE__ */ (0, import_jsx_runtime139.jsxs)("label", { className: "text-[16px] font-semibold uppercase leading-6 text-[var(--text-button-color)]", children: [
11713
+ /* @__PURE__ */ (0, import_jsx_runtime139.jsxs)("label", { className: "text-[16px] font-semibold uppercase leading-6", children: [
11686
11714
  t("open_devices_camera"),
11687
11715
  /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(
11688
11716
  "input",