Website for showcasing all features of Tesseract Web.
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 

90 linhas
2.2 KiB

  1. import * as React from 'react';
  2. import * as CheckControlBase from '@tesseract-design/web-base-checkcontrol';
  3. export type RadioTickBoxProps = Omit<React.HTMLProps<HTMLInputElement>, 'size' | 'type' | 'style'> & {
  4. /**
  5. * Should the component occupy the whole width of its parent?
  6. */
  7. block?: boolean,
  8. /**
  9. * Does the component need to conserve space?
  10. */
  11. compact?: boolean,
  12. /**
  13. * Complementary content of the component.
  14. */
  15. subtext?: React.ReactNode,
  16. }
  17. /**
  18. * Component for performing an action upon activation (e.g. when clicked).
  19. *
  20. * This component functions as a regular button.
  21. */
  22. export const RadioTickBox = React.forwardRef<HTMLInputElement, RadioTickBoxProps>(
  23. (
  24. {
  25. children,
  26. block = false,
  27. compact = false,
  28. subtext,
  29. className: _className,
  30. as: _as,
  31. ...etcProps
  32. }: RadioTickBoxProps,
  33. ref,
  34. ) => {
  35. const styleProps = React.useMemo<CheckControlBase.CheckControlBaseArgs>(() => ({
  36. block,
  37. compact,
  38. appearance: CheckControlBase.CheckControlAppearance.TICK_BOX,
  39. type: 'radio',
  40. }), [block, compact]);
  41. return (
  42. <div
  43. className={CheckControlBase.ClickAreaWrapper(styleProps)}
  44. >
  45. <label
  46. className={CheckControlBase.ClickArea()}
  47. >
  48. <input
  49. {...etcProps}
  50. type="radio"
  51. ref={ref}
  52. className={CheckControlBase.CheckStateContainer(styleProps)}
  53. />
  54. <span>
  55. <span />
  56. <span
  57. className={CheckControlBase.CheckIndicatorArea(styleProps)}
  58. >
  59. <span
  60. className={CheckControlBase.CheckIndicatorWrapper(styleProps)}
  61. />
  62. </span>
  63. <span>
  64. {children}
  65. {
  66. subtext
  67. && (
  68. <>
  69. <br />
  70. <span
  71. className={CheckControlBase.Subtext()}
  72. >
  73. {subtext}
  74. </span>
  75. </>
  76. )
  77. }
  78. </span>
  79. </span>
  80. </label>
  81. </div>
  82. );
  83. },
  84. );
  85. RadioTickBox.displayName = 'ActionButton';