@fountain-ui/core 2.0.0-beta.90 → 2.0.0-beta.92

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.
Files changed (30) hide show
  1. package/build/commonjs/Divider/Divider.js +16 -4
  2. package/build/commonjs/Divider/Divider.js.map +1 -1
  3. package/build/commonjs/Divider/DividerProps.js +9 -0
  4. package/build/commonjs/Divider/DividerProps.js.map +1 -1
  5. package/build/commonjs/Divider/LegacyDivider.js +114 -0
  6. package/build/commonjs/Divider/LegacyDivider.js.map +1 -0
  7. package/build/commonjs/Divider/LegacyDividerProps.js +2 -0
  8. package/build/commonjs/Divider/LegacyDividerProps.js.map +1 -0
  9. package/build/commonjs/Divider/index.js +2 -2
  10. package/build/commonjs/Divider/index.js.map +1 -1
  11. package/build/module/Divider/Divider.js +17 -4
  12. package/build/module/Divider/Divider.js.map +1 -1
  13. package/build/module/Divider/DividerProps.js +2 -1
  14. package/build/module/Divider/DividerProps.js.map +1 -1
  15. package/build/module/Divider/LegacyDivider.js +100 -0
  16. package/build/module/Divider/LegacyDivider.js.map +1 -0
  17. package/build/module/Divider/LegacyDividerProps.js +2 -0
  18. package/build/module/Divider/LegacyDividerProps.js.map +1 -0
  19. package/build/module/Divider/index.js +1 -1
  20. package/build/module/Divider/index.js.map +1 -1
  21. package/build/typescript/Divider/DividerProps.d.ts +12 -9
  22. package/build/typescript/Divider/LegacyDivider.d.ts +3 -0
  23. package/build/typescript/Divider/LegacyDividerProps.d.ts +41 -0
  24. package/build/typescript/Divider/index.d.ts +2 -2
  25. package/package.json +2 -2
  26. package/src/Divider/Divider.tsx +17 -8
  27. package/src/Divider/DividerProps.ts +14 -10
  28. package/src/Divider/LegacyDivider.tsx +114 -0
  29. package/src/Divider/LegacyDividerProps.ts +48 -0
  30. package/src/Divider/index.ts +2 -2
@@ -31,21 +31,33 @@ const styles = _styles.StyleSheet.create({
31
31
  }
32
32
  });
33
33
 
