@remember-web/mixin 0.1.7 → 0.1.8

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.
@@ -5,6 +5,7 @@ var utils = require('./colors/utils.cjs.js');
5
5
  var index = require('./mediaQuery/index.cjs.js');
6
6
  var _const$1 = require('./typography/const.cjs.js');
7
7
  var utils$1 = require('./typography/utils.cjs.js');
8
+ var index$1 = require('./provider/index.cjs.js');
8
9
  var _const = require('./mediaQuery/const.cjs.js');
9
10
 
10
11
 
@@ -55,6 +56,8 @@ exports.TYPOGRAPHY_STYLES = _const$1.TYPOGRAPHY_STYLES;
55
56
  exports.ellipsis = utils$1.ellipsis;
56
57
  exports.getTypographyStyles = utils$1.getTypographyStyles;
57
58
  exports.textEllipsis = utils$1.textEllipsis;
59
+ exports.RUIProvider = index$1.RUIProvider;
60
+ exports.useRUI = index$1.useRUI;
58
61
  exports.DESKTOP_WIDTH = _const.DESKTOP_WIDTH;
59
62
  exports.PHONE_WIDTH = _const.PHONE_WIDTH;
60
63
  //# sourceMappingURL=index.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,4 +1,5 @@
1
1
  export * from './colors';
2
2
  export * from './mediaQuery';
3
3
  export * from './typography';
