@edifice.io/react 2.4.0-develop-pedago.20251029104249 → 2.4.0-develop-pedago.20251104155002

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.
@@ -25,6 +25,10 @@ export interface TextAreaProps extends Omit<React.ComponentPropsWithRef<'textare
25
25
  * Optional class for styling purpose
26
26
  */
27
27
  className?: string;
28
+ /**
29
+ * Show count of characters
30
+ */
31
+ showCounter?: boolean;
28
32
  }
29
33
  /**
30
34
  * TextArea Form Component
@@ -1,5 +1,5 @@
1
- import { jsx, Fragment } from "react/jsx-runtime";
2
- import { forwardRef } from "react";
1
+ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
+ import { forwardRef, useState } from "react";
3
3
  import clsx from "clsx";
4
4
  import { useFormControl } from "../Form/FormContext.js";
5
5
  const TextArea = /* @__PURE__ */ forwardRef(({
@@ -8,14 +8,16 @@ const TextArea = /* @__PURE__ */ forwardRef(({
8
8
  size = "md",
9
9
  height = "md",
10
10
  className,
11
+ showCounter,
11
12
  ...restProps
12
13
  }, ref) => {
14
+ var _a;
13
15
  const {
14
16
  id,
15
17
  isRequired,
16
18
  isReadOnly,
17
19
  status
18
- } = useFormControl(), classes = clsx({
20
+ } = useFormControl(), [currentLength, setCurrentLength] = useState(((_a = restProps.value) == null ? void 0 : _a.toString().length) || 0), classes = clsx({
19
21
  "form-control": !isReadOnly,
20
22
  "form-control-lg": size === "lg",
21
23
  "form-control-sm": size === "sm",
@@ -27,7 +29,20 @@ const TextArea = /* @__PURE__ */ forwardRef(({
27
29
  "form-control-plaintext": isReadOnly,
28
30
  "no-validation-icon": noValidationIcon
29
31
  }, className);
30
- return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("textarea", { ref, id, className: classes, placeholder, required: isRequired, readOnly: isReadOnly, ...restProps }) });
32
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
33
+ /* @__PURE__ */ jsx("textarea", { ref, id, className: classes, placeholder, required: isRequired, readOnly: isReadOnly, ...restProps, onChange: (e) => {
34
+ var _a2;
35
+ setCurrentLength(e.target.value.length), (_a2 = restProps.onChange) == null || _a2.call(restProps, e);
36
+ } }),
37
+ showCounter && !status && /* @__PURE__ */ jsxs("span", { className: clsx("caption text-end float-end mt-n32 py-2 px-12 ", {
38
+ "text-danger": currentLength === restProps.maxLength,
39
+ "text-gray-700": currentLength !== restProps.maxLength
40
+ }), children: [
41
+ currentLength,
42
+ " / ",
43
+ restProps.maxLength
44
+ ] })
45
+ ] });
31
46
  });
32
47
  export {
33
48
  TextArea as default
@@ -66,7 +66,7 @@ const MediaRenderer = (props) => {
66
66
  case "iframe":
67
67
  return /* @__PURE__ */ jsxs(Fragment, { children: [
68
68
  /* @__PURE__ */ jsx("div", { className: "iframe-node-view" }),
69
- /* @__PURE__ */ jsx("iframe", { ref: resizableMedia, src: node.attrs.src, width, height, allowFullScreen: node.attrs.allowfullscreen ?? !0, style: node.attrs.style })
69
+ /* @__PURE__ */ jsx("iframe", { ref: resizableMedia, src: node.attrs.src, width, height, allowFullScreen: node.attrs.allowfullscreen ?? !0 })
70
70
  ] });
71
71
  default:
72
72
  return null;
@@ -4,7 +4,6 @@ import { odeServices } from "@edifice.io/client";
4
4
  import { createPortal } from "react-dom";
5
5
  import { useForm } from "react-hook-form";
6
6
  import { useTranslation } from "react-i18next";
7
- import { TextareaCounter } from "../../../components/TextArea/TextareaCounter.js";
8
7
  import ImagePicker from "../../multimedia/ImagePicker/ImagePicker.js";
9
8
  import { useThumb } from "./hooks/useThumb.js";
10
9
  import { useEdificeClient } from "../../../providers/EdificeClientProvider/EdificeClientProvider.hook.js";
@@ -67,7 +66,7 @@ const DEFAULT_INPUT_MAX_LENGTH = 60, DEFAULT_TEXTAREA_MAX_LENGTH = 400, Resource
67
66
  } = useThumb({
68
67
  isUpdating,
69
68
  selectedResource: isUpdating ? resource : void 0
70
- }), watchedDescription = watch("description"), onSubmit = async function(formData) {
69
+ }), onSubmit = async function(formData) {
71
70
  var _a2, _b2;
72
71
  try {
73
72
  const data = {
@@ -132,15 +131,14 @@ const DEFAULT_INPUT_MAX_LENGTH = 60, DEFAULT_TEXTAREA_MAX_LENGTH = 400, Resource
132
131
  value: /[^ ]/,
133
132
  message: "invalid title"
134
133
  }
135
- }), placeholder: ((_e = customT.placeholder) == null ? void 0 : _e.title) ?? t("explorer.resource.editModal.title.placeholder"), size: "md", "aria-required": !0, maxLength: inputMaxLength })
134
+ }), placeholder: ((_e = customT.placeholder) == null ? void 0 : _e.title) ?? t("explorer.resource.editModal.title.placeholder"), size: "md", "aria-required": !0, maxLength: inputMaxLength, showCounter: !0 })
136
135
  ] }),