34
+ function selectBorderColor(theme, variant, vertical) {
35
+ switch (variant) {
36
+ default:
37
+ case 'base':
38
+ return vertical ? theme.palette.border.weaker : theme.palette.border.weak;
39
+
40
+ case 'strong':
41
+ return vertical ? theme.palette.border.weak : theme.palette.border.base;
42
+ }
43
+ }
44
+
34
45
  function Divider(props) {
35
46
  const {
36
- borderWidth = 1,
47
+ borderWidth: borderWidthProp,
37
48
  children: childrenProp,
38
- color = 'divider',
39
49
  elementAlign = 'center',
40
50
  inset = 0,
41
51
  marginBetweenChildren = 2,
42
52
  style,
53
+ variant = 'base',
43
54
  vertical = false,
44
55
  ...otherProps
45
56
  } = props;
46
57
  const theme = (0, _styles.useTheme)();
47
- const fontColor = theme.palette.text.secondary;
48
- const borderColor = color === 'divider' ? theme.palette.divider : color === 'border' ? theme.palette.border.default : theme.palette[color].main;
58
+ const borderWidth = borderWidthProp ?? (vertical ? 1 : 0.5);
59
+ const fontColor = theme.palette.text.weak;
60
+ const borderColor = selectBorderColor(theme, variant, vertical);
49
61
  const marginSize = theme.spacing(1);
50
62
  const insetSize = theme.spacing(inset);
51
63
  const marginLeft = marginSize;
@@ -1 +1 @@
1
- {"version":3,"names":["styles","StyleSheet","create","container","alignSelf","alignItems","row","flexDirection","column","divider","flexGrow","Divider","props","borderWidth","children","childrenProp","color","elementAlign","inset","marginBetweenChildren","style","vertical","otherProps","theme","useTheme","fontColor","palette","text","secondary","borderColor","border","default","main","marginSize","spacing","insetSize","marginLeft","marginRight","marginTop","marginBottom","marginStyle","insetStyle","borderColorStyle","borderWidthStyle","borderRightWidth","borderBottomWidth","containerStyle","css","undefined","dividerStyle","dividerMarginSize","startDividerStyle","display","endDividerStyle","fontStyle","createFontStyle","selector","typo","caption2","element"],"sources":["Divider.tsx"],"sourcesContent":["import React from 'react';\nimport { Text, View } from 'react-native';\nimport { createFontStyle, css, StyleSheet, useTheme } from '../styles';\nimport { ExtendedStyle } from '../types';\nimport type DividerProps from './DividerProps';\n\nconst styles = StyleSheet.create({\n container: {\n alignSelf: 'stretch',\n alignItems: 'center',\n },\n row: {\n flexDirection: 'row',\n },\n column: {\n flexDirection: 'column',\n },\n divider: {\n flexGrow: 1,\n },\n});\n\nexport default function Divider(props: DividerProps) {\n const {\n borderWidth = 1,\n children: childrenProp,\n color = 'divider',\n elementAlign = 'center',\n inset = 0,\n marginBetweenChildren = 2,\n style,\n vertical = false,\n ...otherProps\n } = props;\n\n const theme = useTheme();\n\n const fontColor = theme.palette.text.secondary;\n const borderColor = color === 'divider'\n ? theme.palette.divider\n : color === 'border'\n ? theme.palette.border.default\n : theme.palette[color].main;\n const marginSize = theme.spacing(1);\n const insetSize = theme.spacing(inset);\n\n const marginLeft = marginSize;\n const marginRight = marginSize;\n const marginTop = marginSize;\n const marginBottom = marginSize;\n\n const marginStyle = vertical\n ? { marginLeft, marginRight }\n : { marginTop, marginBottom };\n\n const insetStyle = vertical\n ? { marginTop: insetSize, marginBottom: insetSize }\n : { marginLeft: insetSize, marginRight: insetSize };\n\n const borderColorStyle = { borderColor };\n const borderWidthStyle = (vertical ? { borderRightWidth: borderWidth } : { borderBottomWidth: borderWidth });\n\n const containerStyle = css([\n insetStyle,\n marginStyle,\n styles.container,\n vertical ? styles.column : styles.row,\n childrenProp ? undefined : borderColorStyle,\n childrenProp ? undefined : borderWidthStyle,\n style,\n ]);\n\n const dividerStyle = css([\n borderColorStyle,\n borderWidthStyle,\n styles.divider,\n ]);\n\n const dividerMarginSize = theme.spacing(marginBetweenChildren);\n const startDividerStyle: ExtendedStyle = {\n display: elementAlign !== 'start' ? 'flex' : 'none',\n ...(vertical ? { marginBottom: dividerMarginSize } : { marginRight: dividerMarginSize }),\n };\n const endDividerStyle: ExtendedStyle = {\n display: elementAlign !== 'end' ? 'flex' : 'none',\n ...(vertical ? { marginTop: dividerMarginSize } : { marginLeft: dividerMarginSize }),\n };\n\n const fontStyle = createFontStyle(theme, {\n selector: (typo) => typo.caption2,\n color: fontColor,\n });\n\n const element = typeof childrenProp === 'string'\n ? <Text style={css(fontStyle)}>{childrenProp}</Text>\n : childrenProp;\n\n const children = childrenProp ? (\n <React.Fragment>\n <View style={css([dividerStyle, startDividerStyle])}/>\n {element}\n <View style={css([dividerStyle, endDividerStyle])}/>\n </React.Fragment>\n ) : null;\n\n return (\n <View\n style={containerStyle}\n {...otherProps}\n >\n {children}\n </View>\n );\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;;;AAIA,MAAMA,MAAM,GAAGC,kBAAA,CAAWC,MAAX,CAAkB;EAC7BC,SAAS,EAAE;IACPC,SAAS,EAAE,SADJ;IAEPC,UAAU,EAAE;EAFL,CADkB;EAK7BC,GAAG,EAAE;IACDC,aAAa,EAAE;EADd,CALwB;EAQ7BC,MAAM,EAAE;IACJD,aAAa,EAAE;EADX,CARqB;EAW7BE,OAAO,EAAE;IACLC,QAAQ,EAAE;EADL;AAXoB,CAAlB,CAAf;;AAgBe,SAASC,OAAT,CAAiBC,KAAjB,EAAsC;EACjD,MAAM;IACFC,WAAW,GAAG,CADZ;IAEFC,QAAQ,EAAEC,YAFR;IAGFC,KAAK,GAAG,SAHN;IAIFC,YAAY,GAAG,QAJb;IAKFC,KAAK,GAAG,CALN;IAMFC,qBAAqB,GAAG,CANtB;IAOFC,KAPE;IAQFC,QAAQ,GAAG,KART;IASF,GAAGC;EATD,IAUFV,KAVJ;EAYA,MAAMW,KAAK,GAAG,IAAAC,gBAAA,GAAd;EAEA,MAAMC,SAAS,GAAGF,KAAK,CAACG,OAAN,CAAcC,IAAd,CAAmBC,SAArC;EACA,MAAMC,WAAW,GAAGb,KAAK,KAAK,SAAV,GACdO,KAAK,CAACG,OAAN,CAAcjB,OADA,GAEdO,KAAK,KAAK,QAAV,GACIO,KAAK,CAACG,OAAN,CAAcI,MAAd,CAAqBC,OADzB,GAEIR,KAAK,CAACG,OAAN,CAAcV,KAAd,EAAqBgB,IAJ/B;EAKA,MAAMC,UAAU,GAAGV,KAAK,CAACW,OAAN,CAAc,CAAd,CAAnB;EACA,MAAMC,SAAS,GAAG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AEkB,YAAY,EAAEW;IAAhB,CAAH,GAAyC;MAAEb,WAAW,EAAEa;IAAf,CAArD;EAFqC,CAAzC;EAIA,MAAMG,eAA8B,GAAG;IACnCD,OAAO,EAAEnC,YAAY,KAAK,KAAjB,GAAyB,MAAzB,GAAkC,MADR;IAEnC,IAAII,QAAQ,GAAG;MAAEiB,SAAS,EAAEY;IAAb,CAAH,GAAsC;MAAEd,UAAU,EAAEc;IAAd,CAAlD;EAFmC,CAAvC;EAKA,MAAMI,SAAS,GAAG,IAAAC,uBAAA,EAAgBhC,KAAhB,EAAuB;IACrCiC,QAAQ,EAAGC,IAAD,IAAUA,IAAI,CAACC,QADY;IAErC1C,KAAK,EAAES;EAF8B,CAAvB,CAAlB;EAKA,MAAMkC,OAAO,GAAG,OAAO5C,YAAP,KAAwB,QAAxB,gBACV,6BAAC,iBAAD;IAAM,KAAK,EAAE,IAAAgC,WAAA,EAAIO,SAAJ;EAAb,GAA8BvC,YAA9B,CADU,GAEVA,YAFN;EAIA,MAAMD,QAAQ,GAAGC,YAAY,gBACzB,6BAAC,cAAD,CAAO,QAAP,qBACI,6BAAC,iBAAD;IAAM,KAAK,EAAE,IAAAgC,WAAA,EAAI,CAACE,YAAD,EAAeE,iBAAf,CAAJ;EAAb,EADJ,EAEKQ,OAFL,eAGI,6BAAC,iBAAD;IAAM,KAAK,EAAE,IAAAZ,WAAA,EAAI,CAACE,YAAD,EAAeI,eAAf,CAAJ;EAAb,EAHJ,CADyB,GAMzB,IANJ;EAQA,oBACI,6BAAC,iBAAD;IACI,KAAK,EAAEP;EADX,GAEQxB,UAFR,GAIKR,QAJL,CADJ;AAQH;;AAAA"}
1
+ {"version":3,"names":["styles","StyleSheet","create","container","alignSelf","alignItems","row","flexDirection","column","divider","flexGrow","selectBorderColor","theme","variant","vertical","palette","border","weaker","weak","base","Divider","props","borderWidth","borderWidthProp","children","childrenProp","elementAlign","inset","marginBetweenChildren","style","otherProps","useTheme","fontColor","text","borderColor","marginSize","spacing","insetSize","marginLeft","marginRight","marginTop","marginBottom","marginStyle","insetStyle","borderColorStyle","borderWidthStyle","borderRightWidth","borderBottomWidth","containerStyle","css","undefined","dividerStyle","dividerMarginSize","startDividerStyle","display","endDividerStyle","fontStyle","createFontStyle","selector","typo","caption2","color","element"],"sources":["Divider.tsx"],"sourcesContent":["import React from 'react';\nimport { Text, View } from 'react-native';\nimport type { Theme } from '@fountain-ui/styles';\nimport { createFontStyle, css, StyleSheet, useTheme } from '../styles';\nimport { ExtendedStyle } from '../types';\nimport type DividerProps from './DividerProps';\nimport type { DividerVariant } from './DividerProps';\n\nconst styles = StyleSheet.create({\n container: {\n alignSelf: 'stretch',\n alignItems: 'center',\n },\n row: {\n flexDirection: 'row',\n },\n column: {\n flexDirection: 'column',\n },\n divider: {\n flexGrow: 1,\n },\n});\n\nfunction selectBorderColor(theme: Theme, variant: DividerVariant, vertical: boolean) {\n switch (variant) {\n default:\n case 'base':\n return vertical ? theme.palette.border.weaker : theme.palette.border.weak;\n case 'strong':\n return vertical ? theme.palette.border.weak : theme.palette.border.base;\n }\n}\n\nexport default function Divider(props: DividerProps) {\n const {\n borderWidth: borderWidthProp,\n children: childrenProp,\n elementAlign = 'center',\n inset = 0,\n marginBetweenChildren = 2,\n style,\n variant = 'base' as DividerVariant,\n vertical = false,\n ...otherProps\n } = props;\n\n const theme = useTheme();\n\n const borderWidth = borderWidthProp ?? (vertical ? 1 : 0.5);\n const fontColor = theme.palette.text.weak;\n const borderColor = selectBorderColor(theme, variant, vertical);\n const marginSize = theme.spacing(1);\n const insetSize = theme.spacing(inset);\n\n const marginLeft = marginSize;\n const marginRight = marginSize;\n const marginTop = marginSize;\n const marginBottom = marginSize;\n\n const marginStyle = vertical\n ? { marginLeft, marginRight }\n : { marginTop, marginBottom };\n\n const insetStyle = vertical\n ? { marginTop: insetSize, marginBottom: insetSize }\n : { marginLeft: insetSize, marginRight: insetSize };\n\n const borderColorStyle = { borderColor };\n const borderWidthStyle = (vertical ? { borderRightWidth: borderWidth } : { borderBottomWidth: borderWidth });\n\n const containerStyle = css([\n insetStyle,\n marginStyle,\n styles.container,\n vertical ? styles.column : styles.row,\n childrenProp ? undefined : borderColorStyle,\n childrenProp ? undefined : borderWidthStyle,\n style,\n ]);\n\n const dividerStyle = css([\n borderColorStyle,\n borderWidthStyle,\n styles.divider,\n ]);\n\n const dividerMarginSize = theme.spacing(marginBetweenChildren);\n const startDividerStyle: ExtendedStyle = {\n display: elementAlign !== 'start' ? 'flex' : 'none',\n ...(vertical ? { marginBottom: dividerMarginSize } : { marginRight: dividerMarginSize }),\n };\n const endDividerStyle: ExtendedStyle = {\n display: elementAlign !== 'end' ? 'flex' : 'none',\n ...(vertical ? { marginTop: dividerMarginSize } : { marginLeft: dividerMarginSize }),\n };\n\n const fontStyle = createFontStyle(theme, {\n selector: (typo) => typo.caption2,\n color: fontColor,\n });\n\n const element = typeof childrenProp === 'string'\n ? <Text style={css(fontStyle)}>{childrenProp}</Text>\n : childrenProp;\n\n const children = childrenProp ? (\n <React.Fragment>\n <View style={css([dividerStyle, startDividerStyle])}/>\n {element}\n <View style={css([dividerStyle, endDividerStyle])}/>\n </React.Fragment>\n ) : null;\n\n return (\n <View\n style={containerStyle}\n {...otherProps}\n >\n {children}\n </View>\n );\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;;;;;AAKA,MAAMA,MAAM,GAAGC,kBAAA,CAAWC,MAAX,CAAkB;EAC7BC,SAAS,EAAE;IACPC,SAAS,EAAE,SADJ;IAEPC,UAAU,EAAE;EAFL,CADkB;EAK7BC,GAAG,EAAE;IACDC,aAAa,EAAE;EADd,CALwB;EAQ7BC,MAAM,EAAE;IACJD,aAAa,EAAE;EADX,CARqB;EAW7BE,OAAO,EAAE;IACLC,QAAQ,EAAE;EADL;AAXoB,CAAlB,CAAf;;AAgBA,SAASC,iBAAT,CAA2BC,KAA3B,EAAyCC,OAAzC,EAAkEC,QAAlE,EAAqF;EACjF,QAAQD,OAAR;IACI;IACA,KA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D;EAFmC,CAAvC;EAKA,MAAMI,SAAS,GAAG,IAAAC,uBAAA,EAAgB7C,KAAhB,EAAuB;IACrC8C,QAAQ,EAAGC,IAAD,IAAUA,IAAI,CAACC,QADY;IAErCC,KAAK,EAAE7B;EAF8B,CAAvB,CAAlB;EAKA,MAAM8B,OAAO,GAAG,OAAOrC,YAAP,KAAwB,QAAxB,gBACV,6BAAC,iBAAD;IAAM,KAAK,EAAE,IAAAwB,WAAA,EAAIO,SAAJ;EAAb,GAA8B/B,YAA9B,CADU,GAEVA,YAFN;EAIA,MAAMD,QAAQ,GAAGC,YAAY,gBACzB,6BAAC,cAAD,CAAO,QAAP,qBACI,6BAAC,iBAAD;IAAM,KAAK,EAAE,IAAAwB,WAAA,EAAI,CAACE,YAAD,EAAeE,iBAAf,CAAJ;EAAb,EADJ,EAEKS,OAFL,eAGI,6BAAC,iBAAD;IAAM,KAAK,EAAE,IAAAb,WAAA,EAAI,CAACE,YAAD,EAAeI,eAAf,CAAJ;EAAb,EAHJ,CADyB,GAMzB,IANJ;EAQA,oBACI,6BAAC,iBAAD;IACI,KAAK,EAAEP;EADX,GAEQlB,UAFR,GAIKN,QAJL,CADJ;AAQH;;AAAA"}
@@ -1,2 +1,11 @@
1
1
  "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.elementAligns = exports.dividerVariants = void 0;
7
+ const elementAligns = ['start', 'center', 'end'];
8
+ exports.elementAligns = elementAligns;
9
+ const dividerVariants = ['base', 'strong'];
10
+ exports.dividerVariants = dividerVariants;
2
11
  //# sourceMappingURL=DividerProps.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["DividerProps.ts"],"sourcesContent":["import React from 'react';\nimport type { ViewProps } from 'react-native';\nimport type { CommonComponentColor, OverridableComponentProps } from '../types';\n\nexport type DividerColor = 'divider' | 'border' | CommonComponentColor;\n\nexport default interface DividerProps extends OverridableComponentProps<ViewProps, {\n /**\n * The content of the component.\n */\n children?: React.ReactNode;\n\n /**\n * The size of the inset. It works as a multiplier factor based on spacing system.\n * @default 0\n */\n inset?: number;\n\n /**\n * If `true`, the divider orientation is set to vertical.\n * @default false\n */\n vertical?: boolean;\n\n /**\n * The color of divider. It supports default divider color and those theme colors that make sense for this component.\n * @default 'divider'\n */\n color?: DividerColor;\n\n /**\n * The size of margin between child element and the divider. It works as a multiplier factor based on spacing system.\n * @default 2\n */\n marginBetweenChildren?: number;\n\n /**\n * The size of border width. It works as an actual pixel-based border width value of a divider.\n * @default 1\n */\n borderWidth?: number;\n\n /**\n * Set position of children.\n * @default center\n */\n elementAlign?: 'start' | 'center' | 'end';\n}> {}\n"],"mappings":""}
1
+ {"version":3,"names":["elementAligns","dividerVariants"],"sources":["DividerProps.ts"],"sourcesContent":["import React from 'react';\nimport type { ViewProps } from 'react-native';\nimport type { OverridableComponentProps } from '../types';\n\nexport const elementAligns = ['start', 'center', 'end'] as const;\nexport type ElementAlign = typeof elementAligns[number];\n\nexport const dividerVariants = ['base', 'strong'] as const;\nexport type DividerVariant = typeof dividerVariants[number];\n\nexport default interface DividerProps extends OverridableComponentProps<ViewProps, {\n /**\n * The content of the component.\n */\n children?: React.ReactNode;\n\n /**\n * The size of the inset. It works as a multiplier factor based on spacing system.\n * @default 0\n */\n inset?: number;\n\n /**\n * If `true`, the divider orientation is set to vertical.\n * @default false\n */\n vertical?: boolean;\n\n /**\n * The size of margin between child element and the divider. It works as a multiplier factor based on spacing system.\n * @default 2\n */\n marginBetweenChildren?: number;\n\n /**\n * The size of border width. It works as an actual pixel-based border width value of a divider.\n * @default if vertical is true 1, otherwise 0.5\n */\n borderWidth?: number;\n\n /**\n * Set position of children.\n * @default center\n */\n elementAlign?: ElementAlign;\n\n /**\n * Select the style of the divider based on this value.\n * @default base\n */\n variant?: DividerVariant;\n}> {}\n"],"mappings":";;;;;;AAIO,MAAMA,aAAa,GAAG,CAAC,OAAD,EAAU,QAAV,EAAoB,KAApB,CAAtB;;AAGA,MAAMC,eAAe,GAAG,CAAC,MAAD,EAAS,QAAT,CAAxB"}
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = Divider;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _reactNative = require("react-native");
11
+
12
+ var _styles = require("../styles");
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+
16
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
17
+
18
+ const styles = _styles.StyleSheet.create({
19
+ container: {
20
+ alignSelf: 'stretch',
21
+ alignItems: 'center'
22
+ },
23
+ row: {
24
+ flexDirection: 'row'
25
+ },
26
+ column: {
27
+ flexDirection: 'column'
28
+ },
29
+ divider: {
30
+ flexGrow: 1
31
+ }
32
+ });
33
+
34
+ function Divider(props) {
35
+ const {
36
+ borderWidth = 1,
37
+ children: childrenProp,
38
+ color = 'divider',
39
+ elementAlign = 'center',
40
+ inset = 0,
41
+ marginBetweenChildren = 2,
42
+ style,
43
+ vertical = false,
44
+ ...otherProps
45
+ } = props;
46
+ const theme = (0, _styles.useTheme)();
47
+ const fontColor = theme.palette.text.secondary;
48
+ const borderColor = color === 'divider' ? theme.palette.divider : color === 'border' ? theme.palette.border.default : theme.palette[color].main;
49
+ const marginSize = theme.spacing(1);
50
+ const insetSize = theme.spacing(inset);
51
+ const marginLeft = marginSize;
52
+ const marginRight = marginSize;
53
+ const marginTop = marginSize;
54
+ const marginBottom = marginSize;
55
+ const marginStyle = vertical ? {
56
+ marginLeft,
57
+ marginRight
58
+ } : {
59
+ marginTop,
60
+ marginBottom
61
+ };
62
+ const insetStyle = vertical ? {
63
+ marginTop: insetSize,
64
+ marginBottom: insetSize
65
+ } : {
66
+ marginLeft: insetSize,
67
+ marginRight: insetSize
68
+ };
69
+ const borderColorStyle = {
70
+ borderColor
71
+ };
72
+ const borderWidthStyle = vertical ? {
73
+ borderRightWidth: borderWidth
74
+ } : {
75
+ borderBottomWidth: borderWidth
76
+ };
77
+ const containerStyle = (0, _styles.css)([insetStyle, marginStyle, styles.container, vertical ? styles.column : styles.row, childrenProp ? undefined : borderColorStyle, childrenProp ? undefined : borderWidthStyle, style]);
78
+ const dividerStyle = (0, _styles.css)([borderColorStyle, borderWidthStyle, styles.divider]);
79
+ const dividerMarginSize = theme.spacing(marginBetweenChildren);
80
+ const startDividerStyle = {
81
+ display: elementAlign !== 'start' ? 'flex' : 'none',
82
+ ...(vertical ? {
83
+ marginBottom: dividerMarginSize
84
+ } : {
85
+ marginRight: dividerMarginSize
86
+ })
87
+ };
88
+ const endDividerStyle = {
89
+ display: elementAlign !== 'end' ? 'flex' : 'none',
90
+ ...(vertical ? {
91
+ marginTop: dividerMarginSize
92
+ } : {
93
+ marginLeft: dividerMarginSize
94
+ })
95
+ };
96
+ const fontStyle = (0, _styles.createFontStyle)(theme, {
97
+ selector: typo => typo.caption2,
98
+ color: fontColor
99
+ });
100
+ const element = typeof childrenProp === 'string' ? /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
101
+ style: (0, _styles.css)(fontStyle)
102
+ }, childrenProp) : childrenProp;
103
+ const children = childrenProp ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
104
+ style: (0, _styles.css)([dividerStyle, startDividerStyle])
105
+ }), element, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
106
+ style: (0, _styles.css)([dividerStyle, endDividerStyle])
107
+ })) : null;
108
+ return /*#__PURE__*/_react.default.createElement(_reactNative.View, _extends({
109
+ style: containerStyle
110
+ }, otherProps), children);
111
+ }
112
+
113
+ ;
114
+ //# sourceMappingURL=LegacyDivider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["styles","StyleSheet","create","container","alignSelf","alignItems","row","flexDirection","column","divider","flexGrow","Divider","props","borderWidth","children","childrenProp","color","elementAlign","inset","marginBetweenChildren","style","vertical","otherProps","theme","useTheme","fontColor","palette","text","secondary","borderColor","border","default","main","marginSize","spacing","insetSize","marginLeft","marginRight","marginTop","marginBottom","marginStyle","insetStyle","borderColorStyle","borderWidthStyle","borderRightWidth","borderBottomWidth","containerStyle","css","undefined","dividerStyle","dividerMarginSize","startDividerStyle","display","endDividerStyle","fontStyle","createFontStyle","selector","typo","caption2","element"],"sources":["LegacyDivider.tsx"],"sourcesContent":["import React from 'react';\nimport { Text, View } from 'react-native';\nimport { createFontStyle, css, StyleSheet, useTheme } from '../styles';\nimport { ExtendedStyle } from '../types';\nimport type DividerProps from './LegacyDividerProps';\n\nconst styles = StyleSheet.create({\n container: {\n alignSelf: 'stretch',\n alignItems: 'center',\n },\n row: {\n flexDirection: 'row',\n },\n column: {\n flexDirection: 'column',\n },\n divider: {\n flexGrow: 1,\n },\n});\n\nexport default function Divider(props: DividerProps) {\n const {\n borderWidth = 1,\n children: childrenProp,\n color = 'divider',\n elementAlign = 'center',\n inset = 0,\n marginBetweenChildren = 2,\n style,\n vertical = false,\n ...otherProps\n } = props;\n\n const theme = useTheme();\n\n const fontColor = theme.palette.text.secondary;\n const borderColor = color === 'divider'\n ? theme.palette.divider\n : color === 'border'\n ? theme.palette.border.default\n : theme.palette[color].main;\n const marginSize = theme.spacing(1);\n const insetSize = theme.spacing(inset);\n\n const marginLeft = marginSize;\n const marginRight = marginSize;\n const marginTop = marginSize;\n const marginBottom = marginSize;\n\n const marginStyle = vertical\n ? { marginLeft, marginRight }\n : { marginTop, marginBottom };\n\n const insetStyle = vertical\n ? { marginTop: insetSize, marginBottom: insetSize }\n : { marginLeft: insetSize, marginRight: insetSize };\n\n const borderColorStyle = { borderColor };\n const borderWidthStyle = (vertical ? { borderRightWidth: borderWidth } : { borderBottomWidth: borderWidth });\n\n const containerStyle = css([\n insetStyle,\n marginStyle,\n styles.container,\n vertical ? styles.column : styles.row,\n childrenProp ? undefined : borderColorStyle,\n childrenProp ? undefined : borderWidthStyle,\n style,\n ]);\n\n const dividerStyle = css([\n borderColorStyle,\n borderWidthStyle,\n styles.divider,\n ]);\n\n const dividerMarginSize = theme.spacing(marginBetweenChildren);\n const startDividerStyle: ExtendedStyle = {\n display: elementAlign !== 'start' ? 'flex' : 'none',\n ...(vertical ? { marginBottom: dividerMarginSize } : { marginRight: dividerMarginSize }),\n };\n const endDividerStyle: ExtendedStyle = {\n display: elementAlign !== 'end' ? 'flex' : 'none',\n ...(vertical ? { marginTop: dividerMarginSize } : { marginLeft: dividerMarginSize }),\n };\n\n const fontStyle = createFontStyle(theme, {\n selector: (typo) => typo.caption2,\n color: fontColor,\n });\n\n const element = typeof childrenProp === 'string'\n ? <Text style={css(fontStyle)}>{childrenProp}</Text>\n : childrenProp;\n\n const children = childrenProp ? (\n <React.Fragment>\n <View style={css([dividerStyle, startDividerStyle])}/>\n {element}\n <View style={css([dividerStyle, endDividerStyle])}/>\n </React.Fragment>\n ) : null;\n\n return (\n <View\n style={containerStyle}\n {...otherProps}\n >\n {children}\n </View>\n );\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;;;AAIA,MAAMA,MAAM,GAAGC,kBAAA,CAAWC,MAAX,CAAkB;EAC7BC,SAAS,EAAE;IACPC,SAAS,EAAE,SADJ;IAEPC,UAAU,EAAE;EAFL,CADkB;EAK7BC,GAAG,EAAE;IACDC,aAAa,EAAE;EADd,CALwB;EAQ7BC,MAAM,EAAE;IACJD,aAAa,EAAE;EADX,CARqB;EAW7BE,OAAO,EAAE;IACLC,QAAQ,EAAE;EADL;AAXoB,CAAlB,CAAf;;AAgBe,SAASC,OAAT,CAAiBC,KAAjB,EAAsC;EACjD,MAAM;IACFC,WAAW,GAAG,CADZ;IAEFC,QAAQ,EAAEC,YAFR;IAGFC,KAAK,GAAG,SAHN;IAIFC,YAAY,GAAG,QAJb;IAKFC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BAAD;IAAM,KAAK,EAAE,IAAAgC,WAAA,EAAI,CAACE,YAAD,EAAeE,iBAAf,CAAJ;EAAb,EADJ,EAEKQ,OAFL,eAGI,6BAAC,iBAAD;IAAM,KAAK,EAAE,IAAAZ,WAAA,EAAI,CAACE,YAAD,EAAeI,eAAf,CAAJ;EAAb,EAHJ,CADyB,GAMzB,IANJ;EAQA,oBACI,6BAAC,iBAAD;IACI,KAAK,EAAEP;EADX,GAEQxB,UAFR,GAIKR,QAJL,CADJ;AAQH;;AAAA"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=LegacyDividerProps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["LegacyDividerProps.ts"],"sourcesContent":["import React from 'react';\nimport type { ViewProps } from 'react-native';\nimport type { CommonComponentColor, OverridableComponentProps } from '../types';\n\nexport type DividerColor = 'divider' | 'border' | CommonComponentColor;\n\nexport default interface DividerProps extends OverridableComponentProps<ViewProps, {\n /**\n * The content of the component.\n */\n children?: React.ReactNode;\n\n /**\n * The size of the inset. It works as a multiplier factor based on spacing system.\n * @default 0\n */\n inset?: number;\n\n /**\n * If `true`, the divider orientation is set to vertical.\n * @default false\n */\n vertical?: boolean;\n\n /**\n * The color of divider. It supports default divider color and those theme colors that make sense for this component.\n * @default 'divider'\n */\n color?: DividerColor;\n\n /**\n * The size of margin between child element and the divider. It works as a multiplier factor based on spacing system.\n * @default 2\n */\n marginBetweenChildren?: number;\n\n /**\n * The size of border width. It works as an actual pixel-based border width value of a divider.\n * @default 1\n */\n borderWidth?: number;\n\n /**\n * Set position of children.\n * @default center\n */\n elementAlign?: 'start' | 'center' | 'end';\n}> {}\n"],"mappings":""}
@@ -6,11 +6,11 @@ Object.defineProperty(exports, "__esModule", {
6
6
  Object.defineProperty(exports, "default", {
7
7
  enumerable: true,
8
8
  get: function () {
9
- return _Divider.default;
9
+ return _LegacyDivider.default;
10
10
  }
11
11
  });
12
12
 
13
- var _Divider = _interopRequireDefault(require("./Divider"));
13
+ var _LegacyDivider = _interopRequireDefault(require("./LegacyDivider"));
14
14
 
15
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
16
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { default } from './Divider';\nexport type { default as DividerProps } from './DividerProps';"],"mappings":";;;;;;;;;;;;AAAA"}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { default } from './LegacyDivider';\nexport type { default as DividerProps } from './LegacyDividerProps';\n"],"mappings":";;;;;;;;;;;;AAAA"}
@@ -18,21 +18,34 @@ const styles = StyleSheet.create({
18
18
  flexGrow: 1
19
19
  }
20
20
  });
