@rpg-engine/long-bow 0.1.28 → 0.1.32
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/components/Button.d.ts +10 -0
- package/dist/components/ListMenu.d.ts +1 -0
- package/dist/{NPCDialog → components/NPCDialog}/NPCDialog.d.ts +2 -2
- package/dist/{NPCDialog → components/NPCDialog}/NPCDialogText.d.ts +0 -0
- package/dist/{NPCDialog → components/NPCDialog}/QuestionDialog/QuestionDialog.d.ts +0 -0
- package/dist/components/RPGUIContainer.d.ts +14 -0
- package/dist/{RPGUI → components}/RPGUIRoot.d.ts +0 -0
- package/dist/{RPGUI/RPGUISlider.d.ts → components/RangeSlider.d.ts} +4 -4
- package/dist/{typography → components/typography}/DynamicText.d.ts +0 -0
- package/dist/index.d.ts +7 -6
- package/dist/long-bow.cjs.development.js +108 -62
- package/dist/long-bow.cjs.development.js.map +1 -1
- package/dist/long-bow.cjs.production.min.js +1 -1
- package/dist/long-bow.cjs.production.min.js.map +1 -1
- package/dist/long-bow.esm.js +110 -62
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Button.tsx +23 -0
- package/src/components/ListMenu.tsx +21 -17
- package/src/{NPCDialog → components/NPCDialog}/NPCDialog.tsx +51 -50
- package/src/{NPCDialog → components/NPCDialog}/NPCDialogText.tsx +1 -1
- package/src/{NPCDialog → components/NPCDialog}/QuestionDialog/QuestionDialog.tsx +1 -1
- package/src/{NPCDialog → components/NPCDialog}/img/npcDialog/npcThumbnails/alice.png +0 -0
- package/src/{NPCDialog → components/NPCDialog}/img/space.gif +0 -0
- package/src/{RPGUI → components}/RPGUIContainer.tsx +10 -3
- package/src/{RPGUI → components}/RPGUIRoot.tsx +0 -0
- package/src/{RPGUI/RPGUISlider.tsx → components/RangeSlider.tsx} +22 -25
- package/src/{typography → components/typography}/DynamicText.tsx +0 -0
- package/src/index.tsx +7 -6
- package/dist/RPGUI/RPGUIContainer.d.ts +0 -9
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var n=require("react"),t=e(n),i=e(require("styled-components"));require("rpgui/rpgui.min.css"),require("rpgui/rpgui.min.js");var
|
|
1
|
+
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var n=require("react"),t=e(n),i=e(require("styled-components")),r=require("uuid");require("rpgui/rpgui.min.css"),require("rpgui/rpgui.min.js");var o,a=["children","type"];(o=exports.IButtonTypes||(exports.IButtonTypes={})).RPGUIButton="rpgui-button",o.RPGUIGoldButton="rpgui-button golden";var l,u=i.div.withConfig({displayName:"ListMenu__Container",componentId:"sc-i9097t-0"})(["display:flex;flex-direction:column;width:100%;justify-content:start;align-items:flex-start;position:absolute;top:","px;left:","px;li{font-size:","em;}"],(function(e){return e.y||0}),(function(e){return e.x||0}),(function(e){return e.fontSize})),s=i.li.withConfig({displayName:"ListMenu__ListElement",componentId:"sc-i9097t-1"})(["margin-right:0.5rem;"]);(l=exports.RPGUIContainerTypes||(exports.RPGUIContainerTypes={})).Framed="framed",l.FramedGold="framed-golden",l.FramedGold2="framed-golden-2",l.FramedGrey="framed-grey";var d=function(e){var n=e.width;return t.createElement(c,{width:void 0===n?"50%":n,height:e.height||"auto",className:"rpgui-container "+e.type},e.children)},c=i.div.withConfig({displayName:"RPGUIContainer__Container",componentId:"sc-a8l4p8-0"})(["height:",";width:",";display:flex;flex-wrap:wrap;image-rendering:pixelated;"],(function(e){return e.height}),(function(e){return e.width}));const p=require("./alice.png"),f=require("./space.gif");var m,x=function(e){var i=e.text,r=e.onFinish,o=e.onStart,a=n.useState(""),l=a[0],u=a[1];return n.useEffect((function(){var e=0,n=setInterval((function(){0===e&&o&&o(),e<i.length?(u(i.substring(0,e+1)),e++):(clearInterval(n),r&&r())}),50);return function(){clearInterval(n)}}),[i]),t.createElement(g,null,l)},g=i.p.withConfig({displayName:"DynamicText__TextContainer",componentId:"sc-1ggl9nd-0"})(["font-size:0.7rem !important;color:white;text-shadow:1px 1px 0px #000000;letter-spacing:1.2px;word-break:normal;"]),h=function(e){var i=e.onClose,r=e.onEndStep,o=e.onStartStep,a=e.text.match(new RegExp(".{1,85}","g")),l=n.useState(0),u=l[0],s=l[1],d=function(e){"Space"===e.code&&((null==a?void 0:a[u+1])?s((function(e){return e+1})):i())};return n.useEffect((function(){return document.addEventListener("keydown",d),function(){return document.removeEventListener("keydown",d)}}),[u]),t.createElement(w,null,t.createElement(x,{text:(null==a?void 0:a[u])||"",onFinish:r,onStart:o}))},w=i.div.withConfig({displayName:"NPCDialogText__Container",componentId:"sc-1cxkdh9-0"})([""]),y=function(e,n,i){void 0===i&&(i=window);var r=t.useRef();t.useEffect((function(){r.current=n}),[n]),t.useEffect((function(){var n=function(e){return r.current(e)};return i.addEventListener(e,n),function(){i.removeEventListener(e,n)}}),[e,i])},v=function(e){var i=e.questions,r=e.answers,o=e.onClose,a=n.useState(i[0]),l=a[0],u=a[1],s=n.useState(!1),d=s[0],c=s[1],p=function(){if(!l.answerIds||0===l.answerIds.length)return null;var e=l.answerIds[0];return r.find((function(n){return n.id===e}))},f=n.useState(p()),m=f[0],g=f[1];n.useEffect((function(){g(p())}),[l]);var h=function(e){return e.map((function(e){return r.find((function(n){return n.id===e}))}))};return y("keydown",(function(e){switch(e.key){case"ArrowDown":var n=h(l.answerIds).findIndex((function(e){return(null==e?void 0:e.id)===m.id+1})),t=l.answerIds[n],r=h(l.answerIds).find((function(e){return(null==e?void 0:e.id)===t}));g(r||p());break;case"ArrowUp":var a=h(l.answerIds).findIndex((function(e){return(null==e?void 0:e.id)===m.id-1})),s=l.answerIds&&l.answerIds[a],d=h(l.answerIds).find((function(e){return(null==e?void 0:e.id)===s}));g(d||h(l.answerIds).pop());break;case"Enter":if(c(!1),null==m||!m.nextQuestionId)return void o();u(i.find((function(e){return e.id===m.nextQuestionId})))}})),t.createElement(C,null,t.createElement(I,null,t.createElement(x,{text:l.text,onStart:function(){return c(!1)},onFinish:function(){return c(!0)}})),d&&t.createElement(b,null,function(){var e=l.answerIds;if(!e)return null;var n=h(e);return n?n.map((function(e){var n=(null==m?void 0:m.id)===(null==e?void 0:e.id),r=n?"yellow":"white";return e?t.createElement(T,{key:"answer_"+e.id},t.createElement(N,{color:r},n?"X":null),t.createElement(E,{key:e.id,onClick:function(){return function(e){c(!1),e.nextQuestionId?u(i.find((function(n){return n.id===e.nextQuestionId}))):o()}(e)},color:r},e.text)):null})):null}()))},C=i.div.withConfig({displayName:"QuestionDialog__Container",componentId:"sc-bxc5u0-0"})(["display:flex;word-break:break-all;box-sizing:border-box;justify-content:flex-start;align-items:flex-start;flex-wrap:wrap;"]),I=i.div.withConfig({displayName:"QuestionDialog__QuestionContainer",componentId:"sc-bxc5u0-1"})(["flex:100%;width:100%;"]),b=i.div.withConfig({displayName:"QuestionDialog__AnswersContainer",componentId:"sc-bxc5u0-2"})(["flex:100%;"]),E=i.p.withConfig({displayName:"QuestionDialog__Answer",componentId:"sc-bxc5u0-3"})(["flex:auto;color:"," !important;font-size:0.65rem !important;background:inherit;border:none;"],(function(e){return e.color})),N=i.span.withConfig({displayName:"QuestionDialog__AnswerSelectedIcon",componentId:"sc-bxc5u0-4"})(["flex:5% 0 0;color:"," !important;"],(function(e){return e.color})),T=i.div.withConfig({displayName:"QuestionDialog__AnswerRow",componentId:"sc-bxc5u0-5"})(["display:flex;flex-wrap:wrap;justify-content:center;align-items:center;margin-bottom:0.5rem;height:22px;p{line-height:unset;margin-top:0;margin-bottom:0rem;}"]);(m=exports.NPCDialogType||(exports.NPCDialogType={})).TextOnly="TextOnly",m.TextAndThumbnail="TextAndThumbnail";var _,S=i.div.withConfig({displayName:"NPCDialog__Container",componentId:"sc-1b4aw74-0"})(["display:flex;width:100%;height:100%;box-sizing:border-box;justify-content:center;align-items:flex-start;position:relative;"]),P=i.div.withConfig({displayName:"NPCDialog__TextContainer",componentId:"sc-1b4aw74-1"})(["flex:"," 0 0;width:355px;"],(function(e){return e.flex})),D=i.div.withConfig({displayName:"NPCDialog__ThumbnailContainer",componentId:"sc-1b4aw74-2"})(["flex:30% 0 0;display:flex;justify-content:flex-end;"]),R=i.img.withConfig({displayName:"NPCDialog__NPCThumbnail",componentId:"sc-1b4aw74-3"})(["image-rendering:pixelated;height:128px;width:128px;"]),k=i.img.withConfig({displayName:"NPCDialog__PressSpaceIndicator",componentId:"sc-1b4aw74-4"})(["position:absolute;right:",";bottom:1rem;height:20.7px;image-rendering:-webkit-optimize-contrast;"],(function(e){return e.right})),G=RPGUI;(_=exports.RangeSliderType||(exports.RangeSliderType={})).Slider="rpgui-slider",_.GoldSlider="rpgui-slider golden";var Q=i.input.withConfig({displayName:"RangeSlider__Input",componentId:"sc-v8mte9-0"})(["opacity:0;"]);exports.Button=function(e){var n=e.children,i=e.type,r=function(e,n){if(null==e)return{};var t,i,r={},o=Object.keys(e);for(i=0;i<o.length;i++)n.indexOf(t=o[i])>=0||(r[t]=e[t]);return r}(e,a);return t.createElement("button",Object.assign({className:i,type:"button"},r),t.createElement("p",null,n))},exports.DynamicText=x,exports.ListMenu=function(e){var n=e.onSelected,i=e.fontSize;return t.createElement(u,{x:e.x,y:e.y,fontSize:void 0===i?.8:i},t.createElement("ul",{className:"rpgui-list-imp",style:{overflow:"hidden"}},e.options.map((function(e){return t.createElement(s,{key:e.text,onClick:function(){n(e.id)}},e.text)}))))},exports.NPCDialog=function(e){var i=e.text,r=e.type,o=e.onClose,a=e.imagePath,l=e.isQuestionDialog,u=void 0!==l&&l,s=e.questions,c=e.answers,m=n.useState(!1),x=m[0],g=m[1];return t.createElement(d,{type:exports.RPGUIContainerTypes.FramedGold,width:u?"600px":"50%",height:"180px"},u&&s&&c?t.createElement(t.Fragment,null,t.createElement(P,{flex:r===exports.NPCDialogType.TextAndThumbnail?"70%":"100%"},t.createElement(v,{questions:s,answers:c,onClose:function(){o&&o()}})),r===exports.NPCDialogType.TextAndThumbnail&&t.createElement(D,null,t.createElement(R,{src:a||p}))):t.createElement(t.Fragment,null,t.createElement(S,null,t.createElement(P,{flex:r===exports.NPCDialogType.TextAndThumbnail?"70%":"100%"},t.createElement(h,{onStartStep:function(){return g(!1)},onEndStep:function(){return g(!0)},text:i||"No text provided.",onClose:function(){o&&o()}})),r===exports.NPCDialogType.TextAndThumbnail&&t.createElement(D,null,t.createElement(R,{src:a||p}))),x&&t.createElement(k,{right:r===exports.NPCDialogType.TextOnly?"1rem":"10.5rem",src:f})))},exports.QuestionDialog=v,exports.RPGUIContainer=d,exports.RPGUIRoot=function(e){return t.createElement("div",{className:"rpgui-content"},e.children)},exports.RangeSlider=function(e){var i=e.type,o=e.valueMin,a=e.valueMax,l=e.width,u=e.onChange,s=r.v4(),d=n.useState(!1),c=d[0],p=d[1];y("mouseup",(function(){c&&f(),p(!1)}));var f=function(){var e=document.getElementById("rpgui-slider-"+s),n=G.get_value(e);u(Number(n))};return t.createElement("div",{onMouseUp:f,onMouseDown:function(){return p(!0)}},t.createElement(Q,{className:i===exports.RangeSliderType.Slider?exports.RangeSliderType.Slider:exports.RangeSliderType.GoldSlider,type:"range",style:{width:l},min:o,max:a,id:"rpgui-slider-"+s}))},exports._RPGUI=G,exports.useEventListener=y;
|
|
2
2
|
//# sourceMappingURL=long-bow.cjs.production.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"long-bow.cjs.production.min.js","sources":["../src/RPGUI/RPGUIRoot.tsx","../src/components/ListMenu.tsx","../src/hooks/useEventListener.ts","../src/RPGUI/RPGUIContainer.tsx","../src/NPCDialog/img/npcDialog/npcThumbnails/alice.png","../src/NPCDialog/img/space.gif","../src/libs/StringHelpers.ts","../src/NPCDialog/NPCDialog.tsx","../src/typography/DynamicText.tsx","../src/NPCDialog/NPCDialogText.tsx","../src/NPCDialog/QuestionDialog/QuestionDialog.tsx","../src/RPGUI/RPGUISlider.tsx"],"sourcesContent":["import React from 'react';\nimport 'rpgui/rpgui.min.css';\nimport 'rpgui/rpgui.min.js';\n\ninterface IProps {\n children: React.ReactNode;\n}\n\n//@ts-ignore\nexport const _RPGUI = RPGUI;\n\nexport const RPGUIRoot: React.FC<IProps> = ({ children }) => {\n return <div className=\"rpgui-content\">{children}</div>;\n};\n","import React from 'react';\nimport styled from 'styled-components';\nimport { RPGUIRoot } from '../RPGUI/RPGUIRoot';\n\ninterface IListMenuOption {\n id: string;\n text: string;\n}\n\nexport interface IListMenuProps {\n x: number;\n y: number;\n options: IListMenuOption[];\n onSelected: (selectedOptionId: string) => void;\n}\n\nexport const ListMenu: React.FC<IListMenuProps> = ({\n options,\n onSelected,\n x,\n y,\n}) => {\n return (\n <RPGUIRoot>\n <Container x={x} y={y}>\n <ul className=\"rpgui-list-imp\" style={{ overflow: 'hidden' }}>\n {options.map((params) => (\n <ListElement\n key={params.text}\n onClick={() => {\n onSelected(params.id);\n }}\n >\n {params.text}\n </ListElement>\n ))}\n </ul>\n </Container>\n </RPGUIRoot>\n );\n};\n\ninterface IContainerProps {\n x?: number;\n y?: number;\n}\n\nconst Container = styled.div<IContainerProps>`\n display: flex;\n flex-direction: column;\n width: 100%;\n justify-content: start;\n align-items: flex-start;\n position: absolute;\n top: ${(props) => props.y || 0}px;\n left: ${(props) => props.x || 0}px;\n`;\n\nconst ListElement = styled.li`\n margin-right: 0.5rem;\n`;\n","import React from 'react';\n\n//@ts-ignore\nexport const useEventListener = (type, handler, el = window) => {\n const savedHandler = React.useRef();\n\n React.useEffect(() => {\n savedHandler.current = handler;\n }, [handler]);\n\n React.useEffect(() => {\n //@ts-ignore\n const listener = (e) => savedHandler.current(e);\n\n el.addEventListener(type, listener);\n\n return () => {\n el.removeEventListener(type, listener);\n };\n }, [type, el]);\n};\n","import React from 'react';\nimport styled from 'styled-components';\n\ninterface IProps {\n type: 'framed' | 'framed-golden' | 'framed-golden-2' | 'framed-grey';\n children: React.ReactNode;\n width?: string;\n height?: string;\n}\n\nexport const RPGUIContainer: React.FC<IProps> = ({\n children,\n type,\n width = '50%',\n height,\n}) => {\n return (\n <Container\n width={width}\n height={height || 'auto'}\n className={`rpgui-container ${type}`}\n >\n {children}\n </Container>\n );\n};\n\ninterface IContainerProps {\n width: string;\n height: string;\n}\n\nconst Container = styled.div<IContainerProps>`\n height: ${(props) => props.height};\n width: ${({ width }) => width};\n display: flex;\n flex-wrap: wrap;\n`;\n","const img = require('./alice.png'); export default img;","const img = require('./space.gif'); export default img;","export const chunkString = (str: string, length: number) => {\n return str.match(new RegExp('.{1,' + length + '}', 'g'));\n};\n","import React, { useState } from 'react';\nimport styled from 'styled-components';\nimport { IQuestionDialog, IQuestionDialogAnswer } from '..';\nimport { RPGUIContainer } from '../RPGUI/RPGUIContainer';\nimport { RPGUIRoot } from '../RPGUI/RPGUIRoot';\nimport aliceDefaultThumbnail from './img/npcDialog/npcThumbnails/alice.png';\nimport pressSpaceGif from './img/space.gif';\nimport { NPCDialogText } from './NPCDialogText';\nimport { QuestionDialog } from './QuestionDialog/QuestionDialog';\nexport enum NPCDialogType {\n TextOnly = 'TextOnly',\n TextAndThumbnail = 'TextAndThumbnail',\n}\n\nexport interface INPCDialogProps {\n text?: string;\n type: NPCDialogType;\n imagePath?: string;\n onClose?: () => void;\n isQuestionDialog: boolean;\n answers?: IQuestionDialogAnswer[];\n questions?: IQuestionDialog[];\n}\n\nexport const NPCDialog: React.FC<INPCDialogProps> = ({\n text,\n type,\n onClose,\n imagePath,\n isQuestionDialog = false,\n questions,\n answers,\n}) => {\n const [showGoNextIndicator, setShowGoNextIndicator] =\n useState<boolean>(false);\n\n return (\n <RPGUIRoot>\n <RPGUIContainer\n type=\"framed-golden\"\n width={isQuestionDialog ? '600px' : '50%'}\n height={'180px'}\n >\n {isQuestionDialog && questions && answers ? (\n <>\n <TextContainer\n flex={type === NPCDialogType.TextAndThumbnail ? '70%' : '100%'}\n >\n <QuestionDialog\n questions={questions}\n answers={answers}\n onClose={() => {\n if (onClose) {\n onClose();\n }\n }}\n />\n </TextContainer>\n {type === NPCDialogType.TextAndThumbnail && (\n <ThumbnailContainer>\n <NPCThumbnail src={imagePath || aliceDefaultThumbnail} />\n </ThumbnailContainer>\n )}\n </>\n ) : (\n <>\n <Container>\n <TextContainer\n flex={type === NPCDialogType.TextAndThumbnail ? '70%' : '100%'}\n >\n <NPCDialogText\n onStartStep={() => setShowGoNextIndicator(false)}\n onEndStep={() => setShowGoNextIndicator(true)}\n text={text || 'No text provided.'}\n onClose={() => {\n if (onClose) {\n onClose();\n }\n }}\n />\n </TextContainer>\n {type === NPCDialogType.TextAndThumbnail && (\n <ThumbnailContainer>\n <NPCThumbnail src={imagePath || aliceDefaultThumbnail} />\n </ThumbnailContainer>\n )}\n </Container>\n {showGoNextIndicator && (\n <PressSpaceIndicator\n right={type === NPCDialogType.TextOnly ? '1rem' : '10.5rem'}\n src={pressSpaceGif}\n />\n )}\n </>\n )}\n </RPGUIContainer>\n </RPGUIRoot>\n );\n};\n\nconst Container = styled.div`\n display: flex;\n width: 100%;\n height: 100%;\n\n box-sizing: border-box;\n justify-content: center;\n align-items: flex-start;\n position: relative;\n`;\n\ninterface ITextContainerProps {\n flex: string;\n}\n\nconst TextContainer = styled.div<ITextContainerProps>`\n flex: ${({ flex }) => flex} 0 0;\n width: 355px;\n`;\n\nconst ThumbnailContainer = styled.div`\n flex: 30% 0 0;\n display: flex;\n justify-content: flex-end;\n`;\n\nconst NPCThumbnail = styled.img`\n image-rendering: pixelated;\n height: 128px;\n width: 128px;\n`;\n\ninterface IPressSpaceIndicatorProps {\n right: string;\n}\n\nconst PressSpaceIndicator = styled.img<IPressSpaceIndicatorProps>`\n position: absolute;\n right: ${({ right }) => right};\n bottom: 1rem;\n height: 20.7px;\n image-rendering: -webkit-optimize-contrast;\n`;\n","import React, { useEffect, useState } from 'react';\nimport styled from 'styled-components';\n\ninterface IProps {\n text: string;\n onFinish?: () => void;\n onStart?: () => void;\n}\n\nexport const DynamicText: React.FC<IProps> = ({ text, onFinish, onStart }) => {\n const [textState, setTextState] = useState<string>('');\n\n useEffect(() => {\n let i = 0;\n const interval = setInterval(() => {\n // on every interval, show one more character\n\n if (i === 0) {\n if (onStart) {\n onStart();\n }\n }\n\n if (i < text.length) {\n setTextState(text.substring(0, i + 1));\n i++;\n } else {\n clearInterval(interval);\n if (onFinish) {\n onFinish();\n }\n }\n }, 50);\n\n return () => {\n clearInterval(interval);\n };\n }, [text]);\n\n return <TextContainer>{textState}</TextContainer>;\n};\n\nconst TextContainer = styled.p`\n font-size: 0.7rem !important;\n color: white;\n text-shadow: 1px 1px 0px #000000;\n letter-spacing: 1.2px;\n word-break: normal;\n`;\n","import React, { useEffect, useState } from 'react';\nimport styled from 'styled-components';\nimport { chunkString } from '../libs/StringHelpers';\nimport { DynamicText } from '../typography/DynamicText';\n\ninterface IProps {\n text: string;\n onClose: () => void;\n onEndStep: () => void;\n onStartStep: () => void;\n}\n\nexport const NPCDialogText: React.FC<IProps> = ({\n text,\n onClose,\n onEndStep,\n onStartStep,\n}) => {\n const textChunks = chunkString(text, 85);\n\n const [chunkIndex, setChunkIndex] = useState<number>(0);\n\n const onHandleSpacePress = (event: KeyboardEvent) => {\n if (event.code === 'Space') {\n const hasNextChunk = textChunks?.[chunkIndex + 1] || false;\n\n if (hasNextChunk) {\n setChunkIndex((prev) => prev + 1);\n } else {\n // if there's no more text chunks, close the dialog\n onClose();\n }\n }\n };\n\n useEffect(() => {\n document.addEventListener('keydown', onHandleSpacePress);\n\n return () => document.removeEventListener('keydown', onHandleSpacePress);\n }, [chunkIndex]);\n\n return (\n <Container>\n <DynamicText\n text={textChunks?.[chunkIndex] || ''}\n onFinish={onEndStep}\n onStart={onStartStep}\n />\n </Container>\n );\n};\n\nconst Container = styled.div``;\n","import React, { useEffect, useState } from 'react';\nimport styled from 'styled-components';\nimport { useEventListener } from '../../hooks/useEventListener';\nimport { DynamicText } from '../../typography/DynamicText';\n\nexport interface IQuestionDialogAnswer {\n id: number;\n text: string;\n nextQuestionId?: number;\n}\n\nexport interface IQuestionDialog {\n id: number;\n text: string;\n answerIds?: number[];\n}\n\nexport interface IProps {\n questions: IQuestionDialog[];\n answers: IQuestionDialogAnswer[];\n onClose: () => void;\n}\n\nexport const QuestionDialog: React.FC<IProps> = ({\n questions,\n answers,\n onClose,\n}) => {\n const [currentQuestion, setCurrentQuestion] = useState(questions[0]);\n\n const [canShowAnswers, setCanShowAnswers] = useState<boolean>(false);\n\n const onGetFirstAnswer = () => {\n if (!currentQuestion.answerIds || currentQuestion.answerIds.length === 0) {\n return null;\n }\n\n const firstAnswerId = currentQuestion.answerIds![0];\n\n return answers.find((answer) => answer.id === firstAnswerId);\n };\n\n const [currentAnswer, setCurrentAnswer] =\n useState<IQuestionDialogAnswer | null>(onGetFirstAnswer()!);\n\n useEffect(() => {\n setCurrentAnswer(onGetFirstAnswer()!);\n }, [currentQuestion]);\n\n const onGetAnswers = (answerIds: number[]) => {\n return answerIds.map((answerId: number) =>\n answers.find((answer) => answer.id === answerId)\n );\n };\n\n const onKeyPress = (e: KeyboardEvent) => {\n switch (e.key) {\n case 'ArrowDown':\n // select next answer, if any.\n // if no next answer, select first answer\n // const nextAnswer = onGetAnswers(currentQuestion.answerIds!).find(\n // (answer) => answer?.id === currentAnswer!.id + 1\n // );\n\n const nextAnswerIndex = onGetAnswers(\n currentQuestion.answerIds!\n ).findIndex((answer) => answer?.id === currentAnswer!.id + 1);\n\n const nextAnswerID = currentQuestion.answerIds![nextAnswerIndex];\n\n // console.log(nextAnswerIndex);\n\n const nextAnswer = onGetAnswers(currentQuestion.answerIds!).find(\n (answer) => answer?.id === nextAnswerID\n );\n\n setCurrentAnswer(nextAnswer || onGetFirstAnswer()!);\n\n break;\n case 'ArrowUp':\n // select previous answer, if any.\n // if no previous answer, select last answer\n\n const previousAnswerIndex = onGetAnswers(\n currentQuestion.answerIds!\n ).findIndex((answer) => answer?.id === currentAnswer!.id - 1);\n\n const previousAnswerID =\n currentQuestion.answerIds &&\n currentQuestion.answerIds[previousAnswerIndex];\n\n const previousAnswer = onGetAnswers(currentQuestion.answerIds!).find(\n (answer) => answer?.id === previousAnswerID\n );\n\n if (previousAnswer) {\n setCurrentAnswer(previousAnswer);\n } else {\n setCurrentAnswer(onGetAnswers(currentQuestion.answerIds!).pop()!);\n }\n\n break;\n case 'Enter':\n setCanShowAnswers(false);\n\n if (!currentAnswer?.nextQuestionId) {\n onClose();\n return;\n } else {\n setCurrentQuestion(\n questions.find(\n (question) => question.id === currentAnswer!.nextQuestionId\n )!\n );\n }\n\n break;\n }\n };\n useEventListener('keydown', onKeyPress);\n\n const onAnswerClick = (answer: IQuestionDialogAnswer) => {\n setCanShowAnswers(false);\n if (answer.nextQuestionId) {\n // if there is a next question, go to it\n setCurrentQuestion(\n questions.find((question) => question.id === answer.nextQuestionId)!\n );\n } else {\n // else, finish dialog!\n onClose();\n }\n };\n\n const onRenderCurrentAnswers = () => {\n const answerIds = currentQuestion.answerIds;\n if (!answerIds) {\n return null;\n }\n\n const answers = onGetAnswers(answerIds);\n\n if (!answers) {\n return null;\n }\n\n return answers.map((answer) => {\n const isSelected = currentAnswer?.id === answer?.id;\n const selectedColor = isSelected ? 'yellow' : 'white';\n\n if (answer) {\n return (\n <AnswerRow key={`answer_${answer.id}`}>\n <AnswerSelectedIcon color={selectedColor}>\n {isSelected ? 'X' : null}\n </AnswerSelectedIcon>\n\n <Answer\n key={answer.id}\n onClick={() => onAnswerClick(answer)}\n color={selectedColor}\n >\n {answer.text}\n </Answer>\n </AnswerRow>\n );\n }\n\n return null;\n });\n };\n\n return (\n <Container>\n <QuestionContainer>\n <DynamicText\n text={currentQuestion.text}\n onStart={() => setCanShowAnswers(false)}\n onFinish={() => setCanShowAnswers(true)}\n />\n </QuestionContainer>\n\n {canShowAnswers && (\n <AnswersContainer>{onRenderCurrentAnswers()}</AnswersContainer>\n )}\n </Container>\n );\n};\n\nconst Container = styled.div`\n display: flex;\n\n word-break: break-all;\n\n box-sizing: border-box;\n justify-content: flex-start;\n align-items: flex-start;\n flex-wrap: wrap;\n`;\n\nconst QuestionContainer = styled.div`\n flex: 100%;\n width: 100%;\n`;\n\nconst AnswersContainer = styled.div`\n flex: 100%;\n`;\n\ninterface IAnswerProps {\n color: string;\n}\n\nconst Answer = styled.p<IAnswerProps>`\n flex: auto;\n color: ${(props) => props.color} !important;\n font-size: 0.65rem !important;\n background: inherit;\n border: none;\n`;\n\nconst AnswerSelectedIcon = styled.span<IAnswerProps>`\n flex: 5% 0 0;\n color: ${(props) => props.color} !important;\n`;\n\nconst AnswerRow = styled.div`\n display: flex;\n flex-wrap: wrap;\n justify-content: center;\n align-items: center;\n margin-bottom: 0.5rem;\n height: 22px;\n\n p {\n line-height: unset;\n margin-top: 0;\n margin-bottom: 0rem;\n }\n`;\n","import React, { useState } from 'react';\nimport styled from 'styled-components';\nimport { v4 as uuidv4 } from 'uuid';\nimport { useEventListener } from '../hooks/useEventListener';\nimport { RPGUIRoot, _RPGUI } from './RPGUIRoot';\n\nexport enum SliderType {\n Slider = 'rpgui-slider',\n GoldSlider = 'rpgui-slider golden',\n}\n\nexport interface ISliderProps {\n type: SliderType;\n valueMin: number;\n valueMax: number;\n width: string;\n\n onChange: (value: number) => void;\n}\n\nexport const RPGUISlider: React.FC<ISliderProps> = ({\n type,\n valueMin,\n valueMax,\n width,\n onChange,\n}) => {\n const sliderId = uuidv4();\n\n const [wasMouseDownFirst, setWasMouseDownFirst] = useState<boolean>(false);\n\n useEventListener('mouseup', () => {\n if (wasMouseDownFirst) {\n onHandleMouseUp();\n }\n setWasMouseDownFirst(false);\n });\n\n const onHandleMouseUp = () => {\n const rpguiSlider = document.getElementById(`rpgui-slider-${sliderId}`);\n const value = _RPGUI.get_value(rpguiSlider);\n\n onChange(Number(value));\n };\n\n return (\n <RPGUIRoot>\n <div\n onMouseUp={onHandleMouseUp}\n onMouseDown={() => setWasMouseDownFirst(true)}\n >\n <Input\n className={\n type === SliderType.Slider\n ? SliderType.Slider\n : SliderType.GoldSlider\n }\n type=\"range\"\n style={{ width: width }}\n min={valueMin}\n max={valueMax}\n id={`rpgui-slider-${sliderId}`}\n />\n </div>\n </RPGUIRoot>\n );\n};\n\nconst Input = styled.input`\n opacity: 0;\n`;\n"],"names":["_RPGUI","RPGUI","RPGUIRoot","React","className","children","Container","styled","div","props","y","x","ListElement","li","useEventListener","type","handler","el","window","savedHandler","useRef","useEffect","current","listener","e","addEventListener","removeEventListener","RPGUIContainer","width","height","img","require","NPCDialogType","DynamicText","text","onFinish","onStart","useState","textState","setTextState","i","interval","setInterval","length","substring","clearInterval","TextContainer","p","NPCDialogText","onClose","onEndStep","onStartStep","textChunks","match","RegExp","chunkIndex","setChunkIndex","onHandleSpacePress","event","code","prev","document","QuestionDialog","questions","answers","currentQuestion","setCurrentQuestion","canShowAnswers","setCanShowAnswers","onGetFirstAnswer","answerIds","firstAnswerId","find","answer","id","currentAnswer","setCurrentAnswer","onGetAnswers","map","answerId","key","nextAnswerIndex","findIndex","nextAnswerID","nextAnswer","previousAnswerIndex","previousAnswerID","previousAnswer","pop","nextQuestionId","question","QuestionContainer","AnswersContainer","isSelected","selectedColor","AnswerRow","AnswerSelectedIcon","color","Answer","onClick","onAnswerClick","onRenderCurrentAnswers","span","SliderType","flex","ThumbnailContainer","NPCThumbnail","PressSpaceIndicator","right","Input","input","onSelected","style","overflow","options","params","imagePath","isQuestionDialog","showGoNextIndicator","setShowGoNextIndicator","TextAndThumbnail","src","aliceDefaultThumbnail","TextOnly","pressSpaceGif","valueMin","valueMax","onChange","sliderId","uuidv4","wasMouseDownFirst","setWasMouseDownFirst","onHandleMouseUp","rpguiSlider","getElementById","value","get_value","Number","onMouseUp","onMouseDown","Slider","GoldSlider","min","max"],"mappings":"6RASaA,EAASC,MAETC,EAA8B,mBAClCC,uBAAKC,UAAU,mBADsBC,WCoCxCC,EAAYC,EAAOC,6EAAPD,yIAOT,SAACE,UAAUA,EAAMC,GAAK,KACrB,SAACD,UAAUA,EAAME,GAAK,KAG1BC,EAAc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7G,IAAAA,KACA8G,IAAAA,SACAC,IAAAA,SACAlG,IAAAA,MACAmG,IAAAA,SAEMC,EAAWC,SAEiC5F,YAAkB,GAA7D6F,OAAmBC,OAE1BrH,EAAiB,WAAW,WACtBoH,GACFE,IAEFD,GAAqB,UAGjBC,EAAkB,eAChBC,EAAcxE,SAASyE,+BAA+BN,GACtDO,EAAQvI,EAAOwI,UAAUH,GAE/BN,EAASU,OAAOF,YAIhBpI,gBAACD,OACCC,uBACEuI,UAAWN,EACXO,YAAa,kBAAMR,GAAqB,KAExChI,gBAAC0G,GACCzG,UACEW,IAASwF,mBAAWqC,OAChBrC,mBAAWqC,OACXrC,mBAAWsC,WAEjB9H,KAAK,QACLiG,MAAO,CAAEpF,MAAOA,GAChBkH,IAAKjB,EACLkB,IAAKjB,EACLpD,mBAAoBsD"}
|
|
1
|
+
{"version":3,"file":"long-bow.cjs.production.min.js","sources":["../src/components/Button.tsx","../src/components/RPGUIContainer.tsx","../src/components/ListMenu.tsx","../src/components/NPCDialog/img/npcDialog/npcThumbnails/alice.png","../src/components/NPCDialog/img/space.gif","../src/libs/StringHelpers.ts","../src/components/NPCDialog/NPCDialog.tsx","../src/components/typography/DynamicText.tsx","../src/components/NPCDialog/NPCDialogText.tsx","../src/hooks/useEventListener.ts","../src/components/NPCDialog/QuestionDialog/QuestionDialog.tsx","../src/components/RangeSlider.tsx","../src/components/RPGUIRoot.tsx"],"sourcesContent":["import React from 'react';\n\nexport enum IButtonTypes {\n RPGUIButton = 'rpgui-button',\n RPGUIGoldButton = 'rpgui-button golden',\n}\n\nexport interface IButtonsProps {\n children: React.ReactNode;\n type: IButtonTypes;\n}\n\nexport const Button: React.FC<IButtonsProps> = ({\n children,\n type,\n ...props\n}) => {\n return (\n <button className={type} type=\"button\" {...props}>\n <p>{children}</p>\n </button>\n );\n};\n","import React from 'react';\nimport styled from 'styled-components';\n\nexport enum RPGUIContainerTypes {\n Framed = 'framed',\n FramedGold = 'framed-golden',\n FramedGold2 = 'framed-golden-2',\n FramedGrey = 'framed-grey',\n}\nexport interface IRPGUIContainerProps {\n type: RPGUIContainerTypes;\n children: React.ReactNode;\n width?: string;\n height?: string;\n}\n\nexport const RPGUIContainer: React.FC<IRPGUIContainerProps> = ({\n children,\n type,\n width = '50%',\n height,\n}) => {\n return (\n <Container\n width={width}\n height={height || 'auto'}\n className={`rpgui-container ${type}`}\n >\n {children}\n </Container>\n );\n};\n\ninterface IContainerProps {\n width: string;\n height: string;\n}\n\nconst Container = styled.div<IContainerProps>`\n height: ${(props) => props.height};\n width: ${({ width }) => width};\n display: flex;\n flex-wrap: wrap;\n image-rendering: pixelated;\n`;\n","import React from 'react';\nimport styled from 'styled-components';\n\ninterface IListMenuOption {\n id: string;\n text: string;\n}\n\nexport interface IListMenuProps {\n x: number;\n y: number;\n options: IListMenuOption[];\n onSelected: (selectedOptionId: string) => void;\n fontSize?: number;\n}\n\nexport const ListMenu: React.FC<IListMenuProps> = ({\n options,\n onSelected,\n x,\n y,\n fontSize = 0.8,\n}) => {\n return (\n <Container x={x} y={y} fontSize={fontSize}>\n <ul className=\"rpgui-list-imp\" style={{ overflow: 'hidden' }}>\n {options.map((params) => (\n <ListElement\n key={params.text}\n onClick={() => {\n onSelected(params.id);\n }}\n >\n {params.text}\n </ListElement>\n ))}\n </ul>\n </Container>\n );\n};\n\ninterface IContainerProps {\n x?: number;\n y?: number;\n fontSize?: number;\n}\n\nconst Container = styled.div<IContainerProps>`\n display: flex;\n flex-direction: column;\n width: 100%;\n justify-content: start;\n align-items: flex-start;\n position: absolute;\n top: ${(props) => props.y || 0}px;\n left: ${(props) => props.x || 0}px;\n\n li {\n font-size: ${(props) => props.fontSize}em;\n }\n`;\n\nconst ListElement = styled.li`\n margin-right: 0.5rem;\n`;\n","const img = require('./alice.png'); export default img;","const img = require('./space.gif'); export default img;","export const chunkString = (str: string, length: number) => {\n return str.match(new RegExp('.{1,' + length + '}', 'g'));\n};\n","import React, { useState } from 'react';\nimport styled from 'styled-components';\nimport { RPGUIContainer, RPGUIContainerTypes } from '../RPGUIContainer';\nimport aliceDefaultThumbnail from './img/npcDialog/npcThumbnails/alice.png';\nimport pressSpaceGif from './img/space.gif';\nimport { NPCDialogText } from './NPCDialogText';\nimport {\n IQuestionDialog,\n IQuestionDialogAnswer,\n QuestionDialog,\n} from './QuestionDialog/QuestionDialog';\n\nexport enum NPCDialogType {\n TextOnly = 'TextOnly',\n TextAndThumbnail = 'TextAndThumbnail',\n}\n\nexport interface INPCDialogProps {\n text?: string;\n type: NPCDialogType;\n imagePath?: string;\n onClose?: () => void;\n isQuestionDialog?: boolean;\n answers?: IQuestionDialogAnswer[];\n questions?: IQuestionDialog[];\n}\n\nexport const NPCDialog: React.FC<INPCDialogProps> = ({\n text,\n type,\n onClose,\n imagePath,\n isQuestionDialog = false,\n questions,\n answers,\n}) => {\n const [showGoNextIndicator, setShowGoNextIndicator] =\n useState<boolean>(false);\n\n return (\n <RPGUIContainer\n type={RPGUIContainerTypes.FramedGold}\n width={isQuestionDialog ? '600px' : '50%'}\n height={'180px'}\n >\n {isQuestionDialog && questions && answers ? (\n <>\n <TextContainer\n flex={type === NPCDialogType.TextAndThumbnail ? '70%' : '100%'}\n >\n <QuestionDialog\n questions={questions}\n answers={answers}\n onClose={() => {\n if (onClose) {\n onClose();\n }\n }}\n />\n </TextContainer>\n {type === NPCDialogType.TextAndThumbnail && (\n <ThumbnailContainer>\n <NPCThumbnail src={imagePath || aliceDefaultThumbnail} />\n </ThumbnailContainer>\n )}\n </>\n ) : (\n <>\n <Container>\n <TextContainer\n flex={type === NPCDialogType.TextAndThumbnail ? '70%' : '100%'}\n >\n <NPCDialogText\n onStartStep={() => setShowGoNextIndicator(false)}\n onEndStep={() => setShowGoNextIndicator(true)}\n text={text || 'No text provided.'}\n onClose={() => {\n if (onClose) {\n onClose();\n }\n }}\n />\n </TextContainer>\n {type === NPCDialogType.TextAndThumbnail && (\n <ThumbnailContainer>\n <NPCThumbnail src={imagePath || aliceDefaultThumbnail} />\n </ThumbnailContainer>\n )}\n </Container>\n {showGoNextIndicator && (\n <PressSpaceIndicator\n right={type === NPCDialogType.TextOnly ? '1rem' : '10.5rem'}\n src={pressSpaceGif}\n />\n )}\n </>\n )}\n </RPGUIContainer>\n );\n};\n\nconst Container = styled.div`\n display: flex;\n width: 100%;\n height: 100%;\n\n box-sizing: border-box;\n justify-content: center;\n align-items: flex-start;\n position: relative;\n`;\n\ninterface ITextContainerProps {\n flex: string;\n}\n\nconst TextContainer = styled.div<ITextContainerProps>`\n flex: ${({ flex }) => flex} 0 0;\n width: 355px;\n`;\n\nconst ThumbnailContainer = styled.div`\n flex: 30% 0 0;\n display: flex;\n justify-content: flex-end;\n`;\n\nconst NPCThumbnail = styled.img`\n image-rendering: pixelated;\n height: 128px;\n width: 128px;\n`;\n\ninterface IPressSpaceIndicatorProps {\n right: string;\n}\n\nconst PressSpaceIndicator = styled.img<IPressSpaceIndicatorProps>`\n position: absolute;\n right: ${({ right }) => right};\n bottom: 1rem;\n height: 20.7px;\n image-rendering: -webkit-optimize-contrast;\n`;\n","import React, { useEffect, useState } from 'react';\nimport styled from 'styled-components';\n\ninterface IProps {\n text: string;\n onFinish?: () => void;\n onStart?: () => void;\n}\n\nexport const DynamicText: React.FC<IProps> = ({ text, onFinish, onStart }) => {\n const [textState, setTextState] = useState<string>('');\n\n useEffect(() => {\n let i = 0;\n const interval = setInterval(() => {\n // on every interval, show one more character\n\n if (i === 0) {\n if (onStart) {\n onStart();\n }\n }\n\n if (i < text.length) {\n setTextState(text.substring(0, i + 1));\n i++;\n } else {\n clearInterval(interval);\n if (onFinish) {\n onFinish();\n }\n }\n }, 50);\n\n return () => {\n clearInterval(interval);\n };\n }, [text]);\n\n return <TextContainer>{textState}</TextContainer>;\n};\n\nconst TextContainer = styled.p`\n font-size: 0.7rem !important;\n color: white;\n text-shadow: 1px 1px 0px #000000;\n letter-spacing: 1.2px;\n word-break: normal;\n`;\n","import React, { useEffect, useState } from 'react';\nimport styled from 'styled-components';\nimport { chunkString } from '../../libs/StringHelpers';\nimport { DynamicText } from '../typography/DynamicText';\n\ninterface IProps {\n text: string;\n onClose: () => void;\n onEndStep: () => void;\n onStartStep: () => void;\n}\n\nexport const NPCDialogText: React.FC<IProps> = ({\n text,\n onClose,\n onEndStep,\n onStartStep,\n}) => {\n const textChunks = chunkString(text, 85);\n\n const [chunkIndex, setChunkIndex] = useState<number>(0);\n\n const onHandleSpacePress = (event: KeyboardEvent) => {\n if (event.code === 'Space') {\n const hasNextChunk = textChunks?.[chunkIndex + 1] || false;\n\n if (hasNextChunk) {\n setChunkIndex((prev) => prev + 1);\n } else {\n // if there's no more text chunks, close the dialog\n onClose();\n }\n }\n };\n\n useEffect(() => {\n document.addEventListener('keydown', onHandleSpacePress);\n\n return () => document.removeEventListener('keydown', onHandleSpacePress);\n }, [chunkIndex]);\n\n return (\n <Container>\n <DynamicText\n text={textChunks?.[chunkIndex] || ''}\n onFinish={onEndStep}\n onStart={onStartStep}\n />\n </Container>\n );\n};\n\nconst Container = styled.div``;\n","import React from 'react';\n\n//@ts-ignore\nexport const useEventListener = (type, handler, el = window) => {\n const savedHandler = React.useRef();\n\n React.useEffect(() => {\n savedHandler.current = handler;\n }, [handler]);\n\n React.useEffect(() => {\n //@ts-ignore\n const listener = (e) => savedHandler.current(e);\n\n el.addEventListener(type, listener);\n\n return () => {\n el.removeEventListener(type, listener);\n };\n }, [type, el]);\n};\n","import React, { useEffect, useState } from 'react';\nimport styled from 'styled-components';\nimport { useEventListener } from '../../../hooks/useEventListener';\nimport { DynamicText } from '../../typography/DynamicText';\n\nexport interface IQuestionDialogAnswer {\n id: number;\n text: string;\n nextQuestionId?: number;\n}\n\nexport interface IQuestionDialog {\n id: number;\n text: string;\n answerIds?: number[];\n}\n\nexport interface IProps {\n questions: IQuestionDialog[];\n answers: IQuestionDialogAnswer[];\n onClose: () => void;\n}\n\nexport const QuestionDialog: React.FC<IProps> = ({\n questions,\n answers,\n onClose,\n}) => {\n const [currentQuestion, setCurrentQuestion] = useState(questions[0]);\n\n const [canShowAnswers, setCanShowAnswers] = useState<boolean>(false);\n\n const onGetFirstAnswer = () => {\n if (!currentQuestion.answerIds || currentQuestion.answerIds.length === 0) {\n return null;\n }\n\n const firstAnswerId = currentQuestion.answerIds![0];\n\n return answers.find((answer) => answer.id === firstAnswerId);\n };\n\n const [currentAnswer, setCurrentAnswer] =\n useState<IQuestionDialogAnswer | null>(onGetFirstAnswer()!);\n\n useEffect(() => {\n setCurrentAnswer(onGetFirstAnswer()!);\n }, [currentQuestion]);\n\n const onGetAnswers = (answerIds: number[]) => {\n return answerIds.map((answerId: number) =>\n answers.find((answer) => answer.id === answerId)\n );\n };\n\n const onKeyPress = (e: KeyboardEvent) => {\n switch (e.key) {\n case 'ArrowDown':\n // select next answer, if any.\n // if no next answer, select first answer\n // const nextAnswer = onGetAnswers(currentQuestion.answerIds!).find(\n // (answer) => answer?.id === currentAnswer!.id + 1\n // );\n\n const nextAnswerIndex = onGetAnswers(\n currentQuestion.answerIds!\n ).findIndex((answer) => answer?.id === currentAnswer!.id + 1);\n\n const nextAnswerID = currentQuestion.answerIds![nextAnswerIndex];\n\n // console.log(nextAnswerIndex);\n\n const nextAnswer = onGetAnswers(currentQuestion.answerIds!).find(\n (answer) => answer?.id === nextAnswerID\n );\n\n setCurrentAnswer(nextAnswer || onGetFirstAnswer()!);\n\n break;\n case 'ArrowUp':\n // select previous answer, if any.\n // if no previous answer, select last answer\n\n const previousAnswerIndex = onGetAnswers(\n currentQuestion.answerIds!\n ).findIndex((answer) => answer?.id === currentAnswer!.id - 1);\n\n const previousAnswerID =\n currentQuestion.answerIds &&\n currentQuestion.answerIds[previousAnswerIndex];\n\n const previousAnswer = onGetAnswers(currentQuestion.answerIds!).find(\n (answer) => answer?.id === previousAnswerID\n );\n\n if (previousAnswer) {\n setCurrentAnswer(previousAnswer);\n } else {\n setCurrentAnswer(onGetAnswers(currentQuestion.answerIds!).pop()!);\n }\n\n break;\n case 'Enter':\n setCanShowAnswers(false);\n\n if (!currentAnswer?.nextQuestionId) {\n onClose();\n return;\n } else {\n setCurrentQuestion(\n questions.find(\n (question) => question.id === currentAnswer!.nextQuestionId\n )!\n );\n }\n\n break;\n }\n };\n useEventListener('keydown', onKeyPress);\n\n const onAnswerClick = (answer: IQuestionDialogAnswer) => {\n setCanShowAnswers(false);\n if (answer.nextQuestionId) {\n // if there is a next question, go to it\n setCurrentQuestion(\n questions.find((question) => question.id === answer.nextQuestionId)!\n );\n } else {\n // else, finish dialog!\n onClose();\n }\n };\n\n const onRenderCurrentAnswers = () => {\n const answerIds = currentQuestion.answerIds;\n if (!answerIds) {\n return null;\n }\n\n const answers = onGetAnswers(answerIds);\n\n if (!answers) {\n return null;\n }\n\n return answers.map((answer) => {\n const isSelected = currentAnswer?.id === answer?.id;\n const selectedColor = isSelected ? 'yellow' : 'white';\n\n if (answer) {\n return (\n <AnswerRow key={`answer_${answer.id}`}>\n <AnswerSelectedIcon color={selectedColor}>\n {isSelected ? 'X' : null}\n </AnswerSelectedIcon>\n\n <Answer\n key={answer.id}\n onClick={() => onAnswerClick(answer)}\n color={selectedColor}\n >\n {answer.text}\n </Answer>\n </AnswerRow>\n );\n }\n\n return null;\n });\n };\n\n return (\n <Container>\n <QuestionContainer>\n <DynamicText\n text={currentQuestion.text}\n onStart={() => setCanShowAnswers(false)}\n onFinish={() => setCanShowAnswers(true)}\n />\n </QuestionContainer>\n\n {canShowAnswers && (\n <AnswersContainer>{onRenderCurrentAnswers()}</AnswersContainer>\n )}\n </Container>\n );\n};\n\nconst Container = styled.div`\n display: flex;\n\n word-break: break-all;\n\n box-sizing: border-box;\n justify-content: flex-start;\n align-items: flex-start;\n flex-wrap: wrap;\n`;\n\nconst QuestionContainer = styled.div`\n flex: 100%;\n width: 100%;\n`;\n\nconst AnswersContainer = styled.div`\n flex: 100%;\n`;\n\ninterface IAnswerProps {\n color: string;\n}\n\nconst Answer = styled.p<IAnswerProps>`\n flex: auto;\n color: ${(props) => props.color} !important;\n font-size: 0.65rem !important;\n background: inherit;\n border: none;\n`;\n\nconst AnswerSelectedIcon = styled.span<IAnswerProps>`\n flex: 5% 0 0;\n color: ${(props) => props.color} !important;\n`;\n\nconst AnswerRow = styled.div`\n display: flex;\n flex-wrap: wrap;\n justify-content: center;\n align-items: center;\n margin-bottom: 0.5rem;\n height: 22px;\n\n p {\n line-height: unset;\n margin-top: 0;\n margin-bottom: 0rem;\n }\n`;\n","import React, { useState } from 'react';\nimport styled from 'styled-components';\nimport { v4 as uuidv4 } from 'uuid';\nimport { useEventListener } from '../hooks/useEventListener';\nimport { _RPGUI } from './RPGUIRoot';\n\nexport enum RangeSliderType {\n Slider = 'rpgui-slider',\n GoldSlider = 'rpgui-slider golden',\n}\n\nexport interface IRangeSliderProps {\n type: RangeSliderType;\n valueMin: number;\n valueMax: number;\n width: string;\n onChange: (value: number) => void;\n}\n\nexport const RangeSlider: React.FC<IRangeSliderProps> = ({\n type,\n valueMin,\n valueMax,\n width,\n onChange,\n}) => {\n const sliderId = uuidv4();\n\n const [wasMouseDownFirst, setWasMouseDownFirst] = useState<boolean>(false);\n\n useEventListener('mouseup', () => {\n if (wasMouseDownFirst) {\n onHandleMouseUp();\n }\n setWasMouseDownFirst(false);\n });\n\n const onHandleMouseUp = () => {\n const rpguiSlider = document.getElementById(`rpgui-slider-${sliderId}`);\n const value = _RPGUI.get_value(rpguiSlider);\n\n onChange(Number(value));\n };\n\n return (\n <div\n onMouseUp={onHandleMouseUp}\n onMouseDown={() => setWasMouseDownFirst(true)}\n >\n <Input\n className={\n type === RangeSliderType.Slider\n ? RangeSliderType.Slider\n : RangeSliderType.GoldSlider\n }\n type=\"range\"\n style={{ width: width }}\n min={valueMin}\n max={valueMax}\n id={`rpgui-slider-${sliderId}`}\n />\n </div>\n );\n};\n\nconst Input = styled.input`\n opacity: 0;\n`;\n","import React from 'react';\nimport 'rpgui/rpgui.min.css';\nimport 'rpgui/rpgui.min.js';\n\ninterface IProps {\n children: React.ReactNode;\n}\n\n//@ts-ignore\nexport const _RPGUI = RPGUI;\n\nexport const RPGUIRoot: React.FC<IProps> = ({ children }) => {\n return <div className=\"rpgui-content\">{children}</div>;\n};\n"],"names":["IButtonTypes","RPGUIContainerTypes","Container","styled","div","props","y","x","fontSize","ListElement","li","RPGUIContainer","width","React","height","className","type","children","img","require","NPCDialogType","DynamicText","text","onFinish","onStart","useState","textState","setTextState","useEffect","i","interval","setInterval","length","substring","clearInterval","TextContainer","p","NPCDialogText","onClose","onEndStep","onStartStep","textChunks","match","RegExp","chunkIndex","setChunkIndex","onHandleSpacePress","event","code","prev","document","addEventListener","removeEventListener","useEventListener","handler","el","window","savedHandler","useRef","current","listener","e","QuestionDialog","questions","answers","currentQuestion","setCurrentQuestion","canShowAnswers","setCanShowAnswers","onGetFirstAnswer","answerIds","firstAnswerId","find","answer","id","currentAnswer","setCurrentAnswer","onGetAnswers","map","answerId","key","nextAnswerIndex","findIndex","nextAnswerID","nextAnswer","previousAnswerIndex","previousAnswerID","previousAnswer","pop","nextQuestionId","question","QuestionContainer","AnswersContainer","isSelected","selectedColor","AnswerRow","AnswerSelectedIcon","color","Answer","onClick","onAnswerClick","onRenderCurrentAnswers","span","RangeSliderType","flex","ThumbnailContainer","NPCThumbnail","PressSpaceIndicator","right","_RPGUI","RPGUI","Input","input","onSelected","style","overflow","options","params","imagePath","isQuestionDialog","showGoNextIndicator","setShowGoNextIndicator","FramedGold","TextAndThumbnail","src","aliceDefaultThumbnail","TextOnly","pressSpaceGif","valueMin","valueMax","onChange","sliderId","uuidv4","wasMouseDownFirst","setWasMouseDownFirst","onHandleMouseUp","rpguiSlider","getElementById","value","get_value","Number","onMouseUp","onMouseDown","Slider","GoldSlider","min","max"],"mappings":"6RAEYA,yBAAAA,EAAAA,uBAAAA,qDAEVA,4CCDUC,EC4CNC,EAAYC,EAAOC,6EAAPD,6JAOT,SAACE,UAAUA,EAAMC,GAAK,KACrB,SAACD,UAAUA,EAAME,GAAK,KAGf,SAACF,UAA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HA,GACFA,QAKPtB,IAASI,sBAAcuG,kBACtB9G,gBAAC4F,OACC5F,gBAAC6F,GAAakB,IAAKN,GAAaO,MAIrCL,GACC3G,gBAAC8F,GACCC,MAAO5F,IAASI,sBAAc0G,SAAW,OAAS,UAClDF,IAAKG,2EMjFwB,mBAClClH,uBAAKE,UAAU,mBADsBE,+BDQU,gBACtDD,IAAAA,KACAgH,IAAAA,SACAC,IAAAA,SACArH,IAAAA,MACAsH,IAAAA,SAEMC,EAAWC,SAEiC3G,YAAkB,GAA7D4G,OAAmBC,OAE1BjF,EAAiB,WAAW,WACtBgF,GACFE,IAEFD,GAAqB,UAGjBC,EAAkB,eAChBC,EAActF,SAASuF,+BAA+BN,GACtDO,EAAQ7B,EAAO8B,UAAUH,GAE/BN,EAASU,OAAOF,YAIhB7H,uBACEgI,UAAWN,EACXO,YAAa,kBAAMR,GAAqB,KAExCzH,gBAACkG,GACChG,UACEC,IAASuF,wBAAgBwC,OACrBxC,wBAAgBwC,OAChBxC,wBAAgByC,WAEtBhI,KAAK,QACLkG,MAAO,CAAEtG,MAAOA,GAChBqI,IAAKjB,EACLkB,IAAKjB,EACLvD,mBAAoByD"}
|
package/dist/long-bow.esm.js
CHANGED
|
@@ -1,25 +1,54 @@
|
|
|
1
1
|
import React, { useState, useEffect } from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
|
+
import { v4 } from 'uuid';
|
|
3
4
|
import 'rpgui/rpgui.min.css';
|
|
4
5
|
import 'rpgui/rpgui.min.js';
|
|
5
|
-
import { v4 } from 'uuid';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
8
|
+
if (source == null) return {};
|
|
9
|
+
var target = {};
|
|
10
|
+
var sourceKeys = Object.keys(source);
|
|
11
|
+
var key, i;
|
|
12
|
+
|
|
13
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
14
|
+
key = sourceKeys[i];
|
|
15
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
16
|
+
target[key] = source[key];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return target;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
var _excluded = ["children", "type"];
|
|
23
|
+
var IButtonTypes;
|
|
24
|
+
|
|
25
|
+
(function (IButtonTypes) {
|
|
26
|
+
IButtonTypes["RPGUIButton"] = "rpgui-button";
|
|
27
|
+
IButtonTypes["RPGUIGoldButton"] = "rpgui-button golden";
|
|
28
|
+
})(IButtonTypes || (IButtonTypes = {}));
|
|
29
|
+
|
|
30
|
+
var Button = function Button(_ref) {
|
|
31
|
+
var children = _ref.children,
|
|
32
|
+
type = _ref.type,
|
|
33
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
34
|
+
|
|
35
|
+
return React.createElement("button", Object.assign({
|
|
36
|
+
className: type,
|
|
37
|
+
type: "button"
|
|
38
|
+
}, props), React.createElement("p", null, children));
|
|
13
39
|
};
|
|
14
40
|
|
|
15
41
|
var ListMenu = function ListMenu(_ref) {
|
|
16
42
|
var options = _ref.options,
|
|
17
43
|
onSelected = _ref.onSelected,
|
|
18
44
|
x = _ref.x,
|
|
19
|
-
y = _ref.y
|
|
20
|
-
|
|
45
|
+
y = _ref.y,
|
|
46
|
+
_ref$fontSize = _ref.fontSize,
|
|
47
|
+
fontSize = _ref$fontSize === void 0 ? 0.8 : _ref$fontSize;
|
|
48
|
+
return React.createElement(Container, {
|
|
21
49
|
x: x,
|
|
22
|
-
y: y
|
|
50
|
+
y: y,
|
|
51
|
+
fontSize: fontSize
|
|
23
52
|
}, React.createElement("ul", {
|
|
24
53
|
className: "rpgui-list-imp",
|
|
25
54
|
style: {
|
|
@@ -32,42 +61,31 @@ var ListMenu = function ListMenu(_ref) {
|
|
|
32
61
|
onSelected(params.id);
|
|
33
62
|
}
|
|
34
63
|
}, params.text);
|
|
35
|
-
})))
|
|
64
|
+
})));
|
|
36
65
|
};
|
|
37
66
|
var Container = /*#__PURE__*/styled.div.withConfig({
|
|
38
67
|
displayName: "ListMenu__Container",
|
|
39
68
|
componentId: "sc-i9097t-0"
|
|
40
|
-
})(["display:flex;flex-direction:column;width:100%;justify-content:start;align-items:flex-start;position:absolute;top:", "px;left:", "px;"], function (props) {
|
|
69
|
+
})(["display:flex;flex-direction:column;width:100%;justify-content:start;align-items:flex-start;position:absolute;top:", "px;left:", "px;li{font-size:", "em;}"], function (props) {
|
|
41
70
|
return props.y || 0;
|
|
42
71
|
}, function (props) {
|
|
43
72
|
return props.x || 0;
|
|
73
|
+
}, function (props) {
|
|
74
|
+
return props.fontSize;
|
|
44
75
|
});
|
|
45
76
|
var ListElement = /*#__PURE__*/styled.li.withConfig({
|
|
46
77
|
displayName: "ListMenu__ListElement",
|
|
47
78
|
componentId: "sc-i9097t-1"
|
|
48
79
|
})(["margin-right:0.5rem;"]);
|
|
49
80
|
|
|
50
|
-
var
|
|
51
|
-
if (el === void 0) {
|
|
52
|
-
el = window;
|
|
53
|
-
}
|
|
81
|
+
var RPGUIContainerTypes;
|
|
54
82
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
var listener = function listener(e) {
|
|
62
|
-
return savedHandler.current(e);
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
el.addEventListener(type, listener);
|
|
66
|
-
return function () {
|
|
67
|
-
el.removeEventListener(type, listener);
|
|
68
|
-
};
|
|
69
|
-
}, [type, el]);
|
|
70
|
-
};
|
|
83
|
+
(function (RPGUIContainerTypes) {
|
|
84
|
+
RPGUIContainerTypes["Framed"] = "framed";
|
|
85
|
+
RPGUIContainerTypes["FramedGold"] = "framed-golden";
|
|
86
|
+
RPGUIContainerTypes["FramedGold2"] = "framed-golden-2";
|
|
87
|
+
RPGUIContainerTypes["FramedGrey"] = "framed-grey";
|
|
88
|
+
})(RPGUIContainerTypes || (RPGUIContainerTypes = {}));
|
|
71
89
|
|
|
72
90
|
var RPGUIContainer = function RPGUIContainer(_ref) {
|
|
73
91
|
var children = _ref.children,
|
|
@@ -83,8 +101,8 @@ var RPGUIContainer = function RPGUIContainer(_ref) {
|
|
|
83
101
|
};
|
|
84
102
|
var Container$1 = /*#__PURE__*/styled.div.withConfig({
|
|
85
103
|
displayName: "RPGUIContainer__Container",
|
|
86
|
-
componentId: "sc-
|
|
87
|
-
})(["height:", ";width:", ";display:flex;flex-wrap:wrap;"], function (props) {
|
|
104
|
+
componentId: "sc-a8l4p8-0"
|
|
105
|
+
})(["height:", ";width:", ";display:flex;flex-wrap:wrap;image-rendering:pixelated;"], function (props) {
|
|
88
106
|
return props.height;
|
|
89
107
|
}, function (_ref2) {
|
|
90
108
|
var width = _ref2.width;
|
|
@@ -137,7 +155,7 @@ var DynamicText = function DynamicText(_ref) {
|
|
|
137
155
|
};
|
|
138
156
|
var TextContainer = /*#__PURE__*/styled.p.withConfig({
|
|
139
157
|
displayName: "DynamicText__TextContainer",
|
|
140
|
-
componentId: "sc-
|
|
158
|
+
componentId: "sc-1ggl9nd-0"
|
|
141
159
|
})(["font-size:0.7rem !important;color:white;text-shadow:1px 1px 0px #000000;letter-spacing:1.2px;word-break:normal;"]);
|
|
142
160
|
|
|
143
161
|
var NPCDialogText = function NPCDialogText(_ref) {
|
|
@@ -180,9 +198,31 @@ var NPCDialogText = function NPCDialogText(_ref) {
|
|
|
180
198
|
};
|
|
181
199
|
var Container$2 = /*#__PURE__*/styled.div.withConfig({
|
|
182
200
|
displayName: "NPCDialogText__Container",
|
|
183
|
-
componentId: "sc-
|
|
201
|
+
componentId: "sc-1cxkdh9-0"
|
|
184
202
|
})([""]);
|
|
185
203
|
|
|
204
|
+
var useEventListener = function useEventListener(type, handler, el) {
|
|
205
|
+
if (el === void 0) {
|
|
206
|
+
el = window;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
var savedHandler = React.useRef();
|
|
210
|
+
React.useEffect(function () {
|
|
211
|
+
savedHandler.current = handler;
|
|
212
|
+
}, [handler]);
|
|
213
|
+
React.useEffect(function () {
|
|
214
|
+
//@ts-ignore
|
|
215
|
+
var listener = function listener(e) {
|
|
216
|
+
return savedHandler.current(e);
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
el.addEventListener(type, listener);
|
|
220
|
+
return function () {
|
|
221
|
+
el.removeEventListener(type, listener);
|
|
222
|
+
};
|
|
223
|
+
}, [type, el]);
|
|
224
|
+
};
|
|
225
|
+
|
|
186
226
|
var QuestionDialog = function QuestionDialog(_ref) {
|
|
187
227
|
var questions = _ref.questions,
|
|
188
228
|
answers = _ref.answers,
|
|
@@ -340,31 +380,31 @@ var QuestionDialog = function QuestionDialog(_ref) {
|
|
|
340
380
|
};
|
|
341
381
|
var Container$3 = /*#__PURE__*/styled.div.withConfig({
|
|
342
382
|
displayName: "QuestionDialog__Container",
|
|
343
|
-
componentId: "sc-
|
|
383
|
+
componentId: "sc-bxc5u0-0"
|
|
344
384
|
})(["display:flex;word-break:break-all;box-sizing:border-box;justify-content:flex-start;align-items:flex-start;flex-wrap:wrap;"]);
|
|
345
385
|
var QuestionContainer = /*#__PURE__*/styled.div.withConfig({
|
|
346
386
|
displayName: "QuestionDialog__QuestionContainer",
|
|
347
|
-
componentId: "sc-
|
|
387
|
+
componentId: "sc-bxc5u0-1"
|
|
348
388
|
})(["flex:100%;width:100%;"]);
|
|
349
389
|
var AnswersContainer = /*#__PURE__*/styled.div.withConfig({
|
|
350
390
|
displayName: "QuestionDialog__AnswersContainer",
|
|
351
|
-
componentId: "sc-
|
|
391
|
+
componentId: "sc-bxc5u0-2"
|
|
352
392
|
})(["flex:100%;"]);
|
|
353
393
|
var Answer = /*#__PURE__*/styled.p.withConfig({
|
|
354
394
|
displayName: "QuestionDialog__Answer",
|
|
355
|
-
componentId: "sc-
|
|
395
|
+
componentId: "sc-bxc5u0-3"
|
|
356
396
|
})(["flex:auto;color:", " !important;font-size:0.65rem !important;background:inherit;border:none;"], function (props) {
|
|
357
397
|
return props.color;
|
|
358
398
|
});
|
|
359
399
|
var AnswerSelectedIcon = /*#__PURE__*/styled.span.withConfig({
|
|
360
400
|
displayName: "QuestionDialog__AnswerSelectedIcon",
|
|
361
|
-
componentId: "sc-
|
|
401
|
+
componentId: "sc-bxc5u0-4"
|
|
362
402
|
})(["flex:5% 0 0;color:", " !important;"], function (props) {
|
|
363
403
|
return props.color;
|
|
364
404
|
});
|
|
365
405
|
var AnswerRow = /*#__PURE__*/styled.div.withConfig({
|
|
366
406
|
displayName: "QuestionDialog__AnswerRow",
|
|
367
|
-
componentId: "sc-
|
|
407
|
+
componentId: "sc-bxc5u0-5"
|
|
368
408
|
})(["display:flex;flex-wrap:wrap;justify-content:center;align-items:center;margin-bottom:0.5rem;height:22px;p{line-height:unset;margin-top:0;margin-bottom:0rem;}"]);
|
|
369
409
|
|
|
370
410
|
var NPCDialogType;
|
|
@@ -388,8 +428,8 @@ var NPCDialog = function NPCDialog(_ref) {
|
|
|
388
428
|
showGoNextIndicator = _useState[0],
|
|
389
429
|
setShowGoNextIndicator = _useState[1];
|
|
390
430
|
|
|
391
|
-
return React.createElement(
|
|
392
|
-
type:
|
|
431
|
+
return React.createElement(RPGUIContainer, {
|
|
432
|
+
type: RPGUIContainerTypes.FramedGold,
|
|
393
433
|
width: isQuestionDialog ? '600px' : '50%',
|
|
394
434
|
height: '180px'
|
|
395
435
|
}, isQuestionDialog && questions && answers ? React.createElement(React.Fragment, null, React.createElement(TextContainer$1, {
|
|
@@ -424,43 +464,51 @@ var NPCDialog = function NPCDialog(_ref) {
|
|
|
424
464
|
}))), showGoNextIndicator && React.createElement(PressSpaceIndicator, {
|
|
425
465
|
right: type === NPCDialogType.TextOnly ? '1rem' : '10.5rem',
|
|
426
466
|
src: img$1
|
|
427
|
-
})))
|
|
467
|
+
})));
|
|
428
468
|
};
|
|
429
469
|
var Container$4 = /*#__PURE__*/styled.div.withConfig({
|
|
430
470
|
displayName: "NPCDialog__Container",
|
|
431
|
-
componentId: "sc-
|
|
471
|
+
componentId: "sc-1b4aw74-0"
|
|
432
472
|
})(["display:flex;width:100%;height:100%;box-sizing:border-box;justify-content:center;align-items:flex-start;position:relative;"]);
|
|
433
473
|
var TextContainer$1 = /*#__PURE__*/styled.div.withConfig({
|
|
434
474
|
displayName: "NPCDialog__TextContainer",
|
|
435
|
-
componentId: "sc-
|
|
475
|
+
componentId: "sc-1b4aw74-1"
|
|
436
476
|
})(["flex:", " 0 0;width:355px;"], function (_ref2) {
|
|
437
477
|
var flex = _ref2.flex;
|
|
438
478
|
return flex;
|
|
439
479
|
});
|
|
440
480
|
var ThumbnailContainer = /*#__PURE__*/styled.div.withConfig({
|
|
441
481
|
displayName: "NPCDialog__ThumbnailContainer",
|
|
442
|
-
componentId: "sc-
|
|
482
|
+
componentId: "sc-1b4aw74-2"
|
|
443
483
|
})(["flex:30% 0 0;display:flex;justify-content:flex-end;"]);
|
|
444
484
|
var NPCThumbnail = /*#__PURE__*/styled.img.withConfig({
|
|
445
485
|
displayName: "NPCDialog__NPCThumbnail",
|
|
446
|
-
componentId: "sc-
|
|
486
|
+
componentId: "sc-1b4aw74-3"
|
|
447
487
|
})(["image-rendering:pixelated;height:128px;width:128px;"]);
|
|
448
488
|
var PressSpaceIndicator = /*#__PURE__*/styled.img.withConfig({
|
|
449
489
|
displayName: "NPCDialog__PressSpaceIndicator",
|
|
450
|
-
componentId: "sc-
|
|
490
|
+
componentId: "sc-1b4aw74-4"
|
|
451
491
|
})(["position:absolute;right:", ";bottom:1rem;height:20.7px;image-rendering:-webkit-optimize-contrast;"], function (_ref3) {
|
|
452
492
|
var right = _ref3.right;
|
|
453
493
|
return right;
|
|
454
494
|
});
|
|
455
495
|
|
|
456
|
-
var
|
|
496
|
+
var _RPGUI = RPGUI;
|
|
497
|
+
var RPGUIRoot = function RPGUIRoot(_ref) {
|
|
498
|
+
var children = _ref.children;
|
|
499
|
+
return React.createElement("div", {
|
|
500
|
+
className: "rpgui-content"
|
|
501
|
+
}, children);
|
|
502
|
+
};
|
|
503
|
+
|
|
504
|
+
var RangeSliderType;
|
|
457
505
|
|
|
458
|
-
(function (
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
})(
|
|
506
|
+
(function (RangeSliderType) {
|
|
507
|
+
RangeSliderType["Slider"] = "rpgui-slider";
|
|
508
|
+
RangeSliderType["GoldSlider"] = "rpgui-slider golden";
|
|
509
|
+
})(RangeSliderType || (RangeSliderType = {}));
|
|
462
510
|
|
|
463
|
-
var
|
|
511
|
+
var RangeSlider = function RangeSlider(_ref) {
|
|
464
512
|
var type = _ref.type,
|
|
465
513
|
valueMin = _ref.valueMin,
|
|
466
514
|
valueMax = _ref.valueMax,
|
|
@@ -488,13 +536,13 @@ var RPGUISlider = function RPGUISlider(_ref) {
|
|
|
488
536
|
onChange(Number(value));
|
|
489
537
|
};
|
|
490
538
|
|
|
491
|
-
return React.createElement(
|
|
539
|
+
return React.createElement("div", {
|
|
492
540
|
onMouseUp: onHandleMouseUp,
|
|
493
541
|
onMouseDown: function onMouseDown() {
|
|
494
542
|
return setWasMouseDownFirst(true);
|
|
495
543
|
}
|
|
496
544
|
}, React.createElement(Input, {
|
|
497
|
-
className: type ===
|
|
545
|
+
className: type === RangeSliderType.Slider ? RangeSliderType.Slider : RangeSliderType.GoldSlider,
|
|
498
546
|
type: "range",
|
|
499
547
|
style: {
|
|
500
548
|
width: width
|
|
@@ -502,12 +550,12 @@ var RPGUISlider = function RPGUISlider(_ref) {
|
|
|
502
550
|
min: valueMin,
|
|
503
551
|
max: valueMax,
|
|
504
552
|
id: "rpgui-slider-" + sliderId
|
|
505
|
-
}))
|
|
553
|
+
}));
|
|
506
554
|
};
|
|
507
555
|
var Input = /*#__PURE__*/styled.input.withConfig({
|
|
508
|
-
displayName: "
|
|
509
|
-
componentId: "sc-
|
|
556
|
+
displayName: "RangeSlider__Input",
|
|
557
|
+
componentId: "sc-v8mte9-0"
|
|
510
558
|
})(["opacity:0;"]);
|
|
511
559
|
|
|
512
|
-
export { DynamicText, ListMenu, NPCDialog, NPCDialogType, QuestionDialog, RPGUIContainer, RPGUIRoot,
|
|
560
|
+
export { Button, DynamicText, IButtonTypes, ListMenu, NPCDialog, NPCDialogType, QuestionDialog, RPGUIContainer, RPGUIContainerTypes, RPGUIRoot, RangeSlider, RangeSliderType, _RPGUI, useEventListener };
|
|
513
561
|
//# sourceMappingURL=long-bow.esm.js.map
|