@nation-a/ui 0.8.1 → 0.9.0

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.js CHANGED
@@ -4814,7 +4814,7 @@ const Backdrop$1 = withContext$1(DialogBackdrop, "backdrop");
4814
4814
  const Trigger$1 = withContext$1(DialogTrigger, "trigger");
4815
4815
  const Content = withContext$1(DialogContent, "content");
4816
4816
  const Title = withContext$1(DialogTitle, "title");
4817
- const Description = withContext$1(DialogDescription, "description");
4817
+ const Description$1 = withContext$1(DialogDescription, "description");
4818
4818
  const Positioner = withContext$1(DialogPositioner, "positioner");
4819
4819
  const Header = withContext$1(ark.header, "header");
4820
4820
  const Footer = withContext$1(
@@ -4843,7 +4843,7 @@ const Dialog = {
4843
4843
  Trigger: Trigger$1,
4844
4844
  Content,
4845
4845
  Title,
4846
- Description,
4846
+ Description: Description$1,
4847
4847
  Positioner,
4848
4848
  Header,
4849
4849
  Footer,
@@ -8754,7 +8754,8 @@ const tagRecipe = cva({
8754
8754
  textStyle: "label.md",
8755
8755
  height: "fit-content",
8756
8756
  width: "fit-content",
8757
- cursor: "default"
8757
+ cursor: "default",
8758
+ outline: "none"
8758
8759
  },
8759
8760
  variants: {
8760
8761
  color: {
@@ -8890,29 +8891,389 @@ function P({ size: C = 24, color: n = "currentColor", ...o }) {
8890
8891
  }
8891
8892
  );
8892
8893
  }
8893
- const Tag = forwardRef(
8894
- ({ color, background, radius, imageSrc, text, onDeleteClick, ...rest }, ref) => {
8895
- const StyledTag = styled(ark.div, tagRecipe);
8896
- return /* @__PURE__ */ jsxs(StyledTag, { color, background, radius, avatar: !!imageSrc, ref, ...rest, children: [
8897
- imageSrc && /* @__PURE__ */ jsx(
8898
- styled.img,
8894
+ const Tag = forwardRef(({ imageSrc, text, onDeleteClick, ...rest }, ref) => {
8895
+ const StyledTag = styled(ark.div, tagRecipe);
8896
+ return /* @__PURE__ */ jsxs(StyledTag, { avatar: !!imageSrc, ref, ...rest, children: [
8897
+ imageSrc ? /* @__PURE__ */ jsx(
8898
+ styled.img,
8899
+ {
8900
+ src: imageSrc,
8901
+ width: 8,
8902
+ height: 8,
8903
+ className: css$1({ borderRadius: "full", overflow: "hidden" }),
8904
+ alt: "avatar thumbnail"
8905
+ }
8906
+ ) : null,
8907
+ text,
8908
+ onDeleteClick ? /* @__PURE__ */ jsx(P, { size: 12, onClick: onDeleteClick, cursor: "pointer" }) : null
8909
+ ] });
8910
+ });
8911
+ Tag.displayName = "Tag";
8912
+ const inputRecipe = cva({
8913
+ base: {
8914
+ display: "flex",
8915
+ flexDirection: "column",
8916
+ alignItems: "center",
8917
+ justifyContent: "center",
8918
+ width: "100%",
8919
+ textStyle: "body.md",
8920
+ cursor: "text",
8921
+ color: "content.neutral.bold",
8922
+ gap: 1,
8923
+ borderStyle: "solid",
8924
+ border: 1,
8925
+ outline: "none",
8926
+ p: 2,
8927
+ "& textarea, & input": {
8928
+ outline: "none",
8929
+ width: "100%",
8930
+ height: "100%"
8931
+ }
8932
+ },
8933
+ variants: {
8934
+ isTextArea: {
8935
+ true: {
8936
+ minHeight: "56px",
8937
+ "& textarea": {
8938
+ background: "transparent",
8939
+ height: "100%",
8940
+ resize: "none",
8941
+ overflowY: "auto"
8942
+ }
8943
+ },
8944
+ false: {
8945
+ minHeight: "48px",
8946
+ maxHeight: "60px"
8947
+ }
8948
+ },
8949
+ variant: {
8950
+ solid: {
8951
+ borderColor: "transparent"
8952
+ },
8953
+ line: {
8954
+ background: "transparent"
8955
+ }
8956
+ },
8957
+ color: {
8958
+ alpha: {
8959
+ "&::placeholder": {
8960
+ color: "content.static.white.subtlest"
8961
+ }
8962
+ },
8963
+ neutral: {
8964
+ "&::placeholder": {
8965
+ color: "content.neutral.subtlest"
8966
+ }
8967
+ }
8968
+ },
8969
+ radius: {
8970
+ md: {
8971
+ borderRadius: 8,
8972
+ px: 2
8973
+ },
8974
+ lg: {
8975
+ borderRadius: 16,
8976
+ px: 2
8977
+ },
8978
+ full: {
8979
+ borderRadius: 9999,
8980
+ px: 4
8981
+ }
8982
+ },
8983
+ state: {
8984
+ // state: Input 컴포넌트 내부 로직, 외부 노출 X (외부에선 disabled만 제어)
8985
+ default: {
8986
+ color: "content.neutral.bold"
8987
+ },
8988
+ selected: {
8989
+ color: "content.neutral.bold"
8990
+ },
8991
+ disabled: {
8992
+ color: "content.neutral.disabled"
8993
+ }
8994
+ }
8995
+ },
8996
+ compoundVariants: [
8997
+ {
8998
+ color: "alpha",
8999
+ state: "disabled",
9000
+ css: {
9001
+ "&::placeholder": {
9002
+ color: "content.static.white.disabled"
9003
+ }
9004
+ }
9005
+ },
9006
+ {
9007
+ color: "neutral",
9008
+ state: "disabled",
9009
+ css: {
9010
+ "&::placeholder": {
9011
+ color: "content.neutral.disabled"
9012
+ }
9013
+ }
9014
+ },
9015
+ {
9016
+ variant: "solid",
9017
+ color: "alpha",
9018
+ state: "default",
9019
+ css: {
9020
+ background: "black.500A"
9021
+ }
9022
+ },
9023
+ {
9024
+ variant: "solid",
9025
+ color: "alpha",
9026
+ state: "selected",
9027
+ css: {
9028
+ background: "black.500A",
9029
+ border: 1,
9030
+ borderColor: "border.neutral.default"
9031
+ }
9032
+ },
9033
+ {
9034
+ variant: "solid",
9035
+ color: "alpha",
9036
+ state: "disabled",
9037
+ css: {
9038
+ background: "black.500A"
9039
+ }
9040
+ },
9041
+ {
9042
+ variant: "solid",
9043
+ color: "neutral",
9044
+ state: "default",
9045
+ css: {
9046
+ background: "background.neutral.default"
9047
+ }
9048
+ },
9049
+ {
9050
+ variant: "solid",
9051
+ color: "neutral",
9052
+ state: "selected",
9053
+ css: {
9054
+ background: "background.neutral.default",
9055
+ border: 1,
9056
+ borderColor: "border.neutral.default"
9057
+ }
9058
+ },
9059
+ {
9060
+ variant: "solid",
9061
+ color: "neutral",
9062
+ state: "disabled",
9063
+ css: {
9064
+ background: "background.neutral.disabled"
9065
+ }
9066
+ },
9067
+ {
9068
+ variant: "line",
9069
+ state: "default",
9070
+ css: {
9071
+ background: "transparent",
9072
+ border: 1,
9073
+ borderColor: "border.neutral.subtle"
9074
+ }
9075
+ },
9076
+ {
9077
+ variant: "line",
9078
+ state: "selected",
9079
+ css: {
9080
+ background: "transparent",
9081
+ border: 1,
9082
+ borderColor: "border.neutral.default"
9083
+ }
9084
+ },
9085
+ {
9086
+ variant: "line",
9087
+ state: "disabled",
9088
+ css: {
9089
+ background: "transparent",
9090
+ border: 1,
9091
+ borderColor: "border.neutral.disabled"
9092
+ }
9093
+ }
9094
+ ],
9095
+ defaultVariants: {
9096
+ isTextArea: false,
9097
+ variant: "solid",
9098
+ color: "neutral",
9099
+ state: "default",
9100
+ radius: "md"
9101
+ }
9102
+ });
9103
+ const labelRecipe = cva({
9104
+ base: {
9105
+ textStyle: "label.sm",
9106
+ textAlign: "start",
9107
+ width: "100%",
9108
+ display: "inline-block"
9109
+ },
9110
+ variants: {
9111
+ state: {
9112
+ default: {},
9113
+ selected: {},
9114
+ disabled: {}
9115
+ },
9116
+ color: {
9117
+ alpha: {
9118
+ color: "content.static.white.bold"
9119
+ },
9120
+ neutral: {
9121
+ color: "content.neutral.subtle"
9122
+ }
9123
+ },
9124
+ radius: {
9125
+ md: {},
9126
+ lg: {},
9127
+ full: {}
9128
+ }
9129
+ },
9130
+ compoundVariants: [
9131
+ {
9132
+ state: "disabled",
9133
+ css: {
9134
+ color: "content.neutral.disabled"
9135
+ }
9136
+ }
9137
+ ],
9138
+ defaultVariants: {
9139
+ color: "neutral",
9140
+ state: "default",
9141
+ radius: "md"
9142
+ }
9143
+ });
9144
+ const StyledInputWrapper = styled(ark.div, inputRecipe);
9145
+ const StyledLabel$1 = styled(ark.label, labelRecipe);
9146
+ const RequiredStar = () => /* @__PURE__ */ jsx(ark.span, { className: css$1({ color: "content.danger.default", paddingLeft: 1 }), children: "*" });
9147
+ const Description = ({ children }) => /* @__PURE__ */ jsx(ark.span, { className: css$1({ textStyle: "label.sm", color: "content.neutral.subtle", paddingLeft: 1, width: "100%", textAlign: "start" }), children });
9148
+ const Input = forwardRef(({ value, required, disabled, label, description, labelPosition = "outside", textLimit, variant, color, radius, onChange, className, ...rest }, ref) => {
9149
+ const [state, setState] = useState(disabled ? "disabled" : "default");
9150
+ useEffect(() => {
9151
+ setState(disabled ? "disabled" : "default");
9152
+ }, [disabled]);
9153
+ const handleInputChange = (e) => {
9154
+ if (disabled) return;
9155
+ const value2 = e.target.value;
9156
+ if (textLimit && value2.length > textLimit) return;
9157
+ setState(value2 ? "selected" : "default");
9158
+ onChange == null ? void 0 : onChange(e);
9159
+ };
9160
+ const Label = ({ visible, children }) => {
9161
+ console.log("color", color);
9162
+ return visible ? /* @__PURE__ */ jsxs(StyledLabel$1, { state, color, radius, children: [
9163
+ children,
9164
+ required && /* @__PURE__ */ jsx(RequiredStar, {})
9165
+ ] }) : null;
9166
+ };
9167
+ return /* @__PURE__ */ jsxs(VStack$1, { gap: 1, children: [
9168
+ /* @__PURE__ */ jsx(Label, { visible: !!(label && labelPosition === "outside"), children: label }),
9169
+ /* @__PURE__ */ jsxs(StyledInputWrapper, { state, variant, color, radius, className: cx(css$1({ display: "flex", flexDirection: "column", gap: 1 }), className), children: [
9170
+ /* @__PURE__ */ jsx(Label, { visible: !!(label && labelPosition === "inside"), children: label }),
9171
+ /* @__PURE__ */ jsx(
9172
+ "input",
8899
9173
  {
8900
- src: imageSrc,
8901
- css: {
8902
- width: "8",
8903
- height: "8",
8904
- borderRadius: "full",
8905
- overflow: "hidden"
8906
- },
8907
- alt: "avatar thumbnail"
9174
+ value,
9175
+ disabled,
9176
+ onFocus: () => !disabled && setState("selected"),
9177
+ onBlur: () => !disabled && setState("default"),
9178
+ onChange: handleInputChange,
9179
+ ref,
9180
+ ...rest
9181
+ }
9182
+ )
9183
+ ] }),
9184
+ description && /* @__PURE__ */ jsx(Description, { children: description })
9185
+ ] });
9186
+ });
9187
+ Input.displayName = "Input";
9188
+ const StyledTextAreaWrapper = styled(ark.div, inputRecipe);
9189
+ const StyledLabel = styled(ark.label, labelRecipe);
9190
+ const TextLengthIndicator = ({ count, limit, disabled }) => {
9191
+ return /* @__PURE__ */ jsx(
9192
+ ark.span,
9193
+ {
9194
+ className: css$1({
9195
+ display: "inline-block",
9196
+ width: "100%",
9197
+ textAlign: "end",
9198
+ paddingRight: 1,
9199
+ marginTop: -0.5,
9200
+ textStyle: "label.sm",
9201
+ color: disabled ? "content.neutral.disabled" : "content.neutral.subtlest"
9202
+ }),
9203
+ children: `${count}${limit ? ` / ${limit}` : ""}`
9204
+ }
9205
+ );
9206
+ };
9207
+ const Textarea = forwardRef(
9208
+ ({
9209
+ value,
9210
+ required = false,
9211
+ disabled = false,
9212
+ label,
9213
+ description,
9214
+ labelPosition = "outside",
9215
+ textLimit,
9216
+ showTextCount = false,
9217
+ isTextArea,
9218
+ color,
9219
+ radius,
9220
+ variant,
9221
+ onChange,
9222
+ className,
9223
+ ...rest
9224
+ }, ref) => {
9225
+ const [state, setState] = useState(disabled ? "disabled" : "default");
9226
+ useEffect(() => {
9227
+ setState(disabled ? "disabled" : "default");
9228
+ }, [disabled]);
9229
+ const handleTextareaChange = (e) => {
9230
+ if (disabled) return;
9231
+ const value2 = e.target.value;
9232
+ if (textLimit && value2.length > textLimit) return;
9233
+ setState(value2 ? "selected" : "default");
9234
+ onChange == null ? void 0 : onChange(e);
9235
+ e.target.scrollTop = e.target.scrollHeight;
9236
+ };
9237
+ const Label = ({ visible, children }) => {
9238
+ return visible ? /* @__PURE__ */ jsxs(StyledLabel, { state, color, radius, children: [
9239
+ children,
9240
+ required && /* @__PURE__ */ jsx(RequiredStar, {})
9241
+ ] }) : null;
9242
+ };
9243
+ return /* @__PURE__ */ jsxs(VStack$1, { gap: 1, children: [
9244
+ /* @__PURE__ */ jsx(Label, { visible: !!(label && labelPosition === "outside"), children: label }),
9245
+ /* @__PURE__ */ jsxs(
9246
+ StyledTextAreaWrapper,
9247
+ {
9248
+ isTextArea: true,
9249
+ state,
9250
+ color,
9251
+ radius,
9252
+ variant,
9253
+ className: cx(css$1({ position: "relative", display: "flex", flexDirection: "column", gap: 1 }), className),
9254
+ children: [
9255
+ /* @__PURE__ */ jsx(Label, { visible: !!(label && labelPosition === "inside"), children: label }),
9256
+ /* @__PURE__ */ jsx(
9257
+ "textarea",
9258
+ {
9259
+ value,
9260
+ disabled,
9261
+ onChange: handleTextareaChange,
9262
+ onFocus: () => !disabled && setState("selected"),
9263
+ onBlur: () => !disabled && setState("default"),
9264
+ ref,
9265
+ ...rest
9266
+ }
9267
+ ),
9268
+ showTextCount && /* @__PURE__ */ jsx(TextLengthIndicator, { count: value.length, limit: textLimit, disabled })
9269
+ ]
8908
9270
  }
8909
9271
  ),
8910
- text,
8911
- onDeleteClick ? /* @__PURE__ */ jsx(P, { size: 12, onClick: onDeleteClick, cursor: "pointer" }) : null
9272
+ description && /* @__PURE__ */ jsx(Description, { children: description })
8912
9273
  ] });
8913
9274
  }
8914
9275
  );
8915
- Tag.displayName = "Tag";
9276
+ Textarea.displayName = "Textarea";
8916
9277
  function definePreset(preset2) {
8917
9278
  return preset2;
8918
9279
  }
@@ -9233,12 +9594,14 @@ export {
9233
9594
  GridItem2 as GridItem,
9234
9595
  HStack2 as HStack,
9235
9596
  index as IconButton,
9597
+ Input,
9236
9598
  Navigation,
9237
9599
  Portal,
9238
9600
  Spinner,
9239
9601
  Stack2 as Stack,
9240
9602
  Tag,
9241
9603
  Text,
9604
+ Textarea as TextArea,
9242
9605
  VStack2 as VStack,
9243
9606
  preset
9244
9607
  };