{"version":3,"file":"input.cjs","sourceRoot":"","sources":["../../../src/ui/components/input.ts"],"names":[],"mappings":";;;AACA,uDAAgF;AAEhF,yDAAqD;AACrD,4CAA2C;AAC3C,wCAAmD;AAEnD;;;GAGG;AACH,IAAY,SAIX;AAJD,WAAY,SAAS;IACnB,0BAAa,CAAA;IACb,8BAAiB,CAAA;IACjB,kCAAqB,CAAA;AACvB,CAAC,EAJW,SAAS,yBAAT,SAAS,QAIpB;AAEY,QAAA,WAAW,GAAG,IAAA,oBAAM,EAC/B,qBAAa,EACb,IAAA,oBAAM,EAAC;IACL,IAAI,EAAE,IAAA,mBAAO,EAAC,gBAAQ,CAAC,KAAK,CAAC;IAC7B,KAAK,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;IACzB,IAAI,EAAE,IAAA,oBAAM,GAAE;IACd,SAAS,EAAE,IAAA,sBAAQ,EACjB,IAAA,mBAAK,EAAC;QACJ,IAAA,qBAAS,EAAC,SAAS,CAAC,IAAI,CAAC;QACzB,IAAA,qBAAS,EAAC,SAAS,CAAC,QAAQ,CAAC;QAC7B,IAAA,qBAAS,EAAC,SAAS,CAAC,MAAM,CAAC;KAC5B,CAAC,CACH;IACD,WAAW,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;IAC/B,KAAK,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;IACzB,KAAK,EAAE,IAAA,sBAAQ,EAAC,IAAA,oBAAM,GAAE,CAAC;CAC1B,CAAC,CACH,CAAC;AAeF;;;;;;;;;;;;;;;;;;;GAmBG;AACU,QAAA,KAAK,GAAG,IAAA,uBAAa,EAAC,gBAAQ,CAAC,KAAK,EAAE,mBAAW,EAAE;IAC9D,MAAM;IACN,WAAW;IACX,aAAa;IACb,OAAO;IACP,OAAO;CACR,CAAC,CAAC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport { assign, object, optional, string, union } from '@metamask/superstruct';\n\nimport { enumValue, literal } from '../../internals';\nimport { createBuilder } from '../builder';\nimport { LiteralStruct, NodeType } from '../nodes';\n\n/**\n * This replicates the available input types from the metamask extension.\n * https://github.com/MetaMask/metamask-extension/main/ui/components/component-library/input/input.constants.js\n */\nexport enum InputType {\n  Text = 'text',\n  Number = 'number',\n  Password = 'password',\n}\n\nexport const InputStruct = assign(\n  LiteralStruct,\n  object({\n    type: literal(NodeType.Input),\n    value: optional(string()),\n    name: string(),\n    inputType: optional(\n      union([\n        enumValue(InputType.Text),\n        enumValue(InputType.Password),\n        enumValue(InputType.Number),\n      ]),\n    ),\n    placeholder: optional(string()),\n    label: optional(string()),\n    error: optional(string()),\n  }),\n);\n\n/**\n * An input node, that renders an input.\n *\n * @property type - The type of the node, must be the string 'input'.\n * @property name - The name for the input.\n * @property value - The value of the input.\n * @property inputType - An optional type, either `text`, `password` or `number`.\n * @property placeholder - An optional input placeholder.\n * @property label - An optional input label.\n * @property error - An optional error text.\n */\nexport type Input = Infer<typeof InputStruct>;\n\n/**\n * Create a {@link Input} node.\n *\n * @param args - The node arguments. This can either be a name and an optional variant, value and placeholder or an object\n * with the properties: `inputType`, `value`, `variant`, `placeholder` and `name`.\n * @param args.name - The name for the input.\n * @param args.value - The value of the input.\n * @param args.inputType - An optional type, either `text`, `password` or `number`.\n * @param args.placeholder - An optional input placeholder.\n * @param args.label - An optional input label.\n * @param args.error - An optional error text.\n * @returns The input node as an object.\n * @deprecated Snaps component functions are deprecated, in favor of the new JSX\n * components. This function will be removed in a future release.\n * @example\n * const node = input('myInput');\n * const node = input('myInput', InputType.Text, 'my placeholder', 'myValue', 'myLabel');\n * const node = input({ name: 'myInput' });\n * const node = input({name: 'myInput', value: 'myValue', inputType: InputType.Password, placeholder: 'placeholder'})\n */\nexport const input = createBuilder(NodeType.Input, InputStruct, [\n  'name',\n  'inputType',\n  'placeholder',\n  'value',\n  'label',\n]);\n"]}