4
+ export * from './provider';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
@@ -3,5 +3,6 @@ export { getBrowserTheme, getColorVariableName, getHexFromRuiCssVariable, getRgb
3
3
  export { desktopOnly, getDeviceWidthMediaQuery, mobileOnly, phoneOnly } from './mediaQuery/index.esm.js';
4
4
  export { PRETENDARD_FONT_FAMILY, TYPOGRAPHY_STYLES } from './typography/const.esm.js';
5
5
  export { ellipsis, getTypographyStyles, textEllipsis } from './typography/utils.esm.js';
6
+ export { RUIProvider, useRUI } from './provider/index.esm.js';
6
7
  export { DESKTOP_WIDTH, PHONE_WIDTH } from './mediaQuery/const.esm.js';
7
8
  //# sourceMappingURL=index.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
1
+ {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
@@ -0,0 +1,43 @@
1
+ "use client";
2
+ 'use strict';
3
+
4
+ var react = require('react');
5
+ var utils = require('../colors/utils.cjs.js');
6
+ var styles = require('./styles.cjs.js');
7
+ var jsxRuntime = require('react/jsx-runtime');
8
+
9
+ var RUIContext = /*#__PURE__*/react.createContext(null);
10
+
11
+ /** theme과 setTheme은 사용하는 곳에서 주입,
12
+ * 기본적으로는 브라우저의 미디어쿼리를 통해서 light, dark를 결정 */
13
+ function RUIProvider(_ref) {
14
+ var children = _ref.children,
15
+ customMixins = _ref.customMixins,
16
+ forceTheme = _ref.forceTheme,
17
+ setTheme = _ref.setTheme;
18
+ var currentTheme = forceTheme !== null && forceTheme !== void 0 ? forceTheme : utils.getBrowserTheme();
19
+ var ruiContextValue = react.useMemo(function () {
20
+ return {
21
+ currentTheme: currentTheme,
22
+ setTheme: setTheme
23
+ };
24
+ }, [currentTheme, setTheme]);
25
+ return /*#__PURE__*/jsxRuntime.jsxs(RUIContext.Provider, {
26
+ value: ruiContextValue,
27
+ children: [/*#__PURE__*/jsxRuntime.jsx(styles.RUIGlobalStyle, {
28
+ customMixins: customMixins,
29
+ forceTheme: forceTheme
30
+ }), children]
31
+ });
32
+ }
33
+ function useRUI() {
34
+ var ruiContextValue = react.useContext(RUIContext);
35
+ if (ruiContextValue === null) {
36
+ throw new Error('useRUI must be used within RUIProvider');
37
+ }
38
+ return ruiContextValue;
39
+ }
40
+
41
+ exports.RUIProvider = RUIProvider;
42
+ exports.useRUI = useRUI;
43
+ //# sourceMappingURL=index.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs.js","sources":["../../../../src/provider/index.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode } from 'react';\nimport { createContext, useContext, useMemo } from 'react';\n\nimport type { ColorThemeType, ThemeType } from '@/colors';\nimport { getBrowserTheme } from '@/colors';\n\nimport { RUIGlobalStyle } from './styles';\n\nexport interface RUIContentProps {\n customMixins?: ColorThemeType;\n forceTheme?: ThemeType;\n setTheme?: (theme: ThemeType) => void;\n}\n\nexport interface RUIContextValue {\n currentTheme: ThemeType;\n setTheme: RUIContentProps['setTheme'];\n}\n\nconst RUIContext = createContext<RUIContextValue | null>(null);\n\n/** theme과 setTheme은 사용하는 곳에서 주입,\n * 기본적으로는 브라우저의 미디어쿼리를 통해서 light, dark를 결정 */\nexport function RUIProvider({\n children,\n customMixins,\n forceTheme,\n setTheme,\n}: { children: ReactNode } & RUIContentProps) {\n const currentTheme: ThemeType = forceTheme ?? getBrowserTheme();\n const ruiContextValue: RUIContextValue = useMemo(\n () => ({ currentTheme, setTheme }),\n [currentTheme, setTheme]\n );\n\n return (\n <RUIContext.Provider value={ruiContextValue}>\n <RUIGlobalStyle customMixins={customMixins} forceTheme={forceTheme} />\n {children}\n </RUIContext.Provider>\n );\n}\n\nexport function useRUI() {\n const ruiContextValue = useContext(RUIContext);\n\n if (ruiContextValue === null) {\n throw new Error('useRUI must be used within RUIProvider');\n }\n\n return ruiContextValue;\n}\n"],"names":["currentTheme","setTheme","value","customMixins","forceTheme"],"mappings":";;;;;;;;AAqBA;;AAEA;AACA;AACO;AAKuC;;;;;;;AAGjCA;AAAcC;;AAAU;AAInC;AACuBC;;AACHC;AAA4BC;;AACnC;AAGf;AAEO;AACL;;AAGE;AACF;AAEA;AACF;;;"}
@@ -0,0 +1,40 @@
1
+ "use client";
2
+ import { useMemo, useContext, createContext } from 'react';
3
+ import { getBrowserTheme } from '../colors/utils.esm.js';
4
+ import { RUIGlobalStyle } from './styles.esm.js';
5
+ import { jsxs, jsx } from 'react/jsx-runtime';
6
+
7
+ var RUIContext = /*#__PURE__*/createContext(null);
8
+
9
+ /** theme과 setTheme은 사용하는 곳에서 주입,
10
+ * 기본적으로는 브라우저의 미디어쿼리를 통해서 light, dark를 결정 */
11
+ function RUIProvider(_ref) {
12
+ var children = _ref.children,
13
+ customMixins = _ref.customMixins,
14
+ forceTheme = _ref.forceTheme,
15
+ setTheme = _ref.setTheme;
16
+ var currentTheme = forceTheme !== null && forceTheme !== void 0 ? forceTheme : getBrowserTheme();
17
+ var ruiContextValue = useMemo(function () {
18
+ return {
19
+ currentTheme: currentTheme,
20
+ setTheme: setTheme
21
+ };
22
+ }, [currentTheme, setTheme]);
23
+ return /*#__PURE__*/jsxs(RUIContext.Provider, {
24
+ value: ruiContextValue,
25
+ children: [/*#__PURE__*/jsx(RUIGlobalStyle, {
26
+ customMixins: customMixins,
27
+ forceTheme: forceTheme
28
+ }), children]
29
+ });
30
+ }
31
+ function useRUI() {
32
+ var ruiContextValue = useContext(RUIContext);
33
+ if (ruiContextValue === null) {
34
+ throw new Error('useRUI must be used within RUIProvider');
35
+ }
36
+ return ruiContextValue;
37
+ }
38
+
39
+ export { RUIProvider, useRUI };
40
+ //# sourceMappingURL=index.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.esm.js","sources":["../../../../src/provider/index.tsx"],"sourcesContent":["'use client';\n\nimport type { ReactNode } from 'react';\nimport { createContext, useContext, useMemo } from 'react';\n\nimport type { ColorThemeType, ThemeType } from '@/colors';\nimport { getBrowserTheme } from '@/colors';\n\nimport { RUIGlobalStyle } from './styles';\n\nexport interface RUIContentProps {\n customMixins?: ColorThemeType;\n forceTheme?: ThemeType;\n setTheme?: (theme: ThemeType) => void;\n}\n\nexport interface RUIContextValue {\n currentTheme: ThemeType;\n setTheme: RUIContentProps['setTheme'];\n}\n\nconst RUIContext = createContext<RUIContextValue | null>(null);\n\n/** theme과 setTheme은 사용하는 곳에서 주입,\n * 기본적으로는 브라우저의 미디어쿼리를 통해서 light, dark를 결정 */\nexport function RUIProvider({\n children,\n customMixins,\n forceTheme,\n setTheme,\n}: { children: ReactNode } & RUIContentProps) {\n const currentTheme: ThemeType = forceTheme ?? getBrowserTheme();\n const ruiContextValue: RUIContextValue = useMemo(\n () => ({ currentTheme, setTheme }),\n [currentTheme, setTheme]\n );\n\n return (\n <RUIContext.Provider value={ruiContextValue}>\n <RUIGlobalStyle customMixins={customMixins} forceTheme={forceTheme} />\n {children}\n </RUIContext.Provider>\n );\n}\n\nexport function useRUI() {\n const ruiContextValue = useContext(RUIContext);\n\n if (ruiContextValue === null) {\n throw new Error('useRUI must be used within RUIProvider');\n }\n\n return ruiContextValue;\n}\n"],"names":["currentTheme","setTheme","value","customMixins","forceTheme"],"mappings":";;;;;;AAqBA;;AAEA;AACA;AACO;AAKuC;;;;;;;AAGjCA;AAAcC;;AAAU;AAInC;AACuBC;;AACHC;AAA4BC;;AACnC;AAGf;AAEO;AACL;;AAGE;AACF;AAEA;AACF;;"}
@@ -0,0 +1,43 @@
1
+ "use client";
2
+ 'use strict';
3
+
4
+ var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
5
+ var _defineProperty = require('@babel/runtime/helpers/defineProperty');
6
+ var _taggedTemplateLiteral = require('@babel/runtime/helpers/taggedTemplateLiteral');
7
+ var styledComponents = require('styled-components');
8
+ var theme = require('../colors/theme.cjs.js');
9
+ var utils = require('../colors/utils.cjs.js');
10
+
11
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
12
+
13
+ var _slicedToArray__default = /*#__PURE__*/_interopDefault(_slicedToArray);
14
+ var _defineProperty__default = /*#__PURE__*/_interopDefault(_defineProperty);
15
+ var _taggedTemplateLiteral__default = /*#__PURE__*/_interopDefault(_taggedTemplateLiteral);
16
+
17
+ var _templateObject;
18
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
19
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty__default.default(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
20
+ var RUIGlobalStyle = styledComponents.createGlobalStyle(function (_ref) {
21
+ var customMixins = _ref.customMixins,
22
+ forceTheme = _ref.forceTheme;
23
+ return styledComponents.css(_templateObject || (_templateObject = _taggedTemplateLiteral__default.default(["\n :root {\n ", ";\n\n @media (prefers-color-scheme: dark) {\n ", "\n }\n }\n "])), getThemeCssFragment({
24
+ theme: forceTheme || 'light',
25
+ customMixins: customMixins
26
+ }), getThemeCssFragment({
27
+ theme: forceTheme || 'dark',
28
+ customMixins: customMixins
29
+ }));
30
+ });
31
+ function getThemeCssFragment(_ref2) {
32
+ var theme$1 = _ref2.theme,
33
+ customMixins = _ref2.customMixins;
34
+ return Object.entries(_objectSpread(_objectSpread({}, theme.RUI_COLOR_THEME[theme$1]), customMixins === null || customMixins === void 0 ? void 0 : customMixins[theme$1])).map(function (_ref3) {
35
+ var _ref4 = _slicedToArray__default.default(_ref3, 2),
36
+ key = _ref4[0],
37
+ value = _ref4[1];
38
+ return "".concat(key, ": ").concat(value, "; ").concat(key, "__rgb: ").concat(utils.hexToRgb(value), ";");
39
+ });
40
+ }
41
+
42
+ exports.RUIGlobalStyle = RUIGlobalStyle;
43
+ //# sourceMappingURL=styles.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.cjs.js","sources":["../../../../src/provider/styles.ts"],"sourcesContent":["'use client';\n\nimport { createGlobalStyle, css } from 'styled-components';\n\nimport { RUI_COLOR_THEME } from '@/colors/theme';\nimport { hexToRgb, type ColorThemeType, type ThemeType } from '@/colors';\n\nexport const RUIGlobalStyle = createGlobalStyle<{\n customMixins?: ColorThemeType;\n forceTheme?: ThemeType;\n}>(\n ({ customMixins, forceTheme }) => css`\n :root {\n ${getThemeCssFragment({ theme: forceTheme || 'light', customMixins })};\n\n @media (prefers-color-scheme: dark) {\n ${getThemeCssFragment({ theme: forceTheme || 'dark', customMixins })}\n }\n }\n `\n);\n\nfunction getThemeCssFragment({\n theme,\n customMixins,\n}: {\n theme: ThemeType;\n customMixins?: ColorThemeType;\n}) {\n return Object.entries({\n ...RUI_COLOR_THEME[theme],\n ...customMixins?.[theme],\n }).map(\n ([key, value]) => `${key}: ${value}; ${key}__rgb: ${hexToRgb(value)};`\n );\n}\n"],"names":["customMixins","key","value"],"mappings":";;;;;;;;;;;;;;;;AAAa;AAAA;AAAA;;AAWX;;;;AAE0DA;;;AAGCA;AAAa;AAAE;AAM5E;AAMG;;;AAKC;AAAEC;AAAKC;AAAK;AAAuD;AAEvE;;"}
@@ -0,0 +1,35 @@
1
+ "use client";
2
+ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
3
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
4
+ import _taggedTemplateLiteral from '@babel/runtime/helpers/taggedTemplateLiteral';
5
+ import { createGlobalStyle, css } from 'styled-components';
6
+ import { RUI_COLOR_THEME } from '../colors/theme.esm.js';
7
+ import { hexToRgb } from '../colors/utils.esm.js';
8
+
9
+ var _templateObject;
10
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
11
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
12
+ var RUIGlobalStyle = createGlobalStyle(function (_ref) {
13
+ var customMixins = _ref.customMixins,
14
+ forceTheme = _ref.forceTheme;
15
+ return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n :root {\n ", ";\n\n @media (prefers-color-scheme: dark) {\n ", "\n }\n }\n "])), getThemeCssFragment({
16
+ theme: forceTheme || 'light',
17
+ customMixins: customMixins
18
+ }), getThemeCssFragment({
19
+ theme: forceTheme || 'dark',
20
+ customMixins: customMixins
21
+ }));
22
+ });
23
+ function getThemeCssFragment(_ref2) {
24
+ var theme = _ref2.theme,
25
+ customMixins = _ref2.customMixins;
26
+ return Object.entries(_objectSpread(_objectSpread({}, RUI_COLOR_THEME[theme]), customMixins === null || customMixins === void 0 ? void 0 : customMixins[theme])).map(function (_ref3) {
27
+ var _ref4 = _slicedToArray(_ref3, 2),
28
+ key = _ref4[0],
29
+ value = _ref4[1];
30
+ return "".concat(key, ": ").concat(value, "; ").concat(key, "__rgb: ").concat(hexToRgb(value), ";");
31
+ });
32
+ }
33
+
34
+ export { RUIGlobalStyle };
35
+ //# sourceMappingURL=styles.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.esm.js","sources":["../../../../src/provider/styles.ts"],"sourcesContent":["'use client';\n\nimport { createGlobalStyle, css } from 'styled-components';\n\nimport { RUI_COLOR_THEME } from '@/colors/theme';\nimport { hexToRgb, type ColorThemeType, type ThemeType } from '@/colors';\n\nexport const RUIGlobalStyle = createGlobalStyle<{\n customMixins?: ColorThemeType;\n forceTheme?: ThemeType;\n}>(\n ({ customMixins, forceTheme }) => css`\n :root {\n ${getThemeCssFragment({ theme: forceTheme || 'light', customMixins })};\n\n @media (prefers-color-scheme: dark) {\n ${getThemeCssFragment({ theme: forceTheme || 'dark', customMixins })}\n }\n }\n `\n);\n\nfunction getThemeCssFragment({\n theme,\n customMixins,\n}: {\n theme: ThemeType;\n customMixins?: ColorThemeType;\n}) {\n return Object.entries({\n ...RUI_COLOR_THEME[theme],\n ...customMixins?.[theme],\n }).map(\n ([key, value]) => `${key}: ${value}; ${key}__rgb: ${hexToRgb(value)};`\n );\n}\n"],"names":["customMixins","key","value"],"mappings":";;;;;;;;AAAa;AAAA;AAAA;;AAWX;;;;AAE0DA;;;AAGCA;AAAa;AAAE;AAM5E;AAMG;;;AAKC;AAAEC;AAAKC;AAAK;AAAuD;AAEvE;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remember-web/mixin",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "RUI Mixin",
5
5
  "homepage": "https://dramancompany.github.io/rui/",
6
6
  "author": "Remember",
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export * from './colors';
2
2
  export * from './mediaQuery';
3
3
  export * from './typography';
4
- // export * from './provider';
4
+ export * from './provider';