@sikka/hawa 0.0.235 → 0.0.236

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sikka/hawa",
3
- "version": "0.0.235",
3
+ "version": "0.0.236",
4
4
  "description": "SaaS Oriented UI Kit",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.es.js",
@@ -4,7 +4,7 @@ import clsx from "clsx"
4
4
  const Property = (props) => {
5
5
  return (
6
6
  <div
7
- className="border-box mr-[5px] flex h-[32px] w-[32px] items-center justify-center rounded bg-gray-400 p-2"
7
+ className="border-box mr-[10px] flex h-[32px] w-[32px] items-center justify-center rounded bg-gray-300 p-2"
8
8
  onMouseDown={props.onMouseDown}
9
9
  >
10
10
  {props.name}
@@ -13,14 +13,18 @@ const Property = (props) => {
13
13
  }
14
14
 
15
15
  type ComponentTypes = {
16
- foo?: string
16
+ rtl?: "enabled" | "disabled" | "auto"
17
+ onSubmit?: (
18
+ content: string,
19
+ stylings: { type: keyof typeof stylers; start: number; finish: number }[]
20
+ ) => void
17
21
  }
18
22
 
19
- const styleClasses = {
20
- bold: "font-bold",
21
- italic: "italic",
22
- under: "underline",
23
- strike: "line-through",
23
+ const stylers = {
24
+ bold: { css: "font-bold", content: "B" },
25
+ italic: { id: "italic", css: "italic", content: "I" },
26
+ under: { id: "under", css: "underline", content: "U" },
27
+ strike: { id: "strike", css: "line-through", content: "S" },
24
28
  }
25
29
 
26
30
  // FIXME: Highlighting a part of styled text with a bit on the left with an overall length not equal to clipboard copied text will result in paste issues
@@ -847,7 +851,7 @@ export const FloatingComment: React.FunctionComponent<ComponentTypes> = (
847
851
  // console.log(data)
848
852
  // console.log(stylings)
849
853
  return `<span class="${stylings
850
- .map((styling) => styleClasses[styling.type])
854
+ .map((styling) => stylers[styling.type].css)
851
855
  .join(" ")}" data-child-index="${index}">${data}</span>`
852
856
  })
853
857
  .join("")
@@ -855,10 +859,36 @@ export const FloatingComment: React.FunctionComponent<ComponentTypes> = (
855
859
  field.current.innerHTML = html
856
860
  }, [text.content, text.stylings, text.revert])
857
861
 
862
+ const getTextDirection = () => {
863
+ let value = props.rtl || "disabled"
864
+
865
+ switch (value) {
866
+ case "enabled":
867
+ return "rtl"
868
+ case "disabled":
869
+ return "ltr"
870
+ case "auto":
871
+ return "ltr"
872
+ }
873
+ }
874
+
858
875
  return (
859
- <div className="align-center box-border flex h-min w-[400px] flex-col items-center justify-center rounded bg-blue-300 shadow-md">
876
+ <div className="align-center box-border flex h-min w-[400px] flex-col items-center justify-center rounded shadow-md">
860
877
  <div className={clsx("flex w-full flex-row justify-start p-2")}>
861
- <Property
878
+ {Object.entries(stylers).map(([id, data]) => {
879
+ return (
880
+ <Property
881
+ name={data.content}
882
+ key={`property-${id}`}
883
+ onMouseDown={(event) => {
884
+ event.preventDefault()
885
+ perform(id)
886
+ }}
887
+ />
888
+ )
889
+ })}
890
+
891
+ {/* <Property
862
892
  name="B"
863
893
  onMouseDown={(event) => {
864
894
  event.preventDefault() // This does not take focus away from field which allows the function to retrieve the current selection data
@@ -885,14 +915,17 @@ export const FloatingComment: React.FunctionComponent<ComponentTypes> = (
885
915
  event.preventDefault()
886
916
  perform("strike")
887
917
  }}
888
- />
918
+ /> */}
889
919
  </div>
890
920
  <div className="h-[1px] w-full bg-slate-600">&nbsp;</div>
891
921
  <div className="w-full">
892
922
  <div
893
923
  ref={field}
894
924
  contentEditable="true"
895
- className="h-[150px] w-full resize-none overflow-auto overflow-x-hidden border-none p-2 outline-none"
925
+ className="rtl h-[150px] w-full resize-none overflow-auto overflow-x-hidden border-none p-2 outline-none"
926
+ style={{
927
+ direction: getTextDirection(),
928
+ }}
896
929
  onPaste={(event) => {
897
930
  // pastes all copied text from the content editable as plain text
898
931
  event.preventDefault()
@@ -980,7 +1013,14 @@ export const FloatingComment: React.FunctionComponent<ComponentTypes> = (
980
1013
  ></div>
981
1014
  </div>
982
1015
  <div className="h-[1px] w-full bg-slate-600">&nbsp;</div>
983
- <button className="my-1 rounded bg-cyan-800 p-2 py-1 text-white">
1016
+ <button
1017
+ className="my-1 rounded bg-cyan-800 p-2 py-1 text-white"
1018
+ onClick={() => {
1019
+ let onSubmit = props.onSubmit || (() => {})
1020
+
1021
+ onSubmit(text.content, text.stylings)
1022
+ }}
1023
+ >
984
1024
  Submit
985
1025
  </button>
986
1026
  </div>
package/src/styles.css CHANGED
@@ -771,6 +771,9 @@ video {
771
771
  .mr-40 {
772
772
  margin-right: 10rem;
773
773
  }
774
+ .mr-\[10px\] {
775
+ margin-right: 10px;
776
+ }
774
777
  .mr-\[5px\] {
775
778
  margin-right: 5px;
776
779
  }