137
136
  /* @__PURE__ */ jsxs(FormControl, { id: "description", isOptional: !0, children: [
138
137
  /* @__PURE__ */ jsx(Label, { children: customT.description ?? t("description") }),
139
138
  /* @__PURE__ */ jsx(TextArea, { defaultValue: (resource == null ? void 0 : resource.description) || "", ...register("description", {
140
139
  required: !1,
141
140
  maxLength: textareaMaxLength
142
- }), placeholder: ((_f = customT.placeholder) == null ? void 0 : _f.description) ?? t("explorer.resource.editModal.description.placeholder"), size: "md", maxLength: textareaMaxLength }),
143
- watchedDescription && /* @__PURE__ */ jsx(TextareaCounter, { content: watchedDescription, maxLength: textareaMaxLength })
141
+ }), placeholder: ((_f = customT.placeholder) == null ? void 0 : _f.description) ?? t("explorer.resource.editModal.description.placeholder"), size: "md", maxLength: textareaMaxLength, showCounter: !0 })
144
142
  ] })
145
143
  ] })
146
144
  ] }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edifice.io/react",
3
- "version": "2.4.0-develop-pedago.20251029104249",
3
+ "version": "2.4.0-develop-pedago.20251104155002",
4
4
  "description": "Edifice React Library",
5
5
  "keywords": [
6
6
  "react",
@@ -131,9 +131,9 @@
131
131
  "react-slugify": "^3.0.3",
132
132
  "swiper": "^10.1.0",
133
133
  "ua-parser-js": "^1.0.36",
134
- "@edifice.io/bootstrap": "2.4.0-develop-pedago.20251029104249",
135
- "@edifice.io/tiptap-extensions": "2.4.0-develop-pedago.20251029104249",
136
- "@edifice.io/utilities": "2.4.0-develop-pedago.20251029104249"
134
+ "@edifice.io/tiptap-extensions": "2.4.0-develop-pedago.20251104155002",
135
+ "@edifice.io/bootstrap": "2.4.0-develop-pedago.20251104155002",
136
+ "@edifice.io/utilities": "2.4.0-develop-pedago.20251104155002"
137
137
  },
138
138
  "devDependencies": {
139
139
  "@babel/plugin-transform-react-pure-annotations": "^7.23.3",
@@ -164,8 +164,8 @@
164
164
  "vite": "^5.4.11",
165
165
  "vite-plugin-dts": "^4.1.0",
166
166
  "vite-tsconfig-paths": "^5.0.1",
167
- "@edifice.io/config": "2.4.0-develop-pedago.20251029104249",
168
- "@edifice.io/client": "2.4.0-develop-pedago.20251029104249"
167
+ "@edifice.io/client": "2.4.0-develop-pedago.20251104155002",
168
+ "@edifice.io/config": "2.4.0-develop-pedago.20251104155002"
169
169
  },
170
170
  "peerDependencies": {
171
171
  "@react-spring/web": "^9.7.5",
@@ -1,8 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- const TextareaCounter = ({
3
- content,
4
- maxLength
5
- }) => /* @__PURE__ */ jsx("p", { className: "small text-gray-700 p-2 text-end", children: content ? `${content.length} / ${maxLength}` : "" });
6
- export {
7
- TextareaCounter
8
- };