@bioturing/components 0.21.0 → 0.21.1
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/README.md +22 -0
- package/dist/components/cmdk/command-score.js.map +1 -1
- package/dist/components/form/item.js +33 -32
- package/dist/components/form/item.js.map +1 -1
- package/dist/components/transition/component.js +45 -44
- package/dist/components/transition/component.js.map +1 -1
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -82,6 +82,28 @@ import '@bioturing/components/tailwind.css';
|
|
|
82
82
|
- React DOM 18.0.0 or higher
|
|
83
83
|
- Ant Design 5.24.9 or higher
|
|
84
84
|
|
|
85
|
+
## Development Guidelines
|
|
86
|
+
|
|
87
|
+
### ESLint Rules
|
|
88
|
+
|
|
89
|
+
This package enforces strict linting rules to ensure code quality:
|
|
90
|
+
|
|
91
|
+
- **No Console Statements**: `console.log()` statements are not allowed in production builds.
|
|
92
|
+
- In development, console statements will trigger warnings
|
|
93
|
+
- In production, console statements will cause build errors
|
|
94
|
+
- Only `console.warn()` and `console.error()` are permitted
|
|
95
|
+
- The Vite build process automatically removes console statements in production
|
|
96
|
+
|
|
97
|
+
To run the linter:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
# Check for linting issues
|
|
101
|
+
npm run lint
|
|
102
|
+
|
|
103
|
+
# Fix auto-fixable issues
|
|
104
|
+
npm run lint:fix
|
|
105
|
+
```
|
|
106
|
+
|
|
85
107
|
## Documentation
|
|
86
108
|
|
|
87
109
|
For detailed documentation and examples, visit the [BioTuring Design System documentation](https://github.com/bioturing-org/design-system).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-score.js","sources":["../../../src/components/cmdk/command-score.ts"],"sourcesContent":["// @ts-nocheck This is a copy of the cmdk component from \"cmdk\" package.\n// It is used here to avoid dependency on cmdk package and radix-ui-components package.\n\n// The scores are arranged so that a continuous match of characters will\n// result in a total score of 1.\n//\n// The best case, this character is a match, and either this is the start\n// of the string, or the previous character was also a match.\nconst SCORE_CONTINUE_MATCH = 1,\n // A new match at the start of a word scores better than a new match\n // elsewhere as it's more likely that the user will type the starts\n // of fragments.\n // NOTE: We score word jumps between spaces slightly higher than slashes, brackets\n // hyphens, etc.\n SCORE_SPACE_WORD_JUMP = 0.9,\n SCORE_NON_SPACE_WORD_JUMP = 0.8,\n // Any other match isn't ideal, but we include it for completeness.\n SCORE_CHARACTER_JUMP = 0.17,\n // If the user transposed two letters, it should be significantly penalized.\n //\n // i.e. \"ouch\" is more likely than \"curtain\" when \"uc\" is typed.\n SCORE_TRANSPOSITION = 0.1,\n // The goodness of a match should decay slightly with each missing\n // character.\n //\n // i.e. \"bad\" is more likely than \"bard\" when \"bd\" is typed.\n //\n // This will not change the order of suggestions based on SCORE_* until\n // 100 characters are inserted between matches.\n PENALTY_SKIPPED = 0.999,\n // The goodness of an exact-case match should be higher than a\n // case-insensitive match by a small amount.\n //\n // i.e. \"HTML\" is more likely than \"haml\" when \"HM\" is typed.\n //\n // This will not change the order of suggestions based on SCORE_* until\n // 1000 characters are inserted between matches.\n PENALTY_CASE_MISMATCH = 0.9999,\n // Match higher for letters closer to the beginning of the word\n PENALTY_DISTANCE_FROM_START = 0.9,\n // If the word has more characters than the user typed, it should\n // be penalised slightly.\n //\n // i.e. \"html\" is more likely than \"html5\" if I type \"html\".\n //\n // However, it may well be the case that there's a sensible secondary\n // ordering (like alphabetical) that it makes sense to rely on when\n // there are many prefix matches, so we don't make the penalty increase\n // with the number of tokens.\n PENALTY_NOT_COMPLETE = 0.99;\n\nconst IS_GAP_REGEXP = /[\\\\/_+.#\"@\\[\\(\\{&]/,\n COUNT_GAPS_REGEXP = /[\\\\/_+.#\"@\\[\\(\\{&]/g,\n IS_SPACE_REGEXP = /[\\s-]/,\n COUNT_SPACE_REGEXP = /[\\s-]/g;\n\nfunction commandScoreInner(\n string,\n abbreviation,\n lowerString,\n lowerAbbreviation,\n stringIndex,\n abbreviationIndex,\n memoizedResults\n) {\n if (abbreviationIndex === abbreviation.length) {\n if (stringIndex === string.length) {\n return SCORE_CONTINUE_MATCH;\n }\n return PENALTY_NOT_COMPLETE;\n }\n\n const memoizeKey = `${stringIndex},${abbreviationIndex}`;\n if (memoizedResults[memoizeKey] !== undefined) {\n return memoizedResults[memoizeKey];\n }\n\n const abbreviationChar = lowerAbbreviation.charAt(abbreviationIndex);\n let index = lowerString.indexOf(abbreviationChar, stringIndex);\n let highScore = 0;\n\n let score, transposedScore, wordBreaks, spaceBreaks;\n\n while (index >= 0) {\n score = commandScoreInner(\n string,\n abbreviation,\n lowerString,\n lowerAbbreviation,\n index + 1,\n abbreviationIndex + 1,\n memoizedResults\n );\n if (score > highScore) {\n if (index === stringIndex) {\n score *= SCORE_CONTINUE_MATCH;\n } else if (IS_GAP_REGEXP.test(string.charAt(index - 1))) {\n score *= SCORE_NON_SPACE_WORD_JUMP;\n wordBreaks = string\n .slice(stringIndex, index - 1)\n .match(COUNT_GAPS_REGEXP);\n if (wordBreaks && stringIndex > 0) {\n score *= Math.pow(PENALTY_SKIPPED, wordBreaks.length);\n }\n } else if (IS_SPACE_REGEXP.test(string.charAt(index - 1))) {\n score *= SCORE_SPACE_WORD_JUMP;\n spaceBreaks = string\n .slice(stringIndex, index - 1)\n .match(COUNT_SPACE_REGEXP);\n if (spaceBreaks && stringIndex > 0) {\n score *= Math.pow(PENALTY_SKIPPED, spaceBreaks.length);\n }\n } else {\n score *= SCORE_CHARACTER_JUMP;\n if (stringIndex > 0) {\n score *= Math.pow(PENALTY_SKIPPED, index - stringIndex);\n }\n }\n\n if (string.charAt(index) !== abbreviation.charAt(abbreviationIndex)) {\n score *= PENALTY_CASE_MISMATCH;\n }\n }\n\n if (\n (score < SCORE_TRANSPOSITION &&\n lowerString.charAt(index - 1) ===\n lowerAbbreviation.charAt(abbreviationIndex + 1)) ||\n (lowerAbbreviation.charAt(abbreviationIndex + 1) ===\n lowerAbbreviation.charAt(abbreviationIndex) && // allow duplicate letters. Ref #7428\n lowerString.charAt(index - 1) !==\n lowerAbbreviation.charAt(abbreviationIndex))\n ) {\n transposedScore = commandScoreInner(\n string,\n abbreviation,\n lowerString,\n lowerAbbreviation,\n index + 1,\n abbreviationIndex + 2,\n memoizedResults\n );\n\n if (transposedScore * SCORE_TRANSPOSITION > score) {\n score = transposedScore * SCORE_TRANSPOSITION;\n }\n }\n\n if (score > highScore) {\n highScore = score;\n }\n\n index = lowerString.indexOf(abbreviationChar, index + 1);\n }\n\n memoizedResults[memoizeKey] = highScore;\n return highScore;\n}\n\nfunction formatInput(string) {\n // convert all valid space characters to space so they match each other\n return string.toLowerCase().replace(COUNT_SPACE_REGEXP, \" \");\n}\n\nexport function commandScore(\n string: string,\n abbreviation: string,\n aliases: string[]\n): number {\n /* NOTE:\n * in the original, we used to do the lower-casing on each recursive call, but this meant that toLowerCase()\n * was the dominating cost in the algorithm, passing both is a little ugly, but considerably faster.\n */\n string =\n aliases && aliases.length > 0\n ? `${string + \" \" + aliases.join(\" \")}`\n : string;\n return commandScoreInner(\n string,\n abbreviation,\n formatInput(string),\n formatInput(abbreviation),\n 0,\n 0,\n {}\n );\n}\n"],"names":["IS_GAP_REGEXP","COUNT_GAPS_REGEXP","IS_SPACE_REGEXP","COUNT_SPACE_REGEXP","commandScoreInner","string","abbreviation","lowerString","lowerAbbreviation","stringIndex","abbreviationIndex","memoizedResults","memoizeKey","abbreviationChar","index","highScore","score","transposedScore","wordBreaks","spaceBreaks","formatInput","commandScore","aliases"],"mappings":"
|
|
1
|
+
{"version":3,"file":"command-score.js","sources":["../../../src/components/cmdk/command-score.ts"],"sourcesContent":["// @ts-nocheck\n/* eslint-disable */\n// This is a copy of the cmdk component from \"cmdk\" package.\n// It is used here to avoid dependency on cmdk package and radix-ui-components package.\n\n// The scores are arranged so that a continuous match of characters will\n// result in a total score of 1.\n//\n// The best case, this character is a match, and either this is the start\n// of the string, or the previous character was also a match.\nconst SCORE_CONTINUE_MATCH = 1,\n // A new match at the start of a word scores better than a new match\n // elsewhere as it's more likely that the user will type the starts\n // of fragments.\n // NOTE: We score word jumps between spaces slightly higher than slashes, brackets\n // hyphens, etc.\n SCORE_SPACE_WORD_JUMP = 0.9,\n SCORE_NON_SPACE_WORD_JUMP = 0.8,\n // Any other match isn't ideal, but we include it for completeness.\n SCORE_CHARACTER_JUMP = 0.17,\n // If the user transposed two letters, it should be significantly penalized.\n //\n // i.e. \"ouch\" is more likely than \"curtain\" when \"uc\" is typed.\n SCORE_TRANSPOSITION = 0.1,\n // The goodness of a match should decay slightly with each missing\n // character.\n //\n // i.e. \"bad\" is more likely than \"bard\" when \"bd\" is typed.\n //\n // This will not change the order of suggestions based on SCORE_* until\n // 100 characters are inserted between matches.\n PENALTY_SKIPPED = 0.999,\n // The goodness of an exact-case match should be higher than a\n // case-insensitive match by a small amount.\n //\n // i.e. \"HTML\" is more likely than \"haml\" when \"HM\" is typed.\n //\n // This will not change the order of suggestions based on SCORE_* until\n // 1000 characters are inserted between matches.\n PENALTY_CASE_MISMATCH = 0.9999,\n // Match higher for letters closer to the beginning of the word\n PENALTY_DISTANCE_FROM_START = 0.9,\n // If the word has more characters than the user typed, it should\n // be penalised slightly.\n //\n // i.e. \"html\" is more likely than \"html5\" if I type \"html\".\n //\n // However, it may well be the case that there's a sensible secondary\n // ordering (like alphabetical) that it makes sense to rely on when\n // there are many prefix matches, so we don't make the penalty increase\n // with the number of tokens.\n PENALTY_NOT_COMPLETE = 0.99;\n\nconst IS_GAP_REGEXP = /[\\\\/_+.#\"@\\[\\(\\{&]/,\n COUNT_GAPS_REGEXP = /[\\\\/_+.#\"@\\[\\(\\{&]/g,\n IS_SPACE_REGEXP = /[\\s-]/,\n COUNT_SPACE_REGEXP = /[\\s-]/g;\n\nfunction commandScoreInner(\n string,\n abbreviation,\n lowerString,\n lowerAbbreviation,\n stringIndex,\n abbreviationIndex,\n memoizedResults\n) {\n if (abbreviationIndex === abbreviation.length) {\n if (stringIndex === string.length) {\n return SCORE_CONTINUE_MATCH;\n }\n return PENALTY_NOT_COMPLETE;\n }\n\n const memoizeKey = `${stringIndex},${abbreviationIndex}`;\n if (memoizedResults[memoizeKey] !== undefined) {\n return memoizedResults[memoizeKey];\n }\n\n const abbreviationChar = lowerAbbreviation.charAt(abbreviationIndex);\n let index = lowerString.indexOf(abbreviationChar, stringIndex);\n let highScore = 0;\n\n let score, transposedScore, wordBreaks, spaceBreaks;\n\n while (index >= 0) {\n score = commandScoreInner(\n string,\n abbreviation,\n lowerString,\n lowerAbbreviation,\n index + 1,\n abbreviationIndex + 1,\n memoizedResults\n );\n if (score > highScore) {\n if (index === stringIndex) {\n score *= SCORE_CONTINUE_MATCH;\n } else if (IS_GAP_REGEXP.test(string.charAt(index - 1))) {\n score *= SCORE_NON_SPACE_WORD_JUMP;\n wordBreaks = string\n .slice(stringIndex, index - 1)\n .match(COUNT_GAPS_REGEXP);\n if (wordBreaks && stringIndex > 0) {\n score *= Math.pow(PENALTY_SKIPPED, wordBreaks.length);\n }\n } else if (IS_SPACE_REGEXP.test(string.charAt(index - 1))) {\n score *= SCORE_SPACE_WORD_JUMP;\n spaceBreaks = string\n .slice(stringIndex, index - 1)\n .match(COUNT_SPACE_REGEXP);\n if (spaceBreaks && stringIndex > 0) {\n score *= Math.pow(PENALTY_SKIPPED, spaceBreaks.length);\n }\n } else {\n score *= SCORE_CHARACTER_JUMP;\n if (stringIndex > 0) {\n score *= Math.pow(PENALTY_SKIPPED, index - stringIndex);\n }\n }\n\n if (string.charAt(index) !== abbreviation.charAt(abbreviationIndex)) {\n score *= PENALTY_CASE_MISMATCH;\n }\n }\n\n if (\n (score < SCORE_TRANSPOSITION &&\n lowerString.charAt(index - 1) ===\n lowerAbbreviation.charAt(abbreviationIndex + 1)) ||\n (lowerAbbreviation.charAt(abbreviationIndex + 1) ===\n lowerAbbreviation.charAt(abbreviationIndex) && // allow duplicate letters. Ref #7428\n lowerString.charAt(index - 1) !==\n lowerAbbreviation.charAt(abbreviationIndex))\n ) {\n transposedScore = commandScoreInner(\n string,\n abbreviation,\n lowerString,\n lowerAbbreviation,\n index + 1,\n abbreviationIndex + 2,\n memoizedResults\n );\n\n if (transposedScore * SCORE_TRANSPOSITION > score) {\n score = transposedScore * SCORE_TRANSPOSITION;\n }\n }\n\n if (score > highScore) {\n highScore = score;\n }\n\n index = lowerString.indexOf(abbreviationChar, index + 1);\n }\n\n memoizedResults[memoizeKey] = highScore;\n return highScore;\n}\n\nfunction formatInput(string) {\n // convert all valid space characters to space so they match each other\n return string.toLowerCase().replace(COUNT_SPACE_REGEXP, \" \");\n}\n\nexport function commandScore(\n string: string,\n abbreviation: string,\n aliases: string[]\n): number {\n /* NOTE:\n * in the original, we used to do the lower-casing on each recursive call, but this meant that toLowerCase()\n * was the dominating cost in the algorithm, passing both is a little ugly, but considerably faster.\n */\n string =\n aliases && aliases.length > 0\n ? `${string + \" \" + aliases.join(\" \")}`\n : string;\n return commandScoreInner(\n string,\n abbreviation,\n formatInput(string),\n formatInput(abbreviation),\n 0,\n 0,\n {}\n );\n}\n"],"names":["IS_GAP_REGEXP","COUNT_GAPS_REGEXP","IS_SPACE_REGEXP","COUNT_SPACE_REGEXP","commandScoreInner","string","abbreviation","lowerString","lowerAbbreviation","stringIndex","abbreviationIndex","memoizedResults","memoizeKey","abbreviationChar","index","highScore","score","transposedScore","wordBreaks","spaceBreaks","formatInput","commandScore","aliases"],"mappings":"AAqDA,MAAMA,IAAgB,sBACpBC,IAAoB,uBACpBC,IAAkB,SAClBC,IAAqB;AAEvB,SAASC,EACPC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACA;AACI,MAAAD,MAAsBJ,EAAa;AACjC,WAAAG,MAAgBJ,EAAO,SAClB,IAEF;AAGT,QAAMO,IAAa,GAAGH,CAAW,IAAIC,CAAiB;AAClD,MAAAC,EAAgBC,CAAU,MAAM;AAClC,WAAOD,EAAgBC,CAAU;AAG7B,QAAAC,IAAmBL,EAAkB,OAAOE,CAAiB;AACnE,MAAII,IAAQP,EAAY,QAAQM,GAA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EAAY,QAAQM,GAAkBC,IAAQ,CAAC;AAGzD,SAAAH,EAAgBC,CAAU,IAAIG,GACvBA;AACT;AAEA,SAASK,EAAYf,GAAQ;AAE3B,SAAOA,EAAO,YAAA,EAAc,QAAQF,GAAoB,GAAG;AAC7D;AAEgB,SAAAkB,EACdhB,GACAC,GACAgB,GACQ;AAMN,SAAAjB,IAAAiB,KAAWA,EAAQ,SAAS,IACxB,GAAGjB,IAAS,MAAMiB,EAAQ,KAAK,GAAG,CAAC,KACnCjB,GACCD;AAAA,IACLC;AAAA,IACAC;AAAA,IACAc,EAAYf,CAAM;AAAA,IAClBe,EAAYd,CAAY;AAAA,IACxB;AAAA,IACA;AAAA,IACA,CAAA;AAAA,EACF;AACF;"}
|
|
@@ -1,42 +1,43 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as e } from "react/jsx-runtime";
|
|
3
|
-
import { isValidElement as a } from "react";
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import { useCls as
|
|
7
|
-
import { IconButton as
|
|
3
|
+
import { useMemo as i, isValidElement as a } from "react";
|
|
4
|
+
import c from "antd/es/form/FormItem";
|
|
5
|
+
import { QuestionIcon as f } from "@bioturing/assets";
|
|
6
|
+
import { useCls as p } from "../utils/antdUtils.js";
|
|
7
|
+
import { IconButton as b } from "../icon-button/component.js";
|
|
8
8
|
const y = ({
|
|
9
|
-
tooltip:
|
|
10
|
-
label:
|
|
11
|
-
optionalMark:
|
|
12
|
-
requiredMark:
|
|
9
|
+
tooltip: m,
|
|
10
|
+
label: l,
|
|
11
|
+
optionalMark: s,
|
|
12
|
+
requiredMark: o = !0,
|
|
13
13
|
...r
|
|
14
14
|
}) => {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
m && "form-item-label-with-required-mark"
|
|
23
|
-
),
|
|
24
|
-
children: [
|
|
25
|
-
t,
|
|
26
|
-
o && /* @__PURE__ */ e(
|
|
27
|
-
p,
|
|
28
|
-
{
|
|
29
|
-
className: l("form-item-explaination-icon"),
|
|
30
|
-
label: typeof o == "string" || a(o) ? o : void 0,
|
|
31
|
-
children: /* @__PURE__ */ e(c, {})
|
|
32
|
-
}
|
|
15
|
+
const n = p(), t = i(
|
|
16
|
+
() => /* @__PURE__ */ e(
|
|
17
|
+
"span",
|
|
18
|
+
{
|
|
19
|
+
className: n(
|
|
20
|
+
"form-item-label-inner",
|
|
21
|
+
o && "form-item-label-with-required-mark"
|
|
33
22
|
),
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
23
|
+
children: [
|
|
24
|
+
l,
|
|
25
|
+
m && /* @__PURE__ */ e(
|
|
26
|
+
b,
|
|
27
|
+
{
|
|
28
|
+
className: n("form-item-explaination-icon"),
|
|
29
|
+
label: typeof m == "string" || a(m) ? m : void 0,
|
|
30
|
+
children: /* @__PURE__ */ e(f, {})
|
|
31
|
+
}
|
|
32
|
+
),
|
|
33
|
+
s && /* @__PURE__ */ e("span", { className: n("form-item-label-optional-mark"), children: typeof s == "boolean" ? "(optional)" : s }),
|
|
34
|
+
o !== !1 && /* @__PURE__ */ e("span", { className: n("form-item-label-required-mark"), children: typeof o == "boolean" ? "*" : o })
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
),
|
|
38
|
+
[l, m, s, o, n]
|
|
38
39
|
);
|
|
39
|
-
return /* @__PURE__ */ e(
|
|
40
|
+
return /* @__PURE__ */ e(c, { label: t, ...r });
|
|
40
41
|
};
|
|
41
42
|
export {
|
|
42
43
|
y as FormItem
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"item.js","sources":["../../../src/components/form/item.tsx"],"sourcesContent":["\"use client\";\nimport { isValidElement } from \"react\";\nimport {\n default as AntdFormItem,\n type FormItemProps as AntdFormItemProps,\n} from \"antd/es/form/FormItem\";\nimport {
|
|
1
|
+
{"version":3,"file":"item.js","sources":["../../../src/components/form/item.tsx"],"sourcesContent":["\"use client\";\nimport { isValidElement, useMemo } from \"react\";\nimport {\n default as AntdFormItem,\n type FormItemProps as AntdFormItemProps,\n} from \"antd/es/form/FormItem\";\nimport { QuestionIcon } from \"@bioturing/assets\";\nimport { IconButton } from \"../icon-button\";\nimport { useCls } from \"../utils\";\n\nexport interface FormItemProps<Values = unknown>\n extends AntdFormItemProps<Values> {\n // tooltip?: React.ReactNode | TooltipProps;\n /**\n * Whether the field is optional. If true, the label will be marked as optional.\n * @default false\n */\n optionalMark?: boolean | React.ReactNode;\n /**\n * Whether show the asterisk when the field is required\n * @default true\n */\n requiredMark?: boolean | React.ReactNode;\n}\n\nexport const FormItem = <Values = unknown,>({\n tooltip,\n label,\n optionalMark,\n requiredMark = true,\n ...rest\n}: FormItemProps<Values>) => {\n const cls = useCls();\n\n // requiredMark is used in the className below\n const renderedLabel = useMemo(\n () => (\n <span\n className={cls(\n \"form-item-label-inner\",\n requiredMark && \"form-item-label-with-required-mark\"\n )}\n >\n {[\n label,\n tooltip && (\n <IconButton\n className={cls(\"form-item-explaination-icon\")}\n label={\n typeof tooltip == \"string\" || isValidElement(tooltip)\n ? tooltip\n : undefined\n }\n >\n <QuestionIcon />\n </IconButton>\n ),\n optionalMark && (\n <span className={cls(\"form-item-label-optional-mark\")}>\n {typeof optionalMark == \"boolean\" ? \"(optional)\" : optionalMark}\n </span>\n ),\n requiredMark !== false && (\n <span className={cls(\"form-item-label-required-mark\")}>\n {typeof requiredMark == \"boolean\" ? \"*\" : requiredMark}\n </span>\n ),\n ]}\n </span>\n ),\n [label, tooltip, optionalMark, requiredMark, cls]\n );\n\n return <AntdFormItem label={renderedLabel} {...rest} />;\n};\n"],"names":["FormItem","tooltip","label","optionalMark","requiredMark","rest","cls","useCls","renderedLabel","useMemo","jsx","IconButton","isValidElement","QuestionIcon","AntdFormItem"],"mappings":";;;;;;;AAyBO,MAAMA,IAAW,CAAoB;AAAA,EAC1C,SAAAC;AAAA,EACA,OAAAC;AAAA,EACA,cAAAC;AAAA,EACA,cAAAC,IAAe;AAAA,EACf,GAAGC;AACL,MAA6B;AAC3B,QAAMC,IAAMC,EAAO,GAGbC,IAAgBC;AAAA,IACpB,MACE,gBAAAC;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,WAAWJ;AAAA,UACT;AAAA,UACAF,KAAgB;AAAA,QAClB;AAAA,QAEC,UAAA;AAAA,UACCF;AAAA,UACAD,KACE,gBAAAS;AAAA,YAACC;AAAA,YAAA;AAAA,cACC,WAAWL,EAAI,6BAA6B;AAAA,cAC5C,OACE,OAAOL,KAAW,YAAYW,EAAeX,CAAO,IAChDA,IACA;AAAA,cAGN,4BAACY,GAAa,CAAA,CAAA;AAAA,YAAA;AAAA,UAChB;AAAA,UAEFV,KACG,gBAAAO,EAAA,QAAA,EAAK,WAAWJ,EAAI,+BAA+B,GACjD,UAAO,OAAAH,KAAgB,YAAY,eAAeA,EACrD,CAAA;AAAA,UAEFC,MAAiB,MACd,gBAAAM,EAAA,QAAA,EAAK,WAAWJ,EAAI,+BAA+B,GACjD,UAAO,OAAAF,KAAgB,YAAY,MAAMA,EAC5C,CAAA;AAAA,QAAA;AAAA,MAEJ;AAAA,IACF;AAAA,IAEF,CAACF,GAAOD,GAASE,GAAcC,GAAcE,CAAG;AAAA,EAClD;AAEA,SAAQ,gBAAAI,EAAAI,GAAA,EAAa,OAAON,GAAgB,GAAGH,GAAM;AACvD;"}
|
|
@@ -1,63 +1,64 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { useRef as
|
|
4
|
-
import { useRender as
|
|
5
|
-
import { mergeProps as
|
|
6
|
-
import { useTransitionStatus as
|
|
2
|
+
import { jsx as y } from "react/jsx-runtime";
|
|
3
|
+
import { useMemo as j, useRef as F, useCallback as A, isValidElement as E, useEffect as N } from "react";
|
|
4
|
+
import { useRender as S } from "@base-ui-components/react/use-render";
|
|
5
|
+
import { mergeProps as L } from "@base-ui-components/react/merge-props";
|
|
6
|
+
import { useTransitionStatus as O } from "@base-ui-components/react/utils";
|
|
7
7
|
import './style.css';/* empty css */
|
|
8
|
-
import { useLatestRef as
|
|
9
|
-
import { useCls as
|
|
10
|
-
import { clsx as
|
|
11
|
-
function
|
|
12
|
-
children:
|
|
13
|
-
className:
|
|
8
|
+
import { useLatestRef as P, useAnimationsFinished as V } from "../hooks/base-ui.js";
|
|
9
|
+
import { useCls as q } from "../utils/antdUtils.js";
|
|
10
|
+
import { clsx as z } from "../utils/cn.js";
|
|
11
|
+
function W({
|
|
12
|
+
children: e = /* @__PURE__ */ y("div", {}),
|
|
13
|
+
className: n,
|
|
14
14
|
starting: s,
|
|
15
15
|
ending: i,
|
|
16
16
|
show: t = !0,
|
|
17
|
-
keepMounted:
|
|
18
|
-
onTransitionComplete:
|
|
19
|
-
listenToChildAnimations:
|
|
20
|
-
asChild:
|
|
21
|
-
...
|
|
17
|
+
keepMounted: o = !1,
|
|
18
|
+
onTransitionComplete: f,
|
|
19
|
+
listenToChildAnimations: b = !1,
|
|
20
|
+
asChild: m = !0,
|
|
21
|
+
...v
|
|
22
22
|
}) {
|
|
23
|
-
const { mounted:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
const { mounted: u, setMounted: a, transitionStatus: r } = O(t), c = P(t), d = q(), R = j(
|
|
24
|
+
() => z(
|
|
25
|
+
n,
|
|
26
|
+
r === "starting" && typeof s == "string" && s,
|
|
27
|
+
r === "ending" && typeof i == "string" && i,
|
|
28
|
+
// hide by display: none when not mounted and keepMounted is true
|
|
29
|
+
u == !1 && o ? d("transition-hidden") : void 0
|
|
30
|
+
),
|
|
31
|
+
[n, s, i, r, u, o, d]
|
|
32
|
+
), p = F(null), l = V(p, {
|
|
32
33
|
waitForNextTick: t,
|
|
33
|
-
subtree:
|
|
34
|
-
}),
|
|
35
|
-
render:
|
|
36
|
-
props:
|
|
37
|
-
ref:
|
|
38
|
-
className:
|
|
39
|
-
"data-starting":
|
|
40
|
-
"data-ending":
|
|
34
|
+
subtree: b
|
|
35
|
+
}), g = A(() => typeof e == "function" || m && E(e) ? e : /* @__PURE__ */ y("div", { children: e }), [e, m]), x = S({
|
|
36
|
+
render: g(),
|
|
37
|
+
props: L(v, {
|
|
38
|
+
ref: p,
|
|
39
|
+
className: R,
|
|
40
|
+
"data-starting": r === "starting" ? "true" : void 0,
|
|
41
|
+
"data-ending": r === "ending" ? "true" : void 0,
|
|
41
42
|
style: {
|
|
42
|
-
...
|
|
43
|
-
...
|
|
43
|
+
...r === "starting" && typeof s == "object" ? s : {},
|
|
44
|
+
...r === "ending" && typeof i == "object" ? i : {}
|
|
44
45
|
}
|
|
45
46
|
})
|
|
46
47
|
});
|
|
47
|
-
return
|
|
48
|
-
|
|
49
|
-
t ===
|
|
48
|
+
return N(() => {
|
|
49
|
+
l(() => {
|
|
50
|
+
t === c.current && (a(t), f == null || f(t));
|
|
50
51
|
});
|
|
51
52
|
}, [
|
|
52
53
|
t,
|
|
53
|
-
|
|
54
|
+
o,
|
|
55
|
+
l,
|
|
56
|
+
a,
|
|
54
57
|
c,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
o
|
|
58
|
-
]), f || n ? b : null;
|
|
58
|
+
f
|
|
59
|
+
]), u || o ? x : null;
|
|
59
60
|
}
|
|
60
61
|
export {
|
|
61
|
-
|
|
62
|
+
W as Transition
|
|
62
63
|
};
|
|
63
64
|
//# sourceMappingURL=component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sources":["../../../src/components/transition/component.tsx"],"sourcesContent":["\"use client\";\nimport {
|
|
1
|
+
{"version":3,"file":"component.js","sources":["../../../src/components/transition/component.tsx"],"sourcesContent":["\"use client\";\nimport {\n CSSProperties,\n isValidElement,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n} from \"react\";\nimport { useRender } from \"@base-ui-components/react/use-render\";\nimport { mergeProps } from \"@base-ui-components/react/merge-props\";\nimport { useTransitionStatus } from \"@base-ui-components/react/utils\";\nimport { clsx, useCls } from \"../utils\";\nimport { useAnimationsFinished, useLatestRef } from \"../hooks\";\n\nimport \"./style.css\";\n\nexport type TransitionProps = Omit<\n useRender.ComponentProps<\"div\">,\n \"render\" | \"children\"\n> & {\n /** Whether the component should be shown */\n show?: boolean;\n /** CSS classes to apply when the component is opened */\n starting?: string | CSSProperties;\n /** CSS classes to apply when the component is closed */\n ending?: string | CSSProperties;\n /** CSS classes to apply to the component */\n className?: string;\n /** Keep mounted */\n keepMounted?: boolean;\n /**\n * Callback function to be called when the transition ends\n */\n onTransitionComplete?: (show?: boolean) => void;\n /**\n * Whether to listen for animations in child elements\n */\n listenToChildAnimations?: boolean;\n /**\n * Whether to render the child as a child element\n * @default true\n */\n asChild?: boolean;\n children?: React.ReactNode | useRender.ComponentProps<\"div\">[\"render\"];\n};\n\nexport function Transition({\n children = <div />,\n className,\n starting,\n ending,\n show = true,\n keepMounted = false,\n onTransitionComplete,\n listenToChildAnimations = false,\n asChild = true,\n ...otherProps\n}: TransitionProps) {\n const { mounted, setMounted, transitionStatus } = useTransitionStatus(show);\n const showRef = useLatestRef(show);\n\n const cls = useCls();\n\n const combinedClassName = useMemo(\n () =>\n clsx(\n className,\n transitionStatus === \"starting\" &&\n typeof starting == \"string\" &&\n starting,\n transitionStatus === \"ending\" && typeof ending == \"string\" && ending,\n // hide by display: none when not mounted and keepMounted is true\n mounted == false && keepMounted ? cls(\"transition-hidden\") : undefined\n ),\n [className, starting, ending, transitionStatus, mounted, keepMounted, cls]\n );\n\n const ref = useRef<HTMLDivElement>(null);\n const runOnceAnimationsFinish = useAnimationsFinished(ref, {\n waitForNextTick: show,\n subtree: listenToChildAnimations,\n });\n\n const getRender = useCallback(() => {\n if (typeof children === \"function\") {\n return children;\n }\n if (asChild && isValidElement(children)) {\n return children;\n }\n return <div>{children}</div>;\n }, [children, asChild]);\n\n const rendered = useRender({\n render: getRender(),\n props: mergeProps<\"div\">(otherProps, {\n ref,\n className: combinedClassName,\n ...{\n \"data-starting\": transitionStatus === \"starting\" ? \"true\" : undefined,\n \"data-ending\": transitionStatus === \"ending\" ? \"true\" : undefined,\n },\n style: {\n ...(transitionStatus === \"starting\" && typeof starting === \"object\"\n ? starting\n : {}),\n ...(transitionStatus === \"ending\" && typeof ending === \"object\"\n ? ending\n : {}),\n },\n }),\n });\n\n useEffect(() => {\n runOnceAnimationsFinish(() => {\n if (show === showRef.current) {\n setMounted(show);\n onTransitionComplete?.(show);\n }\n });\n }, [\n show,\n keepMounted,\n runOnceAnimationsFinish,\n setMounted,\n showRef,\n onTransitionComplete,\n ]);\n\n return mounted || keepMounted ? rendered : null;\n}\n"],"names":["Transition","children","className","starting","ending","show","keepMounted","onTransitionComplete","listenToChildAnimations","asChild","otherProps","mounted","setMounted","transitionStatus","useTransitionStatus","showRef","useLatestRef","cls","useCls","combinedClassName","useMemo","clsx","ref","useRef","runOnceAnimationsFinish","useAnimationsFinished","getRender","useCallback","isValidElement","jsx","rendered","useRender","mergeProps","useEffect"],"mappings":";;;;;;;;;;AA+CO,SAASA,EAAW;AAAA,EACzB,UAAAC,sBAAY,OAAI,EAAA;AAAA,EAChB,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,QAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,aAAAC,IAAc;AAAA,EACd,sBAAAC;AAAA,EACA,yBAAAC,IAA0B;AAAA,EAC1B,SAAAC,IAAU;AAAA,EACV,GAAGC;AACL,GAAoB;AAClB,QAAM,EAAE,SAAAC,GAAS,YAAAC,GAAY,kBAAAC,EAAiB,IAAIC,EAAoBT,CAAI,GACpEU,IAAUC,EAAaX,CAAI,GAE3BY,IAAMC,EAAO,GAEbC,IAAoBC;AAAA,IACxB,MACEC;AAAA,MACEnB;AAAA,MACAW,MAAqB,cACnB,OAAOV,KAAY,YACnBA;AAAA,MACFU,MAAqB,YAAY,OAAOT,KAAU,YAAYA;A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21.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"module": "./dist/index.js",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -66,6 +66,8 @@
|
|
|
66
66
|
"dev": "vite build --watch",
|
|
67
67
|
"rslib:build": "rslib build",
|
|
68
68
|
"rslib:dev": "rslib build --watch",
|
|
69
|
-
"tsdown": "tsdown"
|
|
69
|
+
"tsdown": "tsdown",
|
|
70
|
+
"lint": "eslint --config eslint.config.js 'src/**/*.{ts,tsx}'",
|
|
71
|
+
"lint:fix": "eslint --config eslint.config.js 'src/**/*.{ts,tsx}' --fix"
|
|
70
72
|
}
|
|
71
73
|
}
|