@nation-a/ui 0.8.1 → 0.9.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/dist/index.cjs CHANGED
@@ -4832,7 +4832,7 @@ const Backdrop$1 = withContext$1(DialogBackdrop, "backdrop");
4832
4832
  const Trigger$1 = withContext$1(DialogTrigger, "trigger");
4833
4833
  const Content = withContext$1(DialogContent, "content");
4834
4834
  const Title = withContext$1(DialogTitle, "title");
4835
- const Description = withContext$1(DialogDescription, "description");
4835
+ const Description$1 = withContext$1(DialogDescription, "description");
4836
4836
  const Positioner = withContext$1(DialogPositioner, "positioner");
4837
4837
  const Header = withContext$1(ark.header, "header");
4838
4838
  const Footer = withContext$1(
@@ -4861,7 +4861,7 @@ const Dialog = {
4861
4861
  Trigger: Trigger$1,
4862
4862
  Content,
4863
4863
  Title,
4864
- Description,
4864
+ Description: Description$1,
4865
4865
  Positioner,
4866
4866
  Header,
4867
4867
  Footer,
@@ -8772,7 +8772,8 @@ const tagRecipe = cva({
8772
8772
  textStyle: "label.md",
8773
8773
  height: "fit-content",
8774
8774
  width: "fit-content",
8775
- cursor: "default"
8775
+ cursor: "default",
8776
+ outline: "none"
8776
8777
  },
8777
8778
  variants: {
8778
8779
  color: {
@@ -8908,29 +8909,437 @@ function P({ size: C = 24, color: n = "currentColor", ...o }) {
8908
8909
  }
8909
8910
  );
8910
8911
  }
8911
- const Tag = React.forwardRef(
8912
- ({ color, background, radius, imageSrc, text, onDeleteClick, ...rest }, ref) => {
8913
- const StyledTag = styled(ark.div, tagRecipe);
8914
- return /* @__PURE__ */ jsxRuntime.jsxs(StyledTag, { color, background, radius, avatar: !!imageSrc, ref, ...rest, children: [
8915
- imageSrc && /* @__PURE__ */ jsxRuntime.jsx(
8916
- styled.img,
8912
+ const Tag = React.forwardRef(({ imageSrc, text, onDeleteClick, ...rest }, ref) => {
8913
+ const StyledTag = styled(ark.div, tagRecipe);
8914
+ return /* @__PURE__ */ jsxRuntime.jsxs(StyledTag, { avatar: !!imageSrc, ref, ...rest, children: [
8915
+ imageSrc ? /* @__PURE__ */ jsxRuntime.jsx(
8916
+ styled.img,
8917
+ {
8918
+ src: imageSrc,
8919
+ width: 8,
8920
+ height: 8,
8921
+ className: css$1({ borderRadius: "full", overflow: "hidden" }),
8922
+ alt: "avatar thumbnail"
8923
+ }
8924
+ ) : null,
8925
+ text,
8926
+ onDeleteClick ? /* @__PURE__ */ jsxRuntime.jsx(P, { size: 12, onClick: onDeleteClick, cursor: "pointer" }) : null
8927
+ ] });
8928
+ });
8929
+ Tag.displayName = "Tag";
8930
+ const inputSlotRecipe = sva({
8931
+ className: "input",
8932
+ slots: ["requiredStar", "description", "textLengthIndicator"],
8933
+ base: {
8934
+ requiredStar: {
8935
+ color: "content.danger.default",
8936
+ paddingLeft: 1
8937
+ },
8938
+ description: {
8939
+ textStyle: "label.sm",
8940
+ color: "content.neutral.subtle",
8941
+ paddingLeft: 1,
8942
+ width: "100%",
8943
+ textAlign: "start"
8944
+ },
8945
+ textLengthIndicator: {
8946
+ display: "inline-block",
8947
+ width: "100%",
8948
+ textAlign: "end",
8949
+ paddingRight: 1,
8950
+ marginTop: -0.5,
8951
+ textStyle: "label.sm"
8952
+ }
8953
+ }
8954
+ });
8955
+ const inputRecipe = cva({
8956
+ base: {
8957
+ display: "flex",
8958
+ flexDirection: "column",
8959
+ alignItems: "center",
8960
+ justifyContent: "center",
8961
+ width: "100%",
8962
+ textStyle: "body.md",
8963
+ cursor: "text",
8964
+ color: "content.neutral.bold",
8965
+ gap: 1,
8966
+ borderStyle: "solid",
8967
+ border: 1,
8968
+ outline: "none",
8969
+ p: 2,
8970
+ "& textarea, & input": {
8971
+ outline: "none",
8972
+ width: "100%",
8973
+ height: "100%"
8974
+ }
8975
+ },
8976
+ variants: {
8977
+ isTextArea: {
8978
+ true: {
8979
+ minHeight: "56px",
8980
+ "& textarea": {
8981
+ background: "transparent",
8982
+ height: "100%",
8983
+ resize: "none",
8984
+ overflowY: "auto"
8985
+ }
8986
+ },
8987
+ false: {
8988
+ minHeight: "48px",
8989
+ maxHeight: "60px"
8990
+ }
8991
+ },
8992
+ variant: {
8993
+ solid: {
8994
+ borderColor: "transparent"
8995
+ },
8996
+ line: {
8997
+ background: "transparent"
8998
+ }
8999
+ },
9000
+ color: {
9001
+ alpha: {
9002
+ "&::placeholder": {
9003
+ color: "content.static.white.subtlest"
9004
+ }
9005
+ },
9006
+ neutral: {
9007
+ "&::placeholder": {
9008
+ color: "content.neutral.subtlest"
9009
+ }
9010
+ }
9011
+ },
9012
+ radius: {
9013
+ md: {
9014
+ borderRadius: 8,
9015
+ px: 2
9016
+ },
9017
+ lg: {
9018
+ borderRadius: 16,
9019
+ px: 2
9020
+ },
9021
+ full: {
9022
+ borderRadius: 9999,
9023
+ px: 4
9024
+ }
9025
+ },
9026
+ state: {
9027
+ // state: Input 컴포넌트 내부 로직, 외부 노출 X (외부에선 disabled만 제어)
9028
+ default: {
9029
+ color: "content.neutral.bold"
9030
+ },
9031
+ selected: {
9032
+ color: "content.neutral.bold"
9033
+ },
9034
+ disabled: {
9035
+ color: "content.neutral.disabled"
9036
+ }
9037
+ }
9038
+ },
9039
+ compoundVariants: [
9040
+ {
9041
+ color: "alpha",
9042
+ state: "disabled",
9043
+ css: {
9044
+ "&::placeholder": {
9045
+ color: "content.static.white.disabled"
9046
+ }
9047
+ }
9048
+ },
9049
+ {
9050
+ color: "neutral",
9051
+ state: "disabled",
9052
+ css: {
9053
+ "&::placeholder": {
9054
+ color: "content.neutral.disabled"
9055
+ }
9056
+ }
9057
+ },
9058
+ {
9059
+ variant: "solid",
9060
+ color: "alpha",
9061
+ state: "default",
9062
+ css: {
9063
+ background: "black.500A"
9064
+ }
9065
+ },
9066
+ {
9067
+ variant: "solid",
9068
+ color: "alpha",
9069
+ state: "selected",
9070
+ css: {
9071
+ background: "black.500A",
9072
+ border: 1,
9073
+ borderColor: "border.neutral.default"
9074
+ }
9075
+ },
9076
+ {
9077
+ variant: "solid",
9078
+ color: "alpha",
9079
+ state: "disabled",
9080
+ css: {
9081
+ background: "black.500A"
9082
+ }
9083
+ },
9084
+ {
9085
+ variant: "solid",
9086
+ color: "neutral",
9087
+ state: "default",
9088
+ css: {
9089
+ background: "background.neutral.default"
9090
+ }
9091
+ },
9092
+ {
9093
+ variant: "solid",
9094
+ color: "neutral",
9095
+ state: "selected",
9096
+ css: {
9097
+ background: "background.neutral.default",
9098
+ border: 1,
9099
+ borderColor: "border.neutral.default"
9100
+ }
9101
+ },
9102
+ {
9103
+ variant: "solid",
9104
+ color: "neutral",
9105
+ state: "disabled",
9106
+ css: {
9107
+ background: "background.neutral.disabled"
9108
+ }
9109
+ },
9110
+ {
9111
+ variant: "line",
9112
+ state: "default",
9113
+ css: {
9114
+ background: "transparent",
9115
+ border: 1,
9116
+ borderColor: "border.neutral.subtle"
9117
+ }
9118
+ },
9119
+ {
9120
+ variant: "line",
9121
+ state: "selected",
9122
+ css: {
9123
+ background: "transparent",
9124
+ border: 1,
9125
+ borderColor: "border.neutral.default"
9126
+ }
9127
+ },
9128
+ {
9129
+ variant: "line",
9130
+ state: "disabled",
9131
+ css: {
9132
+ background: "transparent",
9133
+ border: 1,
9134
+ borderColor: "border.neutral.disabled"
9135
+ }
9136
+ }
9137
+ ],
9138
+ defaultVariants: {
9139
+ isTextArea: false,
9140
+ variant: "solid",
9141
+ color: "neutral",
9142
+ state: "default",
9143
+ radius: "md"
9144
+ }
9145
+ });
9146
+ const labelRecipe = cva({
9147
+ base: {
9148
+ textStyle: "label.sm",
9149
+ textAlign: "start",
9150
+ width: "100%",
9151
+ display: "inline-block"
9152
+ },
9153
+ variants: {
9154
+ state: {
9155
+ default: {},
9156
+ selected: {},
9157
+ disabled: {}
9158
+ },
9159
+ color: {
9160
+ alpha: {
9161
+ color: "content.static.white.bold"
9162
+ },
9163
+ neutral: {
9164
+ color: "content.neutral.subtle"
9165
+ }
9166
+ },
9167
+ radius: {
9168
+ md: {},
9169
+ lg: {},
9170
+ full: {}
9171
+ }
9172
+ },
9173
+ compoundVariants: [
9174
+ {
9175
+ state: "disabled",
9176
+ css: {
9177
+ color: "content.neutral.disabled"
9178
+ }
9179
+ }
9180
+ ],
9181
+ defaultVariants: {
9182
+ color: "neutral",
9183
+ state: "default",
9184
+ radius: "md"
9185
+ }
9186
+ });
9187
+ const StyledInputWrapper = styled(ark.div, inputRecipe);
9188
+ const StyledLabel$1 = styled(ark.label, labelRecipe);
9189
+ const RequiredStar = () => /* @__PURE__ */ jsxRuntime.jsx(ark.span, { className: inputSlotRecipe().requiredStar, "aria-hidden": "true", children: "*" });
9190
+ const Description = ({ children }) => /* @__PURE__ */ jsxRuntime.jsx(ark.span, { className: inputSlotRecipe().description, children });
9191
+ const Input = React.forwardRef(
9192
+ ({
9193
+ value,
9194
+ required,
9195
+ disabled,
9196
+ label,
9197
+ description,
9198
+ labelPosition = "outside",
9199
+ textLimit,
9200
+ variant,
9201
+ color,
9202
+ radius,
9203
+ onChange,
9204
+ className,
9205
+ ...rest
9206
+ }, ref) => {
9207
+ const [state, setState] = React.useState(disabled ? "disabled" : "default");
9208
+ React.useEffect(() => {
9209
+ setState(disabled ? "disabled" : "default");
9210
+ }, [disabled]);
9211
+ const handleInputChange = (e) => {
9212
+ if (disabled) return;
9213
+ const value2 = e.target.value;
9214
+ if (textLimit && value2.length > textLimit) return;
9215
+ setState(value2 ? "selected" : "default");
9216
+ onChange == null ? void 0 : onChange(e);
9217
+ };
9218
+ const Label = ({ visible, children }) => {
9219
+ console.log("color", color);
9220
+ return visible ? /* @__PURE__ */ jsxRuntime.jsxs(StyledLabel$1, { state, color, radius, children: [
9221
+ children,
9222
+ required && /* @__PURE__ */ jsxRuntime.jsx(RequiredStar, {})
9223
+ ] }) : null;
9224
+ };
9225
+ return /* @__PURE__ */ jsxRuntime.jsxs(VStack$1, { gap: 1, children: [
9226
+ /* @__PURE__ */ jsxRuntime.jsx(Label, { visible: !!(label && labelPosition === "outside"), children: label }),
9227
+ /* @__PURE__ */ jsxRuntime.jsxs(
9228
+ StyledInputWrapper,
8917
9229
  {
8918
- src: imageSrc,
8919
- css: {
8920
- width: "8",
8921
- height: "8",
8922
- borderRadius: "full",
8923
- overflow: "hidden"
8924
- },
8925
- alt: "avatar thumbnail"
9230
+ state,
9231
+ variant,
9232
+ color,
9233
+ radius,
9234
+ className: cx(css$1({ display: "flex", flexDirection: "column", gap: 1 }), className),
9235
+ children: [
9236
+ /* @__PURE__ */ jsxRuntime.jsx(Label, { visible: !!(label && labelPosition === "inside"), children: label }),
9237
+ /* @__PURE__ */ jsxRuntime.jsx(
9238
+ "input",
9239
+ {
9240
+ value,
9241
+ disabled,
9242
+ onFocus: () => !disabled && setState("selected"),
9243
+ onBlur: () => !disabled && setState("default"),
9244
+ onChange: handleInputChange,
9245
+ ref,
9246
+ ...rest
9247
+ }
9248
+ )
9249
+ ]
8926
9250
  }
8927
9251
  ),
8928
- text,
8929
- onDeleteClick ? /* @__PURE__ */ jsxRuntime.jsx(P, { size: 12, onClick: onDeleteClick, cursor: "pointer" }) : null
9252
+ description && /* @__PURE__ */ jsxRuntime.jsx(Description, { children: description })
8930
9253
  ] });
8931
9254
  }
8932
9255
  );
8933
- Tag.displayName = "Tag";
9256
+ Input.displayName = "Input";
9257
+ const StyledTextAreaWrapper = styled(ark.div, inputRecipe);
9258
+ const StyledLabel = styled(ark.label, labelRecipe);
9259
+ const TextLengthIndicator = ({ count, limit, disabled }) => {
9260
+ return /* @__PURE__ */ jsxRuntime.jsx(
9261
+ ark.span,
9262
+ {
9263
+ className: cx(
9264
+ inputSlotRecipe().textLengthIndicator,
9265
+ css$1({
9266
+ color: disabled ? "content.neutral.disabled" : "content.neutral.subtlest"
9267
+ })
9268
+ ),
9269
+ children: `${count}${limit ? ` / ${limit}` : ""}`
9270
+ }
9271
+ );
9272
+ };
9273
+ const Textarea = React.forwardRef(
9274
+ ({
9275
+ value,
9276
+ required = false,
9277
+ disabled = false,
9278
+ label,
9279
+ description,
9280
+ labelPosition = "outside",
9281
+ textLimit,
9282
+ showTextCount = false,
9283
+ isTextArea,
9284
+ color,
9285
+ radius,
9286
+ variant,
9287
+ onChange,
9288
+ className,
9289
+ ...rest
9290
+ }, ref) => {
9291
+ const [state, setState] = React.useState(disabled ? "disabled" : "default");
9292
+ React.useEffect(() => {
9293
+ setState(disabled ? "disabled" : "default");
9294
+ }, [disabled]);
9295
+ const handleTextareaChange = (e) => {
9296
+ if (disabled) return;
9297
+ const value2 = e.target.value;
9298
+ if (textLimit && value2.length > textLimit) return;
9299
+ setState(value2 ? "selected" : "default");
9300
+ onChange == null ? void 0 : onChange(e);
9301
+ e.target.scrollTop = e.target.scrollHeight;
9302
+ };
9303
+ const Label = ({ visible, children }) => {
9304
+ return visible ? /* @__PURE__ */ jsxRuntime.jsxs(StyledLabel, { state, color, radius, children: [
9305
+ children,
9306
+ required && /* @__PURE__ */ jsxRuntime.jsx(RequiredStar, {})
9307
+ ] }) : null;
9308
+ };
9309
+ return /* @__PURE__ */ jsxRuntime.jsxs(VStack$1, { gap: 1, children: [
9310
+ /* @__PURE__ */ jsxRuntime.jsx(Label, { visible: !!(label && labelPosition === "outside"), children: label }),
9311
+ /* @__PURE__ */ jsxRuntime.jsxs(
9312
+ StyledTextAreaWrapper,
9313
+ {
9314
+ isTextArea: true,
9315
+ state,
9316
+ color,
9317
+ radius,
9318
+ variant,
9319
+ className: cx(css$1({ position: "relative", display: "flex", flexDirection: "column", gap: 1 }), className),
9320
+ children: [
9321
+ /* @__PURE__ */ jsxRuntime.jsx(Label, { visible: !!(label && labelPosition === "inside"), children: label }),
9322
+ /* @__PURE__ */ jsxRuntime.jsx(
9323
+ "textarea",
9324
+ {
9325
+ value,
9326
+ disabled,
9327
+ onChange: handleTextareaChange,
9328
+ onFocus: () => !disabled && setState("selected"),
9329
+ onBlur: () => !disabled && setState("default"),
9330
+ ref,
9331
+ ...rest
9332
+ }
9333
+ ),
9334
+ showTextCount && /* @__PURE__ */ jsxRuntime.jsx(TextLengthIndicator, { count: value.length, limit: textLimit, disabled })
9335
+ ]
9336
+ }
9337
+ ),
9338
+ description && /* @__PURE__ */ jsxRuntime.jsx(Description, { children: description })
9339
+ ] });
9340
+ }
9341
+ );
9342
+ Textarea.displayName = "Textarea";
8934
9343
  function definePreset(preset2) {
8935
9344
  return preset2;
8936
9345
  }
@@ -9250,12 +9659,14 @@ exports.Grid = Grid2;
9250
9659
  exports.GridItem = GridItem2;
9251
9660
  exports.HStack = HStack2;
9252
9661
  exports.IconButton = index;
9662
+ exports.Input = Input;
9253
9663
  exports.Navigation = Navigation;
9254
9664
  exports.Portal = Portal;
9255
9665
  exports.Spinner = Spinner;
9256
9666
  exports.Stack = Stack2;
9257
9667
  exports.Tag = Tag;
9258
9668
  exports.Text = Text;
9669
+ exports.TextArea = Textarea;
9259
9670
  exports.VStack = VStack2;
9260
9671
  exports.preset = preset;
9261
9672
  //# sourceMappingURL=index.cjs.map