21
+
22
+ function selectBorderColor(theme, variant, vertical) {
23
+ switch (variant) {
24
+ default:
25
+ case 'base':
26
+ return vertical ? theme.palette.border.weaker : theme.palette.border.weak;
27
+
28
+ case 'strong':
29
+ return vertical ? theme.palette.border.weak : theme.palette.border.base;
30
+ }
31
+ }
32
+
21
33
  export default function Divider(props) {
22
34
  const {
23
- borderWidth = 1,
35
+ borderWidth: borderWidthProp,
24
36
  children: childrenProp,
25
- color = 'divider',
26
37
  elementAlign = 'center',
27
38
  inset = 0,
28
39
  marginBetweenChildren = 2,
29
40
  style,
41
+ variant = 'base',
30
42
  vertical = false,
31
43
  ...otherProps
32
44
  } = props;
33
45
  const theme = useTheme();
34
- const fontColor = theme.palette.text.secondary;
35
- const borderColor = color === 'divider' ? theme.palette.divider : color === 'border' ? theme.palette.border.default : theme.palette[color].main;
46
+ const borderWidth = borderWidthProp ?? (vertical ? 1 : 0.5);
47
+ const fontColor = theme.palette.text.weak;
48
+ const borderColor = selectBorderColor(theme, variant, vertical);
36
49
  const marginSize = theme.spacing(1);
37
50
  const insetSize = theme.spacing(inset);
38
51
  const marginLeft = marginSize;
@@ -1 +1 @@
1
- {"version":3,"names":["React","Text","View","createFontStyle","css","StyleSheet","useTheme","styles","create","container","alignSelf","alignItems","row","flexDirection","column","divider","flexGrow","Divider","props","borderWidth","children","childrenProp","color","elementAlign","inset","marginBetweenChildren","style","vertical","otherProps","theme","fontColor","palette","text","secondary","borderColor","border","default","main","marginSize","spacing","insetSize","marginLeft","marginRight","marginTop","marginBottom","marginStyle","insetStyle","borderColorStyle","borderWidthStyle","borderRightWidth","borderBottomWidth","containerStyle","undefined","dividerStyle","dividerMarginSize","startDividerStyle","display","endDividerStyle","fontStyle","selector","typo","caption2","element"],"sources":["Divider.tsx"],"sourcesContent":["import React from 'react';\nimport { Text, View } from 'react-native';\nimport { createFontStyle, css, StyleSheet, useTheme } from '../styles';\nimport { ExtendedStyle } from '../types';\nimport type DividerProps from './DividerProps';\n\nconst styles = StyleSheet.create({\n container: {\n alignSelf: 'stretch',\n alignItems: 'center',\n },\n row: {\n flexDirection: 'row',\n },\n column: {\n flexDirection: 'column',\n },\n divider: {\n flexGrow: 1,\n },\n});\n\nexport default function Divider(props: DividerProps) {\n const {\n borderWidth = 1,\n children: childrenProp,\n color = 'divider',\n elementAlign = 'center',\n inset = 0,\n marginBetweenChildren = 2,\n style,\n vertical = false,\n ...otherProps\n } = props;\n\n const theme = useTheme();\n\n const fontColor = theme.palette.text.secondary;\n const borderColor = color === 'divider'\n ? theme.palette.divider\n : color === 'border'\n ? theme.palette.border.default\n : theme.palette[color].main;\n const marginSize = theme.spacing(1);\n const insetSize = theme.spacing(inset);\n\n const marginLeft = marginSize;\n const marginRight = marginSize;\n const marginTop = marginSize;\n const marginBottom = marginSize;\n\n const marginStyle = vertical\n ? { marginLeft, marginRight }\n : { marginTop, marginBottom };\n\n const insetStyle = vertical\n ? { marginTop: insetSize, marginBottom: insetSize }\n : { marginLeft: insetSize, marginRight: insetSize };\n\n const borderColorStyle = { borderColor };\n const borderWidthStyle = (vertical ? { borderRightWidth: borderWidth } : { borderBottomWidth: borderWidth });\n\n const containerStyle = css([\n insetStyle,\n marginStyle,\n styles.container,\n vertical ? styles.column : styles.row,\n childrenProp ? undefined : borderColorStyle,\n childrenProp ? undefined : borderWidthStyle,\n style,\n ]);\n\n const dividerStyle = css([\n borderColorStyle,\n borderWidthStyle,\n styles.divider,\n ]);\n\n const dividerMarginSize = theme.spacing(marginBetweenChildren);\n const startDividerStyle: ExtendedStyle = {\n display: elementAlign !== 'start' ? 'flex' : 'none',\n ...(vertical ? { marginBottom: dividerMarginSize } : { marginRight: dividerMarginSize }),\n };\n const endDividerStyle: ExtendedStyle = {\n display: elementAlign !== 'end' ? 'flex' : 'none',\n ...(vertical ? { marginTop: dividerMarginSize } : { marginLeft: dividerMarginSize }),\n };\n\n const fontStyle = createFontStyle(theme, {\n selector: (typo) => typo.caption2,\n color: fontColor,\n });\n\n const element = typeof childrenProp === 'string'\n ? <Text style={css(fontStyle)}>{childrenProp}</Text>\n : childrenProp;\n\n const children = childrenProp ? (\n <React.Fragment>\n <View style={css([dividerStyle, startDividerStyle])}/>\n {element}\n <View style={css([dividerStyle, endDividerStyle])}/>\n </React.Fragment>\n ) : null;\n\n return (\n <View\n style={containerStyle}\n {...otherProps}\n >\n {children}\n </View>\n );\n};\n"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,IAAT,EAAeC,IAAf,QAA2B,cAA3B;AACA,SAASC,eAAT,EAA0BC,GAA1B,EAA+BC,UAA/B,EAA2CC,QAA3C,QAA2D,WAA3D;AAIA,MAAMC,MAAM,GAAGF,UAAU,CAACG,MAAX,CAAkB;EAC7BC,SAAS,EAAE;IACPC,SAAS,EAAE,SADJ;IAEPC,UAAU,EAAE;EAFL,CADkB;EAK7BC,GAAG,EAAE;IACDC,aAAa,EAAE;EADd,CALwB;EAQ7BC,MAAM,EAAE;IACJD,aAAa,EAAE;EADX,CARqB;EAW7BE,OAAO,EAAE;IACLC,QAAQ,EAAE;EADL;AAXoB,CAAlB,CAAf;AAgBA,eAAe,SAASC,OAAT,CAAiBC,KAAjB,EAAsC;EACjD,MAAM;IACFC,WAAW,GAAG,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AAQ,GAAGC,YAAY,gBACzB,oBAAC,KAAD,CAAO,QAAP,qBACI,oBAAC,IAAD;IAAM,KAAK,EAAEjB,GAAG,CAAC,CAACiD,YAAD,EAAeE,iBAAf,CAAD;EAAhB,EADJ,EAEKO,OAFL,eAGI,oBAAC,IAAD;IAAM,KAAK,EAAE1D,GAAG,CAAC,CAACiD,YAAD,EAAeI,eAAf,CAAD;EAAhB,EAHJ,CADyB,GAMzB,IANJ;EAQA,oBACI,oBAAC,IAAD;IACI,KAAK,EAAEN;EADX,GAEQvB,UAFR,GAIKR,QAJL,CADJ;AAQH;AAAA"}
1
+ {"version":3,"names":["React","Text","View","createFontStyle","css","StyleSheet","useTheme","styles","create","container","alignSelf","alignItems","row","flexDirection","column","divider","flexGrow","selectBorderColor","theme","variant","vertical","palette","border","weaker","weak","base","Divider","props","borderWidth","borderWidthProp","children","childrenProp","elementAlign","inset","marginBetweenChildren","style","otherProps","fontColor","text","borderColor","marginSize","spacing","insetSize","marginLeft","marginRight","marginTop","marginBottom","marginStyle","insetStyle","borderColorStyle","borderWidthStyle","borderRightWidth","borderBottomWidth","containerStyle","undefined","dividerStyle","dividerMarginSize","startDividerStyle","display","endDividerStyle","fontStyle","selector","typo","caption2","color","element"],"sources":["Divider.tsx"],"sourcesContent":["import React from 'react';\nimport { Text, View } from 'react-native';\nimport type { Theme } from '@fountain-ui/styles';\nimport { createFontStyle, css, StyleSheet, useTheme } from '../styles';\nimport { ExtendedStyle } from '../types';\nimport type DividerProps from './DividerProps';\nimport type { DividerVariant } from './DividerProps';\n\nconst styles = StyleSheet.create({\n container: {\n alignSelf: 'stretch',\n alignItems: 'center',\n },\n row: {\n flexDirection: 'row',\n },\n column: {\n flexDirection: 'column',\n },\n divider: {\n flexGrow: 1,\n },\n});\n\nfunction selectBorderColor(theme: Theme, variant: DividerVariant, vertical: boolean) {\n switch (variant) {\n default:\n case 'base':\n return vertical ? theme.palette.border.weaker : theme.palette.border.weak;\n case 'strong':\n return vertical ? theme.palette.border.weak : theme.palette.border.base;\n }\n}\n\nexport default function Divider(props: DividerProps) {\n const {\n borderWidth: borderWidthProp,\n children: childrenProp,\n elementAlign = 'center',\n inset = 0,\n marginBetweenChildren = 2,\n style,\n variant = 'base' as DividerVariant,\n vertical = false,\n ...otherProps\n } = props;\n\n const theme = useTheme();\n\n const borderWidth = borderWidthProp ?? (vertical ? 1 : 0.5);\n const fontColor = theme.palette.text.weak;\n const borderColor = selectBorderColor(theme, variant, vertical);\n const marginSize = theme.spacing(1);\n const insetSize = theme.spacing(inset);\n\n const marginLeft = marginSize;\n const marginRight = marginSize;\n const marginTop = marginSize;\n const marginBottom = marginSize;\n\n const marginStyle = vertical\n ? { marginLeft, marginRight }\n : { marginTop, marginBottom };\n\n const insetStyle = vertical\n ? { marginTop: insetSize, marginBottom: insetSize }\n : { marginLeft: insetSize, marginRight: insetSize };\n\n const borderColorStyle = { borderColor };\n const borderWidthStyle = (vertical ? { borderRightWidth: borderWidth } : { borderBottomWidth: borderWidth });\n\n const containerStyle = css([\n insetStyle,\n marginStyle,\n styles.container,\n vertical ? styles.column : styles.row,\n childrenProp ? undefined : borderColorStyle,\n childrenProp ? undefined : borderWidthStyle,\n style,\n ]);\n\n const dividerStyle = css([\n borderColorStyle,\n borderWidthStyle,\n styles.divider,\n ]);\n\n const dividerMarginSize = theme.spacing(marginBetweenChildren);\n const startDividerStyle: ExtendedStyle = {\n display: elementAlign !== 'start' ? 'flex' : 'none',\n ...(vertical ? { marginBottom: dividerMarginSize } : { marginRight: dividerMarginSize }),\n };\n const endDividerStyle: ExtendedStyle = {\n display: elementAlign !== 'end' ? 'flex' : 'none',\n ...(vertical ? { marginTop: dividerMarginSize } : { marginLeft: dividerMarginSize }),\n };\n\n const fontStyle = createFontStyle(theme, {\n selector: (typo) => typo.caption2,\n color: fontColor,\n });\n\n const element = typeof childrenProp === 'string'\n ? <Text style={css(fontStyle)}>{childrenProp}</Text>\n : childrenProp;\n\n const children = childrenProp ? (\n <React.Fragment>\n <View style={css([dividerStyle, startDividerStyle])}/>\n {element}\n <View style={css([dividerStyle, endDividerStyle])}/>\n </React.Fragment>\n ) : null;\n\n return (\n <View\n style={containerStyle}\n {...otherProps}\n >\n {children}\n </View>\n );\n};\n"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,IAAT,EAAeC,IAAf,QAA2B,cAA3B;AAEA,SAASC,eAAT,EAA0BC,GAA1B,EAA+BC,UAA/B,EAA2CC,QAA3C,QAA2D,WAA3D;AAKA,MAAMC,MAAM,GAAGF,UAAU,CAACG,MAAX,CAAkB;EAC7BC,SAAS,EAAE;IACPC,SAAS,EAAE,SADJ;IAEPC,UAAU,EAAE;EAFL,CADkB;EAK7BC,GAAG,EAAE;IACDC,aAAa,EAAE;EADd,CALwB;EAQ7BC,MAAM,EAAE;IACJD,aAAa,EAAE;EADX,CARqB;EAW7BE,OAAO,EAAE;IACLC,QAAQ,EAAE;EADL;AAXoB,CAAlB,CAAf;;AAgBA,SAASC,iBAAT,CAA2BC,KAA3B,EAAyCC,OAAzC,EAAkEC,QAAlE,EAAqF;EACjF,QAAQD,OAAR;IACI;IACA,KAAK,MAAL;MACI,OAAOC,QAAQ,GAAGF,KAAK,CAACG,OAAN,CAAcC,MAAd,CAAqBC,MAAxB,GAAiCL,KAAK,CAACG,OAAN,CAAcC,MAAd,CAAqBE,IAArE;;IACJ,KAAK,QAAL;MACI,OAAOJ,QAAQ,GAAGF,KAAK,CAACG,OAAN,CAAcC,MAAd,CAAqBE,IAAxB,GAA+BN,KAAK,CAACG,OAAN,CAAcC,MAAd,CAAqBG,IAAnE;EALR;AAOH;;AAED,eAAe,SAASC,OAAT,CAAiBC,KAAjB,EAAsC;EACjD,MAAM;IACFC,WAAW,EAAEC,eADX;IAEFC,QAAQ,EAAEC,YAFR;IAGFC,YAAY,GAAG,QAHb;IAIFC,KAAK,GAAG,CAJN;IAKFC,qBAAqB,GAAG,CALtB;IAMFC,KANE;IAOFhB,OAAO,GAA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M,KAAK,EAAE7D,GAAG,CAAC,CAACmD,YAAD,EAAeI,eAAf,CAAD;EAAhB,EAHJ,CADyB,GAMzB,IANJ;EAQA,oBACI,oBAAC,IAAD;IACI,KAAK,EAAEN;EADX,GAEQjB,UAFR,GAIKN,QAJL,CADJ;AAQH;AAAA"}
@@ -1,2 +1,3 @@
1
-
1
+ export const elementAligns = ['start', 'center', 'end'];
2
+ export const dividerVariants = ['base', 'strong'];
2
3
  //# sourceMappingURL=DividerProps.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["DividerProps.ts"],"sourcesContent":["import React from 'react';\nimport type { ViewProps } from 'react-native';\nimport type { CommonComponentColor, OverridableComponentProps } from '../types';\n\nexport type DividerColor = 'divider' | 'border' | CommonComponentColor;\n\nexport default interface DividerProps extends OverridableComponentProps<ViewProps, {\n /**\n * The content of the component.\n */\n children?: React.ReactNode;\n\n /**\n * The size of the inset. It works as a multiplier factor based on spacing system.\n * @default 0\n */\n inset?: number;\n\n /**\n * If `true`, the divider orientation is set to vertical.\n * @default false\n */\n vertical?: boolean;\n\n /**\n * The color of divider. It supports default divider color and those theme colors that make sense for this component.\n * @default 'divider'\n */\n color?: DividerColor;\n\n /**\n * The size of margin between child element and the divider. It works as a multiplier factor based on spacing system.\n * @default 2\n */\n marginBetweenChildren?: number;\n\n /**\n * The size of border width. It works as an actual pixel-based border width value of a divider.\n * @default 1\n */\n borderWidth?: number;\n\n /**\n * Set position of children.\n * @default center\n */\n elementAlign?: 'start' | 'center' | 'end';\n}> {}\n"],"mappings":""}
1
+ {"version":3,"names":["elementAligns","dividerVariants"],"sources":["DividerProps.ts"],"sourcesContent":["import React from 'react';\nimport type { ViewProps } from 'react-native';\nimport type { OverridableComponentProps } from '../types';\n\nexport const elementAligns = ['start', 'center', 'end'] as const;\nexport type ElementAlign = typeof elementAligns[number];\n\nexport const dividerVariants = ['base', 'strong'] as const;\nexport type DividerVariant = typeof dividerVariants[number];\n\nexport default interface DividerProps extends OverridableComponentProps<ViewProps, {\n /**\n * The content of the component.\n */\n children?: React.ReactNode;\n\n /**\n * The size of the inset. It works as a multiplier factor based on spacing system.\n * @default 0\n */\n inset?: number;\n\n /**\n * If `true`, the divider orientation is set to vertical.\n * @default false\n */\n vertical?: boolean;\n\n /**\n * The size of margin between child element and the divider. It works as a multiplier factor based on spacing system.\n * @default 2\n */\n marginBetweenChildren?: number;\n\n /**\n * The size of border width. It works as an actual pixel-based border width value of a divider.\n * @default if vertical is true 1, otherwise 0.5\n */\n borderWidth?: number;\n\n /**\n * Set position of children.\n * @default center\n */\n elementAlign?: ElementAlign;\n\n /**\n * Select the style of the divider based on this value.\n * @default base\n */\n variant?: DividerVariant;\n}> {}\n"],"mappings":"AAIA,OAAO,MAAMA,aAAa,GAAG,CAAC,OAAD,EAAU,QAAV,EAAoB,KAApB,CAAtB;AAGP,OAAO,MAAMC,eAAe,GAAG,CAAC,MAAD,EAAS,QAAT,CAAxB"}
@@ -0,0 +1,100 @@
1
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+
3
+ import React from 'react';
4
+ import { Text, View } from 'react-native';
5
+ import { createFontStyle, css, StyleSheet, useTheme } from '../styles';
6
+ const styles = StyleSheet.create({
7
+ container: {
8
+ alignSelf: 'stretch',
9
+ alignItems: 'center'
10
+ },
11
+ row: {
12
+ flexDirection: 'row'
13
+ },
14
+ column: {
15
+ flexDirection: 'column'
16
+ },
17
+ divider: {
18
+ flexGrow: 1
19
+ }
20
+ });
21
+ export default function Divider(props) {
22
+ const {
23
+ borderWidth = 1,
24
+ children: childrenProp,
25
+ color = 'divider',
26
+ elementAlign = 'center',
27
+ inset = 0,
28
+ marginBetweenChildren = 2,
29
+ style,
30
+ vertical = false,
31
+ ...otherProps
32
+ } = props;
33
+ const theme = useTheme();
34
+ const fontColor = theme.palette.text.secondary;
35
+ const borderColor = color === 'divider' ? theme.palette.divider : color === 'border' ? theme.palette.border.default : theme.palette[color].main;
36
+ const marginSize = theme.spacing(1);
37
+ const insetSize = theme.spacing(inset);
38
+ const marginLeft = marginSize;
39
+ const marginRight = marginSize;
40
+ const marginTop = marginSize;
41
+ const marginBottom = marginSize;
42
+ const marginStyle = vertical ? {
43
+ marginLeft,
44
+ marginRight
45
+ } : {
46
+ marginTop,
47
+ marginBottom
48
+ };
49
+ const insetStyle = vertical ? {
50
+ marginTop: insetSize,
51
+ marginBottom: insetSize
52
+ } : {
53
+ marginLeft: insetSize,
54
+ marginRight: insetSize
55
+ };
56
+ const borderColorStyle = {
57
+ borderColor
58
+ };
59
+ const borderWidthStyle = vertical ? {
60
+ borderRightWidth: borderWidth
61
+ } : {
62
+ borderBottomWidth: borderWidth
63
+ };
64
+ const containerStyle = css([insetStyle, marginStyle, styles.container, vertical ? styles.column : styles.row, childrenProp ? undefined : borderColorStyle, childrenProp ? undefined : borderWidthStyle, style]);
65
+ const dividerStyle = css([borderColorStyle, borderWidthStyle, styles.divider]);
66
+ const dividerMarginSize = theme.spacing(marginBetweenChildren);
67
+ const startDividerStyle = {
68
+ display: elementAlign !== 'start' ? 'flex' : 'none',
69
+ ...(vertical ? {
70
+ marginBottom: dividerMarginSize
71
+ } : {
72
+ marginRight: dividerMarginSize
73
+ })
74
+ };
75
+ const endDividerStyle = {
76
+ display: elementAlign !== 'end' ? 'flex' : 'none',
77
+ ...(vertical ? {
78
+ marginTop: dividerMarginSize
79
+ } : {
80
+ marginLeft: dividerMarginSize
81
+ })
82
+ };
83
+ const fontStyle = createFontStyle(theme, {
84
+ selector: typo => typo.caption2,
85
+ color: fontColor
86
+ });
87
+ const element = typeof childrenProp === 'string' ? /*#__PURE__*/React.createElement(Text, {
88
+ style: css(fontStyle)
89
+ }, childrenProp) : childrenProp;
90
+ const children = childrenProp ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(View, {
91
+ style: css([dividerStyle, startDividerStyle])
92
+ }), element, /*#__PURE__*/React.createElement(View, {
93
+ style: css([dividerStyle, endDividerStyle])
94
+ })) : null;
95
+ return /*#__PURE__*/React.createElement(View, _extends({
96
+ style: containerStyle
97
+ }, otherProps), children);
98
+ }
99
+ ;
100
+ //# sourceMappingURL=LegacyDivider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","Text","View","createFontStyle","css","StyleSheet","useTheme","styles","create","container","alignSelf","alignItems","row","flexDirection","column","divider","flexGrow","Divider","props","borderWidth","children","childrenProp","color","elementAlign","inset","marginBetweenChildren","style","vertical","otherProps","theme","fontColor","palette","text","secondary","borderColor","border","default","main","marginSize","spacing","insetSize","marginLeft","marginRight","marginTop","marginBottom","marginStyle","insetStyle","borderColorStyle","borderWidthStyle","borderRightWidth","borderBottomWidth","containerStyle","undefined","dividerStyle","dividerMarginSize","startDividerStyle","display","endDividerStyle","fontStyle","selector","typo","caption2","element"],"sources":["LegacyDivider.tsx"],"sourcesContent":["import React from 'react';\nimport { Text, View } from 'react-native';\nimport { createFontStyle, css, StyleSheet, useTheme } from '../styles';\nimport { ExtendedStyle } from '../types';\nimport type DividerProps from './LegacyDividerProps';\n\nconst styles = StyleSheet.create({\n container: {\n alignSelf: 'stretch',\n alignItems: 'center',\n },\n row: {\n flexDirection: 'row',\n },\n column: {\n flexDirection: 'column',\n },\n divider: {\n flexGrow: 1,\n },\n});\n\nexport default function Divider(props: DividerProps) {\n const {\n borderWidth = 1,\n children: childrenProp,\n color = 'divider',\n elementAlign = 'center',\n inset = 0,\n marginBetweenChildren = 2,\n style,\n vertical = false,\n ...otherProps\n } = props;\n\n const theme = useTheme();\n\n const fontColor = theme.palette.text.secondary;\n const borderColor = color === 'divider'\n ? theme.palette.divider\n : color === 'border'\n ? theme.palette.border.default\n : theme.palette[color].main;\n const marginSize = theme.spacing(1);\n const insetSize = theme.spacing(inset);\n\n const marginLeft = marginSize;\n const marginRight = marginSize;\n const marginTop = marginSize;\n const marginBottom = marginSize;\n\n const marginStyle = vertical\n ? { marginLeft, marginRight }\n : { marginTop, marginBottom };\n\n const insetStyle = vertical\n ? { marginTop: insetSize, marginBottom: insetSize }\n : { marginLeft: insetSize, marginRight: insetSize };\n\n const borderColorStyle = { borderColor };\n const borderWidthStyle = (vertical ? { borderRightWidth: borderWidth } : { borderBottomWidth: borderWidth });\n\n const containerStyle = css([\n insetStyle,\n marginStyle,\n styles.container,\n vertical ? styles.column : styles.row,\n childrenProp ? undefined : borderColorStyle,\n childrenProp ? undefined : borderWidthStyle,\n style,\n ]);\n\n const dividerStyle = css([\n borderColorStyle,\n borderWidthStyle,\n styles.divider,\n ]);\n\n const dividerMarginSize = theme.spacing(marginBetweenChildren);\n const startDividerStyle: ExtendedStyle = {\n display: elementAlign !== 'start' ? 'flex' : 'none',\n ...(vertical ? { marginBottom: dividerMarginSize } : { marginRight: dividerMarginSize }),\n };\n const endDividerStyle: ExtendedStyle = {\n display: elementAlign !== 'end' ? 'flex' : 'none',\n ...(vertical ? { marginTop: dividerMarginSize } : { marginLeft: dividerMarginSize }),\n };\n\n const fontStyle = createFontStyle(theme, {\n selector: (typo) => typo.caption2,\n color: fontColor,\n });\n\n const element = typeof childrenProp === 'string'\n ? <Text style={css(fontStyle)}>{childrenProp}</Text>\n : childrenProp;\n\n const children = childrenProp ? (\n <React.Fragment>\n <View style={css([dividerStyle, startDividerStyle])}/>\n {element}\n <View style={css([dividerStyle, endDividerStyle])}/>\n </React.Fragment>\n ) : null;\n\n return (\n <View\n style={containerStyle}\n {...otherProps}\n >\n {children}\n </View>\n );\n};\n"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,IAAT,EAAeC,IAAf,QAA2B,cAA3B;AACA,SAASC,eAAT,EAA0BC,GAA1B,EAA+BC,UAA/B,EAA2CC,QAA3C,QAA2D,WAA3D;AAIA,MAAMC,MAAM,GAAGF,UAAU,CAACG,MAAX,CAAkB;EAC7BC,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,SAAS,GAAGvD,eAAe,CAAC0B,KAAD,EAAQ;IACrC8B,QAAQ,EAAGC,IAAD,IAAUA,IAAI,CAACC,QADY;IAErCvC,KAAK,EAAEQ;EAF8B,CAAR,CAAjC;EAKA,MAAMgC,OAAO,GAAG,OAAOzC,YAAP,KAAwB,QAAxB,gBACV,oBAAC,IAAD;IAAM,KAAK,EAAEjB,GAAG,CAACsD,SAAD;EAAhB,GAA8BrC,YAA9B,CADU,GAEVA,YAFN;EAIA,MAAMD,QAAQ,GAAGC,YAAY,gBACzB,oBAAC,KAAD,CAAO,QAAP,qBACI,oBAAC,IAAD;IAAM,KAAK,EAAEjB,GAAG,CAAC,CAACiD,YAAD,EAAeE,iBAAf,CAAD;EAAhB,EADJ,EAEKO,OAFL,eAGI,oBAAC,IAAD;IAAM,KAAK,EAAE1D,GAAG,CAAC,CAACiD,YAAD,EAAeI,eAAf,CAAD;EAAhB,EAHJ,CADyB,GAMzB,IANJ;EAQA,oBACI,oBAAC,IAAD;IACI,KAAK,EAAEN;EADX,GAEQvB,UAFR,GAIKR,QAJL,CADJ;AAQH;AAAA"}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=LegacyDividerProps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["LegacyDividerProps.ts"],"sourcesContent":["import React from 'react';\nimport type { ViewProps } from 'react-native';\nimport type { CommonComponentColor, OverridableComponentProps } from '../types';\n\nexport type DividerColor = 'divider' | 'border' | CommonComponentColor;\n\nexport default interface DividerProps extends OverridableComponentProps<ViewProps, {\n /**\n * The content of the component.\n */\n children?: React.ReactNode;\n\n /**\n * The size of the inset. It works as a multiplier factor based on spacing system.\n * @default 0\n */\n inset?: number;\n\n /**\n * If `true`, the divider orientation is set to vertical.\n * @default false\n */\n vertical?: boolean;\n\n /**\n * The color of divider. It supports default divider color and those theme colors that make sense for this component.\n * @default 'divider'\n */\n color?: DividerColor;\n\n /**\n * The size of margin between child element and the divider. It works as a multiplier factor based on spacing system.\n * @default 2\n */\n marginBetweenChildren?: number;\n\n /**\n * The size of border width. It works as an actual pixel-based border width value of a divider.\n * @default 1\n */\n borderWidth?: number;\n\n /**\n * Set position of children.\n * @default center\n */\n elementAlign?: 'start' | 'center' | 'end';\n}> {}\n"],"mappings":""}
@@ -1,2 +1,2 @@
1
- export { default } from './Divider';
1
+ export { default } from './LegacyDivider';
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["default"],"sources":["index.ts"],"sourcesContent":["export { default } from './Divider';\nexport type { default as DividerProps } from './DividerProps';"],"mappings":"AAAA,SAASA,OAAT,QAAwB,WAAxB"}
1
+ {"version":3,"names":["default"],"sources":["index.ts"],"sourcesContent":["export { default } from './LegacyDivider';\nexport type { default as DividerProps } from './LegacyDividerProps';\n"],"mappings":"AAAA,SAASA,OAAT,QAAwB,iBAAxB"}
@@ -1,7 +1,10 @@
1
1
  import React from 'react';
2
2
  import type { ViewProps } from 'react-native';
3
- import type { CommonComponentColor, OverridableComponentProps } from '../types';
4
- export declare type DividerColor = 'divider' | 'border' | CommonComponentColor;
3
+ import type { OverridableComponentProps } from '../types';
4
+ export declare const elementAligns: readonly ["start", "center", "end"];
5
+ export declare type ElementAlign = typeof elementAligns[number];
6
+ export declare const dividerVariants: readonly ["base", "strong"];
7
+ export declare type DividerVariant = typeof dividerVariants[number];
5
8
  export default interface DividerProps extends OverridableComponentProps<ViewProps, {
6
9
  /**
7
10
  * The content of the component.
@@ -17,11 +20,6 @@ export default interface DividerProps extends OverridableComponentProps<ViewProp
17
20
  * @default false
18
21
  */
19
22
  vertical?: boolean;
20
- /**
21
- * The color of divider. It supports default divider color and those theme colors that make sense for this component.
22
- * @default 'divider'
23
- */
24
- color?: DividerColor;
25
23
  /**
26
24
  * The size of margin between child element and the divider. It works as a multiplier factor based on spacing system.
27
25
  * @default 2
@@ -29,13 +27,18 @@ export default interface DividerProps extends OverridableComponentProps<ViewProp
29
27
  marginBetweenChildren?: number;
30
28
  /**
31
29
  * The size of border width. It works as an actual pixel-based border width value of a divider.
32
- * @default 1
30
+ * @default if vertical is true 1, otherwise 0.5
33
31
  */
34
32
  borderWidth?: number;
35
33
  /**
36
34
  * Set position of children.
37
35
  * @default center
38
36
  */
39
- elementAlign?: 'start' | 'center' | 'end';
37
+ elementAlign?: ElementAlign;
38
+ /**
39
+ * Select the style of the divider based on this value.
40
+ * @default base
41
+ */
42
+ variant?: DividerVariant;
40
43
  }> {
41
44
  }
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import type DividerProps from './LegacyDividerProps';
3
+ export default function Divider(props: DividerProps): JSX.Element;
@@ -0,0 +1,41 @@
1
+ import React from 'react';
2
+ import type { ViewProps } from 'react-native';
3
+ import type { CommonComponentColor, OverridableComponentProps } from '../types';
4
+ export declare type DividerColor = 'divider' | 'border' | CommonComponentColor;
5
+ export default interface DividerProps extends OverridableComponentProps<ViewProps, {
6
+ /**
7
+ * The content of the component.
8
+ */
9
+ children?: React.ReactNode;
10
+ /**
11
+ * The size of the inset. It works as a multiplier factor based on spacing system.
12
+ * @default 0
13
+ */
14
+ inset?: number;
15
+ /**
16
+ * If `true`, the divider orientation is set to vertical.
17
+ * @default false
18
+ */
19
+ vertical?: boolean;
20
+ /**
21
+ * The color of divider. It supports default divider color and those theme colors that make sense for this component.
22
+ * @default 'divider'
23
+ */
24
+ color?: DividerColor;
25
+ /**
26
+ * The size of margin between child element and the divider. It works as a multiplier factor based on spacing system.
27
+ * @default 2
28
+ */
29
+ marginBetweenChildren?: number;
30
+ /**
31
+ * The size of border width. It works as an actual pixel-based border width value of a divider.
32
+ * @default 1
33
+ */
34
+ borderWidth?: number;
35
+ /**
36
+ * Set position of children.
37
+ * @default center
38
+ */
39
+ elementAlign?: 'start' | 'center' | 'end';
40
+ }> {
41
+ }
@@ -1,2 +1,2 @@
1
- export { default } from './Divider';
2
- export type { default as DividerProps } from './DividerProps';
1
+ export { default } from './LegacyDivider';
2
+ export type { default as DividerProps } from './LegacyDividerProps';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fountain-ui/core",
3
- "version": "2.0.0-beta.90",
3
+ "version": "2.0.0-beta.92",
4
4
  "author": "Fountain-UI Team",
5
5
  "description": "React components that implement Tappytoon's Fountain Design.",
6
6
  "license": "MIT",
@@ -67,5 +67,5 @@
67
67
  "publishConfig": {
68
68
  "access": "public"
69
69
  },
70
- "gitHead": "365f287c04429ca14768c328384f4dbd24d26b4e"
70
+ "gitHead": "879eb4620ace81a958583d4240fdc93b32faf8c1"
71
71
  }
@@ -1,8 +1,10 @@
1
1
  import React from 'react';
2
2
  import { Text, View } from 'react-native';
3
+ import type { Theme } from '@fountain-ui/styles';
3
4
  import { createFontStyle, css, StyleSheet, useTheme } from '../styles';
4
5
  import { ExtendedStyle } from '../types';
5
6
  import type DividerProps from './DividerProps';
7
+ import type { DividerVariant } from './DividerProps';
6
8
 
7
9
  const styles = StyleSheet.create({
8
10
  container: {
@@ -20,27 +22,34 @@ const styles = StyleSheet.create({
20
22
  },
21
23
  });
22
24
 
25
+ function selectBorderColor(theme: Theme, variant: DividerVariant, vertical: boolean) {
26
+ switch (variant) {
27
+ default:
28
+ case 'base':
29
+ return vertical ? theme.palette.border.weaker : theme.palette.border.weak;
30
+ case 'strong':
31
+ return vertical ? theme.palette.border.weak : theme.palette.border.base;
32
+ }
33
+ }
34
+
23
35
  export default function Divider(props: DividerProps) {
24
36
  const {
25
- borderWidth = 1,
37
+ borderWidth: borderWidthProp,
26
38
  children: childrenProp,
27
- color = 'divider',
28
39
  elementAlign = 'center',
29
40
  inset = 0,
30
41
  marginBetweenChildren = 2,
31
42
  style,
43
+ variant = 'base' as DividerVariant,
32
44
  vertical = false,
33
45
  ...otherProps
34
46
  } = props;
35
47
 
36
48
  const theme = useTheme();
37
49
 
38
- const fontColor = theme.palette.text.secondary;
39
- const borderColor = color === 'divider'
40
- ? theme.palette.divider
41
- : color === 'border'
42
- ? theme.palette.border.default
43
- : theme.palette[color].main;
50
+ const borderWidth = borderWidthProp ?? (vertical ? 1 : 0.5);
51
+ const fontColor = theme.palette.text.weak;
52
+ const borderColor = selectBorderColor(theme, variant, vertical);
44
53
  const marginSize = theme.spacing(1);
45
54
  const insetSize = theme.spacing(inset);
46
55
 
@@ -1,8 +1,12 @@
1
1
  import React from 'react';
2
2
  import type { ViewProps } from 'react-native';
3
- import type { CommonComponentColor, OverridableComponentProps } from '../types';
3
+ import type { OverridableComponentProps } from '../types';
4
4
 
5
- export type DividerColor = 'divider' | 'border' | CommonComponentColor;
5
+ export const elementAligns = ['start', 'center', 'end'] as const;
6
+ export type ElementAlign = typeof elementAligns[number];
7
+
8
+ export const dividerVariants = ['base', 'strong'] as const;
9
+ export type DividerVariant = typeof dividerVariants[number];
6
10
 
7
11
  export default interface DividerProps extends OverridableComponentProps<ViewProps, {
8
12
  /**
@@ -22,12 +26,6 @@ export default interface DividerProps extends OverridableComponentProps<ViewProp
22
26
  */
23
27
  vertical?: boolean;
24
28
 
25
- /**
26
- * The color of divider. It supports default divider color and those theme colors that make sense for this component.
27
- * @default 'divider'
28
- */
29
- color?: DividerColor;
30
-
31
29
  /**
32
30
  * The size of margin between child element and the divider. It works as a multiplier factor based on spacing system.
33
31
  * @default 2
@@ -36,7 +34,7 @@ export default interface DividerProps extends OverridableComponentProps<ViewProp
36
34
 
37
35
  /**
38
36
  * The size of border width. It works as an actual pixel-based border width value of a divider.
39
- * @default 1
37
+ * @default if vertical is true 1, otherwise 0.5
40
38
  */
41
39
  borderWidth?: number;
42
40
 
@@ -44,5 +42,11 @@ export default interface DividerProps extends OverridableComponentProps<ViewProp
44
42
  * Set position of children.
45
43
  * @default center
46
44
  */
47
- elementAlign?: 'start' | 'center' | 'end';
45
+ elementAlign?: ElementAlign;
46
+
47
+ /**
48
+ * Select the style of the divider based on this value.
49
+ * @default base
50
+ */
51
+ variant?: DividerVariant;
48
52
  }> {}
@@ -0,0 +1,114 @@
1
+ import React from 'react';
2
+ import { Text, View } from 'react-native';
3
+ import { createFontStyle, css, StyleSheet, useTheme } from '../styles';
4
+ import { ExtendedStyle } from '../types';
5
+ import type DividerProps from './LegacyDividerProps';
6
+
7
+ const styles = StyleSheet.create({
8
+ container: {
9
+ alignSelf: 'stretch',
10
+ alignItems: 'center',
11
+ },
12
+ row: {
13
+ flexDirection: 'row',
14
+ },
15
+ column: {
16
+ flexDirection: 'column',
17
+ },
18
+ divider: {
19
+ flexGrow: 1,
20
+ },
21
+ });
22
+
23
+ export default function Divider(props: DividerProps) {
24
+ const {
25
+ borderWidth = 1,
26
+ children: childrenProp,
27
+ color = 'divider',
28
+ elementAlign = 'center',
29
+ inset = 0,
30
+ marginBetweenChildren = 2,
31
+ style,
32
+ vertical = false,
33
+ ...otherProps
34
+ } = props;
35
+
36
+ const theme = useTheme();
37
+
38
+ const fontColor = theme.palette.text.secondary;
39
+ const borderColor = color === 'divider'
40
+ ? theme.palette.divider
41
+ : color === 'border'
42
+ ? theme.palette.border.default
43
+ : theme.palette[color].main;
44
+ const marginSize = theme.spacing(1);
45
+ const insetSize = theme.spacing(inset);
46
+
47
+ const marginLeft = marginSize;
48
+ const marginRight = marginSize;
49
+ const marginTop = marginSize;
50
+ const marginBottom = marginSize;
51
+
52
+ const marginStyle = vertical
53
+ ? { marginLeft, marginRight }
54
+ : { marginTop, marginBottom };
55
+
56
+ const insetStyle = vertical
57
+ ? { marginTop: insetSize, marginBottom: insetSize }
58
+ : { marginLeft: insetSize, marginRight: insetSize };
59
+
60
+ const borderColorStyle = { borderColor };
61
+ const borderWidthStyle = (vertical ? { borderRightWidth: borderWidth } : { borderBottomWidth: borderWidth });
62
+
63
+ const containerStyle = css([
64
+ insetStyle,
65
+ marginStyle,
66
+ styles.container,
67
+ vertical ? styles.column : styles.row,
68
+ childrenProp ? undefined : borderColorStyle,
69
+ childrenProp ? undefined : borderWidthStyle,
70
+ style,
71
+ ]);
72
+
73
+ const dividerStyle = css([
74
+ borderColorStyle,
75
+ borderWidthStyle,
76
+ styles.divider,
77
+ ]);
78
+
79
+ const dividerMarginSize = theme.spacing(marginBetweenChildren);
80
+ const startDividerStyle: ExtendedStyle = {
81
+ display: elementAlign !== 'start' ? 'flex' : 'none',
82
+ ...(vertical ? { marginBottom: dividerMarginSize } : { marginRight: dividerMarginSize }),
83
+ };
84
+ const endDividerStyle: ExtendedStyle = {
85
+ display: elementAlign !== 'end' ? 'flex' : 'none',
86
+ ...(vertical ? { marginTop: dividerMarginSize } : { marginLeft: dividerMarginSize }),
87
+ };
88
+
89
+ const fontStyle = createFontStyle(theme, {
90
+ selector: (typo) => typo.caption2,
91
+ color: fontColor,
92
+ });
93
+
94
+ const element = typeof childrenProp === 'string'
95
+ ? <Text style={css(fontStyle)}>{childrenProp}</Text>
96
+ : childrenProp;
97
+
98
+ const children = childrenProp ? (
99
+ <React.Fragment>
100
+ <View style={css([dividerStyle, startDividerStyle])}/>
101
+ {element}
102
+ <View style={css([dividerStyle, endDividerStyle])}/>
103
+ </React.Fragment>
104
+ ) : null;
105
+
106
+ return (
107
+ <View
108
+ style={containerStyle}
109
+ {...otherProps}
110
+ >
111
+ {children}
112
+ </View>
113
+ );
114
+ };
@@ -0,0 +1,48 @@
1
+ import React from 'react';
2
+ import type { ViewProps } from 'react-native';
3
+ import type { CommonComponentColor, OverridableComponentProps } from '../types';
4
+
5
+ export type DividerColor = 'divider' | 'border' | CommonComponentColor;
6
+
7
+ export default interface DividerProps extends OverridableComponentProps<ViewProps, {
8
+ /**
9
+ * The content of the component.
10
+ */
11
+ children?: React.ReactNode;
12
+
13
+ /**
14
+ * The size of the inset. It works as a multiplier factor based on spacing system.
15
+ * @default 0
16
+ */
17
+ inset?: number;
18
+
19
+ /**
20
+ * If `true`, the divider orientation is set to vertical.
21
+ * @default false
22
+ */
23
+ vertical?: boolean;
24
+
25
+ /**
26
+ * The color of divider. It supports default divider color and those theme colors that make sense for this component.
27
+ * @default 'divider'
28
+ */
29
+ color?: DividerColor;
30
+
31
+ /**
32
+ * The size of margin between child element and the divider. It works as a multiplier factor based on spacing system.
33
+ * @default 2
34
+ */
35
+ marginBetweenChildren?: number;
36
+
37
+ /**
38
+ * The size of border width. It works as an actual pixel-based border width value of a divider.
39
+ * @default 1
40
+ */
41
+ borderWidth?: number;
42
+
43
+ /**
44
+ * Set position of children.
45
+ * @default center
46
+ */
47
+ elementAlign?: 'start' | 'center' | 'end';
48
+ }> {}
@@ -1,2 +1,2 @@
1
- export { default } from './Divider';
2
- export type { default as DividerProps } from './DividerProps';
1
+ export { default } from './LegacyDivider';
2
+ export type { default as DividerProps } from './LegacyDividerProps';