@xaypay/tui 0.2.21 → 0.2.22

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.es.js CHANGED
@@ -1837,9 +1837,11 @@ const File = /*#__PURE__*/forwardRef(({
1837
1837
  }, ref) => {
1838
1838
  const inpRef = useRef(null);
1839
1839
  const labelRef = useRef(null);
1840
+ const parentlRef = useRef(null);
1840
1841
  const memoizedItems = useMemo(() => filesArray, [filesArray]);
1841
1842
  const [error, setError] = useState('');
1842
1843
  const [isHover, setIsHover] = useState(false);
1844
+ const [removeID, setRemoveID] = useState('');
1843
1845
  const [classProps, setClassProps] = useState({});
1844
1846
  const [singleFile, setSingleFile] = useState(null);
1845
1847
  const [configStyles, setConfigStyles] = useState({});
@@ -2074,14 +2076,10 @@ const File = /*#__PURE__*/forwardRef(({
2074
2076
  }
2075
2077
  };
2076
2078
  const handleClick = () => {
2077
- inpRef.current.files = null;
2078
- inpRef.current.value = null;
2079
- if (multiple) {
2079
+ if (!image && !singleFile) {
2080
+ inpRef.current.files = null;
2081
+ inpRef.current.value = null;
2080
2082
  inpRef.current.click();
2081
- } else {
2082
- if (!image) {
2083
- inpRef.current.click();
2084
- }
2085
2083
  }
2086
2084
  };
2087
2085
  const handleDrop = e => {
@@ -2117,18 +2115,21 @@ const File = /*#__PURE__*/forwardRef(({
2117
2115
  return width;
2118
2116
  };
2119
2117
  const handleLabelMouseEnter = event => {
2118
+ event.preventDefault();
2119
+ setRemoveID(() => v4());
2120
2120
  if (labelRef.current) {
2121
+ const parentElem = parentlRef.current.getBoundingClientRect();
2121
2122
  const rect = labelRef.current.getBoundingClientRect();
2122
2123
  const top = rect.top;
2123
2124
  const left = rect.left;
2124
2125
  const height = rect.height;
2125
2126
  const elementWidth = rect.width;
2126
2127
  const x = event.clientX - rect.left;
2128
+ const parentWidth = parentElem.width;
2127
2129
  const textWidth = getRenderedTextWidth(labelRef.current);
2128
- console.log(textWidth, ' - - - - textWidth');
2129
- console.log(elementWidth, ' - - - - elementWidth');
2130
- if (textWidth > elementWidth) {
2130
+ if (textWidth > Math.ceil(elementWidth)) {
2131
2131
  const newTooltipElem = document.createElement('div');
2132
+ newTooltipElem.id = `fake_id_for_remove_dom${removeID}`;
2132
2133
  const newTootltipTextElem = document.createElement('p');
2133
2134
  const newTooltipChildElem = document.createElement('div');
2134
2135
  const newTooltipDecorElem = document.createElement('div');
@@ -2138,7 +2139,7 @@ const File = /*#__PURE__*/forwardRef(({
2138
2139
  newTooltipElem.style.height = 'fit-content';
2139
2140
  newTooltipElem.style.boxSizing = 'border-box';
2140
2141
  newTooltipElem.style.top = top + height + 'px';
2141
- newTooltipElem.style.width = elementWidth + 'px';
2142
+ newTooltipElem.style.width = parentWidth + 'px';
2142
2143
  newTooltipChildElem.style.width = '100%';
2143
2144
  newTooltipChildElem.style.position = 'relative';
2144
2145
  newTooltipChildElem.style.height = 'fit-content';
@@ -2152,7 +2153,7 @@ const File = /*#__PURE__*/forwardRef(({
2152
2153
  newTooltipDecorElem.style.height = '18px';
2153
2154
  newTooltipDecorElem.style.rotate = '45deg';
2154
2155
  newTooltipDecorElem.style.position = 'absolute';
2155
- newTooltipDecorElem.style.left = x > elementWidth / 2 ? 'calc(100% - 30px)' : '13px';
2156
+ newTooltipDecorElem.style.left = x > elementWidth / 2 ? 'calc(100% - 40px)' : '23px';
2156
2157
  newTooltipDecorElem.style.backgroundColor = labelTooltipBackgroundColor ?? configStyles.FILE.label.tooltip.backgroundColor;
2157
2158
  newTootltipTextElem.innerText = label;
2158
2159
  newTootltipTextElem.style.color = labelTooltipColor ?? configStyles.FILE.label.tooltip.color;
@@ -2169,9 +2170,14 @@ const File = /*#__PURE__*/forwardRef(({
2169
2170
  }
2170
2171
  };
2171
2172
  const handleLabelMouseLeave = () => {
2173
+ const removableElem = document.getElementById(`fake_id_for_remove_dom${removeID}`);
2174
+ if (removableElem) {
2175
+ document.body.removeChild(removableElem);
2176
+ }
2172
2177
  if (tooltipElem) {
2173
2178
  document.body.removeChild(tooltipElem);
2174
2179
  }
2180
+ setRemoveID(() => '');
2175
2181
  };
2176
2182
  useImperativeHandle(ref, () => ({
2177
2183
  handleReset() {
@@ -2246,6 +2252,7 @@ const File = /*#__PURE__*/forwardRef(({
2246
2252
  };
2247
2253
  }, []);
2248
2254
  return configStyles.FILE && /*#__PURE__*/React__default.createElement("div", {
2255
+ ref: parentlRef,
2249
2256
  style: {
2250
2257
  width: '100%',
2251
2258
  maxWidth: maxWidth ?? configStyles.FILE.maxWidth
package/dist/index.js CHANGED
@@ -1868,9 +1868,11 @@ const File = /*#__PURE__*/React.forwardRef(({
1868
1868
  }, ref) => {
1869
1869
  const inpRef = React.useRef(null);
1870
1870
  const labelRef = React.useRef(null);
1871
+ const parentlRef = React.useRef(null);
1871
1872
  const memoizedItems = React.useMemo(() => filesArray, [filesArray]);
1872
1873
  const [error, setError] = React.useState('');
1873
1874
  const [isHover, setIsHover] = React.useState(false);
1875
+ const [removeID, setRemoveID] = React.useState('');
1874
1876
  const [classProps, setClassProps] = React.useState({});
1875
1877
  const [singleFile, setSingleFile] = React.useState(null);
1876
1878
  const [configStyles, setConfigStyles] = React.useState({});
@@ -2105,14 +2107,10 @@ const File = /*#__PURE__*/React.forwardRef(({
2105
2107
  }
2106
2108
  };
2107
2109
  const handleClick = () => {
2108
- inpRef.current.files = null;
2109
- inpRef.current.value = null;
2110
- if (multiple) {
2110
+ if (!image && !singleFile) {
2111
+ inpRef.current.files = null;
2112
+ inpRef.current.value = null;
2111
2113
  inpRef.current.click();
2112
- } else {
2113
- if (!image) {
2114
- inpRef.current.click();
2115
- }
2116
2114
  }
2117
2115
  };
2118
2116
  const handleDrop = e => {
@@ -2148,18 +2146,21 @@ const File = /*#__PURE__*/React.forwardRef(({
2148
2146
  return width;
2149
2147
  };
2150
2148
  const handleLabelMouseEnter = event => {
2149
+ event.preventDefault();
2150
+ setRemoveID(() => v4());
2151
2151
  if (labelRef.current) {
2152
+ const parentElem = parentlRef.current.getBoundingClientRect();
2152
2153
  const rect = labelRef.current.getBoundingClientRect();
2153
2154
  const top = rect.top;
2154
2155
  const left = rect.left;
2155
2156
  const height = rect.height;
2156
2157
  const elementWidth = rect.width;
2157
2158
  const x = event.clientX - rect.left;
2159
+ const parentWidth = parentElem.width;
2158
2160
  const textWidth = getRenderedTextWidth(labelRef.current);
2159
- console.log(textWidth, ' - - - - textWidth');
2160
- console.log(elementWidth, ' - - - - elementWidth');
2161
- if (textWidth > elementWidth) {
2161
+ if (textWidth > Math.ceil(elementWidth)) {
2162
2162
  const newTooltipElem = document.createElement('div');
2163
+ newTooltipElem.id = `fake_id_for_remove_dom${removeID}`;
2163
2164
  const newTootltipTextElem = document.createElement('p');
2164
2165
  const newTooltipChildElem = document.createElement('div');
2165
2166
  const newTooltipDecorElem = document.createElement('div');
@@ -2169,7 +2170,7 @@ const File = /*#__PURE__*/React.forwardRef(({
2169
2170
  newTooltipElem.style.height = 'fit-content';
2170
2171
  newTooltipElem.style.boxSizing = 'border-box';
2171
2172
  newTooltipElem.style.top = top + height + 'px';
2172
- newTooltipElem.style.width = elementWidth + 'px';
2173
+ newTooltipElem.style.width = parentWidth + 'px';
2173
2174
  newTooltipChildElem.style.width = '100%';
2174
2175
  newTooltipChildElem.style.position = 'relative';
2175
2176
  newTooltipChildElem.style.height = 'fit-content';
@@ -2183,7 +2184,7 @@ const File = /*#__PURE__*/React.forwardRef(({
2183
2184
  newTooltipDecorElem.style.height = '18px';
2184
2185
  newTooltipDecorElem.style.rotate = '45deg';
2185
2186
  newTooltipDecorElem.style.position = 'absolute';
2186
- newTooltipDecorElem.style.left = x > elementWidth / 2 ? 'calc(100% - 30px)' : '13px';
2187
+ newTooltipDecorElem.style.left = x > elementWidth / 2 ? 'calc(100% - 40px)' : '23px';
2187
2188
  newTooltipDecorElem.style.backgroundColor = labelTooltipBackgroundColor ?? configStyles.FILE.label.tooltip.backgroundColor;
2188
2189
  newTootltipTextElem.innerText = label;
2189
2190
  newTootltipTextElem.style.color = labelTooltipColor ?? configStyles.FILE.label.tooltip.color;
@@ -2200,9 +2201,14 @@ const File = /*#__PURE__*/React.forwardRef(({
2200
2201
  }
2201
2202
  };
2202
2203
  const handleLabelMouseLeave = () => {
2204
+ const removableElem = document.getElementById(`fake_id_for_remove_dom${removeID}`);
2205
+ if (removableElem) {
2206
+ document.body.removeChild(removableElem);
2207
+ }
2203
2208
  if (tooltipElem) {
2204
2209
  document.body.removeChild(tooltipElem);
2205
2210
  }
2211
+ setRemoveID(() => '');
2206
2212
  };
2207
2213
  React.useImperativeHandle(ref, () => ({
2208
2214
  handleReset() {
@@ -2277,6 +2283,7 @@ const File = /*#__PURE__*/React.forwardRef(({
2277
2283
  };
2278
2284
  }, []);
2279
2285
  return configStyles.FILE && /*#__PURE__*/React__default["default"].createElement("div", {
2286
+ ref: parentlRef,
2280
2287
  style: {
2281
2288
  width: '100%',
2282
2289
  maxWidth: maxWidth ?? configStyles.FILE.maxWidth
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xaypay/tui",
3
- "version": "0.2.21",
3
+ "version": "0.2.22",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.es.js",